diff --git a/BPASmartClient.AGV/AGVHelper.cs b/BPASmartClient.AGV/AGVHelper.cs index 54afe569..29a8c7ce 100644 --- a/BPASmartClient.AGV/AGVHelper.cs +++ b/BPASmartClient.AGV/AGVHelper.cs @@ -239,6 +239,55 @@ namespace BPASmartClient.AGV return "Analysis Error"; } /// + /// AGV从清洗台到4号线体卸桶 + /// + /// + public string AgvFromCleanToLineFourUnLoadRoller(string robotJobId) + { + //string url = AGVRequestUrl.GetInstance.TaskSendUrl; + ////请求报文头 + //HttpRequestHeaderModel.GetInstance.appKey = ""; + //HttpRequestHeaderModel.GetInstance.appSecret = ""; + //HttpRequestHeaderModel.GetInstance.requestId = ""; + //HttpRequestHeaderModel.GetInstance.timestamp = ""; + //HttpRequestHeaderModel.GetInstance.version = "2.8"; + //string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); + ////请求报文体 + //AGVModel.GetInstance.robotJobId = robotJobId;//上游提供 + //AGVModel.GetInstance.warehouseId = 123; //仓库编号 + //AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级 + //AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行 + //AGVModel.GetInstance.jobType = "POINT_ROLLER_MOVE"; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE + ////详细任务数据 + ////点到点 + //AGV_PointRollerJobData.GetInstance.startPoint = "";//起点点位 + //AGV_PointRollerJobData.GetInstance.endPoint = "";//目的点位 + //AGV_PointRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + //AGV_PointRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 + //AGV_PointRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + //AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 + //AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance; + //string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////货位到货位 + ////AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号 + ////AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号 + ////AGV_SlotRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + ////AGV_SlotRollerJobData.GetInstance.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互 + ////AGV_SlotRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 + ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; + ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////启用签名 + ////url = url + "?sign=" + MD5Deal(body); + //string data = HttpRequest(url, head, body); + //object objData = JsonConvert.DeserializeObject(data); + //if (objData != null && objData is HttpResponseBodyModel response) + //{ + // return response.code; + //} + return "Analysis Error"; + } + /// /// AGV离开炒锅1 /// /// @@ -483,6 +532,203 @@ namespace BPASmartClient.AGV //} return "Analysis Error"; } + + /// + /// AGV从1号线运空桶洗桶 + /// + /// + public string AgvLeaveLOneToClean(string robotJobId) + { + //string url = AGVRequestUrl.GetInstance.TaskSendUrl; + ////请求报文头 + //HttpRequestHeaderModel.GetInstance.appKey = ""; + //HttpRequestHeaderModel.GetInstance.appSecret = ""; + //HttpRequestHeaderModel.GetInstance.requestId = ""; + //HttpRequestHeaderModel.GetInstance.timestamp = ""; + //HttpRequestHeaderModel.GetInstance.version = "2.8"; + //string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); + ////请求报文体 + //AGVModel.GetInstance.robotJobId = robotJobId;//上游提供 + //AGVModel.GetInstance.warehouseId = 123; //仓库编号 + //AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级 + //AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行 + //AGVModel.GetInstance.jobType = "POINT_ROLLER_MOVE"; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE + ////详细任务数据 + ////点到点 + //AGV_PointRollerJobData.GetInstance.startPoint = "";//起点点位 + //AGV_PointRollerJobData.GetInstance.endPoint = "";//目的点位 + //AGV_PointRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + //AGV_PointRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 + //AGV_PointRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + //AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 + //AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance; + //string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////货位到货位 + ////AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号 + ////AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号 + ////AGV_SlotRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + ////AGV_SlotRollerJobData.GetInstance.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互 + ////AGV_SlotRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 + ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; + ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////启用签名 + ////url = url + "?sign=" + MD5Deal(body); + //string data = HttpRequest(url, head, body); + //object objData = JsonConvert.DeserializeObject(data); + //if (objData != null && objData is HttpResponseBodyModel response) + //{ + // return response.code; + //} + return "Analysis Error"; + } + /// + /// AGV从2号线运空桶洗桶 + /// + /// + public string AgvLeaveLTwoToClean(string robotJobId) + { + //string url = AGVRequestUrl.GetInstance.TaskSendUrl; + ////请求报文头 + //HttpRequestHeaderModel.GetInstance.appKey = ""; + //HttpRequestHeaderModel.GetInstance.appSecret = ""; + //HttpRequestHeaderModel.GetInstance.requestId = ""; + //HttpRequestHeaderModel.GetInstance.timestamp = ""; + //HttpRequestHeaderModel.GetInstance.version = "2.8"; + //string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); + ////请求报文体 + //AGVModel.GetInstance.robotJobId = robotJobId;//上游提供 + //AGVModel.GetInstance.warehouseId = 123; //仓库编号 + //AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级 + //AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行 + //AGVModel.GetInstance.jobType = "POINT_ROLLER_MOVE"; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE + ////详细任务数据 + ////点到点 + //AGV_PointRollerJobData.GetInstance.startPoint = "";//起点点位 + //AGV_PointRollerJobData.GetInstance.endPoint = "";//目的点位 + //AGV_PointRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + //AGV_PointRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 + //AGV_PointRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + //AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 + //AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance; + //string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////货位到货位 + ////AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号 + ////AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号 + ////AGV_SlotRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + ////AGV_SlotRollerJobData.GetInstance.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互 + ////AGV_SlotRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 + ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; + ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////启用签名 + ////url = url + "?sign=" + MD5Deal(body); + //string data = HttpRequest(url, head, body); + //object objData = JsonConvert.DeserializeObject(data); + //if (objData != null && objData is HttpResponseBodyModel response) + //{ + // return response.code; + //} + return "Analysis Error"; + } + /// + /// AGV从3号线运空桶洗桶 + /// + /// + public string AgvLeaveLThreeToClean(string robotJobId) + { + //string url = AGVRequestUrl.GetInstance.TaskSendUrl; + ////请求报文头 + //HttpRequestHeaderModel.GetInstance.appKey = ""; + //HttpRequestHeaderModel.GetInstance.appSecret = ""; + //HttpRequestHeaderModel.GetInstance.requestId = ""; + //HttpRequestHeaderModel.GetInstance.timestamp = ""; + //HttpRequestHeaderModel.GetInstance.version = "2.8"; + //string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); + ////请求报文体 + //AGVModel.GetInstance.robotJobId = robotJobId;//上游提供 + //AGVModel.GetInstance.warehouseId = 123; //仓库编号 + //AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级 + //AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行 + //AGVModel.GetInstance.jobType = "POINT_ROLLER_MOVE"; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE + ////详细任务数据 + ////点到点 + //AGV_PointRollerJobData.GetInstance.startPoint = "";//起点点位 + //AGV_PointRollerJobData.GetInstance.endPoint = "";//目的点位 + //AGV_PointRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + //AGV_PointRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 + //AGV_PointRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + //AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 + //AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance; + //string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////货位到货位 + ////AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号 + ////AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号 + ////AGV_SlotRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + ////AGV_SlotRollerJobData.GetInstance.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互 + ////AGV_SlotRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 + ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; + ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////启用签名 + ////url = url + "?sign=" + MD5Deal(body); + //string data = HttpRequest(url, head, body); + //object objData = JsonConvert.DeserializeObject(data); + //if (objData != null && objData is HttpResponseBodyModel response) + //{ + // return response.code; + //} + return "Analysis Error"; + } + /// + /// AGV从洗桶处运桶到4号洗桶线 + /// + /// + public string AgvLeaveCleanToLFour(string robotJobId) + { + //string url = AGVRequestUrl.GetInstance.TaskSendUrl; + ////请求报文头 + //HttpRequestHeaderModel.GetInstance.appKey = ""; + //HttpRequestHeaderModel.GetInstance.appSecret = ""; + //HttpRequestHeaderModel.GetInstance.requestId = ""; + //HttpRequestHeaderModel.GetInstance.timestamp = ""; + //HttpRequestHeaderModel.GetInstance.version = "2.8"; + //string head = JsonConvert.SerializeObject(HttpRequestHeaderModel.GetInstance); + ////请求报文体 + //AGVModel.GetInstance.robotJobId = robotJobId;//上游提供 + //AGVModel.GetInstance.warehouseId = 123; //仓库编号 + //AGVModel.GetInstance.jobPriority = 1;//任务执行的优先级 + //AGVModel.GetInstance.jobPriorityType = 1;//0:根据优先级来执行,1:强制执行 + //AGVModel.GetInstance.jobType = "POINT_ROLLER_MOVE"; //SLOT_ROLLER_MOVE / POINT_ROLLER_MOVE + ////详细任务数据 + ////点到点 + //AGV_PointRollerJobData.GetInstance.startPoint = "";//起点点位 + //AGV_PointRollerJobData.GetInstance.endPoint = "";//目的点位 + //AGV_PointRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + //AGV_PointRollerJobData.GetInstance.enableIOLoad = true;//上料交互方式 false:接口交互 true:光电交互 + //AGV_PointRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + //AGV_PointRollerJobData.GetInstance.enableIOUnload = true;//下料交互方式 false:接口交互 true:光电交互 + //AGVModel.GetInstance.jobData = AGV_PointRollerJobData.GetInstance; + //string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////货位到货位 + ////AGV_SlotRollerJobData.GetInstance.startSlotCode = "";//起点槽位编号 + ////AGV_SlotRollerJobData.GetInstance.endSlotCode = "";//目的槽位编号 + ////AGV_SlotRollerJobData.GetInstance.autoLoad = true;//是否自动上料 true:自动上料 false:人工上料 + ////AGV_SlotRollerJobData.GetInstance.enableIOLoad=true;//上料交互方式 false:接口交互 true:光电交互 + ////AGV_SlotRollerJobData.GetInstance.autoUnload = true;//是否自动下料 true:自动下料 false:人工下料 + ////AGV_SlotRollerJobData.GetInstance.enableIOUnload=true;//下料交互方式 false:接口交互 true:光电交互 + ////AGVModel.GetInstance.jobData = AGV_SlotRollerJobData.GetInstance; + ////string body = JsonConvert.SerializeObject(AGVModel.GetInstance); + ////启用签名 + ////url = url + "?sign=" + MD5Deal(body); + //string data = HttpRequest(url, head, body); + //object objData = JsonConvert.DeserializeObject(data); + //if (objData != null && objData is HttpResponseBodyModel response) + //{ + // return response.code; + //} + return "Analysis Error"; + } /// /// 任务取消 /// diff --git a/BPASmartClient.CustomResource/Pages/Model/PlcVariableInfoManage.cs b/BPASmartClient.CustomResource/Pages/Model/PlcVariableInfoManage.cs index b8c11c6c..80834923 100644 --- a/BPASmartClient.CustomResource/Pages/Model/PlcVariableInfoManage.cs +++ b/BPASmartClient.CustomResource/Pages/Model/PlcVariableInfoManage.cs @@ -1,5 +1,6 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -10,6 +11,6 @@ namespace BPASmartClient.CustomResource.Pages.Model { public class PlcVariableInfoManage:ObservableObject { - public ObservableCollection VariablesInfo { get; set; } = new ObservableCollection(); + public ConcurrentDictionary> VariablesInfo { get; set; } = new ConcurrentDictionary>(); } } diff --git a/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml b/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml index 33526ec6..9abfd756 100644 --- a/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml @@ -5,12 +5,14 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel" + xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - @@ -124,6 +408,165 @@ --> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml.cs b/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml.cs index f133e9ba..51a962d4 100644 --- a/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml.cs +++ b/BPASmartClient.CustomResource/Pages/View/VariableConfigView.xaml.cs @@ -29,7 +29,93 @@ namespace BPASmartClient.CustomResource.Pages.View { e.Row.Header = e.Row.GetIndex() + 1; } + private void fryOne_LoadingRow(object sender, DataGridRowEventArgs e) + { + e.Row.Header = e.Row.GetIndex() + 1; + } + + private void fryTwo_LoadingRow(object sender, DataGridRowEventArgs e) + { + e.Row.Header = e.Row.GetIndex() + 1; + } + + private void fryThree_LoadingRow(object sender, DataGridRowEventArgs e) + { + e.Row.Header = e.Row.GetIndex() + 1; + } + + private void fryFour_LoadingRow(object sender, DataGridRowEventArgs e) + { + e.Row.Header = e.Row.GetIndex() + 1; + } + + private void fryFive_LoadingRow(object sender, DataGridRowEventArgs e) + { + e.Row.Header = e.Row.GetIndex() + 1; + } + + private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + ComboBox cbo= sender as ComboBox; + if (cbo != null) + { + switch (cbo.SelectedValue) + { + case "滚筒输送线": + this.GT.Visibility = Visibility.Visible; + this.fryOne.Visibility = Visibility.Collapsed; + this.fryTwo.Visibility=Visibility.Collapsed; + this.fryThree.Visibility = Visibility.Collapsed; + this.fryFour.Visibility = Visibility.Collapsed; + this.fryFive.Visibility = Visibility.Collapsed; + break; + case "炒锅1": + this.GT.Visibility = Visibility.Collapsed; + this.fryOne.Visibility = Visibility.Visible; + this.fryTwo.Visibility = Visibility.Collapsed; + this.fryThree.Visibility = Visibility.Collapsed; + this.fryFour.Visibility = Visibility.Collapsed; + this.fryFive.Visibility = Visibility.Collapsed; + break; + case "炒锅2": + this.GT.Visibility = Visibility.Collapsed; + this.fryOne.Visibility = Visibility.Collapsed; + this.fryTwo.Visibility = Visibility.Visible; + this.fryThree.Visibility = Visibility.Collapsed; + this.fryFour.Visibility = Visibility.Collapsed; + this.fryFive.Visibility = Visibility.Collapsed; + break; + case "炒锅3": + this.GT.Visibility = Visibility.Collapsed; + this.fryOne.Visibility = Visibility.Collapsed; + this.fryTwo.Visibility = Visibility.Collapsed; + this.fryThree.Visibility = Visibility.Visible; + this.fryFour.Visibility = Visibility.Collapsed; + this.fryFive.Visibility = Visibility.Collapsed; + break; + case "炒锅4": + this.GT.Visibility = Visibility.Collapsed; + this.fryOne.Visibility = Visibility.Collapsed; + this.fryTwo.Visibility = Visibility.Collapsed; + this.fryThree.Visibility = Visibility.Collapsed; + this.fryFour.Visibility = Visibility.Visible; + this.fryFive.Visibility = Visibility.Collapsed; + break; + case "炒锅5": + this.GT.Visibility = Visibility.Collapsed; + this.fryOne.Visibility = Visibility.Collapsed; + this.fryTwo.Visibility = Visibility.Collapsed; + this.fryThree.Visibility = Visibility.Collapsed; + this.fryFour.Visibility = Visibility.Collapsed; + this.fryFive.Visibility = Visibility.Visible; + break; + } + + + } + + } - + } } diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/VariableViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/VariableViewModel.cs index f8ff0489..afaae21d 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/VariableViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/VariableViewModel.cs @@ -15,15 +15,45 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel public class VariableViewModel : ObservableObject { public ObservableCollection Variables { get; set; } = new ObservableCollection(); - + + public ObservableCollection FryOneVariables { get; set; } = new ObservableCollection(); + public ObservableCollection FryTwoVariables { get; set; } = new ObservableCollection(); + public ObservableCollection FryThreeVariables { get; set; } = new ObservableCollection(); + public ObservableCollection FryFourVariables { get; set; } = new ObservableCollection(); + public ObservableCollection FryFiveVariables { get; set; } = new ObservableCollection(); + + public List DeviceName { get; set; } = new List { "滚筒输送线", "炒锅1", "炒锅2", "炒锅3", "炒锅4", "炒锅5" }; public RelayCommand SaveDataCommand { get; set; } public VariableViewModel() { Json.Read(); - Variables = Json.Data.VariablesInfo; + + try + { + if (Json.Data.VariablesInfo.Count>0) + { + Variables = Json.Data.VariablesInfo["滚筒输送线"]; + FryOneVariables = Json.Data.VariablesInfo["炒锅1"]; + FryTwoVariables = Json.Data.VariablesInfo["炒锅2"]; + FryThreeVariables = Json.Data.VariablesInfo["炒锅3"]; + FryFourVariables = Json.Data.VariablesInfo["炒锅4"]; + FryFiveVariables = Json.Data.VariablesInfo["炒锅5"]; + } + } + catch (Exception) + { + + + } SaveDataCommand = new RelayCommand(() => { + Json.Data.VariablesInfo["滚筒输送线"] = Variables; + Json.Data.VariablesInfo["炒锅1"] = FryOneVariables; + Json.Data.VariablesInfo["炒锅2"]=FryTwoVariables; + Json.Data.VariablesInfo["炒锅3"] = FryThreeVariables; + Json.Data.VariablesInfo["炒锅4"]= FryFourVariables; + Json.Data.VariablesInfo["炒锅5"] = FryFiveVariables; Json.Save(); MessageBox.Show("保存成功","提示",MessageBoxButton.OK,MessageBoxImage.Information); }); diff --git a/FryPot_DosingSystem/Control/DeviceOperate.cs b/FryPot_DosingSystem/Control/DeviceOperate.cs index 7a33ee88..c5eb9758 100644 --- a/FryPot_DosingSystem/Control/DeviceOperate.cs +++ b/FryPot_DosingSystem/Control/DeviceOperate.cs @@ -20,15 +20,35 @@ namespace FryPot_DosingSystem.Control private static DeviceOperate _instance; public static DeviceOperate GetInstance => _instance ??= new DeviceOperate(); public bool IsConfig { get; set; }//设备plc数据是否配置 - ModbusTcp modbus = new ModbusTcp(); - private string Ip { get; set; } - private string Port { get; set; } + ModbusTcp modbus = new ModbusTcp();//滚筒线Modbus通讯对象 + ModbusTcp fryOneModbus = new ModbusTcp();//炒锅1Modbus通讯对象 + ModbusTcp fryTwoModbus = new ModbusTcp();//炒锅2Modbus通讯对象 + ModbusTcp fryThreeModbus = new ModbusTcp();//炒锅3Modbus通讯对象 + ModbusTcp fryFourModbus = new ModbusTcp();//炒锅4Modbus通讯对象 + ModbusTcp fryFiveModbus = new ModbusTcp();//炒锅5Modbus通讯对象 + // private string Ip { get; set; } + // private string Port { get; set; } public bool Connected { get; set; } + public bool FryOneConnected { get; set; } + public bool FryTwoConnected { get; set; } + public bool FryThreeConnected { get; set; } + public bool FryFourConnected { get; set; } + public bool FryFiveConnected { get; set; } - private string DeviceName { get; set; } + // private string DeviceName { get; set; } public ConcurrentDictionary Data { get; set; } = new ConcurrentDictionary(); + public ConcurrentDictionary FryOneData { get; set; } = new ConcurrentDictionary(); + public ConcurrentDictionary FryTwoData { get; set; } = new ConcurrentDictionary(); + public ConcurrentDictionary FryThreeData { get; set; } = new ConcurrentDictionary(); + public ConcurrentDictionary FryFourData { get; set; } = new ConcurrentDictionary(); + public ConcurrentDictionary FryFiveData { get; set; } = new ConcurrentDictionary(); public ObservableCollection Variables { get; set; } = new ObservableCollection(); + public ObservableCollection FryOneVariables { get; set; } = new ObservableCollection(); + public ObservableCollection FryTwoVariables { get; set; } = new ObservableCollection(); + public ObservableCollection FryThreeVariables { get; set; } = new ObservableCollection(); + public ObservableCollection FryFourVariables { get; set; } = new ObservableCollection(); + public ObservableCollection FryFiveVariables { get; set; } = new ObservableCollection(); public DeviceOperate() { Init(); @@ -37,18 +57,69 @@ namespace FryPot_DosingSystem.Control } public void Init() { - if (Variables.Count > 0) - { - Variables.Clear(); - } + Variables.Clear(); + FryOneVariables.Clear(); + FryTwoVariables.Clear(); + FryThreeVariables.Clear(); + FryFourVariables.Clear(); + FryFiveVariables.Clear(); + Json.Read(); if (Json.Data.VariablesInfo.Count > 0) { try { - foreach (var item in Json.Data.VariablesInfo) + if (Json.Data.VariablesInfo["滚筒输送线"].Count>0) { - Variables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); + //foreach (var item in Json.Data.VariablesInfo["滚筒运输线"]) + //{ + // Variables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); + //} + foreach (KeyValuePair> dic in Json.Data.VariablesInfo) + { + if (string.Equals(dic.Key, "滚筒输送线")) + { + foreach (var item in dic.Value) + { + Variables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); + } + } + if (string.Equals(dic.Key, "炒锅1")) + { + foreach (var item in dic.Value) + { + FryOneVariables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); + } + } + if (string.Equals(dic.Key, "炒锅2")) + { + foreach (var item in dic.Value) + { + FryTwoVariables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); + } + } + if (string.Equals(dic.Key, "炒锅3")) + { + foreach (var item in dic.Value) + { + FryThreeVariables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); + } + } + if (string.Equals(dic.Key, "炒锅4")) + { + foreach (var item in dic.Value) + { + FryFourVariables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); + } + } + if (string.Equals(dic.Key, "炒锅5")) + { + foreach (var item in dic.Value) + { + FryFiveVariables.Add(new PlcVariableModel { Address = item.PlcAddress, Length = (ushort)(item.Length == null ? 0 : item.Length) }); + } + } + } } IsConfig = true; } @@ -59,8 +130,8 @@ namespace FryPot_DosingSystem.Control } } else - { - IsConfig= false; + { + IsConfig = false; } //Variables.Add(new PlcVariableModel() { Address = "D2001", Length = 8 });//1号线体滚筒工位号 //Variables.Add(new PlcVariableModel() { Address = "D2011", Length = 8 });//2号线体滚筒工位号 @@ -88,13 +159,26 @@ namespace FryPot_DosingSystem.Control { if (devices.Devices.Count > 0) { - Ip = devices.Devices[0].Ip; - Port = devices.Devices[0].Port; - DeviceName = devices.Devices[0].DeviceName; - Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); - // Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); App.Current.Dispatcher.Invoke(new Action(() => { BPASmartClient.CustomResource.Pages.Model.MessageLog.GetInstance.RunLog("PLC连接成功"); })); }); + for (int i = 0; i < devices.Devices.Count; i++) + { + string Ip = devices.Devices[i].Ip; + string Port = devices.Devices[i].Port; + string DeviceName = devices.Devices[i].DeviceName; + switch (DeviceName) + { + case "滚筒输送线": Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; + case "炒锅1": Task.Run(() => { fryOneModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; + case "炒锅2": Task.Run(() => { fryTwoModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; + case "炒锅3": Task.Run(() => { fryThreeModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; + case "炒锅4": Task.Run(() => { fryFourModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; + case "炒锅5": Task.Run(() => { fryFiveModbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); }); break; + + } + + } + // Task.Run(() => { modbus.ModbusTcpConnect(Ip, Convert.ToInt32(Port)); App.Current.Dispatcher.Invoke(new Action(() => { BPASmartClient.CustomResource.Pages.Model.MessageLog.GetInstance.RunLog("PLC连接成功"); })); }); } - } + } } } public void ReadData() @@ -103,6 +187,7 @@ namespace FryPot_DosingSystem.Control { ThreadManage.GetInstance().StartLong(new Action(() => { + //滚筒线 Connected = modbus.Connected; while (Connected) { @@ -118,11 +203,106 @@ namespace FryPot_DosingSystem.Control Data.TryAdd(item.Address, res); } } - Thread.Sleep(500); + Thread.Sleep(50); + + } + //炒锅1 + FryOneConnected = fryOneModbus.Connected; + while (FryOneConnected) + { + foreach (var item in FryOneVariables) + { + var res = fryOneModbus.Read(item.Address, item.Length);//读取plc数据 + if (FryOneData.ContainsKey(item.Address)) + { + FryOneData[item.Address] = res; + } + else + { + FryOneData.TryAdd(item.Address, res); + } + } + Thread.Sleep(50); } - Thread.Sleep(1000); - }), $"设备【{DeviceName}】PLC实时数据读取线程"); + //炒锅2 + FryTwoConnected = fryTwoModbus.Connected; + while (FryTwoConnected) + { + foreach (var item in FryTwoVariables) + { + var res = fryTwoModbus.Read(item.Address, item.Length);//读取plc数据 + if (FryTwoData.ContainsKey(item.Address)) + { + FryTwoData[item.Address] = res; + } + else + { + FryTwoData.TryAdd(item.Address, res); + } + } + Thread.Sleep(50); + + } + //炒锅3 + FryThreeConnected = fryThreeModbus.Connected; + while (FryThreeConnected) + { + foreach (var item in FryThreeVariables) + { + var res = fryThreeModbus.Read(item.Address, item.Length);//读取plc数据 + if (FryThreeData.ContainsKey(item.Address)) + { + FryThreeData[item.Address] = res; + } + else + { + FryThreeData.TryAdd(item.Address, res); + } + } + Thread.Sleep(50); + + } + //炒锅4 + FryFourConnected = fryFourModbus.Connected; + while (FryFourConnected) + { + foreach (var item in FryFourVariables) + { + var res = fryFourModbus.Read(item.Address, item.Length);//读取plc数据 + if (FryFourData.ContainsKey(item.Address)) + { + FryFourData[item.Address] = res; + } + else + { + FryFourData.TryAdd(item.Address, res); + } + } + Thread.Sleep(50); + + } + //炒锅5 + FryFiveConnected = fryFiveModbus.Connected; + while (FryFiveConnected) + { + foreach (var item in FryFiveVariables) + { + var res = fryFiveModbus.Read(item.Address, item.Length);//读取plc数据 + if (FryFiveData.ContainsKey(item.Address)) + { + FryFiveData[item.Address] = res; + } + else + { + FryFiveData.TryAdd(item.Address, res); + } + } + Thread.Sleep(50); + + } + Thread.Sleep(500); + }), $"PLC实时数据读取线程"); } } public void WritePlcData(string address, ushort value) @@ -136,5 +316,25 @@ namespace FryPot_DosingSystem.Control { return Data; } + public ConcurrentDictionary GetFryOneData() + { + return FryOneData; + } + public ConcurrentDictionary GetFryTwoData() + { + return FryTwoData; + } + public ConcurrentDictionary GetFryThreeData() + { + return FryThreeData; + } + public ConcurrentDictionary GetFryFourData() + { + return FryFourData; + } + public ConcurrentDictionary GetFryFiveData() + { + return FryFiveData; + } } } diff --git a/FryPot_DosingSystem/Control/DosingLogicControl.cs b/FryPot_DosingSystem/Control/DosingLogicControl.cs index 4ca858f2..753df165 100644 --- a/FryPot_DosingSystem/Control/DosingLogicControl.cs +++ b/FryPot_DosingSystem/Control/DosingLogicControl.cs @@ -29,7 +29,16 @@ namespace FryPot_DosingSystem.Control { public static DosingLogicControl _instance; public static DosingLogicControl GetInstance => _instance ??= new DosingLogicControl(); + /// + /// 滚筒线PLC数据 + /// public ConcurrentDictionary PlcReadData = new ConcurrentDictionary(); + + public ConcurrentDictionary FryOneData = new ConcurrentDictionary(); + public ConcurrentDictionary FryTwoData = new ConcurrentDictionary(); + public ConcurrentDictionary FryThreeData = new ConcurrentDictionary(); + public ConcurrentDictionary FryFourData = new ConcurrentDictionary(); + public ConcurrentDictionary FryFiveData = new ConcurrentDictionary(); /// /// 线体1配方队列 /// @@ -126,18 +135,81 @@ namespace FryPot_DosingSystem.Control //bool LTwoagvFryPotEmptyRollerArrive = false; //线体2的agv是否拿到炒锅空桶 //bool LThreeagvFryPotEmptyRollerArrive = false;//线体3的agv是否拿到炒锅空桶 - string LOnerobotJobId = String.Empty;//线体1当前上游系统任务号,全局唯一 - string LTworobotJobId = String.Empty;//线体2当前上游系统任务号,全局唯一 - string LThreerobotJobId = String.Empty;//线体3当前上游系统任务号,全局唯一 - string LFourrobotJobId = String.Empty;//线体4当前上游系统任务号,全局唯一 + string LOnerobotJobId = string.Empty;//线体1当前上游系统任务号,全局唯一 从线体1到炒锅路径 + string LTworobotJobId = string.Empty;//线体2当前上游系统任务号,全局唯一 从线体2到炒锅路径 + string LThreerobotJobId = string.Empty;//线体3当前上游系统任务号,全局唯一 从线体3到炒锅路径 + string LFourrobotJobId = string.Empty;//线体4当前上游系统任务号,全局唯一 从炒锅1、4到线体4路径 + string LFiverobotJobId = string.Empty; //从炒锅2、5到线体4路径 + string LSixrobotJobId = string.Empty; //从炒锅3到线体4路径 + string LSevenrobotJobId = string.Empty; //从线体1到清洗台路径 + string LEightrobotJobId = string.Empty; //从线体2到清洗台路径 + string LNinerobotJobId = string.Empty; //从线体3到清洗台路径 + string LTenrobotJobId = string.Empty; //从清洗台到线体4路径 - //bool loadInteractive = false;// fasle:不需要上料交互 true:需要上料交互 #endregion /// /// 调试命令注册 /// public void CommandRegist() { + + #region 线体空桶清洗及回收调试 + ActionManage.GetInstance.Register(new Action(() => + { + globalVar.agvArriveLineOneLoadEmptyRoller = true; + + }), "AgvArriveLineOneEmptyRollerLoc"); + ActionManage.GetInstance.Register(new Action(() => + { + globalVar.agvArriveLineTwoLoadEmptyRoller = true; + + }), "AgvArriveLineTwoEmptyRollerLoc"); + ActionManage.GetInstance.Register(new Action(() => + { + globalVar.agvArriveLineThreeLoadEmptyRoller = true; + + }), "AgvArriveLineThreeEmptyRollerLoc"); + ActionManage.GetInstance.Register(new Action(() => + { + globalVar.CleanComplete = 1; + + }), "CleanPlateCallAgv"); + ActionManage.GetInstance.Register(new Action(() => + { + globalVar.agvArriveCleanUnLoad = true;//清洗台空桶下料就位 + + }), "AgvArriveCleanPlateLoc"); + ActionManage.GetInstance.Register(new Action(() => + { + globalVar.agvArriveCleanLoad = true;//清洗台空桶上料就位 + + }), "AgvArriveCleanPlateLocLoad"); + ActionManage.GetInstance.Register(new Action(() => + { + globalVar.agvArriveLineFour = true; + + }), "AgvArriveLineFourLoc"); + + #endregion + //接口调试 + ActionManage.GetInstance.Register(new Action(() => + { + string id = Guid.NewGuid().ToString(); + string errorCode=AGVHelper._Instance.AgvToLineOneLoadRoller(id); + if (errorCode == "SUCCESS") + { + MessageLog.GetInstance.ShowRunLog($"AGV任务下发成功"); + } + else if (errorCode == "Analysis Error") + { + MessageLog.GetInstance.ShowRunLog($"提示:AGV 调用API失败,请检查请求报文"); + } + else + { + MessageLog.GetInstance.ShowRunLog($"提示:AGV任务下发失败,错误码:{errorCode}"); + } + }), "AgvDebug"); + ActionManage.GetInstance.Register(new Action(() => { globalVar.rollerLineOne.OutMaterialingSingle = 1; @@ -279,25 +351,62 @@ namespace FryPot_DosingSystem.Control /// private void FileRegClean() { + int days = 5; //清除期限 string[] filesOne = Directory.GetFiles("AccessFile//DB//炒锅1状态数据"); if (filesOne.Count() > 0) { - + foreach (var item in filesOne) + { + FileInfo info = new FileInfo(item); + DateTime createTime = info.CreationTime; + DateTime timeNow = DateTime.Now; + if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) + { + Directory.Delete(item); + } + } } string[] filesTwo = Directory.GetFiles("AccessFile//DB//炒锅2状态数据"); if (filesTwo.Count() > 0) { - + foreach (var item in filesTwo) + { + FileInfo info = new FileInfo(item); + DateTime createTime = info.CreationTime; + DateTime timeNow = DateTime.Now; + if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) + { + Directory.Delete(item); + } + } } string[] filesThree = Directory.GetFiles("AccessFile//DB//炒锅3状态数据"); if (filesThree.Count() > 0) { - + foreach (var item in filesThree) + { + FileInfo info = new FileInfo(item); + DateTime createTime = info.CreationTime; + DateTime timeNow = DateTime.Now; + if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) + { + Directory.Delete(item); + } + } } string[] filesFour = Directory.GetFiles("AccessFile//DB//炒锅4状态数据"); if (filesFour.Count() > 0) { - + foreach (var item in filesFour) + { + FileInfo info = new FileInfo(item); + DateTime createTime = info.CreationTime; + DateTime timeNow = DateTime.Now; + if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) + { + Directory.Delete(item); + } + } } string[] filesFive = Directory.GetDirectories("AccessFile//DB//炒锅5状态数据"); if (filesFive.Count() > 0) @@ -307,7 +416,7 @@ namespace FryPot_DosingSystem.Control FileInfo info = new FileInfo(item); DateTime createTime = info.CreationTime; DateTime timeNow = DateTime.Now; - if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > 30) + if (TimeDiff(timeNow, createTime) != 0 && TimeDiff(timeNow, createTime) > days) { Directory.Delete(item); } @@ -330,12 +439,12 @@ namespace FryPot_DosingSystem.Control { //计算时间差 //DateDiff = TimeValue.Subtract(NowValue).Duration(); - DateDiff = NowValue.Subtract(TimeValue); - int h= DateDiff.Hours; - int m= DateDiff.Minutes; - return DateDiff.Days; + DateDiff = NowValue.Subtract(TimeValue); + int h = DateDiff.Hours; + int m = DateDiff.Minutes; + return DateDiff.Days; } - catch + catch { return -1; } @@ -500,6 +609,7 @@ namespace FryPot_DosingSystem.Control if (objData != null) { + #region 线体到炒锅 //线体1请求上下料 if (objData.robotJobId == LOnerobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料 { @@ -531,8 +641,84 @@ namespace FryPot_DosingSystem.Control if (objData.robotJobId == LThreerobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段 { globalVar.LThreeagvArriveUnLoad = true;//AGV到达下料位置 + } + #endregion + + #region 炒锅到线体4请求上下料 + if (objData.robotJobId == LFourrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料 + { + globalVar.agvArriveUpLoad = true;//AGV到达上料位置 + + } + if (objData.robotJobId == LFourrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段 + { + globalVar.agvArriveLineFour = true;//AGV到达下料位置 + + } + + if (objData.robotJobId == LFiverobotJobId && objData.command == "LOAD") + { + globalVar.agvArriveLTwoUpLoad = true;//AGV到达上料位置 + + } + if (objData.robotJobId == LFiverobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段 + { + globalVar.agvArriveLineFour = true;//AGV到达下料位置 + + } + + if (objData.robotJobId == LSixrobotJobId && objData.command == "LOAD") + { + globalVar.agvArriveLThreeUpLoad = true;//AGV到达上料位置 + + } + if (objData.robotJobId == LSixrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段 + { + globalVar.agvArriveLineFour = true;//AGV到达下料位置 + } + #endregion + #region 线体到清洗台 + if (objData.robotJobId == LSevenrobotJobId && objData.command == "LOAD")//同一任务号且处于上料阶段,AGV请求上料 + { + globalVar.agvArriveLineOneLoadEmptyRoller = true;//AGV到达上料位置 } + if (objData.robotJobId == LSevenrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段 + { + globalVar.agvArriveCleanUnLoad = true;//AGV到达下料位置 + + } + + if (objData.robotJobId == LEightrobotJobId && objData.command == "LOAD") + { + globalVar.agvArriveLineTwoLoadEmptyRoller = true;//AGV到达上料位置 + + } + if (objData.robotJobId == LEightrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段 + { + globalVar.agvArriveCleanUnLoad = true;//AGV到达下料位置 + + } + + if (objData.robotJobId == LSixrobotJobId && objData.command == "LOAD") + { + globalVar.agvArriveLineThreeLoadEmptyRoller = true;//AGV到达上料位置 + + } + if (objData.robotJobId == LSixrobotJobId && objData.command == "UNLOAD")//同一任务号且处于下料阶段 + { + globalVar.agvArriveCleanUnLoad = true;//AGV到达下料位置 + } + #endregion + + if (objData.robotJobId == LTenrobotJobId && objData.command == "LOAD") + { + globalVar.agvArriveCleanLoad = true;//agv到达清洗台下料位置 + } + if (objData.robotJobId == LTenrobotJobId && objData.command == "UNLOAD") + { + globalVar.agvArriveLineFour = true;//agv到达清洗台下料位置 + } } } @@ -551,24 +737,40 @@ namespace FryPot_DosingSystem.Control { #region 线体上下料任务信息回报 //线体1任务上报 - if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指线体上料 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料 { } //线体2任务上报 - if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指线体上料 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料 { //日志 } //线体3任务上报 - if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指线体上料 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体上料 { //日志 } - + //---------------------空桶从线体去清洗-------------------------------// + //线体1任务上报 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体空桶上料 + { + // globalVar.rollerLineOne.IsEpmtyBefore = false; + } + //线体2任务上报 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体空桶上料 + { + // globalVar.rollerLineTwo.IsEpmtyBefore = false; + } + //线体3任务上报 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")// AGV正在上料,指线体空桶上料 + { + // globalVar.rollerLineThree.IsEpmtyBefore = false; + } //线体1任务上报 - if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指线体上料 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料 { + AgvViewModel.GetInstance().Set滚筒线上数量(1, (globalVar.LOneMaterialNum - 1).ToString()); AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.Yes); if (globalVar.LOneFryPotSerial == 1) @@ -579,11 +781,12 @@ namespace FryPot_DosingSystem.Control { AgvViewModel.GetInstance().Set小车运动(1, CartMotionTrajectory.yc_1_4); } - } + //线体2任务上报 - if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指线体上料 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料 { + AgvViewModel.GetInstance().Set滚筒线上数量(2, (globalVar.LTwoMaterialNum - 1).ToString()); AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.Yes); if (globalVar.LTwoFryPotSerial == 2) @@ -594,14 +797,41 @@ namespace FryPot_DosingSystem.Control { AgvViewModel.GetInstance().Set小车运动(2, CartMotionTrajectory.yc_2_5); } + } //线体3任务上报 - if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指线体上料 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体上料 { + AgvViewModel.GetInstance().Set滚筒线上数量(3, (globalVar.LThreeMaterialNum - 1).ToString()); AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.Yes); AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.yc_3_3); + } + + //线体1任务上报 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LSevenrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体1空桶上料 + { + AgvViewModel.GetInstance().Set滚筒线上数量(1, (globalVar.LOneMaterialNum - 1).ToString()); + AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.OnllYes); + //到清洗处 + } + //线体2任务上报 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LEightrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体2空桶上料 + { + AgvViewModel.GetInstance().Set滚筒线上数量(2, (globalVar.LTwoMaterialNum - 1).ToString()); + AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.OnllYes); + + //到清洗处 + + } + //线体3任务上报 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料点上料完成,这里指线体3空桶上料 + { + AgvViewModel.GetInstance().Set滚筒线上数量(3, (globalVar.LThreeMaterialNum - 1).ToString()); + AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.OnllYes); + //到清洗处 + } //线体1任务上报 if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指线体下料 @@ -637,23 +867,23 @@ namespace FryPot_DosingSystem.Control #region 空桶上下料任务信息回报 //线体1任务上报 - if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指空桶上料 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料 { //日志 } //线体2任务上报 - if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指空桶上料 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料 { //日志 } //线体3任务上报 - if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指空桶上料 + if (objData.state == "ROLLER_LOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "")// AGV正在上料,指炒锅空桶上料 { //日志 } //线体1任务上报 - if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LOnerobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指空桶上料 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料 { globalVar.agvFryPotEmptyRollerArrive = true; AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.OnllYes); @@ -667,7 +897,7 @@ namespace FryPot_DosingSystem.Control } } //线体2任务上报 - if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LTworobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指空桶上料 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LFiverobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料 { globalVar.LTwoagvFryPotEmptyRollerArrive = true; AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.OnllYes); @@ -681,16 +911,18 @@ namespace FryPot_DosingSystem.Control } } //线体3任务上报 - if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LThreerobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指空桶上料 + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "")//指定上料点上料完成,这里指炒锅空桶上料 { globalVar.LThreeagvFryPotEmptyRollerArrive = true; AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.OnllYes); AgvViewModel.GetInstance().Set小车运动(3, CartMotionTrajectory.hs_3); } + + //线体1任务上报 - if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LOnerobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指空桶下料 + if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFourrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料 { - AgvViewModel.GetInstance().Set滚筒线状态(1, IsRun.Start); + AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start); AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.No); if (globalVar.LFourRollerNum >= 8) { @@ -702,9 +934,9 @@ namespace FryPot_DosingSystem.Control } } //线体2任务上报 - if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LTworobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指空桶下料 + if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LFiverobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料 { - AgvViewModel.GetInstance().Set滚筒线状态(2, IsRun.Start); + AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start); AgvViewModel.GetInstance().Set小车是否承载物品(2, IsBool.No); if (globalVar.LFourRollerNum >= 8) { @@ -716,9 +948,9 @@ namespace FryPot_DosingSystem.Control } } //线体3任务上报 - if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LThreerobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指空桶下料 + if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LSixrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指炒锅空桶下料 { - AgvViewModel.GetInstance().Set滚筒线状态(3, IsRun.Start); + AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start); AgvViewModel.GetInstance().Set小车是否承载物品(3, IsBool.No); if (globalVar.LFourRollerNum >= 8) { @@ -730,29 +962,77 @@ namespace FryPot_DosingSystem.Control } } //线体1任务上报 - if (objData.state == "DONE" && objData.robotJobId == LOnerobotJobId && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指空桶下料 + if (objData.state == "DONE" && objData.robotJobId == LFourrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料 { - globalVar.EmptyRollerUnLoadcCom = true; + // globalVar.EmptyRollerUnLoadcCom = true; AgvViewModel.GetInstance().Set小车运动(1, AgvViewModel.GetInstance().GetCommandValue("hj")); AgvViewModel.GetInstance().Set小车停止(1); AgvViewModel.GetInstance().Set停车桩(1, IsBool.Yes); + } //线体2任务上报 - if (objData.state == "DONE" && objData.robotJobId == LTworobotJobId && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指空桶下料 + if (objData.state == "DONE" && objData.robotJobId == LFiverobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料 { - globalVar.LTwoEmptyRollerUnLoadcCom = true; + // globalVar.EmptyRollerUnLoadcCom = true; AgvViewModel.GetInstance().Set小车运动(2, AgvViewModel.GetInstance().GetCommandValue("hj")); AgvViewModel.GetInstance().Set小车停止(2); AgvViewModel.GetInstance().Set停车桩(2, IsBool.Yes); } //线体3任务上报 - if (objData.state == "DONE" && objData.robotJobId == LThreerobotJobId && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指空桶下料 + if (objData.state == "DONE" && objData.robotJobId == LSixrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指炒锅空桶下料 { - globalVar.LThreeEmptyRollerUnLoadcCom = true; + // globalVar.EmptyRollerUnLoadcCom = true; AgvViewModel.GetInstance().Set小车运动(3, AgvViewModel.GetInstance().GetCommandValue("hj")); AgvViewModel.GetInstance().Set小车停止(3); AgvViewModel.GetInstance().Set停车桩(3, IsBool.Yes); } + + if (objData.state == "DONE" && objData.robotJobId == LSevenrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体1到清戏台空桶下料 + { + AgvViewModel.GetInstance().Set小车运动(4, AgvViewModel.GetInstance().GetCommandValue("hj")); + AgvViewModel.GetInstance().Set小车停止(4); + AgvViewModel.GetInstance().Set停车桩(4, IsBool.Yes); + } + if (objData.state == "DONE" && objData.robotJobId == LEightrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体2到清戏台空桶下料 + { + AgvViewModel.GetInstance().Set小车运动(4, AgvViewModel.GetInstance().GetCommandValue("hj")); + AgvViewModel.GetInstance().Set小车停止(4); + AgvViewModel.GetInstance().Set停车桩(4, IsBool.Yes); + } + if (objData.state == "DONE" && objData.robotJobId == LNinerobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指从线体3到清戏台空桶下料 + { + AgvViewModel.GetInstance().Set小车运动(4, AgvViewModel.GetInstance().GetCommandValue("hj")); + AgvViewModel.GetInstance().Set小车停止(4); + AgvViewModel.GetInstance().Set停车桩(4, IsBool.Yes); + } + if (objData.state == "ROLLER_LOAD_FINISH" && objData.robotJobId == LTenrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定上料位置上料完成,指清戏台空桶到上料 + { + AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.OnllYes); + AgvViewModel.GetInstance().Set小车运动(4, CartMotionTrajectory.hs_4);//去四号空桶线 + + } + if (objData.state == "ROLLER_UNLOAD_DOING" && objData.robotJobId == LTenrobotJobId && objData.jobData.targetPointCode == "")//指定下料点正在下料,指清洗台空桶到线体4下料 + { + AgvViewModel.GetInstance().Set滚筒线状态(4, IsRun.Start); + AgvViewModel.GetInstance().Set小车是否承载物品(4, IsBool.No); + if (globalVar.LFourRollerNum >= 8) + { + AgvViewModel.GetInstance().Set滚筒线上数量(4, "8"); + } + else + { + AgvViewModel.GetInstance().Set滚筒线上数量(4, (globalVar.LFourRollerNum + 1).ToString()); + } + } + + if (objData.state == "DONE" && objData.robotJobId == LTenrobotJobId && objData.jobData.startPointCode == "" && objData.jobData.targetPointCode == "")//指定下料位置下料完成,指清戏台空桶到线体4下料 + { + AgvViewModel.GetInstance().Set小车运动(4, AgvViewModel.GetInstance().GetCommandValue("hj")); + AgvViewModel.GetInstance().Set小车停止(4); + AgvViewModel.GetInstance().Set停车桩(4, IsBool.Yes); + + } + #endregion @@ -773,9 +1053,9 @@ namespace FryPot_DosingSystem.Control ThreadManage.GetInstance().StopTask("MainViewReadPlcData", new Action(() => { - //ActionManage.GetInstance.CancelRegister("RecipeSetDown"); - //ActionManage.GetInstance.Register(new Action(RecipeDataParse), "RecipeSetDown"); - // ActionManage.GetInstance.Send("ClearRecipes"); + //ActionManage.GetInstance.CancelRegister("RecipeSetDown"); + //ActionManage.GetInstance.Register(new Action(RecipeDataParse), "RecipeSetDown"); + // ActionManage.GetInstance.Send("ClearRecipes"); ThreadManage.GetInstance().StopTask("滚筒线1任务线程", new Action(() => { ThreadManage.GetInstance().StopTask("滚筒线2任务线程", new Action(() => @@ -935,9 +1215,9 @@ namespace FryPot_DosingSystem.Control globalVar.rollerLineOne.OutMaterialingSingle = data[3]; globalVar.rollerLineTwo.OutMaterialingSingle = data[4]; globalVar.rollerLineThree.OutMaterialingSingle = data[5]; - //globalVar.rollerLineOne.OutMaterialingTroubleSingle = data[6]; - //globalVar.rollerLineTwo.OutMaterialingTroubleSingle = data[7]; - //globalVar.rollerLineThree.OutMaterialingTroubleSingle = data[8]; + //globalVar.rollerLineOne.OutMaterialingTroubleSingle = data[6]; + //globalVar.rollerLineTwo.OutMaterialingTroubleSingle = data[7]; + //globalVar.rollerLineThree.OutMaterialingTroubleSingle = data[8]; AlarmHelper.Alarm.LOneRollerTrouble = data[6]; AlarmHelper.Alarm.LTwoRollerTrouble = data[7]; AlarmHelper.Alarm.LThreeRollerTrouble = data[8]; @@ -977,11 +1257,11 @@ namespace FryPot_DosingSystem.Control })); GetAddressData("D2070", new Action((data) => { - //globalVar.fryPotOne.RollerTroubleSingle = data[0]; - //globalVar.fryPotTwo.RollerTroubleSingle = data[1]; - //globalVar.fryPotThree.RollerTroubleSingle = data[2]; - //globalVar.fryPotFour.RollerTroubleSingle = data[3]; - //globalVar.fryPotFive.RollerTroubleSingle = data[4]; + //globalVar.fryPotOne.RollerTroubleSingle = data[0]; + //globalVar.fryPotTwo.RollerTroubleSingle = data[1]; + //globalVar.fryPotThree.RollerTroubleSingle = data[2]; + //globalVar.fryPotFour.RollerTroubleSingle = data[3]; + //globalVar.fryPotFive.RollerTroubleSingle = data[4]; AlarmHelper.Alarm.FryPotOneRollerTrouble = data[0]; AlarmHelper.Alarm.FryPotTwoRollerTrouble = data[1]; AlarmHelper.Alarm.FryPotThreeRollerTrouble = data[2]; @@ -1004,6 +1284,45 @@ namespace FryPot_DosingSystem.Control globalVar.CleadBarrelExitSingle = data[0]; })); + //炒锅1状态数据 + GetFryOneData("D2001", new Action(data => + { + + })); + //炒锅2状态数据 + GetFryTwoData("D2001", new Action(data => + { + + })); + //炒锅3状态数据 + GetFryThreeData("D2001", new Action(data => + { + + })); + //炒锅4状态数据 + GetFryFourData("D2001", new Action(data => + { + + })); + //炒锅5状态数据 + GetFryFiveData("D2001", new Action(data => + { + + })); + //线体上放空桶 + if (globalVar.rollerLineOne.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineOne.EmptyRollerNum != 0) + { + globalVar.rollerLineOne.EmptyRollerNums.Add(globalVar.rollerLineOne.EmptyRollerNum); + } + if (globalVar.rollerLineTwo.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineTwo.EmptyRollerNum != 0) + { + globalVar.rollerLineTwo.EmptyRollerNums.Add(globalVar.rollerLineTwo.EmptyRollerNum); + } + if (globalVar.rollerLineThree.EmptyRollerConfirmSingle == 1 && globalVar.rollerLineThree.EmptyRollerNum != 0) + { + globalVar.rollerLineThree.EmptyRollerNums.Add(globalVar.rollerLineThree.EmptyRollerNum); + } + //炒锅状态数据 if (globalVar.fryPotOne.OilConfirm == 1) { FryPotMonitorManage.GetInstance.fryOne.OilCapacity = globalVar.fryPotOne.OilCapacity; @@ -1029,7 +1348,7 @@ namespace FryPot_DosingSystem.Control FryPotMonitorManage.GetInstance.fryFive.OilCapacity = globalVar.fryPotFive.OilCapacity; FryPotMonitorManage.GetInstance.fryFive.TotalOilCapactiy += globalVar.fryPotFive.OilCapacity; } - //炒锅状态实时显示 + //炒锅状态实时显示 FryPotStatusDisplay(); RollerLineStatusDisplay(); Thread.Sleep(10); @@ -1361,7 +1680,7 @@ namespace FryPot_DosingSystem.Control } /// - /// 返回指定地址指定长度的数据 + /// 返回滚筒线PLC指定地址指定长度的数据 /// /// /// @@ -1373,6 +1692,46 @@ namespace FryPot_DosingSystem.Control action((ushort[])(PlcReadData[address])); } } + public void GetFryOneData(string address, Action action) + { + FryOneData = DeviceOperate.GetInstance.GetFryOneData(); + if (FryOneData.ContainsKey(address)) + { + action((ushort[])(FryOneData[address])); + } + } + public void GetFryTwoData(string address, Action action) + { + FryTwoData = DeviceOperate.GetInstance.GetFryTwoData(); + if (FryTwoData.ContainsKey(address)) + { + action((ushort[])(FryTwoData[address])); + } + } + public void GetFryThreeData(string address, Action action) + { + FryThreeData = DeviceOperate.GetInstance.GetFryThreeData(); + if (FryThreeData.ContainsKey(address)) + { + action((ushort[])(FryThreeData[address])); + } + } + public void GetFryFourData(string address, Action action) + { + FryFourData = DeviceOperate.GetInstance.GetFryFourData(); + if (FryFourData.ContainsKey(address)) + { + action((ushort[])(FryFourData[address])); + } + } + public void GetFryFiveData(string address, Action action) + { + FryFiveData = DeviceOperate.GetInstance.GetFryFiveData(); + if (FryFiveData.ContainsKey(address)) + { + action((ushort[])(FryFiveData[address])); + } + } /// /// 写Plc数据 /// @@ -1448,9 +1807,12 @@ namespace FryPot_DosingSystem.Control ThreadManage.GetInstance().StartLong(new Action(() => { LineOneProcessExecute(); Thread.Sleep(10); }), "滚筒线1任务线程"); ThreadManage.GetInstance().StartLong(new Action(() => { LineTwoProcessExecute(); Thread.Sleep(10); }), "滚筒线2任务线程"); ThreadManage.GetInstance().StartLong(new Action(() => { LineThreeProcessExecute(); Thread.Sleep(10); }), "滚筒线3任务线程"); - + ThreadManage.GetInstance().StartLong(new Action(() => { LineFourProcessExecute(); Thread.Sleep(10); }), "清洗台任务线程"); } + + + /// /// 线体1的执行流程 /// @@ -1505,37 +1867,173 @@ namespace FryPot_DosingSystem.Control //} } + private void LineFourProcessExecute() + { + AgvFromLineToCleanPlate(); + CleanPlateUpLoad(); + EmptyRollerToLinFour(); + CallAgvToLineFour(); + AgvArriveCleanPlate(); + } + + private void CleanPlateUpLoad() + { + if (globalVar.agvArriveCleanLoad) + { + globalVar.agvArriveCleanLoad = false; + MessageLog.GetInstance.ShowRunLog("清洗台空桶装载完成"); + } + } /// - /// 3号滚筒线数据下发 2022/7/4 新增 + /// 线体到清洗台 /// - /// - private void LThreeRecipeDataToPlc() + private void AgvFromLineToCleanPlate() { - if (LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0 && !LThreeErrorRecipe) + if (AlarmHelper.Alarm.LOneRollerTrouble == 0)//输送线无故障 { - if (globalVar.LThreeCurrentRecipeName != string.Empty) + //线体1到清洗台 + if (!globalVar.rollerLineOne.IsEpmtyBefore) { - MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成"); - if (globalVar.LThreeFryPotSerial == 3) + var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight); + if (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.EmptyRollerNums.Count > 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶 { - FryPotMonitorManage.GetInstance.fryThree.TotalProduct++; - using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryThree.txt", false, Encoding.UTF8)) - { - txtWriter.WriteLine(DateTime.Now.ToShortDateString()); - txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryThree.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy);//炒锅1产量以及总油量记录 - } - //Sqlite.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 - //Sqlite.GetInstance.Save();//保存数据 + //下发AGV去空桶线洗桶任务 + e: string id = Guid.NewGuid().ToString("N"); + if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + goto e; + + string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处 + LFourrobotJobId = id; + Thread.Sleep(500); + LineToCleanCarryTaskErrorCodeAnalysis(info, 1); + globalVar.rollerLineOne.IsEpmtyBefore = true; + AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 } - globalVar.LThreeCurrentRecipeName = string.Empty; - Task.Run(() => { Thread.Sleep(1500); fryThreeRecipe = string.Empty; }); + } + else + { + AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 } } - if (LThreeRecipeQuene.Count > 0 && LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0)//后续添加其它限制条件 + // 线体2到清洗台 + if (AlarmHelper.Alarm.LTwoRollerTrouble == 0)//输送线无故障 { - Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = string.Empty; })); - Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows = new ObservableCollection(); })); + if (!globalVar.rollerLineTwo.IsEpmtyBefore) + { + var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight); + if (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.EmptyRollerNums.Count > 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶 + { + //下发AGV去空桶线洗桶任务 + e: string id = Guid.NewGuid().ToString("N"); + if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + goto e; + + string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处 + LFiverobotJobId = id; + Thread.Sleep(500); + LineToCleanCarryTaskErrorCodeAnalysis(info, 2); + globalVar.rollerLineTwo.IsEpmtyBefore = true; + AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处 + } + } + else + { + AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 + } + } + //线体3到清洗台 + if (AlarmHelper.Alarm.LThreeRollerTrouble == 0)//输送线无故障 + { + if (!globalVar.rollerLineThree.IsEpmtyBefore) + { + var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight); + if (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.EmptyRollerNums.Count > 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶 + { + //下发AGV去空桶线洗桶任务 + e: string id = Guid.NewGuid().ToString("N"); + if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + goto e; + + string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处 + LSixrobotJobId = id; + Thread.Sleep(500); + LineToCleanCarryTaskErrorCodeAnalysis(info, 3); + globalVar.rollerLineThree.IsEpmtyBefore = true; + AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处 + } + } + else + { + AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处 + } + } + } + + /// + /// AGV到达清洗台下料位置 + /// + private void AgvArriveCleanPlate() + { + if (globalVar.agvArriveCleanUnLoad) + { + globalVar.agvArriveCleanUnLoad = false; + MessageLog.GetInstance.ShowRunLog("空桶到达清洗位置,准备卸桶"); + MessageLog.GetInstance.ShowRunLog("卸桶完成"); + //plc交互 + } + } + + /// + /// 呼叫Agv从清洗台运洗好的空桶到四号线体 + /// + public void CallAgvToLineFour() + { + if (globalVar.CleanComplete == 1) + { + //是否需要手动给PLC置位?? + globalVar.CleanComplete = 0; + e: string id = Guid.NewGuid().ToString("N"); + if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + goto e; + + string info = AGVHelper.GetInstance.AgvFromCleanToLineFourUnLoadRoller(id); + LTenrobotJobId = id; + Thread.Sleep(500); + MessageLog.GetInstance.ShowRunLog("清洗台呼叫AGV取桶"); + CleanToLineCarryTaskErrorCodeAnalysis(info, 4); + } + } + /// + /// 3号滚筒线数据下发 2022/7/4 新增 + /// + /// + private void LThreeRecipeDataToPlc() + { + if (LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0 && !LThreeErrorRecipe) + { + if (globalVar.LThreeCurrentRecipeName != string.Empty) + { + MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成"); + if (globalVar.LThreeFryPotSerial == 3) + { + FryPotMonitorManage.GetInstance.fryThree.TotalProduct++; + using (StreamWriter txtWriter = new StreamWriter("AccessFile//" + "Statistic//" + "FryThree.txt", false, Encoding.UTF8)) + { + txtWriter.WriteLine(DateTime.Now.ToShortDateString()); + txtWriter.WriteLine(FryPotMonitorManage.GetInstance.fryThree.TotalProduct + "/" + FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy);//炒锅1产量以及总油量记录 + } + //Sqlite.GetInstance.Base.Add(new PotThreeStatus { Temperature = FryPotMonitorManage.GetInstance.fryThree.Temperature, HotPower = FryPotMonitorManage.GetInstance.fryThree.HotPower, Speed = FryPotMonitorManage.GetInstance.fryThree.Speed, FryPotWeight = FryPotMonitorManage.GetInstance.fryThree.FryPotWeight, OilCapacity = FryPotMonitorManage.GetInstance.fryThree.OilCapacity, TotalOilCapactiy = FryPotMonitorManage.GetInstance.fryThree.TotalOilCapactiy, TotalProduct = FryPotMonitorManage.GetInstance.fryThree.TotalProduct, Time = DateTime.Now.ToShortDateString() });//向表中新增数据 + //Sqlite.GetInstance.Save();//保存数据 + } + globalVar.LThreeCurrentRecipeName = string.Empty; + Task.Run(() => { Thread.Sleep(1500); fryThreeRecipe = string.Empty; }); + } + } + if (LThreeRecipeQuene.Count > 0 && LThreeOutputMaterialQuene.Count == 0 && LThreeInputMaterialQuene.Count == 0)//后续添加其它限制条件 + { + Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.goodsName = string.Empty; })); + Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_3.workflows = new ObservableCollection(); })); AgvViewModel.GetInstance().Set启动或停止炒锅(3, IsRun.Stop); //if (globalVar.LThreeCurrentRecipeName != string.Empty) // MessageLog.GetInstance.ShowUserLog($"【3】号滚筒线【{globalVar.LThreeCurrentRecipeName}】 配方制作完成"); @@ -1572,7 +2070,7 @@ namespace FryPot_DosingSystem.Control } } DeviceOperate.GetInstance.WritePlcData("D1043", (ushort)result.materialCollection.Count);//发送3号滚筒线工序数据 - //AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LThreeFryPotSerial, IsRun.Stop); + //AgvViewModel.GetInstance().Set启动或停止炒锅(globalVar.LThreeFryPotSerial, IsRun.Stop); } } @@ -1964,11 +2462,9 @@ namespace FryPot_DosingSystem.Control { Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_1.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); })); - } else { - Application.Current.Dispatcher.Invoke(new Action(() => { AgvViewModel.GetInstance().wokModel_4.workflows.Add(new WorkflowModel { id = globalVar.LOneCurrentCookingStep, Name = OutputMaterialQuene.ElementAt(0).materialType.MaterialName, isBool = IsBool.Yes }); })); } AgvViewModel.GetInstance().Set小车是否承载物品(1, IsBool.No); @@ -2228,7 +2724,6 @@ namespace FryPot_DosingSystem.Control { if (LThreeOutputMaterialQuene.Count > 0 && globalVar.LThreeInOrOutputLock && globalVar.agvArriveLThreeUpLoad && globalVar.LThreePotOutputRollerArrive && !globalVar.LThreeAgvArrivePot) { - MessageLog.GetInstance.ShowRunLog($"AGV到达【{globalVar.LThreeFryPotSerial}】号炒锅空桶上料位置"); AgvArriveFryPotThreeOutEmptyRollerSingleSetDown();//暂时考虑agv送完料后原地等待,不加条件,直接发送到位信号 globalVar.agvArriveLThreeUpLoad = false; @@ -2269,58 +2764,48 @@ namespace FryPot_DosingSystem.Control } /// - /// 1号线体对应空桶清洗 + /// 4号线体下料 /// - public void LOneEmptyRollerToClean() + public void EmptyRollerToLinFour() { - if (globalVar.EmptyRollerUnLoadcCom)//agv在4号线体下料完成 + if (globalVar.agvArriveLineFour)//agv到达线体4下料位置 { - erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID - if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId) - { - goto erp; - } - string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id); - LOnerobotJobId = id; - FryCarryTaskErrorCodeAnalysis(info, 1); - globalVar.AllowAgvToLineLoadRoller = true; - globalVar.LoadRoller = false; - globalVar.AgvToFryPot = false; - globalVar.PotOneInputMaterialArrive = false; - globalVar.PotOneOutputRollerArrive = false; - globalVar.AgvArrivePot = false; - } - } - /// - /// 2号线体对应空桶清洗 - /// - public void LTwoEmptyRollerToClean() - { - if (globalVar.LTwoEmptyRollerUnLoadcCom)//agv在4号线体下料完成 - { - globalVar.AllowAgvToLineTwoLoadRoller = true; - globalVar.LTwoLoadRoller = false; - globalVar.LTwoAgvToFryPot = false; - globalVar.LTwoPotInputMaterialArrive = false; - globalVar.LTwoPotOutputRollerArrive = false; - globalVar.LTwoAgvArrivePot = false; - } - } - /// - /// 3号线体对应空桶清洗 - /// - public void LThreeEmptyRollerToClean() - { - if (globalVar.LThreeEmptyRollerUnLoadcCom)//agv在4号线体下料完成 - { - globalVar.AllowAgvToLineThreeLoadRoller = true; - globalVar.LThreeLoadRoller = false; - globalVar.LThreeAgvToFryPot = false; - globalVar.LThreePotInputMaterialArrive = false; - globalVar.LThreePotOutputRollerArrive = false; - globalVar.LThreeAgvArrivePot = false; + globalVar.agvArriveLineFour = false; + //线体四信号交互 + MessageLog.GetInstance.ShowRunLog("空桶到达空桶回收线体,准备卸桶"); + MessageLog.GetInstance.ShowRunLog("卸桶完成"); } } + ///// + ///// 2号线体对应空桶清洗 + ///// + //public void LTwoEmptyRollerToLineFour() + //{ + // if (globalVar.LTwoEmptyRollerUnLoadcCom)//agv在4号线体下料完成 + // { + // globalVar.AllowAgvToLineTwoLoadRoller = true; + // globalVar.LTwoLoadRoller = false; + // globalVar.LTwoAgvToFryPot = false; + // globalVar.LTwoPotInputMaterialArrive = false; + // globalVar.LTwoPotOutputRollerArrive = false; + // globalVar.LTwoAgvArrivePot = false; + // } + //} + ///// + ///// 3号线体对应空桶清洗 + ///// + //public void LThreeEmptyRollerToLinFour() + //{ + // if (globalVar.LThreeEmptyRollerUnLoadcCom)//agv在4号线体下料完成 + // { + // globalVar.AllowAgvToLineThreeLoadRoller = true; + // globalVar.LThreeLoadRoller = false; + // globalVar.LThreeAgvToFryPot = false; + // globalVar.LThreePotInputMaterialArrive = false; + // globalVar.LThreePotOutputRollerArrive = false; + // globalVar.LThreeAgvArrivePot = false; + // } + //} /// /// 炒锅滚筒进料运行到位处理 @@ -2603,60 +3088,60 @@ namespace FryPot_DosingSystem.Control { DeviceOperate.GetInstance.WritePlcData("D1062", 1);//agv到炒锅3送料就位信号 } - /// - /// AGV离开炒锅运送空桶任务 - /// - public void AgvFromFryPotToClean(ConcurrentQueue queue) - { - switch (queue.ElementAt(0).materialType.MaterialLoc / 100) - { - case 1: - erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID - if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId) - { - goto erp; - } - string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id); - LOnerobotJobId = id; - FryCarryTaskErrorCodeAnalysis(info, 1); break; - case 2: - erp1: string id1 = Guid.NewGuid().ToString("N");//上游唯一ID - if (id1 == LTworobotJobId) - { - goto erp1; - } - string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1); - LTworobotJobId = id1; - FryCarryTaskErrorCodeAnalysis(info1, 2); break; - case 3: - erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID - if (id2 == LThreerobotJobId) - { - goto erp2; - } - string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2); - LThreerobotJobId = id2; - FryCarryTaskErrorCodeAnalysis(info2, 3); break; - case 4: - erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID - if (id3 == LOnerobotJobId) - { - goto erp3; - } - string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3); - LOnerobotJobId = id3; - FryCarryTaskErrorCodeAnalysis(info3, 4); break; - case 5: - erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID - if (id4 == LTworobotJobId) - { - goto erp4; - } - string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4); - LTworobotJobId = id4; - FryCarryTaskErrorCodeAnalysis(info4, 5); break; - } - } + ///// + ///// AGV离开炒锅运送空桶任务 + ///// + //public void AgvFromFryPotToClean(ConcurrentQueue queue) + //{ + // switch (queue.ElementAt(0).materialType.MaterialLoc / 100) + // { + // case 1: + // erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID + // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId) + // { + // goto erp; + // } + // string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id); + // LOnerobotJobId = id; + // FryCarryTaskErrorCodeAnalysis(info, 1); break; + // case 2: + // erp1: string id1 = Guid.NewGuid().ToString("N");//上游唯一ID + // if (id1 == LTworobotJobId) + // { + // goto erp1; + // } + // string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1); + // LTworobotJobId = id1; + // FryCarryTaskErrorCodeAnalysis(info1, 2); break; + // case 3: + // erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID + // if (id2 == LThreerobotJobId) + // { + // goto erp2; + // } + // string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2); + // LThreerobotJobId = id2; + // FryCarryTaskErrorCodeAnalysis(info2, 3); break; + // case 4: + // erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID + // if (id3 == LOnerobotJobId) + // { + // goto erp3; + // } + // string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3); + // LOnerobotJobId = id3; + // FryCarryTaskErrorCodeAnalysis(info3, 4); break; + // case 5: + // erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID + // if (id4 == LTworobotJobId) + // { + // goto erp4; + // } + // string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4); + // LTworobotJobId = id4; + // FryCarryTaskErrorCodeAnalysis(info4, 5); break; + // } + //} /// /// AGV离开炒锅1,4运送空桶任务 /// @@ -2666,23 +3151,23 @@ namespace FryPot_DosingSystem.Control { case 1: erp: string id = Guid.NewGuid().ToString("N");//上游唯一ID - if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId) + if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) { goto erp; } MessageLog.GetInstance.ShowRunLog("AGV执行【1】号炒锅空桶回收任务"); string info = AGVHelper.GetInstance.AgvLeaveFryPotOne(id); - LOnerobotJobId = id; + LFourrobotJobId = id; FryCarryTaskErrorCodeAnalysis(info, 1); break; case 4: erp3: string id3 = Guid.NewGuid().ToString("N");//上游唯一ID - if (id3 == LOnerobotJobId || id3 == LTworobotJobId || id3 == LThreerobotJobId || id3 == LFourrobotJobId) + if (id3 == LOnerobotJobId || id3 == LTworobotJobId || id3 == LThreerobotJobId || id3 == LFourrobotJobId || id3 == LFiverobotJobId || id3 == LSixrobotJobId || id3 == LSevenrobotJobId || id3 == LEightrobotJobId || id3 == LNinerobotJobId || id3 == LTenrobotJobId) { goto erp3; } MessageLog.GetInstance.ShowRunLog("AGV执行【4】号炒锅空桶回收任务"); string info3 = AGVHelper.GetInstance.AgvLeaveFryPotFour(id3); - LOnerobotJobId = id3; + LFourrobotJobId = id3; FryCarryTaskErrorCodeAnalysis(info3, 4); break; } } @@ -2695,23 +3180,23 @@ namespace FryPot_DosingSystem.Control { case 2: erp1: string id1 = Guid.NewGuid().ToString("N");//上游唯一ID - if (id1 == LOnerobotJobId || id1 == LTworobotJobId || id1 == LThreerobotJobId || id1 == LFourrobotJobId) + if (id1 == LOnerobotJobId || id1 == LTworobotJobId || id1 == LThreerobotJobId || id1 == LFourrobotJobId || id1 == LFiverobotJobId || id1 == LSixrobotJobId || id1 == LSevenrobotJobId || id1 == LEightrobotJobId || id1 == LNinerobotJobId || id1 == LTenrobotJobId) { goto erp1; } MessageLog.GetInstance.ShowRunLog("AGV执行【2】号炒锅空桶回收任务"); string info1 = AGVHelper.GetInstance.AgvLeaveFryPotTwo(id1); - LTworobotJobId = id1; + LFiverobotJobId = id1; FryCarryTaskErrorCodeAnalysis(info1, 2); break; case 5: erp4: string id4 = Guid.NewGuid().ToString("N");//上游唯一ID - if (id4 == LOnerobotJobId || id4 == LTworobotJobId || id4 == LThreerobotJobId || id4 == LFourrobotJobId) + if (id4 == LOnerobotJobId || id4 == LTworobotJobId || id4 == LThreerobotJobId || id4 == LFourrobotJobId || id4 == LFiverobotJobId || id4 == LSixrobotJobId || id4 == LSevenrobotJobId || id4 == LEightrobotJobId || id4 == LNinerobotJobId || id4 == LTenrobotJobId) { goto erp4; } MessageLog.GetInstance.ShowRunLog("AGV执行【5】号炒锅空桶回收任务"); string info4 = AGVHelper.GetInstance.AgvLeaveFryPotFive(id4); - LTworobotJobId = id4; + LFiverobotJobId = id4; FryCarryTaskErrorCodeAnalysis(info4, 5); break; } } @@ -2721,13 +3206,13 @@ namespace FryPot_DosingSystem.Control public void AgvFromFryPotThreeToClean() { erp2: string id2 = Guid.NewGuid().ToString("N");//上游唯一ID - if (id2 == LOnerobotJobId || id2 == LTworobotJobId || id2 == LThreerobotJobId || id2 == LFourrobotJobId) + if (id2 == LOnerobotJobId || id2 == LTworobotJobId || id2 == LThreerobotJobId || id2 == LFourrobotJobId || id2 == LFiverobotJobId || id2 == LSixrobotJobId || id2 == LSevenrobotJobId || id2 == LEightrobotJobId || id2 == LNinerobotJobId || id2 == LTenrobotJobId) { goto erp2; } MessageLog.GetInstance.ShowRunLog("AGV执行【3】号炒锅空桶回收任务"); string info2 = AGVHelper.GetInstance.AgvLeaveFryPotThree(id2); - LThreerobotJobId = id2; + LSixrobotJobId = id2; FryCarryTaskErrorCodeAnalysis(info2, 3); } /// @@ -2754,6 +3239,7 @@ namespace FryPot_DosingSystem.Control //原料到位,agv到位,agv自行运料到炒锅 } } + } else//有故障 { @@ -2769,6 +3255,40 @@ namespace FryPot_DosingSystem.Control } } /// + /// Agv从1号线体运空桶到清洗处 + /// + public void AgvFromLineOneToClean(ushort emptyRollerNum) + { + erp: if (AlarmHelper.Alarm.LOneRollerTrouble == 0)//无故障 + { + if (globalVar.agvArriveLineOneLoadEmptyRoller)//agv到达上料位置 + { + MessageLog.GetInstance.ShowRunLog("AGV到达【1】号滚筒线装桶位置"); + DeviceOperate.GetInstance.WritePlcData("D1052", 1);//agv到达线体1上料位置信号下发plc + MessageLog.GetInstance.ShowRunLog($"AGV正在装载{emptyRollerNum}号空料桶"); + AgvViewModel.GetInstance().Set滚筒线状态(1, IsRun.Start); + globalVar.LOneMaterialNum--; + globalVar.agvArriveLineOneLoadEmptyRoller = false; + globalVar.rollerLineOne.IsEpmtyBefore = false; + globalVar.rollerLineOne.EmptyRollerNums.RemoveAt(0); + //原料到位,agv到位,agv自行运料到清洗处 + } + } + else//有故障 + { + while (AlarmHelper.Alarm.LOneRollerTrouble == 1) + { + Thread.Sleep(5); + if (globalVar.ExitLineOneTask) + return; + } + MessageLog.GetInstance.ShowRunLog("线体【1】滚筒故障解除,继续运行"); + //lineAlarm = 1; + goto erp; + } + + } + /// /// 处理agv从线体2到送料到炒锅的条件 /// /// @@ -2809,6 +3329,40 @@ namespace FryPot_DosingSystem.Control } } /// + /// Agv从2号线体运空桶到清洗处 + /// + public void AgvFromLineTwoToClean(ushort emptyRollerNum) + { + erp: if (AlarmHelper.Alarm.LTwoRollerTrouble == 0)//无故障 + { + if (globalVar.agvArriveLineTwoLoadEmptyRoller)//agv到达上料位置 + { + MessageLog.GetInstance.ShowRunLog("AGV到达【2】号滚筒线装桶位置"); + DeviceOperate.GetInstance.WritePlcData("D1053", 1);//agv到达线体2上料位置信号下发plc + MessageLog.GetInstance.ShowRunLog($"AGV正在装载{emptyRollerNum}号空料桶"); + AgvViewModel.GetInstance().Set滚筒线状态(2, IsRun.Start); + globalVar.LTwoMaterialNum--; + globalVar.agvArriveLineTwoLoadEmptyRoller = false; + globalVar.rollerLineTwo.IsEpmtyBefore = false; + globalVar.rollerLineTwo.EmptyRollerNums.RemoveAt(0); + //原料到位,agv到位,agv自行运料到清洗处 + } + } + else//有故障 + { + while (AlarmHelper.Alarm.LTwoRollerTrouble == 1) + { + Thread.Sleep(5); + if (globalVar.ExitLineOneTask) + return; + } + MessageLog.GetInstance.ShowRunLog("线体【2】滚筒故障解除,继续运行"); + //lineAlarm = 1; + goto erp; + } + + } + /// /// 处理agv从线体3到送料到炒锅的条件 /// /// @@ -2849,7 +3403,41 @@ namespace FryPot_DosingSystem.Control } } /// - /// 线体搬运任务错误码分析 + /// Agv从3号线体运空桶到清洗处 + /// + public void AgvFromLineThreeToClean(ushort emptyRollerNum) + { + erp: if (AlarmHelper.Alarm.LThreeRollerTrouble == 0)//无故障 + { + if (globalVar.agvArriveLineThreeLoadEmptyRoller)//agv到达上料位置 + { + MessageLog.GetInstance.ShowRunLog("AGV到达【3】号滚筒线装桶位置"); + DeviceOperate.GetInstance.WritePlcData("D1054", 1);//agv到达线体3上料位置信号下发plc + MessageLog.GetInstance.ShowRunLog($"AGV正在装载{emptyRollerNum}号空料桶"); + AgvViewModel.GetInstance().Set滚筒线状态(3, IsRun.Start); + globalVar.LThreeMaterialNum--; + globalVar.agvArriveLineThreeLoadEmptyRoller = false; + globalVar.rollerLineThree.IsEpmtyBefore = false; + globalVar.rollerLineThree.EmptyRollerNums.RemoveAt(0); + //原料到位,agv到位,agv自行运料到清洗处 + } + } + else//有故障 + { + while (AlarmHelper.Alarm.LThreeRollerTrouble == 1) + { + Thread.Sleep(5); + if (globalVar.ExitLineOneTask) + return; + } + MessageLog.GetInstance.ShowRunLog("线体【3】滚筒故障解除,继续运行"); + //lineAlarm = 1; + goto erp; + } + + } + /// + /// 线体到炒锅搬运任务错误码分析 /// /// /// @@ -2873,6 +3461,52 @@ namespace FryPot_DosingSystem.Control } } /// + /// 线体到清洗台搬运任务错误码分析 + /// + /// + /// + public void LineToCleanCarryTaskErrorCodeAnalysis(string errorCode, int num) + { + if (errorCode == "SUCCESS") + { + AgvViewModel.GetInstance().Set停车桩(num, IsBool.No); + AgvViewModel.GetInstance().Set小车是否承载物品(num, IsBool.No); + AgvViewModel.GetInstance().Set小车运动(num, AgvViewModel.GetInstance().GetCommandValue($"qc_{num}")); + MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线装桶"); + } + else if (errorCode == "Analysis Error") + { + MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文"); + } + else + { + MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}"); + } + } + /// + /// 清洗台到线体搬运任务错误码分析 + /// + /// + /// + public void CleanToLineCarryTaskErrorCodeAnalysis(string errorCode, int num) + { + if (errorCode == "SUCCESS") + { + AgvViewModel.GetInstance().Set停车桩(num, IsBool.No); + AgvViewModel.GetInstance().Set小车是否承载物品(num, IsBool.No); + AgvViewModel.GetInstance().Set小车运动(num, AgvViewModel.GetInstance().GetCommandValue($"qc_{num}")); + MessageLog.GetInstance.ShowRunLog($"AGV去{num}号滚筒线卸桶"); + } + else if (errorCode == "Analysis Error") + { + MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线API调用失败,请检查请求报文"); + } + else + { + MessageLog.GetInstance.ShowRunLog($"提示:AGV去{num}号滚筒线失败,错误码:{errorCode}"); + } + } + /// /// 炒锅搬运任务错误码分析 /// /// @@ -2899,16 +3533,43 @@ namespace FryPot_DosingSystem.Control { if (InputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineLoadRoller && globalVar.rollerLineOne.OutMaterialingSingle == 1 && !globalVar.LoadRoller) { - e: string id = Guid.NewGuid().ToString("N"); - if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId) - goto e; - - string info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id); - LOnerobotJobId = id; - Thread.Sleep(500); - LineCarryTaskErrorCodeAnalysis(info, 1); - globalVar.LoadRoller = true; - + if (globalVar.rollerLineOne.StationEight == InputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineOne.IsEpmtyBefore)//工位8上面是配方料桶 + { + e: string id = Guid.NewGuid().ToString("N"); + if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + goto e; + + string info = AGVHelper.GetInstance.AgvToLineOneLoadRoller(id); + LOnerobotJobId = id; + Thread.Sleep(500); + LineCarryTaskErrorCodeAnalysis(info, 1); + globalVar.LoadRoller = true; + } + //else // 工位8上面不是配方料桶或没有桶时 + //{ + // if (!globalVar.rollerLineOne.IsEpmtyBefore) + // { + // var res = InputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineOne.StationEight); + // if (res == null && globalVar.rollerLineOne.StationEight != 0 && globalVar.rollerLineOne.StationEight == globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶且工位8的桶号和plc上报的桶号一致,即空桶 + // { + // //下发AGV去空桶线洗桶任务 + // e: string id = Guid.NewGuid().ToString("N"); + // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + // goto e; + + // string info = AGVHelper.GetInstance.AgvLeaveLOneToClean(id);//1号线到洗桶处 + // LFourrobotJobId = id; + // Thread.Sleep(500); + // LineToCleanCarryTaskErrorCodeAnalysis(info, 1); + // globalVar.rollerLineOne.IsEpmtyBefore = true; + // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 + // } + // } + // else + // { + // AgvFromLineOneToClean(globalVar.rollerLineOne.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 + // } + //} } } @@ -2925,16 +3586,44 @@ namespace FryPot_DosingSystem.Control { if (LTwoInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineTwoLoadRoller && globalVar.rollerLineTwo.OutMaterialingSingle == 1 && !globalVar.LTwoLoadRoller) { - e: string id = Guid.NewGuid().ToString("N"); - if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId) - goto e; - - string info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id); - LTworobotJobId = id; - Thread.Sleep(500); - LineCarryTaskErrorCodeAnalysis(info, 2); - globalVar.LTwoLoadRoller = true; + if (globalVar.rollerLineTwo.StationEight == LTwoInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineTwo.IsEpmtyBefore)//工位8上面是配方料桶 + { + e: string id = Guid.NewGuid().ToString("N"); + if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + goto e; + + string info = AGVHelper.GetInstance.AgvToLineTwoLoadRoller(id); + LTworobotJobId = id; + Thread.Sleep(500); + LineCarryTaskErrorCodeAnalysis(info, 2); + globalVar.LTwoLoadRoller = true; + } } + //else// 工位8上面不是配方料桶或没有桶时 + //{ + // if (!globalVar.rollerLineTwo.IsEpmtyBefore) + // { + // var res = LTwoInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineTwo.StationEight); + // if (res == null && globalVar.rollerLineTwo.StationEight != 0 && globalVar.rollerLineTwo.StationEight == globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶 + // { + // //下发AGV去空桶线洗桶任务 + // e: string id = Guid.NewGuid().ToString("N"); + // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + // goto e; + + // string info = AGVHelper.GetInstance.AgvLeaveLTwoToClean(id);//2号线到洗桶处 + // LFiverobotJobId = id; + // Thread.Sleep(500); + // LineToCleanCarryTaskErrorCodeAnalysis(info, 2); + // globalVar.rollerLineTwo.IsEpmtyBefore = true; + // AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体2到清洗处 + // } + // } + // else + // { + // AgvFromLineTwoToClean(globalVar.rollerLineTwo.EmptyRollerNums.ElementAt(0));//AGV从线体1到清洗处 + // } + //} } } public void AgvToLineThreeLoadRoller() @@ -2943,15 +3632,43 @@ namespace FryPot_DosingSystem.Control { if (LThreeInputMaterialQuene.Count > 0 && globalVar.AllowAgvToLineThreeLoadRoller && globalVar.rollerLineThree.OutMaterialingSingle == 1 && !globalVar.LThreeLoadRoller) { - e: string id = Guid.NewGuid().ToString("N"); - if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId) - goto e; - - string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id); - LThreerobotJobId = id; - Thread.Sleep(500); - LineCarryTaskErrorCodeAnalysis(info, 3); - globalVar.LThreeLoadRoller = true; + if (globalVar.rollerLineThree.StationEight == LThreeInputMaterialQuene.ElementAt(0).materialType.MaterialLoc && !globalVar.rollerLineThree.IsEpmtyBefore)//工位8上面是配方料桶 + { + e: string id = Guid.NewGuid().ToString("N"); + if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + goto e; + + string info = AGVHelper.GetInstance.AgvToLineThreeLoadRoller(id); + LThreerobotJobId = id; + Thread.Sleep(500); + LineCarryTaskErrorCodeAnalysis(info, 3); + globalVar.LThreeLoadRoller = true; + } + //else // 工位8上面不是配方料桶或没有桶时 + //{ + // if (!globalVar.rollerLineThree.IsEpmtyBefore) + // { + // var res = LThreeInputMaterialQuene.FirstOrDefault(p => p.materialType.MaterialLoc == globalVar.rollerLineThree.StationEight); + // if (res == null && globalVar.rollerLineThree.StationEight != 0 && globalVar.rollerLineThree.StationEight == globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0))//工位8上面有桶且不是配方上的原料桶,即空桶 + // { + // //下发AGV去空桶线洗桶任务 + // e: string id = Guid.NewGuid().ToString("N"); + // if (id == LOnerobotJobId || id == LTworobotJobId || id == LThreerobotJobId || id == LFourrobotJobId || id == LFiverobotJobId || id == LSixrobotJobId || id == LSevenrobotJobId || id == LEightrobotJobId || id == LNinerobotJobId || id == LTenrobotJobId) + // goto e; + + // string info = AGVHelper.GetInstance.AgvLeaveLThreeToClean(id);//3号线到洗桶处 + // LSixrobotJobId = id; + // Thread.Sleep(500); + // LineToCleanCarryTaskErrorCodeAnalysis(info, 3); + // globalVar.rollerLineThree.IsEpmtyBefore = true; + // AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处 + // } + // } + // else + // { + // AgvFromLineThreeToClean(globalVar.rollerLineThree.EmptyRollerNums.ElementAt(0));//AGV从线体3到清洗处 + // } + //} } } diff --git a/FryPot_DosingSystem/Control/GlobalVariable.cs b/FryPot_DosingSystem/Control/GlobalVariable.cs index 1e149760..d1962539 100644 --- a/FryPot_DosingSystem/Control/GlobalVariable.cs +++ b/FryPot_DosingSystem/Control/GlobalVariable.cs @@ -57,6 +57,10 @@ namespace FryPot_DosingSystem.Control /// PLC初始化状态 /// public ushort PlcInite { get; set; } + /// + /// 清洗台清洗完成信号 + /// + public ushort CleanComplete { get; set; } #region 上位机内部逻辑条件 /// /// 退出线体1任务 @@ -178,8 +182,17 @@ namespace FryPot_DosingSystem.Control public bool LThreeagvFryPotEmptyRollerArrive { get; set; } public bool LThreeEmptyRollerUnLoadcCom { get; set; }//AGV空桶4号线体下料完成 - public int LFourRollerNum { get; set; } = 0; - #endregion + public int LFourRollerNum { get; set; } = 0;//4号线体空桶数量 + //新增 + public bool agvArriveLineFour { get; set; }//agv到达线体4下料位置从清戏台或炒锅 + public bool agvArriveCleanUnLoad { get; set; }//agv到达清洗台下料位置 + public bool agvArriveCleanLoad { get; set; }//agv到达清洗台上料位置 + + public bool agvArriveLineOneLoadEmptyRoller { get; set; }//agv到达线体1空桶上料位置 + public bool agvArriveLineTwoLoadEmptyRoller { get; set; }//agv到达线体2空桶上料位置 + + public bool agvArriveLineThreeLoadEmptyRoller { get; set; }//agv到达线体3空桶上料位置 + #endregion } /// /// 滚筒线1相关变量 @@ -230,8 +243,23 @@ namespace FryPot_DosingSystem.Control /// 当前线体配方完成信号 /// public ushort RecipeCompleteSingle { get; set; } + /// + /// 线体1上空桶确认信号 + /// + public ushort EmptyRollerConfirmSingle { get; set; } + /// + /// 线体1上单个空桶编号 + /// + public ushort EmptyRollerNum { get; set; } - + /// + /// 上一个桶是否是空桶 + /// + public bool IsEpmtyBefore { get; set; } + /// + /// 线体1上所有空桶的编号集合 + /// + public List EmptyRollerNums { get; set; } = new List() {108}; } /// /// 滚筒线2相关变量 @@ -282,6 +310,24 @@ namespace FryPot_DosingSystem.Control /// 当前线体配方完成信号 /// public ushort RecipeCompleteSingle { get; set; } + + /// + /// 线体1上空桶确认信号 + /// + public ushort EmptyRollerConfirmSingle { get; set; } + /// + /// 线体1上单个空桶编号 + /// + public ushort EmptyRollerNum { get; set; } + /// + /// 上一个同时否是空桶 + /// + public bool IsEpmtyBefore { get; set; } + + /// + /// 线体2上所有空桶的编号集合 + /// + public List EmptyRollerNums { get; set; }=new List(); } /// /// 滚筒线3相关变量 @@ -332,6 +378,24 @@ namespace FryPot_DosingSystem.Control /// 当前线体配方完成信号 /// public ushort RecipeCompleteSingle { get; set; } + + /// + /// 线体1上空桶确认信号 + /// + public ushort EmptyRollerConfirmSingle { get; set; } + /// + /// 线体1上单个空桶编号 + /// + public ushort EmptyRollerNum { get; set; } + /// + /// 上一个同时否是空桶 + /// + public bool IsEpmtyBefore { get; set; } + + /// + /// 线体3上所有空桶的编号集合 + /// + public List EmptyRollerNums { get; set; } = new List(); } /// /// 滚筒线4相关变量 diff --git a/FryPot_DosingSystem/Model/FlowProcessManage.cs b/FryPot_DosingSystem/Model/FlowProcessManage.cs new file mode 100644 index 00000000..d27924cb --- /dev/null +++ b/FryPot_DosingSystem/Model/FlowProcessManage.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 FryPot_DosingSystem.Model +{ + internal class FlowProcessManage:ObservableObject + { + public string RecipeName { get; set; } + public ObservableCollection fpModels { get; set; } = new ObservableCollection(); + } +} diff --git a/FryPot_DosingSystem/Model/FlowProcessModel.cs b/FryPot_DosingSystem/Model/FlowProcessModel.cs new file mode 100644 index 00000000..fb2a0a33 --- /dev/null +++ b/FryPot_DosingSystem/Model/FlowProcessModel.cs @@ -0,0 +1,48 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FryPot_DosingSystem.Model +{ + internal class FlowProcessModel:ObservableObject + { + /// + /// 工艺对应配方名称 + /// + public string RecipeName { get { return _recipeName; }set { _recipeName = value;OnPropertyChanged(); } } + private string _recipeName; + /// + /// 工艺步骤 + /// + public int Id { get; set; } + + /// + /// 炒制原料/桶号 + /// + public string FryMaterialNum { get { return _fryMaterialNum; } set { _fryMaterialNum = value;OnPropertyChanged(); } } + private string _fryMaterialNum; + /// + /// 炒制速度 + /// + public double FrySpeed { get { return _frySpeed; }set { _frySpeed = value;OnPropertyChanged(); } } + private double _frySpeed; + /// + /// 炒制重量 + /// + public double FryWeight { get { return _fryMaterialWeight; }set { _fryMaterialWeight = value;OnPropertyChanged(); } } + private double _fryMaterialWeight; + /// + /// 炒制温度 + /// + public double FryTemperature { get { return _fryTemperature; } set { _fryTemperature = value;OnPropertyChanged(); } } + private double _fryTemperature; + /// + /// 炒制时间 + /// + public double FryPeriodTime { get { return _fryPeriodTime; } set { _fryPeriodTime = value;OnPropertyChanged(); } } + private double _fryPeriodTime; + } +} diff --git a/FryPot_DosingSystem/Model/RecipeModel.cs b/FryPot_DosingSystem/Model/RecipeModel.cs index 922bd717..053c0dc4 100644 --- a/FryPot_DosingSystem/Model/RecipeModel.cs +++ b/FryPot_DosingSystem/Model/RecipeModel.cs @@ -29,7 +29,12 @@ namespace FryPot_DosingSystem.Model private string _updateTime; public string UpdateTime { get { return _updateTime; } set { _updateTime = value;OnPropertyChanged(); } } - + /// + /// 工艺流程 + /// + public FlowProcessManage FlowProcess { get { return _flowProcessManage; } set { _flowProcessManage = value;OnPropertyChanged(); } } + private FlowProcessManage _flowProcessManage; + /// /// 配方下发状况信息 /// diff --git a/FryPot_DosingSystem/Resources/fonts/demo_index.html b/FryPot_DosingSystem/Resources/fonts/demo_index.html index 555de870..9e093e12 100644 --- a/FryPot_DosingSystem/Resources/fonts/demo_index.html +++ b/FryPot_DosingSystem/Resources/fonts/demo_index.html @@ -52,12 +52,30 @@ + + + 节点-子流程 +  + + + + + 流程 +  + + 下载  + + + 232编辑、输入 +  + + 账号信息 @@ -118,6 +136,12 @@  + + + 工艺流程_0 +  + + 166-NFC @@ -142,7 +166,7 @@ @font-face { font-family: 'iconfont'; - src: url('iconfont.ttf?t=1659497763775') format('truetype'); + src: url('iconfont.ttf?t=1659942239310') format('truetype'); } 第二步:定义使用 iconfont 的样式 @@ -168,6 +192,24 @@ + + + + 节点-子流程 + + .icon-jiedianziliucheng + + + + + + + 流程 + + .icon-liucheng + + + @@ -177,6 +219,15 @@ + + + + 232编辑、输入 + + .icon-bianjishuru + + + @@ -267,6 +318,15 @@ + + + + 工艺流程_0 + + .icon-gongyiliucheng_0 + + + @@ -303,6 +363,22 @@ + + + + + 节点-子流程 + #icon-jiedianziliucheng + + + + + + + 流程 + #icon-liucheng + + @@ -311,6 +387,14 @@ #icon-xiazai + + + + + 232编辑、输入 + #icon-bianjishuru + + @@ -391,6 +475,14 @@ #icon-mianxingmima + + + + + 工艺流程_0 + #icon-gongyiliucheng_0 + + diff --git a/FryPot_DosingSystem/Resources/fonts/iconfont.ttf b/FryPot_DosingSystem/Resources/fonts/iconfont.ttf index 6abad97c..ead212d3 100644 Binary files a/FryPot_DosingSystem/Resources/fonts/iconfont.ttf and b/FryPot_DosingSystem/Resources/fonts/iconfont.ttf differ diff --git a/FryPot_DosingSystem/View/DebugView.xaml b/FryPot_DosingSystem/View/DebugView.xaml index 3d6e0550..05b34963 100644 --- a/FryPot_DosingSystem/View/DebugView.xaml +++ b/FryPot_DosingSystem/View/DebugView.xaml @@ -32,26 +32,42 @@ - - + + + + + + + - + + + + - - + + + + + + + - + + + + @@ -62,6 +78,10 @@ + + + + @@ -71,6 +91,12 @@ + + + + + + @@ -83,6 +109,10 @@ + + + + @@ -92,6 +122,12 @@ + + + + + + diff --git a/FryPot_DosingSystem/View/FlowProcessView.xaml b/FryPot_DosingSystem/View/FlowProcessView.xaml new file mode 100644 index 00000000..1233e617 --- /dev/null +++ b/FryPot_DosingSystem/View/FlowProcessView.xaml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FryPot_DosingSystem/View/FlowProcessView.xaml.cs b/FryPot_DosingSystem/View/FlowProcessView.xaml.cs new file mode 100644 index 00000000..318c8402 --- /dev/null +++ b/FryPot_DosingSystem/View/FlowProcessView.xaml.cs @@ -0,0 +1,35 @@ +using BPASmartClient.Helper; +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.Shapes; + +namespace FryPot_DosingSystem.View +{ + /// + /// FlowProcessView.xaml 的交互逻辑 + /// + public partial class FlowProcessView : Window + { + public FlowProcessView() + { + InitializeComponent(); + this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; + ActionManage.GetInstance.CancelRegister("CloseFlowProcessView"); + ActionManage.GetInstance.Register(new Action(() => { + this.Close(); + }), "CloseFlowProcessView"); + } + + + } +} diff --git a/FryPot_DosingSystem/View/NewRecipeView.xaml b/FryPot_DosingSystem/View/NewRecipeView.xaml index aa62f481..92f1684c 100644 --- a/FryPot_DosingSystem/View/NewRecipeView.xaml +++ b/FryPot_DosingSystem/View/NewRecipeView.xaml @@ -195,20 +195,20 @@ - + - + + BorderBrush="#FF2AB2E7" VerticalAlignment="Center" FontSize="16" > - + + BorderBrush="#FF2AB2E7" VerticalAlignment="Center" FontSize="16" TextChanged="TextBox_TextChanged"> @@ -217,30 +217,30 @@ - - + + - + - + - + - + - + - + diff --git a/FryPot_DosingSystem/View/RecipeManageView.xaml b/FryPot_DosingSystem/View/RecipeManageView.xaml index c2bc99bd..4d47815e 100644 --- a/FryPot_DosingSystem/View/RecipeManageView.xaml +++ b/FryPot_DosingSystem/View/RecipeManageView.xaml @@ -150,6 +150,7 @@ + diff --git a/FryPot_DosingSystem/ViewModel/DebugViewModel.cs b/FryPot_DosingSystem/ViewModel/DebugViewModel.cs index b829d119..46fdac14 100644 --- a/FryPot_DosingSystem/ViewModel/DebugViewModel.cs +++ b/FryPot_DosingSystem/ViewModel/DebugViewModel.cs @@ -53,8 +53,55 @@ namespace FryPot_DosingSystem.ViewModel public RelayCommand AGVFryPotThreeUpArrive { get; set; } public RelayCommand AGVFryPotThreeGetEmptyRoller { get; set; } + //AGV接口联调 + public RelayCommand AgvDebug { get; set; } + + //线体123空桶清洗以及回收 + public RelayCommand AgvArriveLineOneEmptyRollerLoc { get; set; } + public RelayCommand AgvArriveLineTwoEmptyRollerLoc { get; set; } + public RelayCommand AgvArriveLineThreeEmptyRollerLoc { get; set; } + public RelayCommand CleanPlateCallAgv { get; set; } + public RelayCommand AgvArriveCleanPlateLoc { get; set; }//下料 + public RelayCommand AgvArriveLineFourLoc { get; set; } + + public RelayCommand AgvArriveCleanPlateLocLoad { get; set; }//上料 public DebugViewModel() { + AgvDebug = new RelayCommand(new Action(() => + { + ActionManage.GetInstance.Send("AgvDebug"); + + + })); + AgvArriveLineOneEmptyRollerLoc = new RelayCommand(new Action(() => + { + ActionManage.GetInstance.Send("AgvArriveLineOneEmptyRollerLoc"); + })); + AgvArriveLineTwoEmptyRollerLoc = new RelayCommand(new Action(() => + { + ActionManage.GetInstance.Send("AgvArriveLineTwoEmptyRollerLoc"); + })); + AgvArriveLineThreeEmptyRollerLoc = new RelayCommand(new Action(() => + { + ActionManage.GetInstance.Send("AgvArriveLineThreeEmptyRollerLoc"); + })); + CleanPlateCallAgv = new RelayCommand(new Action(() => + { + ActionManage.GetInstance.Send("CleanPlateCallAgv"); + })); + AgvArriveCleanPlateLoc = new RelayCommand(new Action(() => + { + ActionManage.GetInstance.Send("AgvArriveCleanPlateLoc"); + })); + AgvArriveCleanPlateLocLoad = new RelayCommand(new Action(() => + { + ActionManage.GetInstance.Send("AgvArriveCleanPlateLocLoad"); + })); + AgvArriveLineFourLoc = new RelayCommand(new Action(() => + { + ActionManage.GetInstance.Send("AgvArriveLineFourLoc"); + })); + RollerLineRunning = new RelayCommand(new Action(() => { ActionManage.GetInstance.Send("RollerLineRunning"); diff --git a/FryPot_DosingSystem/ViewModel/DeviceListViewModel.cs b/FryPot_DosingSystem/ViewModel/DeviceListViewModel.cs index bb33d1ba..580908f4 100644 --- a/FryPot_DosingSystem/ViewModel/DeviceListViewModel.cs +++ b/FryPot_DosingSystem/ViewModel/DeviceListViewModel.cs @@ -20,7 +20,7 @@ namespace FryPot_DosingSystem.ViewModel public RelayCommand DeleteDevice { get; set; } public DeviceListViewModel() { - //Json.Read(); + Json.Read(); devices = Json.Data.Devices; DeviceName.Add("滚筒输送线"); DeviceName.Add("炒锅1"); diff --git a/FryPot_DosingSystem/ViewModel/FlowProcessSetViewModel.cs b/FryPot_DosingSystem/ViewModel/FlowProcessSetViewModel.cs new file mode 100644 index 00000000..aad1f5bf --- /dev/null +++ b/FryPot_DosingSystem/ViewModel/FlowProcessSetViewModel.cs @@ -0,0 +1,77 @@ +using BPASmartClient.Helper; +using FryPot_DosingSystem.Model; +using Microsoft.Toolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FryPot_DosingSystem.ViewModel +{ + internal class FlowProcessSetViewModel + { + public int Id { get; set; } = 0; + public ObservableCollection flowProcessModels { get; set; } = new ObservableCollection(); + + public string currnetRecipeName { get; set;} + public RelayCommand CloseWindowCommand { get; set; } + + public RelayCommand ConfirmCommand { get; set; } + public FlowProcessSetViewModel() + { + ActionManage.GetInstance.Register(new Action(recipeName => + { + if (recipeName != null) + { + currnetRecipeName = recipeName.ToString(); + var res = Json.Data.Recipes.FirstOrDefault(p => p.FlowProcess.RecipeName == recipeName.ToString()); + if (res != null && res is NewRecipeModel recipe) //编辑已有工艺 + { + //flowProcessModels = recipe.FlowProcess.fpModels; + foreach (var item in recipe.FlowProcess.fpModels) + { + flowProcessModels.Add(new FlowProcessModel { Id = item.Id, FryMaterialNum = item.FryMaterialNum, FrySpeed = item.FrySpeed, FryWeight = item.FryWeight, FryTemperature = item.FryTemperature, FryPeriodTime = item.FryPeriodTime }); + } + } + else//创建新工艺 + { + var name = Json.Data.Recipes.FirstOrDefault(p=>p.RecipeName==recipeName.ToString()); + if (name != null) + { + name.FlowProcess.RecipeName = recipeName.ToString(); + flowProcessModels.Add(new FlowProcessModel { Id = Id + 1, FryMaterialNum = "油" }); + Id++; + foreach (var item in name.materialCollection) + { + flowProcessModels.Add(new FlowProcessModel { Id = Id + 1, FryMaterialNum = item.MaterialName }); + Id++; + } + name.FlowProcess.fpModels= flowProcessModels; + } + + } + } + + + }), "EditFlowProcess"); + CloseWindowCommand = new RelayCommand(() => + { + + ActionManage.GetInstance.Send("CloseFlowProcessView"); + }); + ConfirmCommand = new RelayCommand(() => + { + var name = Json.Data.Recipes.FirstOrDefault(p => p.RecipeName == currnetRecipeName.ToString()); + if (name != null) + { + name.FlowProcess.RecipeName = currnetRecipeName.ToString(); + name.FlowProcess.fpModels = flowProcessModels; + } + Json.Save(); + ActionManage.GetInstance.Send("CloseFlowProcessView"); + }); + } + } +} diff --git a/FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs b/FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs index 718c6fe5..e54fb21b 100644 --- a/FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs +++ b/FryPot_DosingSystem/ViewModel/NewRecipeViewModel.cs @@ -102,7 +102,7 @@ namespace FryPot_DosingSystem.ViewModel var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeId == recipeID); if (res == null) { - Json.Data.Recipes.Add(new NewRecipeModel { RecipeId = recipeID, RecipeName = RecipeName, materialCollection = materials,DataTime=DateTime.Now.ToShortDateString()});//配方添加 + Json.Data.Recipes.Add(new NewRecipeModel { RecipeId = recipeID, RecipeName = RecipeName, FlowProcess=new FlowProcessManage(), materialCollection = materials,DataTime=DateTime.Now.ToShortDateString()});//配方添加 } else { diff --git a/FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs b/FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs index b2b45648..35e078a1 100644 --- a/FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs +++ b/FryPot_DosingSystem/ViewModel/RecipeSetViewModel.cs @@ -33,6 +33,10 @@ namespace FryPot_DosingSystem.ViewModel public RelayCommand SaveRecipe { get; set; } /// + /// 工艺操作 + /// + public RelayCommand OperateFlowProcess { get; set; } + /// /// 编辑配方 /// public RelayCommand EditRecipeCommand { get; set; } @@ -103,6 +107,18 @@ namespace FryPot_DosingSystem.ViewModel } } }); + //工艺流程操作 + OperateFlowProcess = new RelayCommand((recipeName) => + { + if (recipeName != null && recipeName != string.Empty && recipeName != "") + { + ActionManage.GetInstance.CancelRegister("EditFlowProcess"); + FlowProcessView fps = new FlowProcessView(); + ActionManage.GetInstance.Send("EditFlowProcess", recipeName); + fps.ShowDialog(); + } + + }); } } }
@font-face { font-family: 'iconfont'; - src: url('iconfont.ttf?t=1659497763775') format('truetype'); + src: url('iconfont.ttf?t=1659942239310') format('truetype'); }