diff --git a/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj b/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj
index 190af161..f442881c 100644
--- a/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj
+++ b/BPASmart.ConfigurationSoftware/BPASmart.ConfigurationSoftware.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/BPASmart.PageLoad/BPASmart.PageLoad.csproj b/BPASmart.PageLoad/BPASmart.PageLoad.csproj
index 729ab884..53196873 100644
--- a/BPASmart.PageLoad/BPASmart.PageLoad.csproj
+++ b/BPASmart.PageLoad/BPASmart.PageLoad.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/BPASmart.Server/BPASmart.Server.csproj b/BPASmart.Server/BPASmart.Server.csproj
index ce7c3363..c47c5a34 100644
--- a/BPASmart.Server/BPASmart.Server.csproj
+++ b/BPASmart.Server/BPASmart.Server.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/BPASmart.VariableManager/BPASmart.VariableManager.csproj b/BPASmart.VariableManager/BPASmart.VariableManager.csproj
index c633d45b..caac5a94 100644
--- a/BPASmart.VariableManager/BPASmart.VariableManager.csproj
+++ b/BPASmart.VariableManager/BPASmart.VariableManager.csproj
@@ -30,7 +30,7 @@
-
+
diff --git a/BPASmartClient.AGV/AGVHelper.cs b/BPASmartClient.AGV/AGVHelper.cs
index c0af1913..bc6fd875 100644
--- a/BPASmartClient.AGV/AGVHelper.cs
+++ b/BPASmartClient.AGV/AGVHelper.cs
@@ -96,9 +96,8 @@ namespace BPASmartClient.AGV
/// AGV去1号线体装桶到炒锅1
///
///
- public string AgvToLineOneLoadRoller(string robotJobId)
+ public string AgvToLineOneLoadRoller(string robotJobId, int priority=1)
{
-
//bool b = Convert.ToBoolean(config.AppSettings.Settings["appKey"].Value);//配置文件信息读取
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -113,7 +112,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value);//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -160,7 +159,7 @@ namespace BPASmartClient.AGV
/// AGV去1号线体装桶到炒锅4
///
///
- public string AgvFromLineOneToFryFourLoadRoller(string robotJobId)
+ public string AgvFromLineOneToFryFourLoadRoller(string robotJobId, int priority = 1)
{
//bool b = Convert.ToBoolean(config.AppSettings.Settings["appKey"].Value);//配置文件信息读取
@@ -177,7 +176,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value);//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -223,7 +222,7 @@ namespace BPASmartClient.AGV
/// AGV去2号线体装桶到炒锅2
///
///
- public string AgvToLineTwoLoadRoller(string robotJobId)
+ public string AgvToLineTwoLoadRoller(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -238,7 +237,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority =Convert.ToInt32( config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority =priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -278,7 +277,7 @@ namespace BPASmartClient.AGV
/// AGV去2号线体装桶到炒锅5
///
///
- public string AgvFromLineTwoToFryFiveLoadRoller(string robotJobId)
+ public string AgvFromLineTwoToFryFiveLoadRoller(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -293,7 +292,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -333,7 +332,7 @@ namespace BPASmartClient.AGV
/// AGV去3号线体装桶
///
///
- public string AgvToLineThreeLoadRoller(string robotJobId)
+ public string AgvToLineThreeLoadRoller(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -348,7 +347,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -388,7 +387,7 @@ namespace BPASmartClient.AGV
/// AGV从清洗台到4号线体卸桶
///
///
- public string AgvFromCleanToLineFourUnLoadRoller(string robotJobId)
+ public string AgvFromCleanToLineFourUnLoadRoller(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -403,7 +402,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -443,7 +442,7 @@ namespace BPASmartClient.AGV
/// AGV离开炒锅1
///
///
- public string AgvLeaveFryPotOne(string robotJobId)
+ public string AgvLeaveFryPotOne(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -458,7 +457,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -498,7 +497,7 @@ namespace BPASmartClient.AGV
/// AGV离开炒锅2
///
///
- public string AgvLeaveFryPotTwo(string robotJobId)
+ public string AgvLeaveFryPotTwo(string robotJobId, int priority = 1 )
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -513,7 +512,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -553,7 +552,7 @@ namespace BPASmartClient.AGV
/// AGV离开炒锅3
///
///
- public string AgvLeaveFryPotThree(string robotJobId)
+ public string AgvLeaveFryPotThree(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -568,7 +567,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -608,7 +607,7 @@ namespace BPASmartClient.AGV
/// AGV离开炒锅4
///
///
- public string AgvLeaveFryPotFour(string robotJobId)
+ public string AgvLeaveFryPotFour(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -623,7 +622,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -663,7 +662,7 @@ namespace BPASmartClient.AGV
/// AGV离开炒锅5
///
///
- public string AgvLeaveFryPotFive(string robotJobId)
+ public string AgvLeaveFryPotFive(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -678,7 +677,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -719,7 +718,7 @@ namespace BPASmartClient.AGV
/// AGV从1号线运空桶洗桶
///
///
- public string AgvLeaveLOneToClean(string robotJobId)
+ public string AgvLeaveLOneToClean(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -734,7 +733,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -774,7 +773,7 @@ namespace BPASmartClient.AGV
/// AGV从2号线运空桶洗桶
///
///
- public string AgvLeaveLTwoToClean(string robotJobId)
+ public string AgvLeaveLTwoToClean(string robotJobId,int priority=1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -789,7 +788,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -829,7 +828,7 @@ namespace BPASmartClient.AGV
/// AGV从3号线运空桶洗桶
///
///
- public string AgvLeaveLThreeToClean(string robotJobId)
+ public string AgvLeaveLThreeToClean(string robotJobId,int priority=1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -844,7 +843,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
@@ -884,7 +883,7 @@ namespace BPASmartClient.AGV
/// AGV从洗桶处运桶到4号洗桶线
///
///
- public string AgvLeaveCleanToLFour(string robotJobId)
+ public string AgvLeaveCleanToLFour(string robotJobId, int priority = 1)
{
string url = AGVRequestUrl.GetInstance.TaskSendUrl;
//请求报文头
@@ -899,7 +898,7 @@ namespace BPASmartClient.AGV
AGVModel httpModel = new AGVModel();
httpModel.robotJobId = robotJobId;//上游提供
httpModel.warehouseId = long.Parse(config.AppSettings.Settings["warehouseId"].Value); //仓库编号
- httpModel.jobPriority = Convert.ToInt32(config.AppSettings.Settings["jobPriority"].Value);//任务执行的优先级
+ httpModel.jobPriority = priority;//任务执行的优先级
httpModel.jobPriorityType = Convert.ToInt32(config.AppSettings.Settings["jobPriorityType"].Value); ;//0:根据优先级来执行,1:强制执行
httpModel.jobType = config.AppSettings.Settings["jobType"].Value; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE
//详细任务数据
diff --git a/BPASmartClient.Business/BPASmartClient.Business.csproj b/BPASmartClient.Business/BPASmartClient.Business.csproj
index 87d1b161..0d77ddd4 100644
--- a/BPASmartClient.Business/BPASmartClient.Business.csproj
+++ b/BPASmartClient.Business/BPASmartClient.Business.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
index b728b8dd..86047719 100644
--- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
+++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
@@ -409,8 +409,8 @@
-
-
+
+
diff --git a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
index 785250d5..e504cf29 100644
--- a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
+++ b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs
@@ -25,7 +25,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
if (string.IsNullOrEmpty(name)) name = typeof(AlarmT).Name;
if (_Instance == null) _Instance = new ConcurrentDictionary();
if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new AlarmT());
- return _Instance[name];
+ return _Instance[name];
}
}
private AlarmHelper() { }
@@ -67,7 +67,6 @@ namespace BPASmartClient.CustomResource.Pages.Model
}
Thread.Sleep(100);
}), $"{typeof(AlarmT).Name},报警通用模块监听");
-
}
///
diff --git a/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs b/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs
index f0688f09..4e15c59e 100644
--- a/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs
+++ b/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs
@@ -81,7 +81,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
catch (Exception)
{
- // throw;
+ // throw;
}
}
}
@@ -109,34 +109,40 @@ namespace BPASmartClient.CustomResource.Pages.Model
public bool ShowDialog(string info, DialogType dialogType = DialogType.Information)
{
- PromptView PV = new PromptView();
- PV.TextBlockInfo = info;
- switch (dialogType)
+ bool result = false;
+ Application.Current.Dispatcher.Invoke(() =>
{
- case DialogType.Warning:
- PV.TextBlockIcon = "";
- PV.TextBlockForeground = Brushes.Yellow;
- PV.infoType.Text = "警告:";
- //PV.Cancel.Visibility = Visibility.Collapsed;
- break;
- case DialogType.Error:
- PV.TextBlockIcon = "";
- PV.TextBlockForeground = Brushes.Red;
- PV.infoType.Text = "错误:";
- //PV.Cancel.Visibility = Visibility.Collapsed;
- break;
- case DialogType.Information:
- PV.TextBlockIcon = "";
- PV.TextBlockForeground = Brushes.DeepSkyBlue;
- PV.infoType.Text = "提示:";
- //PV.Cancel.Visibility = Visibility.Visible;
- break;
- default:
- break;
- }
- PV.infoType.Foreground = PV.TextBlockForeground;
- var res = PV.ShowDialog();
- return res == null ? false : (bool)res;
+ PromptView PV = new PromptView();
+ PV.TextBlockInfo = info;
+ switch (dialogType)
+ {
+ case DialogType.Warning:
+ PV.TextBlockIcon = "";
+ PV.TextBlockForeground = Brushes.Yellow;
+ PV.infoType.Text = "警告:";
+ //PV.Cancel.Visibility = Visibility.Collapsed;
+ break;
+ case DialogType.Error:
+ PV.TextBlockIcon = "";
+ PV.TextBlockForeground = Brushes.Red;
+ PV.infoType.Text = "错误:";
+ //PV.Cancel.Visibility = Visibility.Collapsed;
+ break;
+ case DialogType.Information:
+ PV.TextBlockIcon = "";
+ PV.TextBlockForeground = Brushes.DeepSkyBlue;
+ PV.infoType.Text = "提示:";
+ //PV.Cancel.Visibility = Visibility.Visible;
+ break;
+ default:
+ break;
+ }
+ PV.infoType.Foreground = PV.TextBlockForeground;
+
+ var res = PV.ShowDialog();
+ result = res == null ? false : (bool)res;
+ });
+ return result;
}
}
diff --git a/BPASmartClient.CustomResource/Pages/View/MainView.xaml b/BPASmartClient.CustomResource/Pages/View/MainView.xaml
index f7d52d16..fb4ce75c 100644
--- a/BPASmartClient.CustomResource/Pages/View/MainView.xaml
+++ b/BPASmartClient.CustomResource/Pages/View/MainView.xaml
@@ -21,7 +21,7 @@
-
+
@@ -365,6 +365,70 @@
+
@@ -516,6 +580,13 @@
+
+ VerticalScrollBarVisibility="Visible">
diff --git a/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml b/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml
index 94b69fe5..58ac02a5 100644
--- a/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml
+++ b/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml
@@ -310,7 +310,7 @@
+ VerticalScrollBarVisibility="Visible">
diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
index a1a4ddf9..6a8f6c60 100644
--- a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
+++ b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
+using System.Security.Cryptography.Xml;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -94,6 +95,12 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
{
PermissionChange();
}), "PermissionChange");
+
+ ActionManage.GetInstance.Register(new Action
protected ConcurrentDictionary peripheralStatus = new ConcurrentDictionary();
- protected
+ protected
///
/// 外设设备集合
@@ -145,7 +145,7 @@ namespace BPASmartClient.Device
///
///
///
- public void WriteControlExact(string address, object value,int i)
+ public void WriteControlExact(string address, object value, int i)
{
if (peripherals != null)
{
@@ -205,7 +205,7 @@ namespace BPASmartClient.Device
Status.Update($"{TypeName}.{key}", peripheral.GetAllStatus()[key]);
}
}
- if(dicPort2peripheralStatus.ContainsKey(i))
+ if (dicPort2peripheralStatus.ContainsKey(i))
{
dicPort2peripheralStatus[i] = newPeripheralStatus;
}
@@ -284,7 +284,7 @@ namespace BPASmartClient.Device
foreach (var faces in res)
{
if (faces.Name == "IStatus")
- {
+ {
InterfaceStatus = item.GetValue(this) as IStatus;
GetMonitorData(InterfaceStatus);
}
@@ -361,6 +361,7 @@ namespace BPASmartClient.Device
{
ThreadManage.GetInstance().StopTask($"GvlStatusMonitor:{DeviceId}", new Action(() =>
{
+ ActionManage.GetInstance.Send("ClearOrders");
ResetProgram();
ResetStatus();
InitTask();
@@ -380,7 +381,7 @@ namespace BPASmartClient.Device
{
ReadData();
Thread.Sleep(10);
- }), $"ReadData:{DeviceId}",true);
+ }), $"ReadData:{DeviceId}", true);
#endregion
#region 任务流程
diff --git a/BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj b/BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj
index 86b5d8c8..472a4704 100644
--- a/BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj
+++ b/BPASmartClient.DosingSystemSingle/BPASmartClient.DosingSystemSingle.csproj
@@ -16,8 +16,8 @@
-
-
+
+
diff --git a/BPASmartClient.Helper/ExpandMethod.cs b/BPASmartClient.Helper/ExpandMethod.cs
index e3df2666..050ca1c3 100644
--- a/BPASmartClient.Helper/ExpandMethod.cs
+++ b/BPASmartClient.Helper/ExpandMethod.cs
@@ -185,6 +185,126 @@ namespace BPASmartClient.Helper
return false;
}
+ public static string ToBinString(this object value)
+ {
+ int num = 0;
+ int num2 = 0;
+ int num3 = 0;
+ string text = "";
+ long num4 = 0L;
+ try
+ {
+ if (value.GetType().Name.IndexOf("[]") < 0)
+ {
+ string a = value.GetType().Name;
+ switch (a)
+ {
+ case "Byte":
+ num3 = 7;
+ num4 = (byte)value;
+ break;
+ case "UInt16":
+ num3 = 15;
+ num4 = (ushort)value;
+ break;
+ case "Int16":
+ num3 = 15;
+ num4 = (short)value;
+ break;
+ case "UInt32":
+ num3 = 31;
+ num4 = (uint)value;
+ break;
+ case "Int32":
+ num3 = 31;
+ num4 = (int)value;
+ break;
+ case "Int64":
+ num3 = 63;
+ num4 = (long)value;
+ break;
+ default:
+ throw new Exception();
+ }
+
+ for (num = num3; num >= 0; num += -1)
+ {
+ if ((num + 1) % 4 == 0) text = text + " ";
+ text = (((num4 & (long)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1"));
+ }
+ }
+ else
+ {
+ switch (value.GetType().Name)
+ {
+ case "Byte[]":
+ {
+ num3 = 7;
+ byte[] array4 = (byte[])value;
+ for (num2 = 0; num2 <= array4.Length - 1; num2++)
+ {
+ for (num = num3; num >= 0; num += -1)
+ {
+ text = (((array4[num2] & (byte)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1"));
+ }
+ }
+
+ break;
+ }
+ case "Int16[]":
+ {
+ num3 = 15;
+ short[] array2 = (short[])value;
+ for (num2 = 0; num2 <= array2.Length - 1; num2++)
+ {
+ for (num = num3; num >= 0; num += -1)
+ {
+ text = (((array2[num2] & (byte)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1"));
+ }
+ }
+
+ break;
+ }
+ case "Int32[]":
+ {
+ num3 = 31;
+ int[] array3 = (int[])value;
+ for (num2 = 0; num2 <= array3.Length - 1; num2++)
+ {
+ for (num = num3; num >= 0; num += -1)
+ {
+ text = (((array3[num2] & (byte)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1"));
+ }
+ }
+
+ break;
+ }
+ case "Int64[]":
+ {
+ num3 = 63;
+ byte[] array = (byte[])value;
+ for (num2 = 0; num2 <= array.Length - 1; num2++)
+ {
+ for (num = num3; num >= 0; num += -1)
+ {
+ text = (((array[num2] & (byte)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1"));
+ }
+ }
+
+ break;
+ }
+ default:
+ throw new Exception();
+ }
+ }
+
+ return text;
+ }
+ catch
+ {
+ return "";
+ }
+ }
diff --git a/BPASmartClient.Helper/ThreadManage.cs b/BPASmartClient.Helper/ThreadManage.cs
index 25f0cd24..33d37d20 100644
--- a/BPASmartClient.Helper/ThreadManage.cs
+++ b/BPASmartClient.Helper/ThreadManage.cs
@@ -201,5 +201,4 @@ namespace BPASmartClient.Helper
return false;
}
}
-
}
diff --git a/BPASmartClient.JAKA/JakaMachine.cs b/BPASmartClient.JAKA/JakaMachine.cs
index a93c39cb..e45b477d 100644
--- a/BPASmartClient.JAKA/JakaMachine.cs
+++ b/BPASmartClient.JAKA/JakaMachine.cs
@@ -17,18 +17,22 @@ namespace BPASmartClient.JAKA
ThreadManage.GetInstance().StartLong(new Action(() =>
{
IsConnected = jaKaHelper.IsConnected;
- if (!IsConnected) IsWork = false;
- while (IsConnected)
+ if (!IsConnected)
+ {
+ IsWork = false;
+ }
+ if (IsConnected)
{
IsWork = true;
if (status != null)
{
- SetStatus("GetProgramStatus", (int)jaKaHelper.GetProgramStatus());
- SetStatus("Get_RobotAO1", jaKaHelper.Get_RobotAO1());
- SetStatus("Get_RobotDI0", jaKaHelper.Get_RobotDI(0));
- SetStatus("Get_RobotDI1", jaKaHelper.Get_RobotDI(1));
- SetStatus("Get_RobotDI2", jaKaHelper.Get_RobotDI(2));
- SetStatus("Get_RobotDI3", jaKaHelper.Get_RobotDI(3));
+ SetStatus("Get_JakaRobotProgramStatus", (int)jaKaHelper.GetProgramStatus());
+ SetStatus("Get_JakaRobotAO1", Convert.ToInt32(jaKaHelper.Get_RobotAO1()));
+ SetStatus("Get_JakaRobotDI0", jaKaHelper.Get_RobotDI(0));
+ SetStatus("Get_JakaRobotDI1", jaKaHelper.Get_RobotDI(1));
+ SetStatus("Get_JakaRobotDI2", jaKaHelper.Get_RobotDI(2));
+ SetStatus("Get_JakaRobotDI3", jaKaHelper.Get_RobotDI(3));
+ SetStatus("Get_JakaRobotDI5", jaKaHelper.Get_RobotDI(5));
}
Thread.Sleep(500);
}
diff --git a/BPASmartClient.JXJFoodBigStation/App.config b/BPASmartClient.JXJFoodBigStation/App.config
index 3559a687..35b80a6d 100644
--- a/BPASmartClient.JXJFoodBigStation/App.config
+++ b/BPASmartClient.JXJFoodBigStation/App.config
@@ -3,5 +3,7 @@
+
+
\ No newline at end of file
diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs
index 6c3282c2..354b9dc1 100644
--- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs
+++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs
@@ -13,6 +13,7 @@ using BPASmartClient.CustomResource.Pages.View;
using BPASmartClient.CustomResource.Pages.ViewModel;
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodBigStation.Model;
+using BPASmartClient.JXJFoodBigStation.Model.Siemens;
namespace BPASmartClient.JXJFoodBigStation
{
@@ -53,6 +54,10 @@ namespace BPASmartClient.JXJFoodBigStation
protected override void OnExit(ExitEventArgs e)
{
+ Json.Save();
+ Json.Save();
+ Json.Save();
+ Json.Save();
base.OnExit(e);
MessageNotify.GetInstance.LogSave();
ThreadManage.GetInstance().Dispose();
@@ -100,6 +105,13 @@ namespace BPASmartClient.JXJFoodBigStation
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.StockBinRawMaterialView"
});
+ StockBinManage.Add(new SubMenumodel()
+ {
+ SubMenuName = "MES原料数据",
+ SubMenuPermission = new Permission[] { Permission.管理员 },
+ AssemblyName = "BPASmartClient.JXJFoodBigStation",
+ ToggleWindowPath = "View.BomOfMaterialView"
+ });
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "",
@@ -137,7 +149,7 @@ namespace BPASmartClient.JXJFoodBigStation
InfoLog.Add(new SubMenumodel()
{
SubMenuName = "调试日志",
- SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
+ SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.DebugLogView"
});
@@ -217,6 +229,9 @@ namespace BPASmartClient.JXJFoodBigStation
//Config.GetInstance.Init();
//Json.Read();
Json.Read();
+ Json.Read();
+ Json.Read();
+ Json.Read();
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
index bbf2290a..d487ecaa 100644
--- a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
+++ b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
@@ -5,6 +5,7 @@
net6.0-windows
enable
true
+ hbl.ico
@@ -31,6 +32,9 @@
True
Settings.settings
+
+ Code
+
Code
@@ -51,6 +55,10 @@
$(DefaultXamlRuntime)
Designer
+
+ $(DefaultXamlRuntime)
+ Designer
+
$(DefaultXamlRuntime)
Designer
diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
index 2cd82517..ff7f543e 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
@@ -16,8 +16,32 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// plc心跳上传
///
public static bool HeartBeatFromPlc { get; set; }
+ ///
+ /// 订单取消的状态位
+ ///
+ public static bool Order_Cancel { get; set; }
+ ///
+ /// 订单取消的配方号
+ ///
+ public static string Order_CancelRecipeCode { get; set; } = "";
+ public static int Order_CancelStep { get; set; }
+ ///
+ /// 第一个配方的配料时间
+ ///
+ public static DateTime DosingRecipe1Time { get; set; }
+ ///
+ /// 第二个配方的配料时间
+ ///
+ public static DateTime DosingRecipe2Time { get; set; }
+ ///
+ /// 第三个配方的配料时间
+ ///
+ public static DateTime DosingRecipe3Time { get; set; }
+ ///
+ /// 第四个配方的配料时间
+ ///
+ public static DateTime DosingRecipe4Time { get; set; }
- public static DateTime DosingTime { get; set; }
///
/// plc心跳下发
///
@@ -38,17 +62,44 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
///
public static int Recipe4DosingStatus { get; set; }
+
+
+ public static int[] RecipeDosingStatus { get; set; } = new int[4] { 0, 0, 0, 0 };
+ public static bool[] AllowIssueRecipe { get; set; } = new bool[4] { false, false, false, false };
+ public static bool[] ReceviceFinishRecipe { get; set; } = new bool[4] { false, false, false, false };
+ public static bool[] DosingFinishRecipe { get; set; } = new bool[4] { false, false, false, false };
+
+ public static bool[] IsTrayArrive { get; set; } = new bool[5] { false, false, false, false,false };
+ public static DateTime[] RecipeDosingTime { get; set; } = new DateTime[4] { DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now };
+
///
/// 是否处于手动下发配方
///
public static bool IsUseLocalRecipe { get; set; } = false;
+
+ ///
+ /// 洗桶的标识符
+ ///
+ public static bool BarrelWasherSign { get; set; }
///
/// 订单请求
///
public static bool Order_Request { get; set; } = false;
+ ///
+ /// 下发配方的状态位
+ ///
public static int SiemensSendRecipeStatus { get; set; } = 0;
+ ///
+ /// 大料站最大的料仓数目
+ ///
public const int Max_DosingSotckBinNum = 14;
+ public static StockBinName stockBinName { get; set; } = new StockBinName();
+
+ ///
+ /// 原料的名称和原料编号对应,Mes提供的信息
+ ///
+ public static Dictionary RawMaterialsNameCode { get; set; } = new Dictionary();
public static ushort AGVPutTray { get; set; }
public static ushort AGVGetTray { get; set; }
@@ -57,6 +108,37 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public static ushort TrayCylinder { get; set; }
public static DB_Read HKPlc_Read = new DB_Read();
- public static bool IsUseLocalName { get; set; } = true;
+
+ ///
+ /// 是否连接海科PLC
+ ///
+ public static bool IsAllowHKPlcConnect { get; set; }
+ ///
+ /// 是否连接西门子PLC
+ ///
+ public static bool IsAllowSiemensConnect { get; set; }
+
+ ///
+ /// 配方1配料完成
+ ///
+ public static bool Recipe1DosingFinish { get; set; } = false;
+ ///
+ /// 配方2配料完成
+ ///
+ public static bool Recipe2DosingFinish { get; set; } = false;
+ ///
+ /// 配方3配料完成
+ ///
+ public static bool Recipe3DosingFinish { get; set; } = false;
+ ///
+ /// 配方4配料完成
+ ///
+ public static bool Recipe4DosingFinish { get; set; } = false;
+
+ ///
+ /// 订单是否是洗桶
+ ///
+ public static bool Order_IsWashingBarrel { get; set; } = false;
+ public static int TrayEnable { get; set; } = 15;
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs
index b311851b..4d12381e 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs
@@ -1,4 +1,5 @@
-using System;
+using BPASmartClient.S7Net;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -57,6 +58,25 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
///
public bool Tray5InPlace { get; set; }
///
+ /// 配方1配料完成
+ ///
+ public bool Recipe1DoisngFinish { get; set; }
+
+ ///
+ /// 配方2配料完成
+ ///
+ public bool Recipe2DoisngFinish { get; set; }
+
+ ///
+ /// 配方3配料完成
+ ///
+ public bool Recipe3DoisngFinish { get; set; }
+
+ ///
+ /// 配方4配料完成
+ ///
+ public bool Recipe4DoisngFinish { get; set; }
+ ///
/// 配方编码
///
public short RecipeCode { get; set; }
@@ -123,5 +143,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public float Bareel5Bin12SetWeight { get; set; }
public float Bareel5Bin13SetWeight { get; set; }
public float Bareel5Bin14SetWeight { get; set; }
+ public bool OrderCancel_Sign { get; set; }
+ public short OrderCancel_TrayCode { get; set; }
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
index cb36ab25..b384f96d 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
@@ -18,17 +18,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public bool IsConnected => HK_PLC_S7.IsConnected;
public DB_Read PlcRead = new DB_Read();
public DL_DataColl_DB DataColl =new DL_DataColl_DB();
- public StockBinName StockBinName = new StockBinName();
public void Init()
{
- DB_Write PlcWrite = new DB_Write();
- HK_PLC_S7.WriteClass(PlcWrite, 99);
- ThreadManage.GetInstance().StartLong(new Action(() =>
+ try
{
+ DB_Write PlcWrite = new DB_Write();
+ HK_PLC_S7.WriteClass(PlcWrite, 99);
+ }
+ catch (Exception ex) {
+ MessageNotify.GetInstance.ShowRunLog("DB99块初始化值 失败");
+ }
+ ThreadManage.GetInstance().StartLong(new Action(() =>
+ {/*
+ var res = HK_PLC_S7.ReadClass(97);//料仓里原料的编码
+ if (res != null && res is StockBinName data9)
+ {
+ GVL_BigStation.stockBinName = data9;
+ }*/
if (IsConnected)
{
var res1 = HK_PLC_S7.ReadClass(98);
- var res2 = HK_PLC_S7.ReadClass(97);
+ var res2 = HK_PLC_S7.ReadClass(97);//料仓里原料的编码
if (res1 != null && res1 is DB_Read data1)
{
PlcRead = data1;
@@ -36,7 +46,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
}
if (res2 != null && res2 is StockBinName data2)
{
- StockBinName = data2;
+ GVL_BigStation.stockBinName = data2;
}
var res3 = HK_PLC_S7.ReadClass(48);
if (res3 != null && res3 is DL_DataColl_DB data)
@@ -45,7 +55,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
}
}
Thread.Sleep(10);
- }),"信号收发处理",true);
+ }),"海科数据交互",true);
}
///
/// 下发配方数据
@@ -58,6 +68,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
HK_PLC_S7.Write("DB99.DBW2.0",Convert.ToInt16(recipe.TrayCode));
HK_PLC_S7.Write("DB99.DBW4.0", Convert.ToInt16(recipe.TrayCode));
+ MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号DB99.DBW2.0:{recipe.TrayCode},下发完成");
for (int barrel = 1; barrel < 6; barrel++)
{
if (barrel != 3)//桶的编号不为3 只为1,2,4,5号桶
diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs
index d3fc305f..0aa62220 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs
@@ -9,33 +9,33 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
public class StockBinName
{
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName1 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName2 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName3 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName4 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName5 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName6 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName7 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName8 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName9 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName10 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName11 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName12 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName13 { get; set; } = "";
- [Siemens(6)]
+ [Siemens(4)]
public string RawMaterialName14 { get; set; } = "";
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/HardWare/BomMaterial.cs b/BPASmartClient.JXJFoodBigStation/Model/HardWare/BomMaterial.cs
new file mode 100644
index 00000000..6dc11273
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/HardWare/BomMaterial.cs
@@ -0,0 +1,16 @@
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model
+{
+ public class BomMaterial
+ {
+ public ObservableCollection RawMaterials { get; set; } = new ObservableCollection();
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
index 23dbd280..738a4e2e 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
@@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -26,28 +27,32 @@ namespace BPASmartClient.JXJFoodBigStation.Model
///
/// 西门子配方数据
///
- public ObservableCollection SiemensRecipes = new ObservableCollection();
+ public ObservableCollection SiemensRecipes { get; set; } = new ObservableCollection();
///
/// 本地配方数据
///
- public ObservableCollection LocalRecipes = new ObservableCollection();
+ public ObservableCollection LocalRecipes { get; set; } = new ObservableCollection();
///
/// 配方等待执行
///
- public ObservableCollection RecipeWaitExecute = new ObservableCollection();
+ public ObservableCollection RecipeWaitExecute { get; set; } = new ObservableCollection();
///
/// 配方正在执行
///
- public ObservableCollection RecipeExecuting = new ObservableCollection();
+ public ObservableCollection RecipeExecuting { get; set; } = new ObservableCollection();
///
/// 配方执行完成
///
- public ObservableCollection RecipeExecuteComple = new ObservableCollection();
+ public ObservableCollection RecipeExecuteComple { get; set; } = new ObservableCollection();
///
/// 原料的名称和料仓的位置对应
///
- public Dictionary RawMaterialsNamePos = new Dictionary();
- public ObservableCollection RawMaterialsInfo = new ObservableCollection();
+ public ConcurrentDictionary RawMaterialsNamePos { get; set; } = new ConcurrentDictionary();
+ ///
+ /// 硬件料仓的原料信息
+ ///
+ public ObservableCollection HardWareRawMaterialInfo { get; set; } = new ObservableCollection();
+ public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection();
///
/// 西门子配方队列
///
@@ -55,6 +60,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public ConcurrentQueue SiemensRecipeQueue2 = new ConcurrentQueue();
public ConcurrentQueue SiemensRecipeQueue3 = new ConcurrentQueue();
public ConcurrentQueue SiemensRecipeQueue4 = new ConcurrentQueue();
+
+ public ConcurrentDictionary> SiemensRecipeQueue = new ConcurrentDictionary>();
+ public ObservableCollection recipe = new ObservableCollection();
///
/// 本地配方队列
///
@@ -62,10 +70,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public ConcurrentQueue LocalRecipeQueue2 = new ConcurrentQueue();
public ConcurrentQueue LocalRecipeQueue3 = new ConcurrentQueue();
public ConcurrentQueue LocalRecipeQueue4 = new ConcurrentQueue();
+
+ ///
+ /// 海科PLC的IP
+ ///
+ public string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
+ ///
+ /// 西门子PLC的IP
+ ///
+ public string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
public void Init()
{
- testRawMaterialNameData();//自定义料仓名称
- ActionManage.GetInstance.CancelRegister("SiemensSendRecipe");
ActionManage.GetInstance.Register(new Action
private void StockBinParReset()
{
- HKDevice.HK_PLC_S7.Write("DB99.DBW2.0", 0);//
+ HKDevice.HK_PLC_S7.Write("DB99.DBW2.0", 0);
HKDevice.HK_PLC_S7.Write("DB99.DBW4.0", 0);
for (int i = 0; i < 56; i++)
{
@@ -1500,31 +1729,668 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
private void testRawMaterialNameData()
{
- RawMaterialsNamePos.Clear();
- RawMaterialsInfo.Clear();
- if (GVL_BigStation.IsUseLocalName)
+ //RawMaterialsInfo = Json.Data.RawMaterial;
+ /*foreach (var material in RawMaterialsInfo)
{
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0007", RawMaterialLocation = 1 });//香菇丁
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0015", RawMaterialLocation = 2 });//竹笋丁
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0005", RawMaterialLocation = 3 });//卤牛肉丁
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0014", RawMaterialLocation = 4 });//野山椒粒
-
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0031", RawMaterialLocation = 1 });//备料大蒜
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0040", RawMaterialLocation = 2 });//花椒酱
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0018", RawMaterialLocation = 4 });//榨菜丁
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0033", RawMaterialLocation = 5 });//炸豌豆
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0008", RawMaterialLocation = 8 });//高水分糍粑海椒
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0010", RawMaterialLocation = 9 });//辣豆瓣
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0030", RawMaterialLocation = 11 });//备用生姜
- RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0012", RawMaterialLocation = 12 });//豆豉细粒
- foreach (var material in RawMaterialsInfo)
+ if (!string.IsNullOrEmpty(material.RawMaterialName))
+ {
+ if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName))
+ {
+ RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation);
+ }
+ }
+ }*/
+ if (RawMaterialsNamePos.Count == 14)
+ {
+ for (int i = 0; i < typeof(StockBinName).GetProperties().Length; i++)
{
- RawMaterialsNamePos.Add(material.RawMaterialName,(short)material.RawMaterialLocation);
+ PropertyInfo pro = GVL_BigStation.stockBinName.GetType().GetProperty(typeof(StockBinName).GetProperties()[i].Name);
+ RawMaterialsNamePos[i + 1] = pro.GetValue(GVL_BigStation.stockBinName, null).ToString();
}
}
- else
+ else
+ {
+ RawMaterialsNamePos.TryAdd(1, GVL_BigStation.stockBinName.RawMaterialName1);
+ RawMaterialsNamePos.TryAdd(2, GVL_BigStation.stockBinName.RawMaterialName2);
+ RawMaterialsNamePos.TryAdd(3, GVL_BigStation.stockBinName.RawMaterialName3);
+ RawMaterialsNamePos.TryAdd(4, GVL_BigStation.stockBinName.RawMaterialName4);
+ RawMaterialsNamePos.TryAdd(5, GVL_BigStation.stockBinName.RawMaterialName5);
+ RawMaterialsNamePos.TryAdd(6, GVL_BigStation.stockBinName.RawMaterialName6);
+ RawMaterialsNamePos.TryAdd(7, GVL_BigStation.stockBinName.RawMaterialName7);
+ RawMaterialsNamePos.TryAdd(8, GVL_BigStation.stockBinName.RawMaterialName8);
+ RawMaterialsNamePos.TryAdd(9, GVL_BigStation.stockBinName.RawMaterialName9);
+ RawMaterialsNamePos.TryAdd(10, GVL_BigStation.stockBinName.RawMaterialName10);
+ RawMaterialsNamePos.TryAdd(11, GVL_BigStation.stockBinName.RawMaterialName11);
+ RawMaterialsNamePos.TryAdd(12, GVL_BigStation.stockBinName.RawMaterialName12);
+ RawMaterialsNamePos.TryAdd(13, GVL_BigStation.stockBinName.RawMaterialName13);
+ RawMaterialsNamePos.TryAdd(14, GVL_BigStation.stockBinName.RawMaterialName14);
+ foreach (var item in RawMaterialsNamePos)
+ {
+ HardWareRawMaterialInfo.Add(new RawMaterial() { RawMaterialCount = HardWareRawMaterialInfo.Count + 1, RawMaterialLocation = item.Key, RawMaterialName = item.Value, RawMaterialChineseName = "" });
+ }
+ }
+ foreach (var item in RawMaterialsNamePos)
{
- if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName1)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName1)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName1, 1);
+ int num = Array.FindIndex(Json.Data.RawMaterials.ToArray(), p => p.RawMaterialName == item.Value);
+ int index = Array.FindIndex(HardWareRawMaterialInfo.ToArray(), p => p.RawMaterialLocation == item.Key);
+ if (index == -1)
+ {
+ HardWareRawMaterialInfo.Clear();
+ }
+ else if (num >= 0 && index >= 0)
+ {
+ string name = Json.Data.RawMaterials.ElementAt(num).RawMaterialChineseName;
+ HardWareRawMaterialInfo.ElementAt(index).RawMaterialLocation = item.Key;
+ HardWareRawMaterialInfo.ElementAt(index).RawMaterialName = item.Value;
+ HardWareRawMaterialInfo.ElementAt(index).RawMaterialChineseName = name;
+ }
+ else if (num == -1)
+ {
+ HardWareRawMaterialInfo.ElementAt(index).RawMaterialLocation = item.Key;
+ HardWareRawMaterialInfo.ElementAt(index).RawMaterialName = "";
+ HardWareRawMaterialInfo.ElementAt(index).RawMaterialChineseName = "";
+ }
+ }
+
+ RawMaterialsInfo = HardWareRawMaterialInfo;
+ }
+ ///
+ /// MES的物料名称和物料编码对应
+ ///
+ public void RawMaterialNameWithCode()
+ {
+ GVL_BigStation.RawMaterialsNameCode.Add("0001", "色拉油");
+ GVL_BigStation.RawMaterialsNameCode.Add("0002", "一级菜油");
+ GVL_BigStation.RawMaterialsNameCode.Add("0003", "菜籽油");
+ GVL_BigStation.RawMaterialsNameCode.Add("0004", "青花椒油");
+ GVL_BigStation.RawMaterialsNameCode.Add("0005", "卤牛肉丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0006", "冻鸡肉丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0007", "香菇丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0008", "高水分糍粑海椒");
+ GVL_BigStation.RawMaterialsNameCode.Add("0009", "低水分糍粑海椒");
+ GVL_BigStation.RawMaterialsNameCode.Add("0010", "辣豆瓣");
+ GVL_BigStation.RawMaterialsNameCode.Add("0011", "整豆豉");
+ GVL_BigStation.RawMaterialsNameCode.Add("0012", "豆豉细粒");
+ GVL_BigStation.RawMaterialsNameCode.Add("0013", "卤黄豆");
+ GVL_BigStation.RawMaterialsNameCode.Add("0014", "野山椒粒");
+ GVL_BigStation.RawMaterialsNameCode.Add("0015", "竹笋丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0016", "香辣酱辣椒酱");
+ GVL_BigStation.RawMaterialsNameCode.Add("0017", "芽菜粒");
+ GVL_BigStation.RawMaterialsNameCode.Add("0018", "榨菜丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0019", "盐菜");
+ GVL_BigStation.RawMaterialsNameCode.Add("0020", "洋葱丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0021", "番茄酱");
+ GVL_BigStation.RawMaterialsNameCode.Add("0022", "甜豆瓣");
+ GVL_BigStation.RawMaterialsNameCode.Add("0023", "甜面酱");
+ GVL_BigStation.RawMaterialsNameCode.Add("0024", "芝麻酱");
+ GVL_BigStation.RawMaterialsNameCode.Add("0025", "炸花生");
+ GVL_BigStation.RawMaterialsNameCode.Add("0026", "盐渍青椒丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0027", "备料剁红椒");
+ GVL_BigStation.RawMaterialsNameCode.Add("0028", "萝卜丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0029", "油芝麻");
+ GVL_BigStation.RawMaterialsNameCode.Add("0030", "生姜");
+ GVL_BigStation.RawMaterialsNameCode.Add("0031", "大蒜");
+ GVL_BigStation.RawMaterialsNameCode.Add("0032", "榨菜酱");
+ GVL_BigStation.RawMaterialsNameCode.Add("0033", "炸碗豆");
+ GVL_BigStation.RawMaterialsNameCode.Add("0034", "大头菜丁");
+ GVL_BigStation.RawMaterialsNameCode.Add("0035", "酱油");
+ GVL_BigStation.RawMaterialsNameCode.Add("0036", "I+G");
+ GVL_BigStation.RawMaterialsNameCode.Add("0037", "味精");
+ GVL_BigStation.RawMaterialsNameCode.Add("0038", "白糖");
+ GVL_BigStation.RawMaterialsNameCode.Add("0039", "食盐");
+ GVL_BigStation.RawMaterialsNameCode.Add("0040", "花椒酱");
+ GVL_BigStation.RawMaterialsNameCode.Add("0041", "调味膏2");
+ GVL_BigStation.RawMaterialsNameCode.Add("0042", "调味膏5");
+ GVL_BigStation.RawMaterialsNameCode.Add("0043", "十三香调味膏");
+ GVL_BigStation.RawMaterialsNameCode.Add("0044", "酱香膏");
+ GVL_BigStation.RawMaterialsNameCode.Add("0045", "芽菜香料粉");
+ GVL_BigStation.RawMaterialsNameCode.Add("0046", "香料A");
+ GVL_BigStation.RawMaterialsNameCode.Add("0047", "香料D");
+ GVL_BigStation.RawMaterialsNameCode.Add("0048", "猪肉精膏");
+ GVL_BigStation.RawMaterialsNameCode.Add("0049", "调味膏3");
+ GVL_BigStation.RawMaterialsNameCode.Add("0050", "柠檬酸粉");
+ GVL_BigStation.RawMaterialsNameCode.Add("0051", "辣椒红");
+ GVL_BigStation.RawMaterialsNameCode.Add("0052", "辣椒油树脂");
+ GVL_BigStation.RawMaterialsNameCode.Add("0053", "水态混和酸");
+ GVL_BigStation.RawMaterialsNameCode.Add("0054", "加水稀释后防腐剂");
+ GVL_BigStation.RawMaterialsNameCode.Add("0055", "异维C钠粉");
+ GVL_BigStation.RawMaterialsNameCode.Add("0056", "琼脂粉");
+ GVL_BigStation.RawMaterialsNameCode.Add("0057", "香葱油");
+ GVL_BigStation.RawMaterialsNameCode.Add("0058", "水态甜味剂");
+ GVL_BigStation.RawMaterialsNameCode.Add("0059", "孜然粉");
+ GVL_BigStation.RawMaterialsNameCode.Add("0060", "孜然油");
+ }
+ ///
+ /// 设备连接 西门子和海科PLC
+ ///
+ public void DeviceConnectInit()
+ {
+ GVL_BigStation.IsAllowHKPlcConnect = ConfigurationManager.AppSettings["HKPlc_Connect"].ToLower() == "true" ? true : false;
+ GVL_BigStation.IsAllowSiemensConnect = ConfigurationManager.AppSettings["Siemens_Connect"].ToLower() == "true" ? true : false;
+ try
+ {
+ if (GVL_BigStation.IsAllowHKPlcConnect)
+ {
+ HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageNotify.GetInstance.ShowRunLog("海科plc连接失败,等待重新连接");
+ }
+ finally
+ {
+ HKDevice.Init();
+ MessageNotify.GetInstance.ShowRunLog("海科plc初始化");
+ if (HKDevice.IsConnected && GVL_BigStation.IsAllowHKPlcConnect)
+ {
+ MessageNotify.GetInstance.ShowRunLog("海科plc连接成功");
+ }
+ }
+ try
+ {
+ if (GVL_BigStation.IsAllowSiemensConnect)
+ {
+ SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageNotify.GetInstance.ShowRunLog("西门子plc连接失败,等待重新连接");
+ }
+ finally
+ {
+ SiemensDevice.Init();
+ MessageNotify.GetInstance.ShowRunLog("西门子plc初始化");
+ if (SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect)
+ {
+ MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
+ }
+ }
+ }
+
+ public void ThreadInit()
+ {
+ ThreadManage.GetInstance().StartLong(new Action(() =>
+ {
+ if (!HKDevice.IsConnected && GVL_BigStation.IsAllowHKPlcConnect)
+ {
+ HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP);
+ MessageNotify.GetInstance.ShowRunLog("海科plc重新连接成功");
+ }
+ if (!SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect)
+ {
+ SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
+ MessageNotify.GetInstance.ShowRunLog("西门子plc重新连接");
+ }
+ Thread.Sleep(10);
+ }), "西门子和海科PLC重新连接", true);
+ ThreadManage.GetInstance().StartLong(new Action(() =>
+ {
+ GVL_BigStation.HeartBeatToPlc = !GVL_BigStation.HeartBeatToPlc;
+ HKDevice.HK_PLC_S7.Write("DB99.DBX0.0", GVL_BigStation.HeartBeatToPlc);
+ GVL_BigStation.HeartBeatFromPlc = HKDevice.PlcRead.HeartBeat;//读取plc心跳
+ if (HKDevice.IsConnected)
+ {
+ if (GVL_BigStation.AGVPutTray.GetBitValue(1))
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", true);
+ }
+ else
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false);
+ }
+ if (GVL_BigStation.AGVPutTray.GetBitValue(2))
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", true);
+ }
+ else
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false);
+ }
+ if (GVL_BigStation.AGVPutTray.GetBitValue(3))
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", true);
+ }
+ else
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false);
+ }
+ if (GVL_BigStation.AGVPutTray.GetBitValue(4))
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", true);
+ }
+ else
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false);
+ }
+ if (GVL_BigStation.AGVPutTray.GetBitValue(5))
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", true);
+ }
+ else
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false);
+ }
+ GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(1, HKDevice.PlcRead.Tray1Sensor);
+ GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(2, HKDevice.PlcRead.Tray2Sensor);
+ GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(3, HKDevice.PlcRead.Tray3Sensor);
+ GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(4, HKDevice.PlcRead.Tray4Sensor);
+ GVL_BigStation.TraySensor = GVL_BigStation.TraySensor.SetBitValue(5, HKDevice.PlcRead.Tray5Sensor);
+ GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(1, !HKDevice.PlcRead.Tray1Cylinder);
+ GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(2, !HKDevice.PlcRead.Tray2Cylinder);
+ GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(3, !HKDevice.PlcRead.Tray3Cylinder);
+ GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(4, !HKDevice.PlcRead.Tray4Cylinder);
+ GVL_BigStation.TrayCylinder = GVL_BigStation.TrayCylinder.SetBitValue(5, !HKDevice.PlcRead.Tray5Cylinder);
+ if (HKDevice.PlcRead.IsAllowIssueRecipe1 || HKDevice.PlcRead.IsAllowIssueRecipe2 || HKDevice.PlcRead.IsAllowIssueRecipe3 || HKDevice.PlcRead.IsAllowIssueRecipe4)
+ {
+ GVL_BigStation.Order_Request = true;
+ }
+ }
+ if (SiemensDevice.IsConnected)
+ {
+ GVL_BigStation.AGVPutTray = SiemensDevice.DL_Status.AGV_Put_Done;
+ GVL_BigStation.AGVGetTray = SiemensDevice.DL_Status.AGV_Get_Done;
+ SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW30", GVL_BigStation.TraySensor);
+ SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW32", GVL_BigStation.TrayCylinder);
+ SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW34", (ushort)GVL_BigStation.TrayEnable);
+ }
+ Thread.Sleep(10);
+ }), "海科plc和西门子数据交互", true);
+ ThreadManage.GetInstance().StartLong(new Action(() =>
+ {
+ testRawMaterialNameData();//自定义料仓名称
+ if (GVL_BigStation.Order_Cancel)
+ {
+ Order_Cancel();
+ }
+ else
+ {
+ /*if (GVL_BigStation.IsUseLocalRecipe)
+ {
+ LocalRecipeRecevice();
+ LocalRecipeDosing();
+ }
+ else
+ {*/
+ ReceviceData();
+ RecipeInfoToHKPLC();
+ /* }*/
+ }
+ Thread.Sleep(10);
+ }), "配方数据执行流程", true);
+ }
+ ///
+ /// 初始化变量复位
+ ///
+ public void VarResetInit()
+ {
+ LocalRecipeQueue1.Clear();
+ LocalRecipeQueue2.Clear();
+ LocalRecipeQueue3.Clear();
+ LocalRecipeQueue4.Clear();
+ SiemensRecipeQueue1.Clear();
+ SiemensRecipeQueue2.Clear();
+ SiemensRecipeQueue3.Clear();
+ SiemensRecipeQueue4.Clear();
+ }
+ public void RecipeDosing()
+ {
+ GVL_BigStation.AllowIssueRecipe[0] = HKDevice.PlcRead.IsAllowIssueRecipe1;
+ GVL_BigStation.AllowIssueRecipe[1] = HKDevice.PlcRead.IsAllowIssueRecipe2;
+ GVL_BigStation.AllowIssueRecipe[2] = HKDevice.PlcRead.IsAllowIssueRecipe3;
+ GVL_BigStation.AllowIssueRecipe[3] = HKDevice.PlcRead.IsAllowIssueRecipe4;
+ GVL_BigStation.ReceviceFinishRecipe[0] = HKDevice.PlcRead.ReceiveFinishRecipe1;
+ GVL_BigStation.ReceviceFinishRecipe[1] = HKDevice.PlcRead.ReceiveFinishRecipe2;
+ GVL_BigStation.ReceviceFinishRecipe[2] = HKDevice.PlcRead.ReceiveFinishRecipe3;
+ GVL_BigStation.ReceviceFinishRecipe[3] = HKDevice.PlcRead.ReceiveFinishRecipe4;
+ GVL_BigStation.DosingFinishRecipe[0] = HKDevice.PlcRead.Recipe1DosingFinish;
+ GVL_BigStation.DosingFinishRecipe[1] = HKDevice.PlcRead.Recipe2DosingFinish;
+ GVL_BigStation.DosingFinishRecipe[2] = HKDevice.PlcRead.Recipe3DosingFinish;
+ GVL_BigStation.DosingFinishRecipe[3] = HKDevice.PlcRead.Recipe4DosingFinish;
+ GVL_BigStation.IsTrayArrive[0] = HKDevice.PlcRead.Tray1InPlace;
+ GVL_BigStation.IsTrayArrive[1] = HKDevice.PlcRead.Tray2InPlace;
+ GVL_BigStation.IsTrayArrive[2] = HKDevice.PlcRead.Tray3InPlace;
+ GVL_BigStation.IsTrayArrive[3] = HKDevice.PlcRead.Tray4InPlace;
+ GVL_BigStation.IsTrayArrive[4] = HKDevice.PlcRead.Tray5InPlace;
+ #region 接收配方
+ SiemensRecipes = Json.Data.Recipes;
+ if (SiemensRecipes.Count > 0)
+ {
+ foreach (var data in SiemensRecipes)
+ {
+ foreach (var item in SiemensRecipeQueue)
+ {
+ if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key-1])
+ {
+ if (SiemensDevice.DL_Status is DL_Status_DB status)
+ {
+ switch (GVL_BigStation.SiemensSendRecipeStatus)
+ {
+ case 3:
+ SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10);
+ SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true);
+ MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给西门子");
+ GVL_BigStation.SiemensSendRecipeStatus = 4;
+ break;
+ case 4:
+ if (SiemensDevice.DL_Status.Dosing_Start_ACK)
+ {
+ SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10);
+ SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false);
+ MessageNotify.GetInstance.ShowRunLog($"配方1,西门子确认开始配料");
+ GVL_BigStation.SiemensSendRecipeStatus = 5;
+ }
+ break;
+ case 5:
+ if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
+ {
+ item.Value.Enqueue(data.RecipeCode);
+ MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列");
+ GVL_BigStation.SiemensSendRecipeStatus = 0;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ SiemensRecipeQueue.Clear();
+ GVL_BigStation.BarrelWasherSign = false;
+ for (int i = 0; i < GVL_BigStation.RecipeDosingStatus.Length; i++)
+ {
+ GVL_BigStation.RecipeDosingStatus[i] = 0;
+ }
+ }
+ #endregion
+ #region 取消配方
+ if (GVL_BigStation.Order_Cancel) //订单取消
+ {
+ if (!string.IsNullOrEmpty(GVL_BigStation.Order_CancelRecipeCode))
+ {
+ string code = GVL_BigStation.Order_CancelRecipeCode;
+ int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == GVL_BigStation.Order_CancelRecipeCode);
+ short TrayCode = 0;
+ if (index >= 0)
+ {
+ TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode;
+ }
+ switch (GVL_BigStation.Order_CancelStep)
+ {
+ case 0:
+ if (index == -1)
+ {
+ GVL_BigStation.Order_CancelStep = 10;
+ }
+ else
+ {
+ GVL_BigStation.Order_CancelStep = 20;
+ foreach (var item in SiemensRecipeQueue)
+ {
+ if (item.Value.Contains(code))
+ {
+ GVL_BigStation.Order_CancelStep = 30;
+ }
+ }
+ }
+ break;
+ case 10:
+ SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
+ GVL_BigStation.Order_CancelStep = 11;
+ break;
+ case 11:
+ if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
+ {
+ SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
+ GVL_BigStation.Order_CancelStep = 12;
+ }
+ break;
+ case 12:
+ MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}");
+ GVL_BigStation.Order_Cancel = false;
+ GVL_BigStation.Order_CancelRecipeCode = "";
+ GVL_BigStation.Order_CancelStep = 0;
+ break;
+
+ case 20:
+ SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
+ GVL_BigStation.Order_CancelStep = 21;
+ break;
+ case 21:
+ if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
+ {
+ SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
+ GVL_BigStation.Order_CancelStep = 22;
+ }
+ break;
+ case 22:
+ GVL_BigStation.SiemensSendRecipeStatus = 0;
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ Json.Data.Recipes.RemoveAt(index);
+ });
+ MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{GVL_BigStation.Order_CancelRecipeCode}");
+ GVL_BigStation.Order_Cancel = false;
+ GVL_BigStation.Order_CancelRecipeCode = "";
+ GVL_BigStation.Order_CancelStep = 0;
+ break;
+
+ case 30:
+ foreach (var item in SiemensRecipeQueue)
+ {
+ if (item.Value.Contains(code))
+ {
+ if (GVL_BigStation.RecipeDosingStatus[item.Key-1] != 0)
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true);
+ HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode);
+ GVL_BigStation.RecipeDosingStatus[item.Key - 1] = 0;
+ item.Value.TryDequeue(out code);
+ GVL_BigStation.Order_CancelStep = 32;
+ MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
+ }
+ else
+ {
+ GVL_BigStation.Order_CancelStep = 32;
+ MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
+ }
+ }
+ }
+ break;
+ case 32:
+ SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true);
+ GVL_BigStation.Order_CancelStep = 33;
+ break;
+ case 33:
+ if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false)
+ {
+ SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false);
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ Json.Data.Recipes.RemoveAt(index);
+ });
+ GVL_BigStation.Order_CancelStep = 0;
+ MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ #endregion
+ #region 配料
+ foreach (var data in SiemensRecipeQueue)
+ {
+ int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == data.Value.ElementAt(0));
+ if (index >= 0 && index < SiemensRecipes.Count)
+ {
+ string code = SiemensRecipes.ElementAt(index).RecipeCode;
+ int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
+ if (GVL_BigStation.RecipeDosingStatus[data.Key] == 0 && GVL_BigStation.AllowIssueRecipe[data.Key] && GVL_BigStation.IsTrayArrive[trayCode - 1])//配方4是否允许下发配发
+ {
+ if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
+ {
+ if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据
+ {
+ GVL_BigStation.BarrelWasherSign = true;
+ HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶
+ MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶");
+
+ GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now;
+ HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
+ HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
+ GVL_BigStation.RecipeDosingStatus[data.Key] = 1;
+ MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
+ }
+ }
+ else
+ {
+ GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now;
+ HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
+ HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
+ GVL_BigStation.RecipeDosingStatus[data.Key] = 1;
+ MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
+ }
+ }
+ if (GVL_BigStation.RecipeDosingStatus[data.Key] == 1 && GVL_BigStation.ReceviceFinishRecipe[data.Key])
+ {
+ if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
+ {
+ HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶
+ MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位");
+ }
+ GVL_BigStation.RecipeDosingStatus[data.Key] = 2;
+ HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true);
+ StockBinParReset();
+ MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
+ }
+ if (GVL_BigStation.RecipeDosingStatus[data.Key] == 2 && GVL_BigStation.DosingFinishRecipe[data.Key])
+ {
+ if (SiemensRecipes.ElementAt(index).IsWashingBarrel)
+ {
+ GVL_BigStation.BarrelWasherSign = false;
+ }
+ MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
+ ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index));
+ if (SiemensDevice.IsConnected)
+ {
+ FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
+ FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
+ FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode;
+ for (int i = 0; i < FinishData.Material.Length; i++)
+ {
+ FinishData.Material[i] = new UDT1();
+ }
+ for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
+ {
+ FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
+ FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
+ FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight);
+ MessageNotify.GetInstance.ShowRunLog($"配方{data.Key},配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg");
+ }
+ FinishData.Ask_For_Finish = true;
+ double a = DateTime.Now.Subtract(GVL_BigStation.RecipeDosingTime[data.Key]).TotalSeconds;
+ FinishData.ProcessTime = Convert.ToInt16(a);
+ SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361);
+ MessageNotify.GetInstance.ShowRunLog($"{code}配方配料完成,将信号反馈给西门子");
+ }
+ data.Value.TryDequeue(out code);
+ if (!GVL_BigStation.IsUseLocalRecipe)
+ {
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
+ });
+ }
+ else
+ {
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
+ });
+ }
+ HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", true);
+ GVL_BigStation.RecipeDosingStatus[data.Key] = 3;
+ }
+ if (GVL_BigStation.RecipeDosingStatus[data.Key] == 3 && GVL_BigStation.DosingFinishRecipe[data.Key] == false)
+ {
+ HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", false);
+ GVL_BigStation.RecipeDosingStatus[data.Key] = 0;
+ }
+ }
+ }
+ #endregion
+ }
+ ///
+ /// 读取配料完成时,每个料仓的配料重量
+ ///
+ ///
+ public void ReadStockBinDosingWeight(RecipeData recipes)
+ {
+ foreach (var item in recipes.RawMaterial)
+ {
+ if (item.RawMaterialLocation == 1)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 2)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 3)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 4)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 5)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 6)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 7)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 8)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 9)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 10)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 11)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 12)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 13)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
+ }
+ else if (item.RawMaterialLocation == 14)
+ {
+ item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
+ }
}
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterial.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterial.cs
index e25effb7..125b6ae7 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterial.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterial.cs
@@ -10,10 +10,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public class RawMaterial :ObservableObject
{
private int _mIp;
- public int DeviceIp { get { return _mIp; } set { _mIp = value; }}
+ public int DeviceIp { get { return _mIp; } set { _mIp = value; OnPropertyChanged(); } }
- public short RawMaterialCount { get { return _mRawMaterialCount; } set { _mRawMaterialCount = value; OnPropertyChanged(); } }
- private short _mRawMaterialCount;
+ public int RawMaterialCount { get { return _mRawMaterialCount; } set { _mRawMaterialCount = value; OnPropertyChanged(); } }
+ private int _mRawMaterialCount;
+
+ ///
+ /// 原料中文名
+ ///
+ public string RawMaterialChineseName { get { return _mRawMaterialChineseName; } set { _mRawMaterialChineseName = value; OnPropertyChanged(); } }
+ private string _mRawMaterialChineseName;
///
/// 原料名称
@@ -36,7 +42,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
///
/// 实际的下料中重量
///
- public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } }
+ public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; OnPropertyChanged(); } }
private float _mLaying_Off_Weight;
///
diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialData.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialData.cs
new file mode 100644
index 00000000..ac8e0844
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialData.cs
@@ -0,0 +1,16 @@
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model
+{
+ public class RawMaterialData
+ {
+ public ObservableCollection RawMaterial { get; set; } = new ObservableCollection();
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs
index aa3f42fa..9d1a21c9 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs
@@ -28,9 +28,29 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } }
private int _mTrayCode;
+ ///
+ /// 配方类型是否为洗桶
+ ///
+ public string OrderType { get { return _mOrderType; } set { _mOrderType = value; OnPropertyChanged(); } }
+ private string _mOrderType;
+
+ ///
+ /// 配方类型是否为洗桶
+ ///
+ public bool IsWashingBarrel { get { return _mIsWashingBarrel; } set { _mIsWashingBarrel = value; OnPropertyChanged(); } }
+ private bool _mIsWashingBarrel;
+
///
/// 原料数据
///
public ObservableCollection RawMaterial { get; set; } = new ObservableCollection();
+
+ public RecipeSource RecipesSource { get { return _mRecipesSource; } set { _mRecipesSource = value; OnPropertyChanged(); } }
+ private RecipeSource _mRecipesSource = RecipeSource.远程;
+ }
+ public enum RecipeSource
+ {
+ 本地,
+ 远程
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/RecipeDosing.cs b/BPASmartClient.JXJFoodBigStation/Model/RecipeDosing.cs
new file mode 100644
index 00000000..d55082c1
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/Model/RecipeDosing.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.Model
+{
+ public class RecipeDosing
+ {
+ public string RecipeCode { get; set; }
+ public int RecipeTray { get; set; }
+ public int DosingStatus { get; set; }
+
+
+ public bool IsAllowIssue { get; set; }
+ public bool IsAGVArrive { get; set; }
+ public bool IsReceviceFinish { get; set; }
+ public bool IsDosingFinish { get; set; }
+
+ public DateTime DosingStartTime { get; set; }
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs
index c90f5442..87a4e144 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs
@@ -40,6 +40,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
///
public bool Order_Request_Ack { get; set; }
///
+ /// 订单取消
+ ///
+ public bool Order_Cancel { get; set; }
+ ///
/// 备用
///
public short[] Standby { get; set; } = new short[4];
@@ -48,6 +52,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
///
public bool Order_Request { get; set; }
///
+ /// 订单取消回复
+ ///
+ public bool Order_Cancel_Ack { get; set; }
+ ///
/// 备用
///
public short[] Standby1 { get; set; } = new short[4];
diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
index d84885f9..1456067a 100644
--- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
+++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
@@ -7,6 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using BPASmartClient.S7Net;
using System.Threading;
+using BPASmartClient.CustomResource.Pages.Model;
namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
@@ -31,19 +32,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
if (GVL_BigStation.Order_Request && GVL_BigStation.SiemensSendRecipeStatus == 0)
{
- GVL_BigStation.SiemensSendRecipeStatus = 1;
this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true);
+ MessageNotify.GetInstance.ShowRunLog($"向西门子请求订单");
+ GVL_BigStation.SiemensSendRecipeStatus = 1;
}
if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1)
{
- GVL_BigStation.SiemensSendRecipeStatus = 2;
ActionManage.GetInstance.Send("SiemensSendRecipe", start);
this.Siemens_PLC_S7.Write("DB2301.DBX330.0", false);
+ MessageNotify.GetInstance.ShowRunLog($"西门子下发订单:{start.RecipeCode}");
+ GVL_BigStation.SiemensSendRecipeStatus = 2;
}
if (TTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 2)
{
- GVL_BigStation.SiemensSendRecipeStatus = 3;
GVL_BigStation.Order_Request = false;
+ MessageNotify.GetInstance.ShowRunLog($"西门子确认上位机接收到订单:{start.RecipeName}");
+ GVL_BigStation.SiemensSendRecipeStatus = 3;
+ }
+ if (RTrig.GetInstance("Order_Cancel").Start(start.Order_Cancel)) //订单取消
+ {
+ GVL_BigStation.Order_Cancel = true;
+ GVL_BigStation.Order_CancelRecipeCode = start.RecipeCode;
+ MessageNotify.GetInstance.ShowRunLog($"西门子下发取消工单指令:{start.RecipeName}");
}
}
if (res1 != null && res1 is DL_Status_DB status)
@@ -52,7 +62,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
}
if (res2 != null && res2 is DL_Finish_DB finish)
{
- if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC) && GVL_BigStation.SiemensSendRecipeStatus == 7)
+ if (finish.Ask_For_Finish_PLC &&(GVL_BigStation.Recipe1DosingFinish || GVL_BigStation.Recipe2DosingFinish || GVL_BigStation.Recipe3DosingFinish || GVL_BigStation.Recipe4DosingFinish))
{
finish.Order_No = "";
finish.Product_Code = "";
@@ -61,10 +71,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
{
finish.Material[i] = new UDT1();
}
- GVL_BigStation.SiemensSendRecipeStatus = 0;
finish.Ask_For_Finish = false;
finish.ProcessTime = 0;
this.Siemens_PLC_S7.WriteClass(finish, 2361);
+ if (GVL_BigStation.Recipe1DosingFinish) GVL_BigStation.Recipe1DosingFinish = false;
+ if (GVL_BigStation.Recipe2DosingFinish) GVL_BigStation.Recipe2DosingFinish = false;
+ if (GVL_BigStation.Recipe3DosingFinish) GVL_BigStation.Recipe3DosingFinish = false;
+ if (GVL_BigStation.Recipe4DosingFinish) GVL_BigStation.Recipe4DosingFinish = false;
}
}
Thread.Sleep(10);
@@ -75,7 +88,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
}
}
Thread.Sleep(10);
- }), "监听服务数据");
+ }), "西门子数据交互",true);
}
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml b/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml
new file mode 100644
index 00000000..cebe958f
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml.cs b/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml.cs
new file mode 100644
index 00000000..6c013785
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/View/BomOfMaterialView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace BPASmartClient.JXJFoodBigStation.View
+{
+ ///
+ /// HKPlcCommMonitor.xaml 的交互逻辑
+ ///
+ public partial class BomOfMaterialView : UserControl
+ {
+ public BomOfMaterialView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml
index ae8c420d..e0d3a366 100644
--- a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml
@@ -374,7 +374,7 @@
@@ -386,7 +386,7 @@
-
+
@@ -568,7 +568,6 @@
-
@@ -637,7 +636,7 @@
Foreground="#FF0084FF"
Text=" 号仓" />
-
+ Style="{StaticResource ImageButtonStyle}">-->
+
+
@@ -23,7 +25,8 @@
Width="200"
Height="40"
Margin="5,0,5,0"
- Command="{Binding Tray1InPlace}"
+ Command="{Binding TrayInPlace}"
+ CommandParameter="1"
Content="AGV到达工位1"
FontSize="20"
Panel.ZIndex="0"
@@ -32,7 +35,8 @@
Width="200"
Height="40"
Margin="5,0,5,0"
- Command="{Binding Tray2InPlace}"
+ Command="{Binding TrayInPlace}"
+ CommandParameter="2"
Content="AGV到达工位2"
FontSize="20"
Panel.ZIndex="0"
@@ -41,7 +45,8 @@
Width="200"
Height="40"
Margin="5,0,5,0"
- Command="{Binding Tray3InPlace}"
+ Command="{Binding TrayInPlace}"
+ CommandParameter="3"
Content="AGV到达工位3"
FontSize="20"
Panel.ZIndex="0"
@@ -50,7 +55,8 @@
Width="200"
Height="40"
Margin="5,0,5,0"
- Command="{Binding Tray4InPlace}"
+ Command="{Binding TrayInPlace}"
+ CommandParameter="4"
Content="AGV到达工位4"
FontSize="20"
Panel.ZIndex="0"
@@ -59,30 +65,170 @@
Width="200"
Height="40"
Margin="5,0,5,0"
- Command="{Binding Tray5InPlace}"
+ Command="{Binding TrayInPlace}"
+ CommandParameter="5"
Content="AGV到达工位5"
FontSize="20"
Panel.ZIndex="0"
Style="{StaticResource ImageButtonStyle}">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
index 63e35bc1..0d22968d 100644
--- a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml
@@ -289,8 +289,8 @@
+
-
diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
index ef78e4b8..3c220ef4 100644
--- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
@@ -159,11 +159,23 @@
+
+
+
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+ Text="配方编号:" />
-
+
+
+
+
+
+
+
+
+
+
-
@@ -448,34 +447,115 @@
Margin="5">
-
-
+
+
+
+
+
+
+
+
+
+ Grid.RowSpan="8"
+ Grid.ColumnSpan="2"
+ Source="/BPASmartClient.CustomResource;component/Image/配方背景/竖背景框.png"
+ Stretch="Fill" />
+ Grid.Row="0"
+ Grid.ColumnSpan="2"
+ FontSize="14"
+ Margin="5,0,0,0"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ Foreground="#FF2AB2E7"
+ Text="配方信息" />
+ Grid.Row="1"
+ Grid.Column="0"
+ Margin="2,5,0,0"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ FontSize="12"
+ Foreground="#FF2AB2E7"
+ Text="配方名称:" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -841,11 +923,11 @@
-
-
+
diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml.cs b/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml.cs
index a5099747..66464759 100644
--- a/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml.cs
+++ b/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml.cs
@@ -28,24 +28,24 @@ namespace BPASmartClient.JXJFoodBigStation.View
private void RadioButtonCompelete_Click(object sender, RoutedEventArgs e)
{
- repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeCompelete;
- repiceList.Visibility = Visibility.Visible;
- repiceListMaking.Visibility = Visibility.Hidden;
+ //repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeCompelete;
+ //repiceList.Visibility = Visibility.Visible;
+ //repiceListMaking.Visibility = Visibility.Hidden;
}
private void RadioButtonWait_Click(object sender, RoutedEventArgs e)
{
- repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeWait;
- repiceList.Visibility = Visibility.Visible;
- repiceListMaking.Visibility = Visibility.Hidden;
+ //repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeWait;
+ //repiceList.Visibility = Visibility.Visible;
+ //repiceListMaking.Visibility = Visibility.Hidden;
}
private void RadioButtonMaking_Click(object sender, RoutedEventArgs e)
{
- repiceListMaking.Visibility = Visibility.Visible;
- repiceList.Visibility = Visibility.Hidden;
+ //repiceListMaking.Visibility = Visibility.Visible;
+ //repiceList.Visibility = Visibility.Hidden;
}
}
diff --git a/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml b/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml
index 945d9bdc..b90c7de9 100644
--- a/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml
@@ -455,8 +455,8 @@
-
-
+
+
+ VerticalScrollBarVisibility="Visible">
diff --git a/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml b/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml
index ef94f4c8..a0ea54b5 100644
--- a/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml
+++ b/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml
@@ -13,17 +13,16 @@
+
-
-
+
-
@@ -51,19 +49,18 @@
-
+
-
-
+
-
+
-
+
@@ -84,6 +81,7 @@
@@ -103,34 +101,29 @@
Cursor="SizeWE" />
-
-
+
+
+
diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/BomOfMaterialViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/BomOfMaterialViewModel.cs
new file mode 100644
index 00000000..81339514
--- /dev/null
+++ b/BPASmartClient.JXJFoodBigStation/ViewModel/BomOfMaterialViewModel.cs
@@ -0,0 +1,75 @@
+using BPASmartClient.CustomResource.Pages.Model;
+using BPASmartClient.CustomResource.UserControls;
+using BPASmartClient.CustomResource.UserControls.MessageShow;
+using BPASmartClient.Helper;
+using BPASmartClient.JXJFoodBigStation.Model;
+using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using Microsoft.Toolkit.Mvvm.Input;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodBigStation.ViewModel
+{
+ public class BomOfMaterialViewModel : ObservableObject
+ {
+ public BomOfMaterialViewModel()
+ {
+ RawMaterialInfo = Json.Data.RawMaterials;
+ /*if (RawMaterialInfo.Count ==0)
+ {
+ Json.Data.RawMaterials.Clear();
+ ProcessControl.GetInstance.RawMaterialNameWithCode();//原料的名称和编码对应 :西门子mes定义的物料编码
+ foreach (var item in GVL_BigStation.RawMaterialsNameCode)
+ {
+ Json.Data.RawMaterials.Add(new RawMaterial() { RawMaterialCount = Json.Data.RawMaterials.Count + 1, RawMaterialName = item.Key, RawMaterialChineseName = item.Value });
+ }
+ RawMaterialInfo = Json.Data.RawMaterials;
+ NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"读取程序的Bom清单");
+ }*/
+ AddMaterial = new RelayCommand(() =>
+ {
+ RawMaterialInfo.Add(new RawMaterial()
+ {
+ RawMaterialCount = Json.Data.RawMaterials.Count +1 ,
+ });
+ });
+ SaveMaterials = new RelayCommand(() =>
+ {
+ if (MessageNotify.GetInstance.ShowDialog("请确认是否保存!") == true)
+ {
+ Json.Save();
+ MessageNotify.GetInstance.ShowUserLog($"Mes物料清单保存成功");
+ NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功");
+ }
+ });
+ RemoveCommand = new RelayCommand((Count) =>
+ {
+ if (Count is int cnt)
+ {
+ var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialCount == cnt);
+ if (res != null)
+ {
+ if (MessageNotify.GetInstance.ShowDialog("请确认是否删除!") == true)
+ {
+ RawMaterialInfo.Remove(res);
+ NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"删除成功");
+ }
+ }
+ }
+ });
+ }
+ public ObservableCollection RawMaterialInfo { get; set; } = new ObservableCollection();
+ public RelayCommand AddMaterial { get; set; }
+ public RelayCommand SaveMaterials { get; set; }
+ public RelayCommand RemoveCommand { get; set; }
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs
index 0e7ef82a..c17c5f0b 100644
--- a/BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs
+++ b/BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs
@@ -110,7 +110,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
int index = Array.FindIndex(PlcInfo.ToArray(), p => p.Address == address);
if (index != -1)
{
- if(ProcessControl.GetInstance.HKDevice.IsConnected) ProcessControl.GetInstance.HKDevice.HK_PLC_S7.Write(address , PlcInfo.ElementAt(index).SetValue);
+ if (ProcessControl.GetInstance.HKDevice.IsConnected) ProcessControl.GetInstance.HKDevice.HK_PLC_S7.Write(address, PlcInfo.ElementAt(index).SetValue);
}
}*/
});
@@ -121,7 +121,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
Type type = typeof(T);
}*/
- public ObservableCollection PlcInfo { get; set; } = new ObservableCollection();
+ public static ObservableCollection PlcInfo { get; set; } = new ObservableCollection();
public RelayCommand
-
+
@@ -26,12 +26,25 @@
+
+ Code
+
+
+ Code
+
Code
+
+ Code
+
+
+ $(DefaultXamlRuntime)
+ Designer
+
$(DefaultXamlRuntime)
@@ -42,6 +55,10 @@
$(DefaultXamlRuntime)
Designer
+
+ $(DefaultXamlRuntime)
+ Designer
+
$(DefaultXamlRuntime)
Designer
@@ -50,6 +67,10 @@
$(DefaultXamlRuntime)
Designer
+
+ $(DefaultXamlRuntime)
+ Designer
+
$(DefaultXamlRuntime)
Designer
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterial.cs
new file mode 100644
index 00000000..56606358
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterial.cs
@@ -0,0 +1,21 @@
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model.Bom
+{
+ public class BomMaterial:ObservableObject
+ {
+ public int Count { get { return _count; } set { _count = value; OnPropertyChanged(); } }
+ public int _count { get; set; }
+
+ public string MaterialCode { get { return _materialCode; }set { _materialCode = value;OnPropertyChanged(); } }
+ private string _materialCode="";
+
+ public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } }
+ private string _materialName="";
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs
new file mode 100644
index 00000000..d7cacf1b
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs
@@ -0,0 +1,16 @@
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model.Bom
+{
+ public class BomMaterialData
+ {
+ public ObservableCollection Materials { get; set; } = new ObservableCollection();
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcInfos.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcInfos.cs
new file mode 100644
index 00000000..472a0ef7
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcInfos.cs
@@ -0,0 +1,27 @@
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model.GVL
+{
+ public class PlcInfos: ObservableObject
+ {
+ public int Count { get { return _Count; } set { _Count = value;OnPropertyChanged(); } }
+ private int _Count { get; set; }
+
+ public string Name { get { return _Name; } set { _Name = value; OnPropertyChanged(); } }
+ private string _Name { get; set; }
+ public string Address { get { return _Address; } set { _Address = value; OnPropertyChanged(); } }
+ private string _Address { get; set; }
+ public string Type { get { return _Type; } set { _Type = value; OnPropertyChanged(); } }
+ private string _Type { get; set; }
+ public string Describe { get { return _Describe; } set { _Describe = value; OnPropertyChanged(); } }
+ private string _Describe { get; set; }
+ public string Value { get { return _Value; } set { _Value = value; OnPropertyChanged(); } }
+ private string _Value { get; set; }
+
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL/VarCommAttribute.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL/VarCommAttribute.cs
new file mode 100644
index 00000000..1e23d1d9
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL/VarCommAttribute.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model.GVL
+{
+ [AttributeUsage(AttributeTargets.Property)]
+ public sealed class VarCommAttribute:Attribute
+ {
+ public VarCommAttribute(string address,string des)
+ {
+ Address = address;
+ Describe = des;
+ }
+ public string Describe { get; set; }
+ public string Address { get; set; }
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
index 72e17586..50859211 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
@@ -1,4 +1,6 @@
-using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
+using BPASmartClient.JXJFoodSmallStation.Model.GVL;
+using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
+using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -14,131 +16,278 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
private volatile static GVL_SmallStation SmallStation;
public static GVL_SmallStation GetInstance => SmallStation ?? (SmallStation = new GVL_SmallStation());
private GVL_SmallStation() { }
+
+ public PlcReadAddressDB3 plcReadDataDB3 { get; set; } = new PlcReadAddressDB3();
+ ///
+ /// 配料站料仓数目
+ ///
+ public const int Max_DosingSotckBinNum = 15;
+ ///
+ /// 风送料仓数目
+ ///
+ public const int Max_PowderSotckBinNum = 5;
+
+ [VarComm("Global", "订单取消")]
+ ///
+ /// 订单取消
+ ///
+ public bool Order_Cancel { get; set; }
+
+ [VarComm("Global", "订单取消的配方编号")]
+ ///
+ /// 订单取消的配方编号
+ ///
+ public string Order_CancelRecipeCode { get; set; } = "";
+
+
+ [VarComm("Global", "柔性配料料仓配料情况")]
+ ///
+ /// 料仓配料情况
+ ///
+ public ushort StockBinDosing { get; set; } = 0;
+
+ [VarComm("Global", "托盘1托盘到位情况0:未到位,1=AGV到位,2=托盘有货架,3=AGV取托盘完成")]
+ ///
+ /// 托盘1托盘到位情况
+ ///
+ public int Tray1LogicFinish { get; set; } = 0;
+
+ [VarComm("Global", "托盘2托盘到位情况0:未到位,1=AGV到位,2=托盘有货架,3=AGV取托盘完成")]
///
- /// 托盘1托盘到位 逻辑完成
+ /// 托盘2托盘到位 逻辑完成
///
- public static bool TrayLogicFinish { get; set; } = false;
+ public int Tray2LogicFinish { get; set; } = 0;
+
+ [VarComm("Global", "托盘1有货架")]
///
/// 托盘1有货架
///
- public static bool Station1HaveTray { get; set; }
+ public bool Station1HaveTray { get; set; }
+
+
+ [VarComm("Global", "托盘2有货架")]
///
/// 托盘2有货架
///
- public static bool Station2HaveTray { get; set; }
+ public bool Station2HaveTray { get; set; }
+
+
+ [VarComm("Global", "托盘1传感器信号")]
+ ///
+ /// 托盘1传感器信号
+ ///
+ public bool Station1Sensor { get; set; }
- public static bool Station1Sensor { get; set; }
+ [VarComm("Global", "托盘2传感器信号")]
///
/// 托盘2传感器信号
///
- public static bool Station2Sensor { get; set; }
- public static bool Station1Cylinder { get; set; }
+ public bool Station2Sensor { get; set; }
+
+
+ [VarComm("Global", "托盘1气缸信号")]
+ ///
+ /// 托盘1气缸信号
+ ///
+ public bool Station1Cylinder { get; set; }
+
+ [VarComm("Global", "托盘2气缸信号")]
///
/// 托盘2气缸信号
///
- public static bool Station2Cylinder { get; set; }
+ public bool Station2Cylinder { get; set; }
- public static bool AGV_PutTray1Finish { get; set; }
- public static bool AGV_GetTray1Finish { get; set; }
- public static bool CylinderReset { get; set; }
+ [VarComm("Global", "AGV放托盘1完成")]
///
- /// 配料站料仓数目
+ /// AGV放托盘1完成
///
- public const int Max_DosingSotckBinNum = 15;
+ public bool AGV_PutTray1Finish { get; set; }
+
+ [VarComm("Global", "AGV取托盘1完成")]
///
- /// 风送料仓数目
+ /// AGV取托盘1完成
///
- public const int Max_PowderSotckBinNum = 5;
- public bool HeartBeatToPlc { get; set; } = false;
- public bool HeartBeatFromPlc { get; set; } = false;
+ public bool AGV_GetTray1Finish { get; set; }
+
+ [VarComm("Global", "AGV放托盘2完成")]
///
- /// 是否允许西门子下发配方
+ /// AGV放托盘1完成
///
- public static bool IsAllowSiemensSendRecipe { get; set; } = false;
+ public bool AGV_PutTray2Finish { get; set; }
+
+ [VarComm("Global", "AGV取托盘2完成")]
///
- /// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收完成 4:请求配料 5:西门子开始配料确认 6:配方配料完成 7:配料完成确认
+ /// AGV取托盘2完成
///
- public static int SiemensSendRecipeStatus { get; set; } = 0;
+ public bool AGV_GetTray2Finish { get; set; }
+
+ [VarComm("Global", "托盘1气缸复位")]
///
- /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
+ /// 托盘1气缸复位
///
- public int RecipeStatusID { get; set; } = 0;
+ public bool CylinderReset { get; set; }
+ [VarComm("Global", "发送给plc的心跳")]
///
- /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
+ /// 发送给plc的心跳
///
- public int RecipeStatusIDTray2 { get; set; } = 0;
+ public bool HeartBeatToPlc { get; set; } = false;
+ [VarComm("Global", "来自plc的心跳")]
///
- /// Tray1的柔性味魔方配料标志(下发配方时,若柔性味魔方的状态=3,复位该状态)
+ /// 来自plc的心跳
///
- public bool DosingTray1 { get; set; } = false;//默认为true,初始时,判断柔性味魔方的状态。
+ public bool HeartBeatFromPlc { get; set; } = false;
+
+ [VarComm("Global", "是否允许西门子下发配方")]
///
- /// Tray2的柔性味魔方配料标志
+ /// 是否允许西门子下发配方
///
- public bool DosingTray2 { get; set; } = false;
+ public bool IsAllowSiemensSendRecipe { get; set; } = false;
- public int DosingTray1Loc { get; set; } = 0;
- public int DosingTray2Loc { get; set; } = 0;
+ [VarComm("Global", "西门子下发配方状态0=等待下发配方 1=请求下发配方 2=接收配方 3=配方接收配方完成 4=请求配料 5=西门子确认开始配料 6=西门子确认开始配料信号复位")]
///
- /// 当前料仓的位置
+ /// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收配方完成 4:上位机向西门子请求配料 5:西门子确认开始配料 6:西门子确认开始配料 信号复位
///
- public int StockInIsWork { get; set; } = 0;
+ public int SiemensSendRecipeStatus { get; set; } = 0;
+
+ [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
+ ///
+ /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料
+ ///
+ public int RecipeStatusIDTray1 { get; set; } = 0;
+
+ [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
+ ///
+ /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料
+ ///
+ public int[] RecipeProcessStatus { get; set; } = new int[5] { 0, 0, 0, 0, 0 };
+
+ [VarComm("Global", "配方2下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")]
///
- /// 记录AGV进站送货的指令顺序
+ /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料
///
- public int AgvDeliveryPosition { get; set; }= 0;
+ public int RecipeStatusIDTray2 { get; set; } = 0;
+
+ [VarComm("Global", "当前配方正在配料位置")]
///
- /// 记录AGV进站取货的指令顺序
+ /// 当前料仓的位置
///
- public int AgvPickUpPosition { get; set; } = 0;
+ public int StockInIsWork { get; set; } = 0;
+
+ [VarComm("Global", "是否使用粉仓配料")]
///
- /// 是否使用粉仓
+ /// 是否使用粉仓配料
///
public bool IsUseWindSend { get; set; } = false;
+
+ [VarComm("Global", "粉仓正在配料")]
///
- /// 风送配料完成标志
+ /// 粉仓正在配料
///
- public bool WindSendDosingFinish { get; set; } = false;
+ public bool WindSendDosing { get; set; } = false;
+
///
- /// 顶升气缸的信号
+ /// 所有气缸的信号
///
- public bool[] Cylinder_JackInfo = new bool[15];
+ public bool[] Cylinder_JackInfo { get; set; } = new bool[30];
#region 本地模拟配方
+
+ [VarComm("Global", "是否使用本地模拟配方")]
///
/// 是否使用本地模拟配方
///
public bool IsUseLocalRecipe { get; set; }
+
///
- /// 是否使用本地模拟订单+风送配方
+ /// 配料时间
///
- public bool IsUseWindSendDosing { get; set; }
- public static int test1 = 1;
public DateTime time1;
+
+ ///
+ /// 原料的名称和原料编号对应,Mes提供的信息
+ ///
+ public ConcurrentDictionary RawMaterialsNameCode { get; set; } = new ConcurrentDictionary();
+
+ [VarComm("Global", "风送是否允许AGV到工站")]
///
/// 风送是否允许AGV到工站
///
- public static bool WindSendAllowAGVPutGet { get; set; } = false;
+ public bool WindSendAllowAGVPutGet { get; set; } = false;
+
+ [VarComm("Global", "粉料仓配料完成")]
///
/// 粉料仓配料完成
///
- public static bool WindSendDosingComple { get; set; } = false;
+ public bool WindSendDosingComple { get; set; } = false;
+
+ [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")]
+ ///
+ /// PLC的系统模式 DB44.DBX0.1
+ ///
+ public bool PlcSystemMode { get; set; } = false;
+
+ [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")]
+ ///
+ /// 不使用15个料仓报警
+ ///
+ public bool DisEnableStockBinAlarm { get; set; } = false;
+
+ [VarComm("Global", "PLC的系统自动启停 DB44.DBX0.0")]
///
- /// 系统模式
+ /// PLC的系统自动启停 DB44.DBX0.0
///
- public static bool SystemMode { get; set; } = false;
+ public bool PlcSystemIsAutoRun { get; set; } = false;
+
+ [VarComm("Global", "PLC的系统自动暂停/开始 DB44.DBX0.2")]
///
- /// 系统状态
+ /// PLC的系统自动暂停/开始 DB44.DBX0.2
///
- public static bool SystemStatus { get; set; } = false;
+ public bool PlcSystemIsPause { get; set; } = false;
+
+ [VarComm("Global", "延迟采集料仓的配料完成重量")]
///
- /// 系统运行状态
+ /// 延迟采集料仓的配料完成重量
///
- public static bool SystemRunStatus { get; set; } = false;
+ public int Time { get; set; } = 1000;
+
+ [VarComm("Global", "取消订单的步骤号")]
+ ///
+ /// 取消订单的步骤: 1-9:配料过程中配方1取消配方 10-19:配料过程中配方2取消配方 20-29:下发订单的过程中取消订单(订单未到达上位机) 30-39:下发订单的过程中取消订单(订单未到达PLC)
+ ///
+ public int OrderCancelStep { get; set; } = 0;
+
+ [VarComm("Global", "机器人的状态")]
+ ///
+ /// 机器人的状态
+ ///
+ public ushort RobotStatus { get; set; } = 0;
+
+ [VarComm("Global", "机器人的程序号")]
+ ///
+ /// 机器人的程序号
+ ///
+ public byte RobotProgramNum { get; set; } = 0;
#endregion
}
+ public enum IssueRecipeCondition
+ {
+ 等待小料站PLC允许下配方,
+ 等待西门子下发配方,
+ 等待西门子下发配方信号复位,
+ 等待上位机请求配料,
+ 等待西门子确认配料,
+ 等待西门子确认配料信号复位,
+ }
+ public enum ProcessCondition
+ {
+ 等待AGV到位,
+ 等待小料站PLC接受配方完成,
+ 等待配方配料完成,
+ 等待AGV取托盘完成
+ }
}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs
deleted file mode 100644
index f47bd894..00000000
--- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using BPASmartClient.Helper;
-using BPASmartClient.Modbus;
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
-{
- public class DataComm
- {
- public volatile static DataComm Instance;
- public static DataComm GetInstance => Instance ?? (new DataComm());
- public DataComm() { }
- ///
- /// 是否允许配料
- ///
- public bool IsAllowDosing { get { return _mIsAllowDosing; } set { _mIsAllowDosing = value; } }
- private bool _mIsAllowDosing;
-
- public bool DosingFinishToPLC { get { return _mDosingFinishToPLC; } set { _mDosingFinishToPLC = value; } }
- private bool _mDosingFinishToPLC;
-
- private int _mStockBinLocationToPLC;
- public int StockBinLocationToPLC { get { return _mStockBinLocationToPLC; } set { _mStockBinLocationToPLC = value; } }
-
- public bool StatusSignToBPA { get { return _mStatusSignToBPA; } set { _mStatusSignToBPA = value; } }
- private bool _mStatusSignToBPA;
-
- private int _mStockBinLocationToBPA;
- public int StockBinLocationToBPA { get { return _mStockBinLocationToBPA; } set { _mStockBinLocationToBPA = value; } }
-
- private int _mBarrelNumToPLC;
- public int BarrelNumToPLC { get { return _mBarrelNumToPLC; } set { _mBarrelNumToPLC = value; } }
-
- /*public ConcurrentDictionary DeviceLists = new ConcurrentDictionary();*/
- }
-
-}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs
new file mode 100644
index 00000000..dee7a188
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceRead.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
+{
+ public class HKDeviceRead
+ {
+ public bool HeartBeat { get; set; }
+ public bool SystemMode { get; set; }
+ public bool SystemStart { get; set; }
+ public bool SystemPause { get; set; }
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
index c6809398..f90bd07f 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using BPASmartClient.S7Net;
using BPASmartClient.CustomResource.Pages.Model;
using System.Threading;
+using System.Collections.ObjectModel;
namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
@@ -27,42 +28,48 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
DeviceStatus = data;
}
+ var res1 = this.HK_PLC_S7.ReadClass(3);
+ if (res1 != null && res1 is PlcReadAddressDB3 data1)
+ {
+ GVL_SmallStation.GetInstance.plcReadDataDB3 = data1;
+ }
}
+ Thread.Sleep(10);
}),"海科PLC设备状态",true);
}
- ///
- /// 单个配料机配料完成
- ///
- ///
- public void SingleDosing(uint value)
- {
- if (IsConnected)
- {
- HK_PLC_S7.Write(HKPlcCommAddress.SingleStockBinLocationToPLC, value);
- HK_PLC_S7.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1);
- }
- }
- ///
- /// 复位plc允许接料信号
- ///
- public void AllowDosingSignReset()
- {
- HK_PLC_S7.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0);
- }
- ///
- /// 复位plc到达某料仓信号
- ///
- public void StockStateSignReset()
- {
- HK_PLC_S7.Write(HKPlcCommAddress.StockState, (ushort)0);
- }
- ///
- /// 复位一个配方配料完成信号
- ///
- public void RecipeDosingFinishReset()
- {
- HK_PLC_S7.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0);
- }
+ /////
+ ///// 单个配料机配料完成
+ /////
+ /////
+ //public void SingleDosing(uint value)
+ //{
+ // if (IsConnected)
+ // {
+ // HK_PLC_S7.Write(HKPlcCommAddress.SingleStockBinLocationToPLC, value);
+ // HK_PLC_S7.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1);
+ // }
+ //}
+ /////
+ ///// 复位plc允许接料信号
+ /////
+ //public void AllowDosingSignReset()
+ //{
+ // HK_PLC_S7.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0);
+ //}
+ /////
+ ///// 复位plc到达某料仓信号
+ /////
+ //public void StockStateSignReset()
+ //{
+ // HK_PLC_S7.Write(HKPlcCommAddress.StockState, (ushort)0);
+ //}
+ /////
+ ///// 复位一个配方配料完成信号
+ /////
+ //public void RecipeDosingFinishReset()
+ //{
+ // HK_PLC_S7.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0);
+ //}
///
/// 下发配方数据
///
@@ -182,5 +189,41 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
}
}
}
+
+ public void IssueRecipeToPlc(ObservableCollection rawMaterials,int recipeLoction)
+ {
+ if (IsConnected)
+ {
+ ushort barrel1 = 0;
+ ushort barrel2 = 0;
+ ushort barrel3 = 0;
+ foreach (var item in rawMaterials)
+ {
+ switch (item.RawMaterialBarrelNum)
+ {
+ case 1:
+ barrel1 = barrel1.SetBitValue((byte)item.RawMaterialLocation, true);
+ break;
+ case 2:
+ barrel2 = barrel2.SetBitValue((byte)item.RawMaterialLocation, true);
+ break;
+ case 3:
+ barrel3 = barrel3.SetBitValue((byte)item.RawMaterialLocation, true);
+ break;
+ default:
+ break;
+ }
+ }
+ string AddresBarrel1 = "DB4.DBW" + (12 + (recipeLoction - 1) * 6);
+ string AddresBarrel2 = "DB4.DBW" + (14 + (recipeLoction - 1) * 6);
+ string AddresBarrel3 = "DB4.DBW" + (16 + (recipeLoction - 1) * 6);
+ HK_PLC_S7.Write(AddresBarrel1, barrel1);
+ HK_PLC_S7.Write(AddresBarrel2, barrel2);
+ HK_PLC_S7.Write(AddresBarrel3, barrel3);
+ MessageNotify.GetInstance.ShowRunLog($"配方下发,plc配方位置{recipeLoction},桶1料仓配料{barrel1.ToBinString}");
+ MessageNotify.GetInstance.ShowRunLog($"配方下发,plc配方位置{recipeLoction},桶2料仓配料{barrel1.ToBinString}");
+ MessageNotify.GetInstance.ShowRunLog($"配方下发,plc配方位置{recipeLoction},桶3料仓配料{barrel1.ToBinString}");
+ }
+ }
}
-}
+}
\ No newline at end of file
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceWrite.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceWrite.cs
new file mode 100644
index 00000000..5ca62ab8
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceWrite.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
+{
+ public class HKDeviceWrite
+ {
+ public string Address { get; set; }
+ public PlcVarType PlcVarType { get; set; } = PlcVarType.Bool;
+ public object Value { get; set; }
+ }
+ public enum PlcVarType
+ {
+ Bool,
+ Byte,
+ Int,
+ Dint,
+ Real,
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs
new file mode 100644
index 00000000..26f141b4
--- /dev/null
+++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs
@@ -0,0 +1,178 @@
+using BPASmartClient.JXJFoodSmallStation.Model.GVL;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
+{
+ public class PlcReadAddressDB3
+ {
+ [VarComm("DB3.DBX0.0","心跳")]
+ public bool HeartBeat { get; set; }
+ [VarComm("DB3.DBX0.1", "备用1")]
+ public bool Standby1 { get; set; }
+ [VarComm("DB3.DBX0.2", "备用2")]
+ public bool Standby2 { get; set; }
+ [VarComm("DB3.DBX0.3", "备用3")]
+ public bool Standby3 { get; set; }
+ [VarComm("DB3.DBX0.4", "备用4")]
+ public bool Standby4 { get; set; }
+ [VarComm("DB3.DBX0.5", "备用5")]
+ public bool Standby5 { get; set; }
+ [VarComm("DB3.DBX0.6", "备用6")]
+ public bool Standby6 { get; set; }
+ [VarComm("DB3.DBX0.7", "工站1有托盘")]
+ public bool WorkStation1HaveTray { get; set; }
+
+ [VarComm("DB3.DBX1.0", "工站2有托盘")]
+ public bool WorkStation2HaveTray { get; set; }
+ [VarComm("DB3.DBX1.1", "工站1配料完成")]
+ public bool WorkStation1DosingComplete { get; set; }
+ [VarComm("DB3.DBX1.2", "工站2配料完成")]
+ public bool WorkStation2DosingComplete { get; set; }
+ [VarComm("DB3.DBX1.3", "工站1接收配方完成")]
+ public bool WorkStation1ReceviceRecipeComplete { get; set; }
+ [VarComm("DB3.DBX1.4", "工站2接收配方完成")]
+ public bool WorkStation2ReceviceRecipeComplete { get; set; }
+ [VarComm("DB3.DBX1.5", "工站1气缸报警")]
+ public bool WorkStation1CylinderAlarm { get; set; }
+ [VarComm("DB3.DBX1.6", "工站2气缸报警")]
+ public bool WorkStation2CylinderAlarm { get; set; }
+ [VarComm("DB3.DBX1.7", "允许配方1下发配方")]
+ public bool AllowRecipe1Issue { get; set; }
+
+ [VarComm("DB3.DBX2.0", "允许配方2下发配方")]
+ public bool AllowRecipe2Issue { get; set; }
+ [VarComm("DB3.DBX2.1", "工站1传感器信号")]
+ public bool WorkStation1Sensor { get; set; }
+ [VarComm("DB3.DBX2.2", "工站2传感器信号")]
+ public bool WorkStation2Sensor { get; set; }
+ [VarComm("DB3.DBX2.3", "工站1气缸信号,false=伸出")]
+ public bool WorkStation1Cylinder { get; set; }
+ [VarComm("DB3.DBX2.4", "工站2气缸信号,false=伸出")]
+ public bool WorkStation2Cylinder { get; set; }
+ [VarComm("DB3.DBX2.5", "工站1取消订单")]
+ public bool WorkStation1OrderCancel { get; set; }
+ [VarComm("DB3.DBX2.6", "工站2取消订单")]
+ public bool WorkStation2OrderCancel { get; set; }
+ [VarComm("DB3.DBX2.7", "备用7")]
+ public bool Standby7 { get; set; }
+ [VarComm("DB3.DBB3", "备用")]
+ public byte Standby81 { get; set; }
+ [VarComm("DB3.DBB4", "备用")]
+ public byte Standby82 { get; set; }
+ [VarComm("DB3.DBB5", "备用")]
+ public byte Standby83 { get; set; }
+ [VarComm("DB3.DBW6", "备用")]
+ public int Standby9 { get; set; }
+
+ [VarComm("DB3.DBD10", "工站1_1号桶的位置")]
+ public float WorkStation1Barrel1Pos { get; set; }
+ [VarComm("DB3.DBD14", "工站1_2号桶的位置")]
+ public float WorkStation1Barrel2Pos { get; set; }
+ [VarComm("DB3.DBD18", "工站1_3号桶的位置")]
+ public float WorkStation1Barrel3Pos { get; set; }
+ [VarComm("DB3.DBD22", "工站1_4号桶的位置")]
+ public float WorkStation1Barrel4Pos { get; set; }
+ [VarComm("DB3.DBD26", "工站2_1号桶的位置")]
+ public float WorkStation2Barrel1Pos { get; set; }
+ [VarComm("DB3.DBD30", "工站2_2号桶的位置")]
+ public float WorkStation2Barrel2Pos { get; set; }
+ [VarComm("DB3.DBD34", "工站2_3号桶的位置")]
+ public float WorkStation2Barrel3Pos { get; set; }
+ [VarComm("DB3.DBD38", "工站2_4号桶的位置")]
+ public float WorkStation2Barrel4Pos { get; set; }
+
+ [VarComm("DB3.DBD42", "备用")]
+ public int StandBy42 { get; set; }
+ [VarComm("DB3.DBD46", "备用")]
+ public int StandBy46 { get; set; }
+
+ [VarComm("DB3.DBX50.0", "工站1_1号桶允许配料")]
+ public bool WorkStation1Barrel1AllowDosing { get; set; }
+ [VarComm("DB3.DB50.1", "工站1_2号桶允许配料")]
+ public bool WorkStation1Barrel2AllowDosing { get; set; }
+ [VarComm("DB3.DB50.2", "工站1_3号桶允许配料")]
+ public bool WorkStation1Barrel3AllowDosing { get; set; }
+ [VarComm("DB3.DB50.3", "工站1_4号桶允许配料")]
+ public bool WorkStation1Barrel4AllowDosing { get; set; }
+ [VarComm("DB3.DB50.4", "工站2_1号桶允许配料")]
+ public bool WorkStation2Barrel1AllowDosing { get; set; }
+ [VarComm("DB3.DB50.5", "工站2_2号桶允许配料")]
+ public bool WorkStation2Barrel2AllowDosing { get; set; }
+ [VarComm("DB3.DB50.6", "工站2_3号桶允许配料")]
+ public bool WorkStation2Barrel3AllowDosing { get; set; }
+ [VarComm("DB3.DB50.7", "工站2_4号桶允许配料")]
+ public bool WorkStation2Barrel4AllowDosing { get; set; }
+
+ [VarComm("DB3.DBD52", "备用")]
+ public int Standby15 { get; set; }
+ [VarComm("DB3.DBD56", "备用")]
+ public int Standby16 { get; set; }
+ [VarComm("DB3.DBD60", "备用")]
+ public int Standby17 { get; set; }
+ [VarComm("DB3.DBD64", "备用")]
+ public int Standby18 { get; set; }
+ [VarComm("DB3.DBD68", "备用")]
+ public int Standby19 { get; set; }
+ [VarComm("DB3.DBD72", "备用")]
+ public int Standby20 { get; set; }
+ [VarComm("DB3.DBD76", "备用")]
+ public int Standby21 { get; set; }
+ [VarComm("DB3.DBD80", "备用")]
+ public int Standby22 { get; set; }
+ [VarComm("DB3.DBD84", "备用")]
+ public int Standby23 { get; set; }
+ [VarComm("DB3.DBD88", "备用")]
+ public int Standby24 { get; set; }
+ [VarComm("DB3.DBD92", "备用")]
+ public int Standby25 { get; set; }
+ [VarComm("DB3.DBD96", "备用")]
+ public int Standby26 { get; set; }
+
+ [VarComm("DB3.DBX100.0", "机器人运行模式")]
+ public bool RobotRunMode { get; set; }
+ [VarComm("DB3.DBX100.1", "机器人自动运行")]
+ public bool RobotAutoRun { get; set; }
+ [VarComm("DB3.DBX100.2", "机器人停止")]
+ public bool RobotStop { get; set; }
+ [VarComm("DB3.DBX100.3", "机器人运行")]
+ public bool RobotRun { get; set; }
+ [VarComm("DB3.DBX100.4", "机器人运行报警")]
+ public bool RobotRunAlarm { get; set; }
+ [VarComm("DB3.DBX100.5", "机器人在原点")]
+ public bool RobotInHomed { get; set; }
+ [VarComm("DB3.DBX100.6", "机器人备用")]
+ public bool Standby30 { get; set; }
+ [VarComm("DB3.DBX100.7", "机器人取空桶完成")]
+ public bool RobotGetEmptyBarrelComplete { get; set; }
+
+ [VarComm("DB3.DBX101.0", "机器人放空桶完成")]
+ public bool RobotPutEmptyBarrelComplete { get; set; }
+ [VarComm("DB3.DBX101.1", "机器人取满桶完成")]
+ public bool RobotGetFullBarrelComplete { get; set; }
+ [VarComm("DB3.DBX101.2", "机器人放满桶完成")]
+ public bool RobotPutFullBarrelComplete { get; set; }
+ [VarComm("DB3.DBX101.3", "备用")]
+ public bool Standby31 { get; set; }
+ [VarComm("DB3.DBX101.4", "备用")]
+ public bool Standby32 { get; set; }
+ [VarComm("DB3.DBX101.5", "备用")]
+ public bool Standby33 { get; set; }
+ [VarComm("DB3.DBX101.6", "备用")]
+ public bool Standby34 { get; set; }
+ [VarComm("DB3.DBX101.7", "备用")]
+ public bool Standby35 { get; set; }
+
+ [VarComm("DB3.DBB102", "机器人运行的程序号")]
+ public byte RobotProgramNum { get; set; }
+ [VarComm("DB3.DBB103", "备用")]
+ public byte Standby36 { get; set; }
+ [VarComm("DB3.DBB104", "备用")]
+ public byte Standby37 { get; set; }
+ [VarComm("DB3.DBB105", "备用")]
+ public byte Standby38 { get; set; }
+ }
+}
diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
index 189889f9..ae6dc6ef 100644
--- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
+++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
@@ -1,6 +1,8 @@
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Helper;
+using BPASmartClient.JXJFoodSmallStation.Model.GVL;
using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC;
+using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial;
using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
using BPASmartClient.Modbus;
@@ -10,6 +12,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -17,7 +20,7 @@ using System.Threading.Tasks;
namespace BPASmartClient.JXJFoodSmallStation.Model
{
public class ProcessControl
- {
+ {
private volatile static ProcessControl _Instance;
public static ProcessControl GetInstance => _Instance ?? (_Instance = new ProcessControl());
private ProcessControl() { }
@@ -30,15 +33,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// 原料的名称和料仓的位置对应
///
public Dictionary RawMaterialsNamePos = new Dictionary();
+ public ObservableCollection RawMaterialsInfo => Json.Data.rawMaterialStockBin;
///
/// 配方队列
///
- public ConcurrentQueue RecipeQueue = new ConcurrentQueue();
+ public ConcurrentQueue RecipeQueueTray1 = new ConcurrentQueue();
+
public ConcurrentQueue RecipeQueueTray2 = new ConcurrentQueue();
+
+
public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus();
+
+ public ObservableCollection CommData { get; set; } = new ObservableCollection();
+ public ObservableCollection ProcessVar { get; set; } = new ObservableCollection();
XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
///
/// 风送PLC的DB块
@@ -48,697 +58,384 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// 接收原料数据
///
public RecipeRawMaterial RawMaterial;
+ public DateTime StockBinAlarmTime = DateTime.Now;
+
+ public string? HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
+ public string? Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
+ public string? WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"];
+
public void Init()
{
- testData();
- //Json.Data.Recipes = Json.Data.Recipes;
- for (int i = 0; i < 16; i++)
+ PlcVarMonitor();
+ StockBinNameWithPos();
+ RawMaterialNameWithCode();
+ RegisterInit();
+ DeviceConnect();
+ //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
+ ThreadManage.GetInstance().StartLong(new Action(() =>
{
- if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null)
+ if (HKDevice.IsConnected)
{
- if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName))
+ GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc;
+ HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc);
+ GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read("DB45.DBX0.0");
+ if (DeviceInquire.GetInstance.devices.Count < 15 && HKDevice.IsConnected && Json.Data.Recipes.Count > 0 && GVL_SmallStation.GetInstance.DisEnableStockBinAlarm == false && DateTime.Now.Subtract(StockBinAlarmTime).TotalSeconds >= 60)
{
- RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum);
+ HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ MessageNotify.GetInstance.ShowDialog($"未读取到15个柔性味魔方料仓", DialogType.Error);
+ StockBinAlarmTime = DateTime.Now;
+ });
+ HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
}
}
- }
- ActionManage.GetInstance.CancelRegister("SiemensRecipeRecive");
- ActionManage.GetInstance.Register(new Action((res) =>
+ Thread.Sleep(200);
+ }), "海科plc通信心跳", true);
+ ThreadManage.GetInstance().StartLong(new Action(() =>
{
- ObservableCollection RawMaterials = new ObservableCollection();
- ObservableCollection WindSendData = new ObservableCollection();
- if (SiemensDevice.IsConnected)
+ if (GVL_SmallStation.GetInstance.Order_Cancel)
{
- if (res != null && res is XL_Start_DB recipe)
- {
- if (!string.IsNullOrEmpty(recipe.RecipeCode)) {
- RawMaterials.Clear();
- for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++)
- {
- if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name))
- {
- if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name))
- {
- RawMaterials.Add(new RemoteRecipeRawMaterial()
- {
- RawMaterialName = recipe.Material[i].Material_Name,
- RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
- RawMaterialWeight = recipe.Material[i].Material_Weight,
- RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
- });
- }
- else
- {
- //MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合");
- }
- }
- else
- {
- break;
- }
- }
- for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++)
- {
- if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name))
- {
- WindSendData.Add(new WindSendRawMaterial()
- {
- RawMaterialName = recipe.Powder[i].Powder_Name,
- RawMaterialWeight = recipe.Powder[i].Powder_Weight
- });
- }
- else
- {
- break;
- }
- }
- App.Current.Dispatcher.Invoke(() => {
- Json.Data.Recipes.Add(new RemoteRecipeData()
- {
- RecipeName = recipe.RecipeName,
- RecipeCode = recipe.RecipeCode,
- RawMaterial = RawMaterials,
- TrayCode = recipe.StockCode,
- WindSend = WindSendData
- });
- });
- }
- }
+ CancelOrder();//订单取消,不执行配方流程
}
- }), "SiemensRecipeRecive", true);
- ActionManage.GetInstance.CancelRegister("SiemensRecipeFinish");
- ActionManage.GetInstance.Register(new Action((res) =>
- {
- if (SiemensDevice.IsConnected)
+ else
{
- if (res != null && res is RemoteRecipeData recipe)
- {
- RecipeFinishInfo.Order_No = recipe.RecipeCode;
- RecipeFinishInfo.Product_Code = recipe.RecipeName;
- RecipeFinishInfo.Job_No = (short)recipe.TrayCode;
- for (int i = 0; i < recipe.RawMaterial.Count; i++)
- {
- RecipeFinishInfo.Material[i] = new UDT1();
- RecipeFinishInfo.Material[i].Material_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName;
- RecipeFinishInfo.Material[i].Material_BarrelNum = recipe.RawMaterial.ElementAt(i).RawMaterialBarrelNum;
- RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight;
- }
- for (int i = 0; i < recipe.WindSend.Count; i++)
- {
- RecipeFinishInfo.Powder[i] = new UDT2();
- RecipeFinishInfo.Powder[i].Powder_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName;
- RecipeFinishInfo.Powder[i].Powder_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight;
- }
- if (GVL_SmallStation.SiemensSendRecipeStatus == 6)
- {
- GVL_SmallStation.SiemensSendRecipeStatus = 7;
- RecipeFinishInfo.Ask_For_Finish = true;
- SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
- }
- }
+ ReceviceData();//配方请求
+ RecipeInfoToHKPLC();//配方配料
}
- }), "SiemensRecipeFinish", true);
- ActionManage.GetInstance.CancelRegister("LocalSimulationRecipeIssue");
- ActionManage.GetInstance.Register(new Action((res) =>
+ Thread.Sleep(10);
+ }), "小料站流程控制", true);
+ ThreadManage.GetInstance().StartLong(new Action(() =>
{
- if (res != null && res is RemoteRecipeData recipe)
+ RealTimeData();
+ foreach (var item in Json.Data.windSendRawMaterial)
{
- Json.Data.Recipes.Add(recipe);
+ if (GVL_SmallStation.GetInstance.RawMaterialsNameCode.ContainsKey(item.RawMaterialName))
+ {
+ item.RawMaterialChineseName = GVL_SmallStation.GetInstance.RawMaterialsNameCode[item.RawMaterialName];
+ }
+ else
+ {
+ item.RawMaterialChineseName = "";
+ }
}
- }), "LocalSimulationRecipeIssue", true);
- string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"];
- string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"];
- string WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"];
-
- try
+ Thread.Sleep(10);
+ }), "西门子PLC和小料站PLC的实时数据交互流程", true);
+ ThreadManage.GetInstance().StartLong(new Action(() =>
{
- if (Json.Data.deviceConnectPar.HKPlcConnect)
- {
- HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
- }
- if (Json.Data.deviceConnectPar.SiemensConnect)
+ HKPlcRead();
+ GetStatus();
+ Thread.Sleep(10);
+ }), "海科PLC实时数据", true);
+ }
+ ///
+ /// 气缸的传感器值
+ ///
+ private void GetStatus()
+ {
+ for (int i = 0; i < 8; i++)
+ {
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[i] = HKDevice.HK_PLC_S7.Read("DB5.DBX0." + i);
+ }
+ for (int i = 0; i < 7; i++)
+ {
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read("DB5.DBX1." + i);
+ }
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[20] = HKDevice.HK_PLC_S7.Read("DB5.DBX3.6");//进料桶气缸
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[21] = HKDevice.HK_PLC_S7.Read("DB5.DBX3.7");//出料筒气缸1
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[22] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.0");//出料筒气缸2
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[23] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.1");//出料筒气缸3
+
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[24] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.2");//托盘1_1气缸
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[25] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.3");//托盘1_2气缸
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[26] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.4");//托盘2_1气缸
+ GVL_SmallStation.GetInstance.Cylinder_JackInfo[27] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.5");//托盘2_2气缸
+ }
+ ///
+ /// DB块的变量实时值
+ ///
+ private void HKPlcRead()
+ {
+ if (HKDevice.IsConnected)
+ {
+ foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties())
{
- SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
+ int index = Array.FindIndex(CommData.ToArray(), p => p.Name == item.Name);
+ if (index >= 0)
+ {
+ CommData.ElementAt(index).Value = GVL_SmallStation.GetInstance.plcReadDataDB3.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3, null).ToString();
+ }
}
- if (Json.Data.deviceConnectPar.WindSendConnect)
+ }
+ foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties())
+ {
+ int index = Array.FindIndex(ProcessVar.ToArray(), p => p.Name == item.Name);
+ if (index >= 0)
{
- WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP);
+ ProcessVar.ElementAt(index).Value = GVL_SmallStation.GetInstance.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance, null).ToString();
}
- if (HKDevice.IsConnected)
+ }
+ }
+ ///
+ /// 小料站和西门子PLC之间的实时数据
+ ///
+ private void RealTimeData()
+ {
+ if (HKDevice.IsConnected)
+ {
+ //获取系统状态
+ GVL_SmallStation.GetInstance.PlcSystemIsAutoRun = HKDevice.HK_PLC_S7.Read("DB44.DBX0.0");//系统启停
+ GVL_SmallStation.GetInstance.PlcSystemMode = HKDevice.HK_PLC_S7.Read("DB44.DBX0.1");//系统模式
+ GVL_SmallStation.GetInstance.PlcSystemIsPause = HKDevice.HK_PLC_S7.Read("DB44.DBX0.2");//系统暂停
+
+ GVL_SmallStation.GetInstance.Station1HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX0.7");//工站1 有货架
+ GVL_SmallStation.GetInstance.Station2HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX1.0");//工站2 有货架
+ if (GVL_SmallStation.GetInstance.WindSendDosingComple)
{
- HKDevice.Init();
- MessageNotify.GetInstance.ShowRunLog("海科plc连接成功,并初始化完成");
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.7", true);
+ GVL_SmallStation.GetInstance.WindSendDosingComple = false;
+ MessageNotify.GetInstance.ShowRunLog("风送配料完成信号,发给产线plc信号");
}
- if (SiemensDevice.IsConnected)
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1"))
{
- SiemensDevice.Init();
- MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功,并初始化完成");
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.7", false);
}
- if (WindSendDevice.IsConnected)
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7"))//允许下配方1或者允许下配方2
{
- WindSendDevice.Init();
- MessageNotify.GetInstance.ShowRunLog("风送plc连接成功,并初始化完成");
+ GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe = true;
}
+ GVL_SmallStation.GetInstance.Station1Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.1");
+ GVL_SmallStation.GetInstance.Station2Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.2");
+ GVL_SmallStation.GetInstance.Station1Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.3");
+ GVL_SmallStation.GetInstance.Station2Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.4");
+ GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read("DB3.DBW100");
+ GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read("DB3.DBB102");
}
- catch (Exception ex)
- {
- }
- ThreadManage.GetInstance().StartLong(new Action(() =>
+ if (SiemensDevice.IsConnected)
{
- if (!HKDevice.IsConnected && Json.Data.deviceConnectPar.HKPlcConnect)
- {
- HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP);
- MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接");
- if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功");
- }
- if (!SiemensDevice.IsConnected && Json.Data.deviceConnectPar.SiemensConnect)
- {
- SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
- MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接");
- if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功");
- }
- if (!WindSendDevice.IsConnected && Json.Data.deviceConnectPar.WindSendConnect)
+ ushort TrayCylinder = 0;
+ ushort TraySensor = 0;
+ if (GVL_SmallStation.GetInstance.Station1Sensor)
{
- WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP);
- MessageNotify.GetInstance.ShowRunLog("风送plc重新连接成功");
+ TraySensor = TraySensor.SetBitValue(1, true);
}
- Thread.Sleep(50);
- }), "设备连接", true);
- RecipeQueue.Clear();
- //手动控制系统模式
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", true); }), "SystemStart", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", false); }), "SystemStop", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.2", true); }), "SystemPause", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.2", false); }), "SystemReset", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.1", false); }), "SystemAutoMode", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.1", true); }), "SystemDebugMode", true);
- //流程控制
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.3", true); }), "ManualSystemReset", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.4", true); }), "CLearRecipeInfo", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true); }), "AGVPutTrayFinish", true);
- //手动控制电机轴
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", true); }), "StartAxisLoadCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", false); }), "StopAxisLoadCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", true); }), "StartAxisMidCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", false); }), "StopAxisMidCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", true); }), "StartAxisUnLoadCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", false); }), "StopAxisUnLoadCommand", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", true); }), "StartAxis1Command", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", false); }), "StopAxis1Command", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", true); }), "StartAxis2Command", true);
- ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", false); }), "StopAxis2Command", true);
- //电机速度
- ActionManage.GetInstance.Register(new Action((o) =>
- {
- if (o != null && o is short value)
+ else
{
- HKDevice.HK_PLC_S7.Write("DB47.DBD8", value);
+ TraySensor = TraySensor.SetBitValue(0, false);
}
- }), "AxisLoadSpeedSet", true);
- ActionManage.GetInstance.Register(new Action((o) =>
- {
- if (o != null && o is short value)
+ if (!GVL_SmallStation.GetInstance.Station1Cylinder)
{
- HKDevice.HK_PLC_S7.Write("DB47.DBD10", value);
+ TrayCylinder = TrayCylinder.SetBitValue(1, true);
}
- }), "AxisMidSpeedSet", true);
- ActionManage.GetInstance.Register(new Action((o) =>
- {
- if (o != null && o is short value)
+ else
{
- HKDevice.HK_PLC_S7.Write("DB47.DBD12", value);
+ TrayCylinder = TrayCylinder.SetBitValue(0, false);
}
- }), "AxisUnLoadSpeedSet", true);
- ActionManage.GetInstance.Register(new Action((o) =>
- {
- if (o != null && o is float value)
+ this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet);
+ this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW190", TraySensor);//添加工位传感器的信号
+ this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号
+ ushort AGV_Put = (ushort)SiemensDevice.XL_Status.AgvFinishPut;
+ if (AGV_Put.Get16bitValue(1))
{
- HKDevice.HK_PLC_S7.Write("DB47.DBD0", value);
+ GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true;
}
- }), "Axis1SpeedSet", true);
- ActionManage.GetInstance.Register(new Action((o) =>
- {
- if (o != null && o is float value)
+ else
{
- HKDevice.HK_PLC_S7.Write("DB47.DBD4", value);
+ GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
}
- }), "Axis2SpeedSet", true);
- RecipeQueue.Clear();
- //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- if (HKDevice.IsConnected)
+ ushort AGV_Get = (ushort)SiemensDevice.XL_Status.AgvFinishGet;
+ if (AGV_Get.Get16bitValue(1))
{
- GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc;
- HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc);
- GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read("DB45.DBX0.0");
- //获取系统状态
- GVL_SmallStation.SystemStatus = HKDevice.HK_PLC_S7.Read("DB44.DBX0.0");//系统启停
- GVL_SmallStation.SystemMode = HKDevice.HK_PLC_S7.Read("DB44.DBX0.1");//系统模式
- GVL_SmallStation.SystemRunStatus = HKDevice.HK_PLC_S7.Read("DB44.DBX0.2");//系统暂停
+ GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true;
}
- Thread.Sleep(200);
- }), "通信心跳", true);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- DeviceStatusDispose();
- ReceviceData();
- RecipeInfoToHKPLC();
- Thread.Sleep(10);
- }), "西门子配发下发流程处理", true);
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- if (HKDevice.IsConnected)
+ else
{
- ManualOpen();
- ManualClose();
+ GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
}
- Thread.Sleep(10);
- }), "手动操作", true);
- }
- private void GetStatus()
- {
- for (int i = 0; i < 8; i++)
- {
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[i] = HKDevice.HK_PLC_S7.Read("DB5.DBX0." + i);
- }
- for (int i = 0; i < 7; i++)
- {
- GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read("DB5.DBX0." + i);
}
}
- private void ManualOpen()
+
+ public void CancelOrder()
{
- ActionManage.GetInstance.Register(new Action((o) =>
+ if (GVL_SmallStation.GetInstance.Order_Cancel) //订单取消
{
- if (o != null)
+ if (!string.IsNullOrEmpty(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
{
- if (o.ToString().Contains("升降气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.0", true);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.1", true);
- break;
- case 3:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.2", true);
- break;
- case 4:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.3", true);
- break;
- case 5:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.4", true);
- break;
- case 6:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.5", true);
- break;
- case 7:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.6", true);
- break;
- case 8:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.7", true);
- break;
- case 9:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.0", true);
- break;
- case 10:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.1", true);
- break;
- case 11:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.2", true);
- break;
- case 12:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.3", true);
- break;
- case 13:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.4", true);
- break;
- case 14:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.5", true);
- break;
- case 15:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.6", true);
- break;
- default:
- break;
- }
- }
- else if (o.ToString().Contains("阻挡气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.7", true);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.0", true);
- break;
- case 3:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.1", true);
- break;
- case 4:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.2", true);
- break;
- case 5:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.3", true);
- break;
- case 6:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.4", true);
- break;
- case 7:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.5", true);
- break;
- case 8:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.6", true);
- break;
- case 9:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.7", true);
- break;
- case 10:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.0", true);
- break;
- case 11:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.1", true);
- break;
- case 12:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.2", true);
- break;
- case 13:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.3", true);
- break;
- case 14:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.4", true);
- break;
- case 15:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.5", true);
- break;
- default:
- break;
- }
- }
- else if (o.ToString().Contains("进料桶顶升气缸"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", false);//默认顶升
- }
- else if (o.ToString().Contains("出料桶顶升气缸1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", true);
- }
- else if (o.ToString().Contains("出料桶顶升气缸2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", true);
- }
- else if (o.ToString().Contains("出料桶顶升气缸3"))
+ string code = GVL_SmallStation.GetInstance.Order_CancelRecipeCode;
+ int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == code);
+ switch (GVL_SmallStation.GetInstance.OrderCancelStep)
{
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", true);
- }
- else if (o.ToString().Contains("托盘气缸1_1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", false);//默认伸出
- }
- else if (o.ToString().Contains("托盘气缸1_2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", false);
- }
- else if (o.ToString().Contains("托盘气缸2_1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", false);
- }
- else if (o.ToString().Contains("托盘气缸2_2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", false);
- }
- }
- }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
- }
- private void ManualClose()
- {
- ActionManage.GetInstance.Register(new Action((o) =>
- {
- if (o != null)
- {
- if (o.ToString().Contains("升降气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.0", false);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.1", false);
- break;
- case 3:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.2", false);
- break;
- case 4:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.3", false);
- break;
- case 5:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.4", false);
- break;
- case 6:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.5", false);
- break;
- case 7:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.6", false);
- break;
- case 8:
- HKDevice.HK_PLC_S7.Write("DB5.DBX0.7", false);
- break;
- case 9:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.0", false);
- break;
- case 10:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.1", false);
- break;
- case 11:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.2", false);
- break;
- case 12:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.3", false);
- break;
- case 13:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.4", false);
- break;
- case 14:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.5", false);
- break;
- case 15:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.6", false);
- break;
- default:
- break;
+ case 0://前提条件判断
+ if (index == -1)
+ {
+ GVL_SmallStation.GetInstance.OrderCancelStep = 30;
+ MessageNotify.GetInstance.ShowRunLog($"配方中并未找到订单{code}");
+ }
+ else
+ {
+ if (RecipeQueueTray1.Contains(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
+ {
+ GVL_SmallStation.GetInstance.OrderCancelStep = 1;
+ }
+ else if (RecipeQueueTray2.Contains(GVL_SmallStation.GetInstance.Order_CancelRecipeCode))
+ {
+ GVL_SmallStation.GetInstance.OrderCancelStep = 10;
+ }
+ else
+ {
+ GVL_SmallStation.GetInstance.OrderCancelStep = 20;
+ }
+ }
+ break;
- }
- }
- else if (o.ToString().Contains("阻挡气缸"))
- {
- int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1));
- switch (index)
- {
- case 1:
- HKDevice.HK_PLC_S7.Write("DB5.DBX1.7", false);
- break;
- case 2:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.0", false);
- break;
- case 3:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.1", false);
- break;
- case 4:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.2", false);
- break;
- case 5:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.3", false);
- break;
- case 6:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.4", false);
- break;
- case 7:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.5", false);
- break;
- case 8:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.6", false);
- break;
- case 9:
- HKDevice.HK_PLC_S7.Write("DB5.DBX2.7", false);
- break;
- case 10:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.0", false);
- break;
- case 11:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.1", false);
- break;
- case 12:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.2", false);
- break;
- case 13:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.3", false);
- break;
- case 14:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.4", false);
- break;
- case 15:
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.5", false);
- break;
- default:
- break;
+ //Case 1-9为
+ case 1:
+ if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 != 0)
+ {
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
+ HKDevice.HK_PLC_S7.Write("DB4.DBX2.1", true);
+ MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}");
+ GVL_SmallStation.GetInstance.OrderCancelStep = 2;
+ }
+ else
+ {
+ MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
+ GVL_SmallStation.GetInstance.OrderCancelStep = 3;
+ }
+ break;
+ case 2:
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX2.5"))
+ {
+ if (GVL_SmallStation.GetInstance.Station1Cylinder == false)
+ {
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
+ GVL_SmallStation.GetInstance.OrderCancelStep = 3;
+ MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
+ }
+ }
+ break;
+ case 3:
+ SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
+ GVL_SmallStation.GetInstance.OrderCancelStep = 4;
+ break;
+ case 4:
+ if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false)
+ {
+ SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
+ GVL_SmallStation.GetInstance.OrderCancelStep = 9;
+ MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
+ }
+ break;
+ case 9:
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ Json.Data.Recipes.RemoveAt(index);
+ });
+ RecipeQueueTray1.TryDequeue(out code);
+ GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
+ GVL_SmallStation.GetInstance.Order_Cancel = false;
+ GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
+ GVL_SmallStation.GetInstance.OrderCancelStep = 0;
+ break;
+ case 10:
+ if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 != 0)
+ {
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
+ HKDevice.HK_PLC_S7.Write("DB4.DBX2.2", true);
+ MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}");
+ GVL_SmallStation.GetInstance.OrderCancelStep = 11;
+ }
+ else
+ {
+ MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}");
+ GVL_SmallStation.GetInstance.OrderCancelStep = 12;
+ }
+ break;
+ case 11:
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX2.6"))
+ {
+ if (GVL_SmallStation.GetInstance.Station2Cylinder == false)
+ {
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
+ GVL_SmallStation.GetInstance.OrderCancelStep = 12;
+ MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}");
+ }
+ }
+ break;
- }
- }
- else if (o.ToString().Contains("进料桶顶升气缸"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", true);
- }
- else if (o.ToString().Contains("出料桶顶升气缸1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", false);
- }
- else if (o.ToString().Contains("出料桶顶升气缸2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", false);
- }
- else if (o.ToString().Contains("出料桶顶升气缸3"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", false);
- }
- else if (o.ToString().Contains("托盘气缸1_1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", true);
- }
- else if (o.ToString().Contains("托盘气缸1_2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", true);
- }
- else if (o.ToString().Contains("托盘气缸2_1"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", true);
- }
- else if (o.ToString().Contains("托盘气缸2_2"))
- {
- HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", true);
- }
+ case 12:
+ SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
+ GVL_SmallStation.GetInstance.OrderCancelStep = 13;
+ break;
+ case 13:
+ if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false)
+ {
+ SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
+ GVL_SmallStation.GetInstance.OrderCancelStep = 14;
+ MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
+ }
+ break;
+ case 19:
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ Json.Data.Recipes.RemoveAt(index);
+ });
+ RecipeQueueTray2.TryDequeue(out code);
+ GVL_SmallStation.GetInstance.Order_Cancel = false;
+ GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;
+ GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
+ GVL_SmallStation.GetInstance.OrderCancelStep = 0;
+ break;
- }
- }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中
- }
- ///
- ///
- ///
- private void DeviceStatusDispose()
- {
- if (HKDevice.IsConnected)
- {
- GVL_SmallStation.Station1HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX0.7");//工站1 有货架
- GVL_SmallStation.Station2HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX1.0");//工站1 有货架
- if (RTrig.GetInstance("WindSendDosingCompleToHKPLC").Start(GVL_SmallStation.WindSendDosingComple))
- {
- GVL_SmallStation.WindSendDosingComple = false;
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.7", true);
- MessageNotify.GetInstance.ShowRunLog("风送配料完成信号,发给产线plc信号");
- }
- if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1"))
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.7", false);
- }
- if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7"))//允许下配方1或者允许下配方2
- {
- GVL_SmallStation.IsAllowSiemensSendRecipe = true;
- //MessageNotify.GetInstance.ShowRunLog("Plc允许下发配方");
- }
+ //20-29为订单还未下发至PLC
+ case 20:
+ SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
+ GVL_SmallStation.GetInstance.OrderCancelStep = 21;
+ break;
+ case 21:
+ if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false)
+ {
+ SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
+ GVL_SmallStation.GetInstance.OrderCancelStep = 29;
+ MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}");
+ }
+ break;
+ case 29:
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ Json.Data.Recipes.RemoveAt(index);
+ });
+ GVL_SmallStation.GetInstance.Order_Cancel = false;
+ GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
+ GVL_SmallStation.GetInstance.OrderCancelStep = 0;
+ break;
- GVL_SmallStation.Station1Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.1");
- GVL_SmallStation.Station2Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.2");
- GVL_SmallStation.Station1Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.3");
- GVL_SmallStation.Station2Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.4");
- if (!GVL_SmallStation.TrayLogicFinish)
- {
- if (GVL_SmallStation.AGV_PutTray1Finish)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true);
- GVL_SmallStation.AGV_PutTray1Finish = false;
- MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc");
- }
- if (GVL_SmallStation.Station1HaveTray)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", false);
- GVL_SmallStation.TrayLogicFinish = true;
- MessageNotify.GetInstance.ShowRunLog("托盘1有货架");
- }
- else
- {
- if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") == true)
- {
- if (GVL_SmallStation.CylinderReset)
+ //30-39为订单还未下发至上位机
+ case 30:
+ SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true);
+ GVL_SmallStation.GetInstance.OrderCancelStep = 31;
+ break;
+ case 31:
+ if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false)
{
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", true);
+ SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false);
+ GVL_SmallStation.GetInstance.OrderCancelStep = 39;
+ MessageNotify.GetInstance.ShowRunLog($"西门子取消订单完成,订单号:{code}");
}
- MessageNotify.GetInstance.ShowRunLog("气缸收紧错位");
- }
- else
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", false);
- }
+ break;
+ case 39:
+ GVL_SmallStation.GetInstance.Order_Cancel = false;
+ GVL_SmallStation.GetInstance.Order_CancelRecipeCode = "";
+ GVL_SmallStation.GetInstance.OrderCancelStep = 0;
+ break;
}
}
- else
- {
- if (GVL_SmallStation.AGV_GetTray1Finish)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", true);
- if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7") == true)
- {
- HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", false);
- GVL_SmallStation.TrayLogicFinish = false;
- GVL_SmallStation.AGV_GetTray1Finish = false;
- }
- }
-
- }
- }
- if (SiemensDevice.IsConnected)
- {
- ushort TrayCylinder = 0;
- ushort TraySensor = 0;
- if (GVL_SmallStation.Station1Sensor)
- {
- TraySensor = TraySensor.SetBitValue(1, true);
- }
- else
- {
- TraySensor = TraySensor.SetBitValue(0, false);
- }
- if (!GVL_SmallStation.Station1Cylinder)
- {
- TrayCylinder = TrayCylinder.SetBitValue(1, true);
- }
- else
- {
- TrayCylinder = TrayCylinder.SetBitValue(0, false);
- }
- this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.WindSendAllowAGVPutGet);
- this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW190", TraySensor);//添加工位传感器的信号
- this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号
-
- if (RTrig.GetInstance("AGV_PutTray1Finish1111").Start(SiemensDevice.XL_Status.AgvFinishPut == 1))
- {
- GVL_SmallStation.AGV_PutTray1Finish = true;
- }
- if (RTrig.GetInstance("AGV_GetTray1Finish111").Start(SiemensDevice.XL_Status.AgvFinishGet == 1))
- {
- GVL_SmallStation.AGV_GetTray1Finish = true;
- }
}
}
- ///
- /// 将配方添加到配方队列中
- ///
+ ///
+ /// 将配方添加到配方队列中
+ ///
private void ReceviceData()
{
if (!GVL_SmallStation.GetInstance.IsUseLocalRecipe)
@@ -750,36 +447,41 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (data.TrayCode == 1)
{
- if (!(RecipeQueue.Contains(data.RecipeCode)))
+ if (!(RecipeQueueTray1.Contains(data.RecipeCode)))
{
if (SiemensDevice.XL_Status is XL_Status_DB status)
{
- if (GVL_SmallStation.SiemensSendRecipeStatus == 3)
- {
- GVL_SmallStation.SiemensSendRecipeStatus = 4;
- SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
- }
- if (GVL_SmallStation.SiemensSendRecipeStatus == 4)
- {
- if (SiemensDevice.XL_Status.Dosing_Confirm)
- {
- GVL_SmallStation.SiemensSendRecipeStatus = 5;
- SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},配料信号复位");
- }
- }
- if (GVL_SmallStation.SiemensSendRecipeStatus == 5)
+ switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
{
- MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
- if (SiemensDevice.XL_Status.Dosing_Confirm == false)
- {
- RecipeQueue.Enqueue(data.RecipeCode);
- GVL_SmallStation.SiemensSendRecipeStatus = 6;
+ case 3:
+ SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
+ SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4;
+ MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
+ break;
+ case 4:
+ if (SiemensDevice.XL_Status.Dosing_Confirm)
+ {
+ SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串
+ SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5;
+ MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
+ }
+ break;
+ case 5:
+ if (SiemensDevice.XL_Status.Dosing_Confirm == false)
+ {
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
+ MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
+ }
+ break;
+ case 6:
+ RecipeQueueTray1.Enqueue(data.RecipeCode);
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列");
- }
+ break;
+ default:
+ break;
}
}
}
@@ -790,28 +492,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (SiemensDevice.XL_Status is XL_Status_DB status)
{
- if (GVL_SmallStation.SiemensSendRecipeStatus == 3)
- {
- GVL_SmallStation.SiemensSendRecipeStatus = 4;
- SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
- }
- if (GVL_SmallStation.SiemensSendRecipeStatus == 4)
- {
- if (SiemensDevice.XL_Status.Dosing_Confirm)
- {
- GVL_SmallStation.SiemensSendRecipeStatus = 5;
- SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);
- SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
- }
- }
- if (GVL_SmallStation.SiemensSendRecipeStatus == 5)
+ switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus)
{
- if (SiemensDevice.XL_Status.Dosing_Confirm == false)
- {
- GVL_SmallStation.SiemensSendRecipeStatus = 0;
+ case 3:
+ SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10);
+ SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true);
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4;
+ MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料");
+ break;
+ case 4:
+ if (SiemensDevice.XL_Status.Dosing_Confirm)
+ {
+ SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串
+ SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false);
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5;
+ MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料");
+ }
+ break;
+ case 5:
+ if (SiemensDevice.XL_Status.Dosing_Confirm == false)
+ {
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6;
+ MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成");
+ }
+ break;
+ case 6:
RecipeQueueTray2.Enqueue(data.RecipeCode);
- }
+ GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0;
+ MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列");
+ break;
+ default:
+ break;
}
}
}
@@ -820,13 +531,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
}
else
{
- RecipeQueue.Clear();
+ RecipeQueueTray1.Clear();
RecipeQueueTray2.Clear();
- GVL_SmallStation.GetInstance.RecipeStatusID = 0;
+ /*GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
+ GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;*/
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
}
}
- else
+ else
{
RemoteRecipes = Json.Data.Recipes;
if (RemoteRecipes.Count > 0)
@@ -835,33 +548,28 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
if (data.TrayCode == 1)
{
- if (!(RecipeQueue.Contains(data.RecipeCode)))
+ if (!(RecipeQueueTray1.Contains(data.RecipeCode)))
{
- RecipeQueue.Enqueue(data.RecipeCode);
+ RecipeQueueTray1.Enqueue(data.RecipeCode);
}
}
else if (data.TrayCode == 2)
{
if (!(RecipeQueueTray2.Contains(data.RecipeCode)))
{
-
RecipeQueueTray2.Enqueue(data.RecipeCode);
- }
+ }
}
}
}
else
{
- RecipeQueue.Clear();
+ RecipeQueueTray1.Clear();
RecipeQueueTray2.Clear();
+ /*GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
+ GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;*/
- GVL_SmallStation.GetInstance.DosingTray1 = false;
- GVL_SmallStation.GetInstance.DosingTray1Loc = 0;
-
- GVL_SmallStation.GetInstance.DosingTray2 = false;
- GVL_SmallStation.GetInstance.DosingTray2Loc = 0;
-
- GVL_SmallStation.GetInstance.RecipeStatusID = 0;
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0;
}
}
@@ -871,9 +579,120 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
///
private void RecipeInfoToHKPLC()
{
- if (RecipeQueue.Count > 0 && GVL_SmallStation.TrayLogicFinish)
+ switch (GVL_SmallStation.GetInstance.Tray1LogicFinish)
+ {
+ case 0:
+ if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish && RecipeQueueTray1.Count > 0)
+ {
+ HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true);
+ GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false;
+ GVL_SmallStation.GetInstance.Tray1LogicFinish = 1;
+ MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc");
+ }
+ break;
+ case 1:
+ if (GVL_SmallStation.GetInstance.Station1HaveTray)
+ {
+ HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", false);
+ GVL_SmallStation.GetInstance.Tray1LogicFinish = 2;
+ MessageNotify.GetInstance.ShowRunLog("托盘1有货架");
+ }
+ else
+ {
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") == true)
+ {
+ if (GVL_SmallStation.GetInstance.CylinderReset)
+ {
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", true);
+ }
+ MessageNotify.GetInstance.ShowRunLog("气缸收紧错位");
+ }
+ else
+ {
+ GVL_SmallStation.GetInstance.Tray1LogicFinish = 1;
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", false);
+ }
+ }
+ break;
+ case 2:
+ if (GVL_SmallStation.GetInstance.AGV_GetTray1Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0)
+ {
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", true);
+ GVL_SmallStation.GetInstance.Tray1LogicFinish = 3;
+ MessageNotify.GetInstance.ShowRunLog("AGV取托盘1完成,发送给海科信号后1s后复位");
+ }
+ break;
+ case 3:
+ if (HKDevice.HK_PLC_S7.Read("DB4.DBX1.1") == true)
+ {
+ Thread.Sleep(1000);
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", false);
+ GVL_SmallStation.GetInstance.Tray1LogicFinish = 0;
+ GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false;
+ MessageNotify.GetInstance.ShowRunLog("AGV取托盘1完成,信号复位");
+ }
+ break;
+ default:
+ break;
+ }
+ switch (GVL_SmallStation.GetInstance.Tray2LogicFinish)
+ {
+ case 0:
+ if (GVL_SmallStation.GetInstance.AGV_PutTray2Finish)
+ {
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", true);
+ GVL_SmallStation.GetInstance.AGV_PutTray2Finish = false;
+ GVL_SmallStation.GetInstance.Tray2LogicFinish = 1;
+ MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc");
+ }
+ break;
+ case 1:
+ if (GVL_SmallStation.GetInstance.Station2HaveTray)
+ {
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", false);
+ GVL_SmallStation.GetInstance.Tray2LogicFinish = 2;
+ MessageNotify.GetInstance.ShowRunLog("托盘1有货架");
+ }
+ else
+ {
+ if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.6") == true)
+ {
+ if (GVL_SmallStation.GetInstance.CylinderReset)
+ {
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.6", true);
+ }
+ MessageNotify.GetInstance.ShowRunLog("气缸收紧错位");
+ }
+ else
+ {
+ GVL_SmallStation.GetInstance.Tray2LogicFinish = 1;
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.6", false);
+ }
+ }
+ break;
+ case 2:
+ if (GVL_SmallStation.GetInstance.AGV_GetTray2Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0)
+ {
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", true);
+ GVL_SmallStation.GetInstance.Tray2LogicFinish = 3;
+ }
+ break;
+ case 3:
+ if (HKDevice.HK_PLC_S7.Read("DB4.DBX1.2") == true)
+ {
+ Thread.Sleep(1000);
+ HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", false);
+ GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;
+ GVL_SmallStation.GetInstance.AGV_GetTray2Finish = false;
+ }
+ break;
+ default:
+ break;
+ }
+ #region 托盘1配料
+ if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
{
- int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0));
+ int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray1.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
{
string code = RemoteRecipes.ElementAt(index).RecipeCode;
@@ -882,171 +701,269 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
string windSend = RemoteRecipes.ElementAt(index).ToString();
if (trayCode == 1)
{
- if (GVL_SmallStation.GetInstance.RecipeStatusID == 0)
+ //粉料仓下发配方
+ if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing==false)
{
- if (GVL_SmallStation.GetInstance.IsUseWindSend)
+ GVL_SmallStation.GetInstance.WindSendDosing = true;
+ WindSendData.TargetRecipeCode = code;
+ WindSendData.IsAllowDosing = true;
+ foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
{
- WindSendData.TargetRecipeCode = code;
- WindSendData.IsAllowDosing = true;
- foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
+ if (item.RawMaterialName == "0037" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
{
- if (item.RawMaterialName == "0037")
- {
- WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
- }
- if (item.RawMaterialName == "0038")
- {
- WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
- }
- if (item.RawMaterialName == "")
- {
- WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
- }
- if (item.RawMaterialName == "")
- {
- WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
- }
- if (item.RawMaterialName == "0036")
- {
- WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
- }
+ WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
+ }
+ if (item.RawMaterialName == "0038" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
+ {
+ WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
+ }
+ if (item.RawMaterialName == "0039" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
+ {
+ WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
+ }
+ if (item.RawMaterialName == "0045" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
+ {
+ WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
+ }
+ if (item.RawMaterialName == "0046" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
+ {
+ WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
}
- WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData, 95);
}
+ WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData, 95);
+ }
+ if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0)
+ {
+ StockBinInit();
+ GVL_SmallStation.GetInstance.StockBinDosing = 0;
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation);
+ GVL_SmallStation.GetInstance.StockBinDosing= GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)item.RawMaterialLocation,true);//哪些仓位需要配料写入
}
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
- GVL_SmallStation.GetInstance.RecipeStatusID = 1;
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
GVL_SmallStation.GetInstance.time1 = DateTime.Now;
}
-
- if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") && GVL_SmallStation.GetInstance.RecipeStatusID == 1)
+ bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read("DB3.DBX1.3");
+ if ( recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
{
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
- GVL_SmallStation.GetInstance.RecipeStatusID = 2;
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
}
- if (GVL_SmallStation.GetInstance.RecipeStatusID == 2)
+ if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
{
- if (GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray1Loc == 0)
+ if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.0")))
{
- if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.0")))
+ var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10");
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
+ if (res > 0 && res is float loc)
{
- var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10");
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
- if (res > 0 && res is float loc)
+ int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
+ if (weight <= 0)
+ {
+ int i = (int)loc;
+ if (i >= 1 && i <= 8)
+ {
+ string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo);
+ }
+ else if (i >= 9 && i <= 15)
+ {
+ string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ }
+ GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ }
+ else
{
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
}
- GVL_SmallStation.GetInstance.DosingTray1 = true;
- GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成");
+ else
+ {
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
+ }
}
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
}
- else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1")))
+ }
+ else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1")))
+ {
+ var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14");
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
+ if (res > 0 && res is float loc)
{
- var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14");
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
- if (res > 0 && res is float loc)
+ int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ if (weight <= 0)
+ {
+ int i = (int)loc;
+ if (i >= 1 && i <= 8)
+ {
+ string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo);
+ }
+ else if (i >= 9 && i <= 15)
+ {
+ string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ }
+ GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ }
+ else
{
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
}
- GVL_SmallStation.GetInstance.DosingTray1 = true;
- GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成");
+ else
+ {
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
+ }
}
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
}
- else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.2")))
+ }
+ else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.2")))
+ {
+ var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18");
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
+ if (res > 0 && res is float loc)
{
- var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18");
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
- if (res > 0 && res is float loc)
+ int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ if (weight <= 0)
+ {
+ int i = (int)loc;
+ if (i >= 1 && i <= 8)
+ {
+ string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo);
+ }
+ else if (i >= 9 && i <= 15)
+ {
+ string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ }
+ GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ }
+ else
{
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight*1000;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
}
- GVL_SmallStation.GetInstance.DosingTray1 = true;
- GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成");
+ else
+ {
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
+ }
}
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
}
- else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.3")))
+ }
+ else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.3")))
+ {
+ var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22");
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
+ if (res > 0 && res is float loc)
{
- var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22");
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
- if (res > 0 && res is float loc)
+ int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ if (weight <= 0)
+ {
+ int i = (int)loc;
+ if (i >= 1 && i <= 8)
+ {
+ string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo);
+ }
+ else if (i >= 9 && i <= 15)
+ {
+ string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ }
+ GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ }
+ else
{
- int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
- float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight*1000;
if (loc_index >= 0)
{
DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
}
- GVL_SmallStation.GetInstance.DosingTray1 = true;
- GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc;
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成");
+ else
+ {
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
+ }
}
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
}
}
- if (GVL_SmallStation.GetInstance.DosingTray1 && GVL_SmallStation.GetInstance.DosingTray1Loc > 0 && GVL_SmallStation.GetInstance.DosingTray1Loc < 16)
+ for (int i = 1; i < 16; i++)
{
- int i = GVL_SmallStation.GetInstance.DosingTray1Loc;
- if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)
+ if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
{
- MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成");
int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
- RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
- bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
- MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
- if (info)
+ if (res >= 0)
{
- MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功");
- }
- else
- {
- MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败");
- }
- if (i >= 1 && i <= 8)
- {
- string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo);
- }
- else if (i >= 9 && i <= 15)
- {
- string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
- MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ Thread.Sleep(GVL_SmallStation.GetInstance.Time);
+ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
+ bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
+ MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
+ float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
+ int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
+ if (iIndex >= 0)
+ {
+ if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
+ {
+ HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
+ App.Current.Dispatcher.Invoke(() =>
+ {
+ MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
+ HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
+ });
+ }
+ }
+ if (i >= 1 && i <= 8)
+ {
+ string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo);
+ }
+ else if (i >= 9 && i <= 15)
+ {
+ string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ }
}
- GVL_SmallStation.GetInstance.DosingTray1 = false;
- GVL_SmallStation.GetInstance.DosingTray1Loc = 0;
+ GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
}
}
if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.1"))))
{
+ if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
+ {
+ for (int i = 1; i < 17; i++)
+ {
+ if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
+ {
+ MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
+ }
+ }
+ }
var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
- MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成");
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
{
MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
}
- if (SiemensDevice.IsConnected)
+ if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
{
RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
@@ -1069,202 +986,1406 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
}
- if (GVL_SmallStation.SiemensSendRecipeStatus == 6)
- {
- double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
- GVL_SmallStation.SiemensSendRecipeStatus = 7;
- RecipeFinishInfo.Ask_For_Finish = true;
- RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
- SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
- }
+ double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
+ RecipeFinishInfo.Ask_For_Finish = true;
+ RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
+ SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
+
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
+ }
+ else
+ {
+ MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
}
+ GVL_SmallStation.GetInstance.WindSendDosing = false;
App.Current.Dispatcher.Invoke(() =>
{
Json.Data.Recipes.Remove(res);
});
- RecipeQueue.TryDequeue(out code);
+ RecipeQueueTray1.TryDequeue(out code);
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
- GVL_SmallStation.GetInstance.RecipeStatusID = 0;
+ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
}
}
- }
+ }
}
}
- if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.Station2HaveTray)
+ //if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
+ //{
+ // foreach (var queue in RecipeQueueTray1)
+ // {
+ // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == queue.ToString());
+ // if (index >= 0 && index < RemoteRecipes.Count)
+ // {
+ // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
+ // string code = RemoteRecipes.ElementAt(index).RecipeCode;
+ // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
+ // string windSend = RemoteRecipes.ElementAt(index).ToString();
+ // if (trayCode == 1)
+ // {
+ // //粉料仓下发配方
+ // if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing == false)
+ // {
+ // GVL_SmallStation.GetInstance.WindSendDosing = true;
+ // WindSendData.TargetRecipeCode = code;
+ // WindSendData.IsAllowDosing = true;
+ // foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
+ // {
+ // if (item.RawMaterialName == "0037" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
+ // }
+ // if (item.RawMaterialName == "0038" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
+ // }
+ // if (item.RawMaterialName == "0039" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
+ // }
+ // if (item.RawMaterialName == "0045" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
+ // }
+ // if (item.RawMaterialName == "0046" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
+ // }
+ // }
+ // WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData, 95);
+ // }
+ // if (GVL_SmallStation.GetInstance.RecipeProcessStatus[0] == 0)
+ // {
+ // StockBinInit();
+ // GVL_SmallStation.GetInstance.StockBinDosing = 0;
+ // HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, 1);
+ // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
+ // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
+ // GVL_SmallStation.GetInstance.time1 = DateTime.Now;
+ // }
+ // bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read("DB3.DBX1.3");
+ // if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
+ // {
+ // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
+ // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
+ // }
+ // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
+ // {
+ // if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.0")))
+ // {
+ // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10");
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
+ // if (res > 0 && res is float loc)
+ // {
+ // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
+ // if (weight <= 0)
+ // {
+ // int i = (int)loc;
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // else
+ // {
+ // if (loc_index >= 0)
+ // {
+ // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
+ // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
+ // }
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
+ // }
+ // }
+ // else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1")))
+ // {
+ // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14");
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
+ // if (res > 0 && res is float loc)
+ // {
+ // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ // if (weight <= 0)
+ // {
+ // int i = (int)loc;
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // else
+ // {
+ // if (loc_index >= 0)
+ // {
+ // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
+ // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
+ // }
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
+ // }
+ // }
+ // else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.2")))
+ // {
+ // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18");
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
+ // if (res > 0 && res is float loc)
+ // {
+ // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ // if (weight <= 0)
+ // {
+ // int i = (int)loc;
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // else
+ // {
+ // if (loc_index >= 0)
+ // {
+ // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
+ // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
+ // }
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
+ // }
+ // }
+ // else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.3")))
+ // {
+ // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22");
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
+ // if (res > 0 && res is float loc)
+ // {
+ // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ // if (weight <= 0)
+ // {
+ // int i = (int)loc;
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // else
+ // {
+ // if (loc_index >= 0)
+ // {
+ // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
+ // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
+ // }
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
+ // }
+ // }
+ // for (int i = 1; i < 16; i++)
+ // {
+ // if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
+ // {
+ // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
+ // if (res >= 0)
+ // {
+ // Thread.Sleep(GVL_SmallStation.GetInstance.Time);
+ // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
+ // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
+ // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
+ // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
+ // int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
+ // if (iIndex >= 0)
+ // {
+ // if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
+ // {
+ // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
+ // App.Current.Dispatcher.Invoke(() =>
+ // {
+ // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
+ // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
+ // });
+ // }
+ // }
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // }
+ // if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.1"))))
+ // {
+ // if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
+ // {
+ // for (int i = 1; i < 17; i++)
+ // {
+ // if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
+ // }
+ // }
+ // }
+ // var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
+ // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
+ // }
+ // if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
+ // {
+ // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
+ // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
+ // RecipeFinishInfo.Job_No = (short)trayCode;
+ // for (int i = 0; i < 20; i++)
+ // {
+ // RecipeFinishInfo.Material[i] = new UDT1();
+ // }
+ // for (int i = 0; i < 10; i++)
+ // {
+ // RecipeFinishInfo.Powder[i] = new UDT2();
+ // }
+ // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
+ // {
+ // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
+ // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
+ // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
+ // }
+ // for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
+ // {
+ // RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
+ // }
+ // double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
+ // RecipeFinishInfo.Ask_For_Finish = true;
+ // RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
+ // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
+
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
+ // }
+ // GVL_SmallStation.GetInstance.WindSendDosing = false;
+ // App.Current.Dispatcher.Invoke(() =>
+ // {
+ // Json.Data.Recipes.Remove(res);
+ // });
+ // RecipeQueueTray1.TryDequeue(out code);
+ // HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
+ // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
+ // }
+ // }
+ // }
+ // }
+ // }
+ //} //if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方
+ //{
+ // foreach (var queue in RecipeQueueTray1)
+ // {
+ // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == queue.ToString());
+ // if (index >= 0 && index < RemoteRecipes.Count)
+ // {
+ // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
+ // string code = RemoteRecipes.ElementAt(index).RecipeCode;
+ // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
+ // string windSend = RemoteRecipes.ElementAt(index).ToString();
+ // if (trayCode == 1)
+ // {
+ // //粉料仓下发配方
+ // if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing == false)
+ // {
+ // GVL_SmallStation.GetInstance.WindSendDosing = true;
+ // WindSendData.TargetRecipeCode = code;
+ // WindSendData.IsAllowDosing = true;
+ // foreach (var item in RemoteRecipes.ElementAt(index).WindSend)
+ // {
+ // if (item.RawMaterialName == "0037" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(0).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight;
+ // }
+ // if (item.RawMaterialName == "0038" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(1).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight;
+ // }
+ // if (item.RawMaterialName == "0039" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(2).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight;
+ // }
+ // if (item.RawMaterialName == "0045" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(3).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight;
+ // }
+ // if (item.RawMaterialName == "0046" || item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(4).RawMaterialName)
+ // {
+ // WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight;
+ // }
+ // }
+ // WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData, 95);
+ // }
+ // if (GVL_SmallStation.GetInstance.RecipeProcessStatus[0] == 0)
+ // {
+ // StockBinInit();
+ // GVL_SmallStation.GetInstance.StockBinDosing = 0;
+ // HKDevice.IssueRecipeToPlc(RemoteRecipes.ElementAt(index).RawMaterial, 1);
+ // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true);
+ // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1;
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成");
+ // GVL_SmallStation.GetInstance.time1 = DateTime.Now;
+ // }
+ // bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read("DB3.DBX1.3");
+ // if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1)
+ // {
+ // HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false);
+ // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2;
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成");
+ // }
+ // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2)
+ // {
+ // if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.0")))
+ // {
+ // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10");
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料");
+ // if (res > 0 && res is float loc)
+ // {
+ // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg
+ // if (weight <= 0)
+ // {
+ // int i = (int)loc;
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // else
+ // {
+ // if (loc_index >= 0)
+ // {
+ // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量
+ // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方");
+ // }
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料");
+ // }
+ // }
+ // else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1")))
+ // {
+ // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14");
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料");
+ // if (res > 0 && res is float loc)
+ // {
+ // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ // if (weight <= 0)
+ // {
+ // int i = (int)loc;
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // else
+ // {
+ // if (loc_index >= 0)
+ // {
+ // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
+ // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方");
+ // }
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料");
+ // }
+ // }
+ // else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.2")))
+ // {
+ // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18");
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料");
+ // if (res > 0 && res is float loc)
+ // {
+ // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ // if (weight <= 0)
+ // {
+ // int i = (int)loc;
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // else
+ // {
+ // if (loc_index >= 0)
+ // {
+ // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
+ // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方");
+ // }
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料");
+ // }
+ // }
+ // else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.3")))
+ // {
+ // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22");
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料");
+ // if (res > 0 && res is float loc)
+ // {
+ // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc);
+ // float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;
+ // if (weight <= 0)
+ // {
+ // int i = (int)loc;
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // else
+ // {
+ // if (loc_index >= 0)
+ // {
+ // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量
+ // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc;
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方");
+ // }
+ // }
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料");
+ // }
+ // }
+ // for (int i = 1; i < 16; i++)
+ // {
+ // if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
+ // {
+ // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i);
+ // if (res >= 0)
+ // {
+ // Thread.Sleep(GVL_SmallStation.GetInstance.Time);
+ // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback;
+ // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset();
+ // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}");
+ // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000);
+ // int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName);
+ // if (iIndex >= 0)
+ // {
+ // if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange)
+ // {
+ // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true);
+ // App.Current.Dispatcher.Invoke(() =>
+ // {
+ // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning);
+ // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false);
+ // });
+ // }
+ // }
+ // if (i >= 1 && i <= 8)
+ // {
+ // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo);
+ // }
+ // else if (i >= 9 && i <= 15)
+ // {
+ // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4);
+ // MessageNotify.GetInstance.ShowRunLog(commInfo1);
+ // }
+ // }
+ // GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false
+ // }
+ // }
+ // if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.1"))))
+ // {
+ // if (GVL_SmallStation.GetInstance.StockBinDosing > 0)
+ // {
+ // for (int i = 1; i < 17; i++)
+ // {
+ // if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i))
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓");
+ // }
+ // }
+ // }
+ // var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code);
+ // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g");
+ // }
+ // if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe)
+ // {
+ // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
+ // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
+ // RecipeFinishInfo.Job_No = (short)trayCode;
+ // for (int i = 0; i < 20; i++)
+ // {
+ // RecipeFinishInfo.Material[i] = new UDT1();
+ // }
+ // for (int i = 0; i < 10; i++)
+ // {
+ // RecipeFinishInfo.Powder[i] = new UDT2();
+ // }
+ // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
+ // {
+ // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
+ // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
+ // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001;
+ // }
+ // for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++)
+ // {
+ // RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight;
+ // }
+ // double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds;
+ // RecipeFinishInfo.Ask_For_Finish = true;
+ // RecipeFinishInfo.DosingTime = Convert.ToInt16(a);
+ // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261);
+
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子");
+ // }
+ // else
+ // {
+ // MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方");
+ // }
+ // GVL_SmallStation.GetInstance.WindSendDosing = false;
+ // App.Current.Dispatcher.Invoke(() =>
+ // {
+ // Json.Data.Recipes.Remove(res);
+ // });
+ // RecipeQueueTray1.TryDequeue(out code);
+ // HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false);
+ // GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0;
+ // }
+ // }
+ // }
+ // }
+ // }
+ //}
+ #endregion
+ #region 托盘2配料 ---硬件不具备条件,不使用
+ //if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.GetInstance.Tray2LogicFinish == 2)
+ //{
+ // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0));
+ // if (index >= 0 && index < RemoteRecipes.Count)
+ // {
+ // string code = RemoteRecipes.ElementAt(index).RecipeCode;
+ // int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
+ // string recipeName = RemoteRecipes.ElementAt(index).RecipeName;
+ // if (trayCode == 2)
+ // {
+ // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0)
+ // {
+ // StockBinInit();
+ // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},初始化");
+ // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
+ // {
+ // HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation, 2);
+ // }
+ // HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true);
+ // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 1;
+ // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},下发完成");
+ // }
+
+ // if (HKDevice.HK_PLC_S7.Read