diff --git a/BPASmartClient.AGV/AGVHelper.cs b/BPASmartClient.AGV/AGVHelper.cs index ca56e07e..95be2611 100644 --- a/BPASmartClient.AGV/AGVHelper.cs +++ b/BPASmartClient.AGV/AGVHelper.cs @@ -471,7 +471,7 @@ namespace BPASmartClient.AGV httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料 httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互 httpJobData.loadEquipmentId = 5; - httpJobData.unloadEquipmentId = 4; + httpJobData.unloadEquipmentId = 40; httpModel.jobData = httpJobData; string body = "["+JsonConvert.SerializeObject(httpModel)+"]"; //货位到货位 @@ -526,7 +526,7 @@ namespace BPASmartClient.AGV httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料 httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互 httpJobData.loadEquipmentId = 6; - httpJobData.unloadEquipmentId = 4; + httpJobData.unloadEquipmentId = 41; httpModel.jobData = httpJobData; string body ="["+ JsonConvert.SerializeObject(httpModel)+"]"; //货位到货位 @@ -581,7 +581,7 @@ namespace BPASmartClient.AGV httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料 httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互 httpJobData.loadEquipmentId = 7; - httpJobData.unloadEquipmentId = 4; + httpJobData.unloadEquipmentId = 42; httpModel.jobData = httpJobData; string body ="["+ JsonConvert.SerializeObject(httpModel)+"]"; //货位到货位 @@ -636,7 +636,7 @@ namespace BPASmartClient.AGV httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料 httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互 httpJobData.loadEquipmentId = 8; - httpJobData.unloadEquipmentId = 4; + httpJobData.unloadEquipmentId = 40; httpModel.jobData = httpJobData; string body = "["+JsonConvert.SerializeObject(httpModel)+"]"; //货位到货位 @@ -691,7 +691,7 @@ namespace BPASmartClient.AGV httpJobData.autoUnload = Convert.ToBoolean(config.AppSettings.Settings["autoUnload"].Value); //是否自动下料 true:自动下料 false:人工下料 httpJobData.enableIOUnload = Convert.ToBoolean(config.AppSettings.Settings["enableIOUnload"].Value); ;//下料交互方式 false:接口交互 true:光电交互 httpJobData.loadEquipmentId = 9; - httpJobData.unloadEquipmentId = 4; + httpJobData.unloadEquipmentId = 41; httpModel.jobData = httpJobData; string body = "["+JsonConvert.SerializeObject(httpModel)+"]"; //货位到货位 diff --git a/BPASmartClient.CustomResource/Image/弹窗.png b/BPASmartClient.CustomResource/Image/弹窗.png index 7d4f8fdd..ce73a3c8 100644 Binary files a/BPASmartClient.CustomResource/Image/弹窗.png and b/BPASmartClient.CustomResource/Image/弹窗.png differ diff --git a/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs b/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs index e1325b1a..f0688f09 100644 --- a/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs +++ b/BPASmartClient.CustomResource/Pages/Model/MessageNotify.cs @@ -66,15 +66,23 @@ namespace BPASmartClient.CustomResource.Pages.Model { lock (runLock) { - RunLog runLog = new RunLog() + try { - Date = DateTime.Now.ToString("yyyy-MM-dd"), - Time = DateTime.Now.ToString("HH:mm:ss"), - RunLogInfo = info - }; - Sqlite.GetInstance.Base.Add(runLog); - Application.Current.Dispatcher.Invoke(new Action(() => { runLogs.Insert(0, runLog); })); - RunLog?.Invoke(info); + RunLog runLog = new RunLog() + { + Date = DateTime.Now.ToString("yyyy-MM-dd"), + Time = DateTime.Now.ToString("HH:mm:ss"), + RunLogInfo = info + }; + Sqlite.GetInstance.Base.Add(runLog); + Application.Current.Dispatcher.Invoke(new Action(() => { runLogs.Insert(0, runLog); })); + RunLog?.Invoke(info); + } + catch (Exception) + { + + // throw; + } } } diff --git a/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml b/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml index ef67919e..e265a036 100644 --- a/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml @@ -263,7 +263,8 @@ Margin="10,0,0,0" HorizontalAlignment="Left" Style="{StaticResource DataTextBlockStyle}" - Text="{Binding RunLogInfo}" /> + Text="{Binding RunLogInfo}" + TextWrapping="Wrap"/> + Text="{Binding LogInfo}" + TextWrapping="Wrap" + /> 0) - { - foreach (var items in MenuManage.GetInstance.menuModels) - { - foreach (var item in items.subMenumodels) - { - items.MainMenuVisibility = Visibility.Visible; - if (res.userTreeViewModels.FirstOrDefault(p => p.Name == item.SubMenuName) != null) - { - item.SubMenuVisibility = Visibility.Visible; - } - } - } - } - } - } + ////分配后的权限 + //if (res.permission == Enums.Permission.管理员) + //{ + // foreach (var items in MenuManage.GetInstance.menuModels) + // { + // items.MainMenuVisibility = Visibility.Visible; + // foreach (var item in items.subMenumodels) + // { + // item.SubMenuVisibility = Visibility.Visible; + // } + // } + //} + //else + //{ + // if (res.userTreeViewModels != null) + // { + // if (res.userTreeViewModels.Count > 0) + // { + // foreach (var items in MenuManage.GetInstance.menuModels) + // { + // foreach (var item in items.subMenumodels) + // { + // items.MainMenuVisibility = Visibility.Visible; + // if (res.userTreeViewModels.FirstOrDefault(p => p.Name == item.SubMenuName) != null) + // { + // item.SubMenuVisibility = Visibility.Visible; + // } + // } + // } + // } + // } + //} ActionManage.GetInstance.Send("PermissionChange"); diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs index e2d6bde9..a1a4ddf9 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs @@ -20,6 +20,40 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel public MainViewModel() { NavChangedCommand = new RelayCommand(DoNavChanged); + BPASmartClient.Message. MessageLog.GetInstance.InfoNotify = new Action((o) => + { + Application.Current?.Dispatcher?.Invoke(() => + { + //ff20aefe + var temp = new MessageModel() + { + LogInfo = o, + Forground = new SolidColorBrush(Color.FromArgb(255, 32, 174, 254)) + }; + if (DebugLogViewModel.MessageModels.Count > 0) + DebugLogViewModel.MessageModels.Insert(0, temp); + else + DebugLogViewModel.MessageModels.Add(temp); + }); + }); + + BPASmartClient.Message.MessageLog.GetInstance.ExInfoNotify = new Action((o) => + { + Application.Current?.Dispatcher?.Invoke(() => + { + //FFF53F62 + var temp = new MessageModel() + { + LogInfo = o, + Forground = new SolidColorBrush(Color.FromArgb(255, 245, 63, 98)) + }; + if (DebugLogViewModel.MessageModels.Count > 0) + DebugLogViewModel.MessageModels.Insert(0, temp); + else + DebugLogViewModel.MessageModels.Add(temp); + }); + }); + BPA.Helper.MessageLog.GetInstance.NotifyShow = new Action((o) => { Application.Current?.Dispatcher?.Invoke(() => diff --git a/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml b/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml index 635e3b0e..43527aa4 100644 --- a/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml +++ b/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml @@ -137,4 +137,83 @@ + + + + \ No newline at end of file diff --git a/BPASmartClient.Helper/Json.cs b/BPASmartClient.Helper/Json.cs index e20bdb75..c9950a08 100644 --- a/BPASmartClient.Helper/Json.cs +++ b/BPASmartClient.Helper/Json.cs @@ -22,6 +22,8 @@ namespace BPASmartClient.Helper public static T Data { get; set; } = new T(); + + /// /// 保存数据 /// @@ -36,12 +38,14 @@ namespace BPASmartClient.Helper /// public static void Read() { - if (File.Exists(path)) - { - string JsonString = File.ReadAllText(path); - var result = JsonConvert.DeserializeObject(JsonString); - if (result != null) { Data = result; } - } + + if (File.Exists(path)) + { + string JsonString = File.ReadAllText(path); + var result = JsonConvert.DeserializeObject(JsonString); + if (result != null) { Data = result; } + } + } /// diff --git a/BPASmartClient.HubHelper/HubHelper.cs b/BPASmartClient.HubHelper/HubHelper.cs index a687570a..7ae097ae 100644 --- a/BPASmartClient.HubHelper/HubHelper.cs +++ b/BPASmartClient.HubHelper/HubHelper.cs @@ -19,7 +19,6 @@ namespace BPASmartClient.HubHelper public void Connect(string ip, int port) { hubConnection = new HubConnectionBuilder().WithAutomaticReconnect().WithUrl($"http://{ip}:{port}/personhub").Build();//连接 - hubConnection.On("Report", (s) => { Report?.Invoke(s); });//客户端注册方法 hubConnection.On("Upstreamrequest", (s) => { Upstreamrequest?.Invoke(s); });//客户端注册方法 diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index 6c30552b..9d89af9c 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -27,8 +27,8 @@ namespace BPASmartClient.JXJFoodBigStation base.OnStartup(e); MenuInit(); DataInit(); - ProcessControl.GetInstance.Init(); MainView mv = new MainView(); + ProcessControl.GetInstance.Init(); LoginView lv = new LoginView(); var res = lv.ShowDialog(); if (res != null && res == true) @@ -134,6 +134,14 @@ namespace BPASmartClient.JXJFoodBigStation AssemblyName = "BPASmartClient.JXJFoodBigStation", ToggleWindowPath = "View.HardwareStatusView" }); + DeviceMonitor.Add(new SubMenumodel() + { + SubMenuName = "通讯状态", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.JXJFoodBigStation", + ToggleWindowPath = "View.HKPlcCommMonitorView" + }); + MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj index 995eb85b..68535b92 100644 --- a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj +++ b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj @@ -17,6 +17,21 @@ + + + True + True + Settings.settings + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + $(DefaultXamlRuntime) diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs index a0138be2..11f6b211 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs @@ -8,55 +8,86 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { public class DB_Read { + [PlcComm("plc心跳上报")] /// /// plc心跳上报 /// public bool HeartBeat { get; set; } + [PlcComm("配方1允许下发配方")] /// /// 配方1允许下发配方 /// public bool IsAllowIssueRecipe1 { get; set; } + + [PlcComm("配方2允许下发配方")] public bool IsAllowIssueRecipe2 { get; set; } + + [PlcComm("配方3允许下发配方")] public bool IsAllowIssueRecipe3 { get; set; } + + [PlcComm("配方4允许下发配方")] public bool IsAllowIssueRecipe4 { get; set; } + [PlcComm("配方1接收配方完成")] /// /// 配方1 接收配方完成 /// public bool ReceiveFinishRecipe1 { get; set; } + [PlcComm("配方2接收配方完成")] public bool ReceiveFinishRecipe2 { get; set; } + [PlcComm("配方3接收配方完成")] public bool ReceiveFinishRecipe3 { get; set; } + [PlcComm("配方4接收配方完成")] public bool ReceiveFinishRecipe4 { get; set; } - + [PlcComm("配方1配料完成")] /// /// 配方1 配料完成 /// public bool Recipe1DosingFinish { get; set; } + [PlcComm("配方2配料完成")] public bool Recipe2DosingFinish { get; set; } + [PlcComm("配方3配料完成")] public bool Recipe3DosingFinish { get; set; } + [PlcComm("配方4配料完成")] public bool Recipe4DosingFinish { get; set; } - + [PlcComm("配方1托盘编号")] /// /// 配方1 托盘编号 /// public short Recipe1TrayCode { get; set; } + [PlcComm("配方2托盘编号")] public short Recipe2TrayCode { get; set; } + [PlcComm("配方3托盘编号")] public short Recipe3TrayCode { get; set; } + [PlcComm("配方4托盘编号")] public short Recipe4TrayCode { get; set; } - + [PlcComm("料仓1实际下料重量")] public float StockBin1ActualWeight { get; set; } + [PlcComm("料仓2实际下料重量")] public float StockBin2ActualWeight { get; set; } + [PlcComm("料仓3实际下料重量")] public float StockBin3ActualWeight { get; set; } + [PlcComm("料仓4实际下料重量")] public float StockBin4ActualWeight { get; set; } + [PlcComm("料仓5实际下料重量")] public float StockBin5ActualWeight { get; set; } + [PlcComm("料仓6实际下料重量")] public float StockBin6ActualWeight { get; set; } + [PlcComm("料仓7实际下料重量")] public float StockBin7ActualWeight { get; set; } + [PlcComm("料仓8实际下料重量")] public float StockBin8ActualWeight { get; set; } + [PlcComm("料仓9实际下料重量")] public float StockBin9ActualWeight { get; set; } + [PlcComm("料仓10实际下料重量")] public float StockBin10ActualWeight { get; set; } + [PlcComm("料仓11实际下料重量")] public float StockBin11ActualWeight { get; set; } + [PlcComm("料仓12实际下料重量")] public float StockBin12ActualWeight { get; set; } + [PlcComm("料仓13实际下料重量")] public float StockBin13ActualWeight { get; set; } + [PlcComm("料仓14实际下料重量")] public float StockBin14ActualWeight { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index c056e608..aa47784a 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -30,6 +30,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC if (res1 != null && res1 is DB_Read data1) { PlcRead = data1; + GVL_BigStation.HeartBeatFromPlc = data1.HeartBeat;//读取plc心跳 } if (res2 != null && res2 is StockBinName data2) { diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcCommAttribute.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcCommAttribute.cs new file mode 100644 index 00000000..38ac837a --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcCommAttribute.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC +{ + [AttributeUsage(AttributeTargets.Property)] + public sealed class PlcCommAttribute:Attribute + { + public PlcCommAttribute(string describe) + { + Describe = describe; + } + public string Describe { get; set; } + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs index 69529513..d3fc305f 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs @@ -10,32 +10,32 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public class StockBinName { [Siemens(6)] - public string RawMaterialName1 { get; set; } + public string RawMaterialName1 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName2 { get; set; } + public string RawMaterialName2 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName3 { get; set; } + public string RawMaterialName3 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName4 { get; set; } + public string RawMaterialName4 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName5 { get; set; } + public string RawMaterialName5 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName6 { get; set; } + public string RawMaterialName6 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName7 { get; set; } + public string RawMaterialName7 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName8 { get; set; } + public string RawMaterialName8 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName9 { get; set; } + public string RawMaterialName9 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName10 { get; set; } + public string RawMaterialName10 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName11 { get; set; } + public string RawMaterialName11 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName12 { get; set; } + public string RawMaterialName12 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName13 { get; set; } + public string RawMaterialName13 { get; set; } = ""; [Siemens(6)] - public string RawMaterialName14 { get; set; } + public string RawMaterialName14 { get; set; } = ""; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/PlcVarMonitor.cs b/BPASmartClient.JXJFoodBigStation/Model/PlcVarMonitor.cs new file mode 100644 index 00000000..b7e7110b --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/PlcVarMonitor.cs @@ -0,0 +1,32 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model +{ + public class PlcVarMonitor: ObservableObject + { + private int _serialNum; + public int SerialNum { get { return _serialNum; } set { _serialNum = value;OnPropertyChanged(); } } + + private string _variable; + public string Variable { get { return _variable; } set { _variable = value; OnPropertyChanged(); } } + + private string _address; + public string Address { get { return _address; } set { _address = value; OnPropertyChanged(); } } + + private string _type; + public string Type { get { return _type; } set { _type = value; OnPropertyChanged(); } } + + private string _describe; + public string Describe { get { return _describe; } set { _describe = value; OnPropertyChanged(); } } + + private string _nowValue; + public string NowValue { get { return _nowValue; } set { _nowValue = value; OnPropertyChanged(); } } + private string _setValue; + public string SetValue { get { return _setValue; } set { _setValue = value; OnPropertyChanged(); } } + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index b80059a4..9bda9e19 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -24,27 +24,47 @@ namespace BPASmartClient.JXJFoodBigStation.Model public HKDeviceStatus HKDevice = new HKDeviceStatus(); DL_Finish_DB FinishData = new DL_Finish_DB(); /// - /// 配方数据 + /// 西门子配方数据 /// - public ObservableCollection Recipes = new ObservableCollection(); + public ObservableCollection SiemensRecipes = new ObservableCollection(); /// - /// 配方数据 + /// 本地配方数据 /// - public ObservableCollection IssuedComplete = new ObservableCollection(); + public ObservableCollection LocalRecipes = new ObservableCollection(); + + /// + /// 配方等待执行 + /// + public ObservableCollection RecipeWaitExecute = new ObservableCollection(); + /// + /// 配方正在执行 + /// + public ObservableCollection RecipeExecuting = new ObservableCollection(); + /// + /// 配方执行完成 + /// + public ObservableCollection RecipeExecuteComple = new ObservableCollection(); /// /// 原料的名称和料仓的位置对应 /// public Dictionary RawMaterialsNamePos = new Dictionary(); /// - /// 配方队列 + /// 西门子配方队列 /// - public ConcurrentQueue RecipeQueue1 = new ConcurrentQueue(); - public ConcurrentQueue RecipeQueue2 = new ConcurrentQueue(); - public ConcurrentQueue RecipeQueue3 = new ConcurrentQueue(); - public ConcurrentQueue RecipeQueue4 = new ConcurrentQueue(); + public ConcurrentQueue SiemensRecipeQueue1 = new ConcurrentQueue(); + public ConcurrentQueue SiemensRecipeQueue2 = new ConcurrentQueue(); + public ConcurrentQueue SiemensRecipeQueue3 = new ConcurrentQueue(); + public ConcurrentQueue SiemensRecipeQueue4 = new ConcurrentQueue(); + /// + /// 本地配方队列 + /// + public ConcurrentQueue LocalRecipeQueue1 = new ConcurrentQueue(); + public ConcurrentQueue LocalRecipeQueue2 = new ConcurrentQueue(); + public ConcurrentQueue LocalRecipeQueue3 = new ConcurrentQueue(); + public ConcurrentQueue LocalRecipeQueue4 = new ConcurrentQueue(); public void Init() { - testData(); + testRawMaterialNameData();//自定义料仓名称 ActionManage.GetInstance.CancelRegister("SiemensSendRecipe"); ActionManage.GetInstance.Register(new Action((res) => { @@ -68,7 +88,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } else { - //报警,配方的原料名称下发和设备不一致 + MessageNotify.GetInstance.ShowAlarmLog($"本地原料名称和西门子下发的原料名称无法对应,原料位置:{i}"); } } App.Current.Dispatcher.Invoke(() => @@ -89,13 +109,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model try { //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); if (HKDevice.IsConnected) { HKDevice.Init(); MessageNotify.GetInstance.ShowRunLog("海科plc连接成功"); } - if (SiemensDevice.IsConnected || true) + if (SiemensDevice.IsConnected) { SiemensDevice.Init(); MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); @@ -105,39 +125,480 @@ namespace BPASmartClient.JXJFoodBigStation.Model { } - RecipeQueue1.Clear(); - RecipeQueue2.Clear(); - RecipeQueue3.Clear(); - RecipeQueue4.Clear(); + LocalRecipeQueue1.Clear(); + LocalRecipeQueue2.Clear(); + LocalRecipeQueue3.Clear(); + LocalRecipeQueue4.Clear(); + SiemensRecipeQueue1.Clear(); + SiemensRecipeQueue2.Clear(); + SiemensRecipeQueue3.Clear(); + SiemensRecipeQueue4.Clear(); ThreadManage.GetInstance().StartLong(new Action(() => { - SystemStatus(); ReceviceData(); RecipeInfoToHKPLC(); Thread.Sleep(10); - }), "流程处理", true); + }), "西门子配方执行流程", true); + ThreadManage.GetInstance().StartLong(new Action(() => + { + if (GVL_BigStation.IsUseLocalRecipe) + { + LocalRecipeRecevice(); + LocalRecipeDosing(); + } + Thread.Sleep(10); + }), "本地配方执行流程", true); } - private void SystemStatus() - { - GVL_BigStation.HeartBeatFromPlc = HKDevice.PlcRead.HeartBeat;//读取plc心跳 + private void LocalRecipeRecevice() + { + if (LocalRecipes.Count > 0) + { + foreach (var data in LocalRecipes) + { + if (LocalRecipeQueue1.Count == 0 && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode)) + { + if (!(LocalRecipeQueue1.Contains(data.RecipeCode))) + { + LocalRecipeQueue1.Enqueue(data.RecipeCode); + } + } + else if (LocalRecipeQueue2.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode)) + { + if (!(LocalRecipeQueue2.Contains(data.RecipeCode))) + { + LocalRecipeQueue2.Enqueue(data.RecipeCode); + } + } + else if (LocalRecipeQueue3.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode)) + { + if (!(LocalRecipeQueue3.Contains(data.RecipeCode))) + { + LocalRecipeQueue3.Enqueue(data.RecipeCode); + } + } + else if (LocalRecipeQueue4.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode)) + { + if (!(LocalRecipeQueue4.Contains(data.RecipeCode))) + { + LocalRecipeQueue4.Enqueue(data.RecipeCode); + } + } + } + } + else + { + LocalRecipeQueue1.Clear(); + LocalRecipeQueue2.Clear(); + LocalRecipeQueue3.Clear(); + LocalRecipeQueue4.Clear(); + GVL_BigStation.Recipe1DosingStatus = 0; + GVL_BigStation.Recipe2DosingStatus = 0; + GVL_BigStation.Recipe3DosingStatus = 0; + GVL_BigStation.Recipe4DosingStatus = 0; + } } - private void ReceviceData() + private void LocalRecipeDosing() { - if (!GVL_BigStation.IsUseLocalRecipe && Recipes.Count == 0)//一个配方执行完成后,再获取配方数据 + if (LocalRecipeQueue1.Count > 0) { - Recipes = Json.Data.Recipes; + int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue1.ElementAt(0)); + if (index >= 0 && index < LocalRecipes.Count) + { + string code = LocalRecipes.ElementAt(index).RecipeCode; + int trayCode = LocalRecipes.ElementAt(index).TrayCode; + if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发 + { + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.PlcWrite.Recipe1IssuedFinish = true; + GVL_BigStation.Recipe1DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } + if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1) + { + GVL_BigStation.Recipe1DosingStatus = 2; + HKDevice.PlcWrite.Recipe1IssuedFinish = false; + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + } + if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) + { + GVL_BigStation.Recipe1DosingStatus = 3; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + if (HKDevice.PlcRead.Recipe1TrayCode == 1) + { + foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) + { + if (item.RawMaterialLocation == 1) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + } + else if (item.RawMaterialLocation == 2) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + } + else if (item.RawMaterialLocation == 3) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + } + else if (item.RawMaterialLocation == 4) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + } + else if (item.RawMaterialLocation == 5) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + } + else if (item.RawMaterialLocation == 6) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + } + else if (item.RawMaterialLocation == 7) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + } + else if (item.RawMaterialLocation == 8) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + } + else if (item.RawMaterialLocation == 9) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + } + else if (item.RawMaterialLocation == 10) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + } + else if (item.RawMaterialLocation == 11) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + } + else if (item.RawMaterialLocation == 12) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + } + else if (item.RawMaterialLocation == 13) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + } + else if (item.RawMaterialLocation == 14) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + } + } + } + LocalRecipeQueue1.TryDequeue(out code); + RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将配方添加到完成列表 + //App.Current.Dispatcher.Invoke(() => { + // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + //}); + LocalRecipes.RemoveAt(index); + GVL_BigStation.Recipe1DosingStatus = 0; + } + } } - else if (GVL_BigStation.IsUseLocalRecipe && Recipes.Count == 0) + if (LocalRecipeQueue2.Count > 0) { - Recipes = Json.Data.Recipes; + int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue2.ElementAt(0)); + if (index >= 0 && index < LocalRecipes.Count) + { + string code = LocalRecipes.ElementAt(index).RecipeCode; + int trayCode = LocalRecipes.ElementAt(index).TrayCode; + if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发 + { + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.PlcWrite.Recipe2IssuedFinish = true; + GVL_BigStation.Recipe2DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } + if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1) + { + GVL_BigStation.Recipe2DosingStatus = 2; + HKDevice.PlcWrite.Recipe2IssuedFinish = false; + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + } + if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) + { + GVL_BigStation.Recipe2DosingStatus = 3; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + if (HKDevice.PlcRead.Recipe2TrayCode > 0) + { + foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) + { + if (item.RawMaterialLocation == 1) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + } + else if (item.RawMaterialLocation == 2) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + } + else if (item.RawMaterialLocation == 3) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + } + else if (item.RawMaterialLocation == 4) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + } + else if (item.RawMaterialLocation == 5) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + } + else if (item.RawMaterialLocation == 6) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + } + else if (item.RawMaterialLocation == 7) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + } + else if (item.RawMaterialLocation == 8) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + } + else if (item.RawMaterialLocation == 9) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + } + else if (item.RawMaterialLocation == 10) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + } + else if (item.RawMaterialLocation == 11) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + } + else if (item.RawMaterialLocation == 12) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + } + else if (item.RawMaterialLocation == 13) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + } + else if (item.RawMaterialLocation == 14) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + } + } + } + LocalRecipeQueue2.TryDequeue(out code); + RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下 + //App.Current.Dispatcher.Invoke(() => { + // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + //}); + LocalRecipes.RemoveAt(index); + GVL_BigStation.Recipe2DosingStatus = 0; + } + } + } + if (LocalRecipeQueue3.Count > 0) + { + int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue3.ElementAt(0)); + if (index >= 0 && index < LocalRecipes.Count) + { + string code = LocalRecipes.ElementAt(index).RecipeCode; + int trayCode = LocalRecipes.ElementAt(index).TrayCode; + if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发 + { + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.PlcWrite.Recipe3IssuedFinish = true; + GVL_BigStation.Recipe3DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } + if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1) + { + GVL_BigStation.Recipe3DosingStatus = 2; + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + } + if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) + { + GVL_BigStation.Recipe3DosingStatus = 3; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + if (HKDevice.PlcRead.Recipe3TrayCode > 0) + { + foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) + { + if (item.RawMaterialLocation == 1) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + } + else if (item.RawMaterialLocation == 2) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + } + else if (item.RawMaterialLocation == 3) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + } + else if (item.RawMaterialLocation == 4) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + } + else if (item.RawMaterialLocation == 5) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + } + else if (item.RawMaterialLocation == 6) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + } + else if (item.RawMaterialLocation == 7) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + } + else if (item.RawMaterialLocation == 8) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + } + else if (item.RawMaterialLocation == 9) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + } + else if (item.RawMaterialLocation == 10) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + } + else if (item.RawMaterialLocation == 11) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + } + else if (item.RawMaterialLocation == 12) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + } + else if (item.RawMaterialLocation == 13) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + } + else if (item.RawMaterialLocation == 14) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + } + } + } + HKDevice.HK_PLC_S7.Write("DB98.DBX1.1", false); + LocalRecipeQueue3.TryDequeue(out code); + RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下 + //App.Current.Dispatcher.Invoke(() => { + // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + //}); + LocalRecipes.RemoveAt(index); + GVL_BigStation.Recipe3DosingStatus = 0; + } + } + } + if (LocalRecipeQueue4.Count > 0) + { + int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue4.ElementAt(0)); + if (index >= 0 && index < LocalRecipes.Count) + { + string code = LocalRecipes.ElementAt(index).RecipeCode; + int trayCode = LocalRecipes.ElementAt(index).TrayCode; + if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发 + { + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.PlcWrite.Recipe4IssuedFinish = true; + GVL_BigStation.Recipe4DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } + if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1) + { + GVL_BigStation.Recipe4DosingStatus = 2; + HKDevice.PlcWrite.Recipe4IssuedFinish = false; + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + } + if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) + { + GVL_BigStation.Recipe4DosingStatus = 3; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + if (HKDevice.PlcRead.Recipe4TrayCode > 0) + { + foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) + { + if (item.RawMaterialLocation == 1) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + } + else if (item.RawMaterialLocation == 2) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + } + else if (item.RawMaterialLocation == 3) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + } + else if (item.RawMaterialLocation == 4) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + } + else if (item.RawMaterialLocation == 5) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + } + else if (item.RawMaterialLocation == 6) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + } + else if (item.RawMaterialLocation == 7) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + } + else if (item.RawMaterialLocation == 8) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + } + else if (item.RawMaterialLocation == 9) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + } + else if (item.RawMaterialLocation == 10) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + } + else if (item.RawMaterialLocation == 11) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + } + else if (item.RawMaterialLocation == 12) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + } + else if (item.RawMaterialLocation == 13) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + } + else if (item.RawMaterialLocation == 14) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + } + } + } + HKDevice.HK_PLC_S7.Write("DB98.DBX1.3", false); + LocalRecipeQueue4.TryDequeue(out code); + RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下 + //App.Current.Dispatcher.Invoke(() => { + // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + //}); + LocalRecipes.RemoveAt(index); + GVL_BigStation.Recipe4DosingStatus = 0; + } + } } - if (Recipes.Count > 0) + } + private void ReceviceData() + { + SiemensRecipes = Json.Data.Recipes; + if (SiemensRecipes.Count > 0) { - foreach (var data in Recipes) + foreach (var data in SiemensRecipes) { - if (RecipeQueue1.Count == 0 && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) + if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode)) { - if (!(RecipeQueue1.Contains(data.RecipeCode))) + if (!(SiemensRecipeQueue1.Contains(data.RecipeCode))) { if (SiemensDevice.DL_Status is DL_Status_DB status) { @@ -161,16 +622,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { GVL_BigStation.SiemensSendRecipeStatus = 6; - RecipeQueue1.Enqueue(data.RecipeCode); + SiemensRecipeQueue1.Enqueue(data.RecipeCode); } } } - } } - else if (RecipeQueue2.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) + else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode)) { - if (!(RecipeQueue2.Contains(data.RecipeCode))) + if (!(SiemensRecipeQueue2.Contains(data.RecipeCode))) { if (SiemensDevice.DL_Status is DL_Status_DB status) { @@ -194,15 +654,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { GVL_BigStation.SiemensSendRecipeStatus = 6; - RecipeQueue2.Enqueue(data.RecipeCode); + SiemensRecipeQueue2.Enqueue(data.RecipeCode); } } } } } - else if (RecipeQueue3.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode)) + else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode)) { - if (!(RecipeQueue3.Contains(data.RecipeCode))) + if (!(SiemensRecipeQueue3.Contains(data.RecipeCode))) { if (SiemensDevice.DL_Status is DL_Status_DB status) { @@ -226,15 +686,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { GVL_BigStation.SiemensSendRecipeStatus = 6; - RecipeQueue3.Enqueue(data.RecipeCode); + SiemensRecipeQueue3.Enqueue(data.RecipeCode); } } } } } - else if (RecipeQueue4.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode)) + else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode)) { - if (!(RecipeQueue4.Contains(data.RecipeCode))) + if (!(SiemensRecipeQueue4.Contains(data.RecipeCode))) { if (SiemensDevice.DL_Status is DL_Status_DB status) { @@ -258,7 +718,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { GVL_BigStation.SiemensSendRecipeStatus = 6; - RecipeQueue4.Enqueue(data.RecipeCode); + SiemensRecipeQueue4.Enqueue(data.RecipeCode); } } } @@ -268,10 +728,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model } else { - RecipeQueue1.Clear(); - RecipeQueue2.Clear(); - RecipeQueue3.Clear(); - RecipeQueue4.Clear(); + SiemensRecipeQueue1.Clear(); + SiemensRecipeQueue2.Clear(); + SiemensRecipeQueue3.Clear(); + SiemensRecipeQueue4.Clear(); GVL_BigStation.Recipe1DosingStatus = 0; GVL_BigStation.Recipe2DosingStatus = 0; GVL_BigStation.Recipe3DosingStatus = 0; @@ -280,16 +740,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model } private void RecipeInfoToHKPLC() { - if (RecipeQueue1.Count > 0) + if (SiemensRecipeQueue1.Count > 0) { - int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue1.ElementAt(0)); - if (index >= 0 && index < Recipes.Count) + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue1.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) { - string code = Recipes.ElementAt(index).RecipeCode; - int trayCode = Recipes.ElementAt(index).TrayCode; + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发 { - HKDevice.StockBinPar(Recipes.ElementAt(index)); + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe1IssuedFinish = true; GVL_BigStation.Recipe1DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); @@ -307,7 +767,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe1TrayCode == 1) { - foreach (var item in Recipes.ElementAt(index).RawMaterial) + foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -366,24 +826,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - FinishData.Order_No = Recipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = Recipes.ElementAt(index).RecipeName; - for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++) - { - FinishData.Material[i] = new UDT1(); - FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; - } } if (SiemensDevice.IsConnected) { + FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + for (int i = 0; i < FinishData.Material.Length; i++) + { + FinishData.Material[i] = new UDT1(); + } + for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + { + FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + } FinishData.Ask_For_Finish = true; GVL_BigStation.SiemensSendRecipeStatus = 7; SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); } - RecipeQueue1.TryDequeue(out code); - IssuedComplete.Add(Recipes.ElementAt(index));//将配方添加到完成列表 + SiemensRecipeQueue1.TryDequeue(out code); + RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将配方添加到完成列表 if (!GVL_BigStation.IsUseLocalRecipe) { App.Current.Dispatcher.Invoke(() => { @@ -400,16 +864,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - if (RecipeQueue2.Count > 0) + if (SiemensRecipeQueue2.Count > 0) { - int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue2.ElementAt(0)); - if (index >= 0 && index < Recipes.Count) + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue2.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) { - string code = Recipes.ElementAt(index).RecipeCode; - int trayCode = Recipes.ElementAt(index).TrayCode; + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发 { - HKDevice.StockBinPar(Recipes.ElementAt(index)); + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe2IssuedFinish = true; GVL_BigStation.Recipe2DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); @@ -427,7 +891,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe2TrayCode > 0) { - foreach (var item in Recipes.ElementAt(index).RawMaterial) + foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -486,14 +950,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - FinishData.Order_No = Recipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = Recipes.ElementAt(index).RecipeName; - for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++) + FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + for (int i = 0; i < FinishData.Material.Length; i++) { FinishData.Material[i] = new UDT1(); - FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + } + for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + { + FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } } if (SiemensDevice.IsConnected) @@ -501,8 +968,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); } - RecipeQueue2.TryDequeue(out code); - IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下 + SiemensRecipeQueue2.TryDequeue(out code); + RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index)); if (!GVL_BigStation.IsUseLocalRecipe) { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 @@ -515,16 +982,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - if (RecipeQueue3.Count > 0) + if (SiemensRecipeQueue3.Count > 0) { - int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue3.ElementAt(0)); - if (index >= 0 && index < Recipes.Count) + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue3.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) { - string code = Recipes.ElementAt(index).RecipeCode; - int trayCode = Recipes.ElementAt(index).TrayCode; + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发 { - HKDevice.StockBinPar(Recipes.ElementAt(index)); + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe3IssuedFinish = true; GVL_BigStation.Recipe3DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); @@ -541,7 +1008,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe3TrayCode > 0) { - foreach (var item in Recipes.ElementAt(index).RawMaterial) + foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -600,14 +1067,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - FinishData.Order_No = Recipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = Recipes.ElementAt(index).RecipeName; - for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++) + FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + for (int i = 0; i < FinishData.Material.Length; i++) { FinishData.Material[i] = new UDT1(); - FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + } + for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + { + FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } } if (SiemensDevice.IsConnected) @@ -615,8 +1085,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); } HKDevice.HK_PLC_S7.Write("DB98.DBX1.1", false); - RecipeQueue3.TryDequeue(out code); - IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下 + SiemensRecipeQueue3.TryDequeue(out code); + RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下 if (!GVL_BigStation.IsUseLocalRecipe) { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 @@ -629,16 +1099,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - if (RecipeQueue4.Count > 0) + if (SiemensRecipeQueue4.Count > 0) { - int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue4.ElementAt(0)); - if (index >= 0 && index < Recipes.Count) + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue4.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) { - string code = Recipes.ElementAt(index).RecipeCode; - int trayCode = Recipes.ElementAt(index).TrayCode; + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发 { - HKDevice.StockBinPar(Recipes.ElementAt(index)); + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe4IssuedFinish = true; GVL_BigStation.Recipe4DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); @@ -656,7 +1126,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe4TrayCode > 0) { - foreach (var item in Recipes.ElementAt(index).RawMaterial) + foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -715,14 +1185,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - FinishData.Order_No = Recipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = Recipes.ElementAt(index).RecipeName; - for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++) + FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + for (int i = 0; i < FinishData.Material.Length; i++) { FinishData.Material[i] = new UDT1(); - FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + } + for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + { + FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } } if (SiemensDevice.IsConnected) @@ -730,8 +1203,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); } HKDevice.HK_PLC_S7.Write("DB98.DBX1.3", false); - RecipeQueue4.TryDequeue(out code); - IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下 + SiemensRecipeQueue4.TryDequeue(out code); + RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下 if (!GVL_BigStation.IsUseLocalRecipe) { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 @@ -768,7 +1241,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.PlcWrite.Bareel1Bin13SetWeight = 0; HKDevice.PlcWrite.Bareel1Bin14SetWeight = 0; - HKDevice.PlcWrite.Bareel2Bin1SetWeight = 0; HKDevice.PlcWrite.Bareel2Bin2SetWeight = 0; HKDevice.PlcWrite.Bareel2Bin3SetWeight = 0; @@ -814,25 +1286,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.PlcWrite.Bareel5Bin13SetWeight = 0; HKDevice.PlcWrite.Bareel5Bin14SetWeight = 0; } - private void testData() + private void testRawMaterialNameData() { RawMaterialsNamePos.Clear(); if (!HKDevice.IsConnected) { - RawMaterialsNamePos.Add("A10", 1); - RawMaterialsNamePos.Add("A20", 2); - RawMaterialsNamePos.Add("A30", 3); - RawMaterialsNamePos.Add("A40", 4); - RawMaterialsNamePos.Add("A50", 5); - RawMaterialsNamePos.Add("A60", 6); - RawMaterialsNamePos.Add("A70", 7); - RawMaterialsNamePos.Add("A80", 8); - RawMaterialsNamePos.Add("A90", 9); - RawMaterialsNamePos.Add("A100", 10); - RawMaterialsNamePos.Add("A110", 11); - RawMaterialsNamePos.Add("A120", 12); - RawMaterialsNamePos.Add("A130", 13); - RawMaterialsNamePos.Add("A140", 14); + RawMaterialsNamePos.Add("0005", 1); + RawMaterialsNamePos.Add("0006", 2); + RawMaterialsNamePos.Add("0007", 3); + RawMaterialsNamePos.Add("0008", 4); + RawMaterialsNamePos.Add("0009", 5); + RawMaterialsNamePos.Add("0010", 6); + RawMaterialsNamePos.Add("0011", 7); + RawMaterialsNamePos.Add("0012", 8); + RawMaterialsNamePos.Add("0013", 9); + RawMaterialsNamePos.Add("0014", 10); + RawMaterialsNamePos.Add("0015", 11); + RawMaterialsNamePos.Add("0016", 12); + RawMaterialsNamePos.Add("0017", 13); + RawMaterialsNamePos.Add("0018", 14); + RawMaterialsNamePos.Add("0019", 14); + RawMaterialsNamePos.Add("0020", 14); + RawMaterialsNamePos.Add("0021", 14); + RawMaterialsNamePos.Add("0022", 14); + RawMaterialsNamePos.Add("0023", 14); + RawMaterialsNamePos.Add("0024", 14); + RawMaterialsNamePos.Add("0025", 14); + RawMaterialsNamePos.Add("0026", 14); + RawMaterialsNamePos.Add("0027", 14); + RawMaterialsNamePos.Add("0028", 14); + RawMaterialsNamePos.Add("0029", 14); + RawMaterialsNamePos.Add("0030", 14); + RawMaterialsNamePos.Add("0031", 14); + RawMaterialsNamePos.Add("0032", 14); + RawMaterialsNamePos.Add("0033", 14); + RawMaterialsNamePos.Add("0034", 14); + RawMaterialsNamePos.Add("0035", 14); + RawMaterialsNamePos.Add("0040", 14); } /* HKDevice.StockBinName.RawMaterialName1 = "1"; diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs index 80e91369..b432859e 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs @@ -20,12 +20,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens /// /// 生产工单编码 /// - public string Order_No{get; set; } + public string Order_No { get; set; } = ""; [Siemens(16)] /// /// 产品名称 /// - public string Product_Code { get; set; } + public string Product_Code { get; set; } = ""; public short job_No { get; set; } /// /// 原料信息 @@ -43,7 +43,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens public class UDT1 { [Siemens(6)] - public string Material_Name { get; set; } + public string Material_Name { get; set; } = ""; public float Material_Laying_Off_Weight { get; set; } public short Material_BarrelNum { get; set; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index 4631b4dd..df0b907b 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -29,20 +29,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens var res3 = this.Siemens_PLC_S7.ReadClass(2391); if (res != null && res is DL_Start_DB start) { - if (a) - { - start.RecipeName = "配方1"; - start.RecipeCode = "1201"; - start.Order_Request_Ack = true; - - for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum ; i++) - { - start.Material[i] = new UDT(); - start.Material[i].Material_Name = "" + (i +1); - start.Material[i].Material_Weight = 100 + (i + 1); - start.Material[i].Material_BarrelNum = (short)(i + 1); - } - } if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request) && GVL_BigStation.SiemensSendRecipeStatus == 0) { GVL_BigStation.SiemensSendRecipeStatus = 1; @@ -78,7 +64,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens GVL_BigStation.SiemensSendRecipeStatus = 0; finish.Ask_For_Finish = false; finish.ProcessTime = 0; - this.Siemens_PLC_S7.WriteClass(finish, 2261); + this.Siemens_PLC_S7.WriteClass(finish, 2361); } } Thread.Sleep(10); diff --git a/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs b/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs new file mode 100644 index 00000000..804602c2 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace BPASmartClient.JXJFoodBigStation.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Properties/Settings.settings b/BPASmartClient.JXJFoodBigStation/Properties/Settings.settings new file mode 100644 index 00000000..049245f4 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Properties/Settings.settings @@ -0,0 +1,6 @@ + + + + + + diff --git a/BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml b/BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml new file mode 100644 index 00000000..f6643621 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml.cs b/BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml.cs new file mode 100644 index 00000000..1a28b47b --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.JXJFoodBigStation.View +{ + /// + /// HKPlcCommMonitor.xaml 的交互逻辑 + /// + public partial class HKPlcCommMonitorView : UserControl + { + public HKPlcCommMonitorView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml index a41f7228..ef78e4b8 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml @@ -159,7 +159,7 @@ - + diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml index f9553271..446f7695 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml @@ -506,7 +506,7 @@ - + @@ -514,14 +514,11 @@ - - - diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs new file mode 100644 index 00000000..5ac45999 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs @@ -0,0 +1,131 @@ +using BPA.Helper; +using BPASmartClient.JXJFoodBigStation.Model; +using BPASmartClient.JXJFoodBigStation.Model.HK_PLC; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.ViewModel +{ + public class HKPlcCommMonitorViewModel:ObservableObject + { + HKDeviceStatus DeviceStatus = new HKDeviceStatus(); + public HKPlcCommMonitorViewModel() + { + Type type = typeof(DB_Read); + PropertyInfo[] properties = type.GetProperties(); + double Offset = 0.0; + string addressPos = ""; + ThreadManage.GetInstance().StartLong(new Action(() => + { + foreach (PropertyInfo mi in properties) + { + PropertyInfo a = DeviceStatus.PlcRead.GetType().GetProperty(mi.Name); + object ab = a.GetValue(DeviceStatus.PlcRead, null); + + int index = Array.FindIndex(PlcInfo.ToArray(), p => p.Describe == mi.Name); + if (index != -1) + { + PlcInfo.ElementAt(index).NowValue = ab.ToString(); + } + } + Thread.Sleep(10); + }), "plc变量读取"); + foreach (PropertyInfo mi in properties) + { + PropertyInfo a = DeviceStatus.PlcRead.GetType().GetProperty(mi.Name); + object ab = a.GetValue(DeviceStatus.PlcRead, null); + if (mi.PropertyType.Name == "Int16") + { + addressPos = "DBD"; + Offset = Math.Ceiling(Offset); + if (Offset / 2.0 - Math.Floor(Offset / 2.0) > 0.0) + { + Offset += 1.0; + } + } + else if (mi.PropertyType.Name == "Boolean") + { + addressPos = "DBX"; + Offset = Math.Round(Offset, 1); + if ((Offset - Math.Floor(Offset)) >= 0.8) + { + Offset = Math.Ceiling(Offset); + } + } + else if (mi.PropertyType.Name == "Single") + { + addressPos = "DBD"; + Offset = Math.Ceiling(Offset); + if (Offset / 2.0 - Math.Floor(Offset / 2.0) > 0.0) + { + Offset += 1.0; + } + } + var num = DeviceStatus.PlcRead; + var res = a.GetCustomAttribute(); + string describe = ""; + if (res != null) + { + describe = res.Describe; + } + else + { + describe = ""; + } + PlcInfo.Add(new PlcVarMonitor() + { + SerialNum = PlcInfo.Count + 1, + Variable = mi.Name, + Address = "DB98." + addressPos + string.Format("{0:N1}", Offset), + Type = mi.PropertyType.Name, + Describe = describe, + NowValue = ab.ToString(), + }); + + if (mi.PropertyType.Name == "Int16") + { + Offset += 2; + } + else if (mi.PropertyType.Name == "Boolean") + { + Offset += 0.1; + } + else if (mi.PropertyType.Name == "Single") + { + Offset += 4; + } + } + + SetValueCommand = new RelayCommand((o) => + { + if (o != null && o is String setValue) + { + int index = Array.FindIndex(PlcInfo.ToArray(), p => p.SetValue == setValue); + if (index != -1) + { + DeviceStatus.HK_PLC_S7.Write(PlcInfo.ElementAt(index).Address, setValue); + } + } + }); + } + /*public static string GetPropertyValue( T t,string PropertyName) + { + Type type = typeof(T); + + }*/ + public ObservableCollection PlcInfo { get; set; } = new ObservableCollection(); + + public RelayCommand SetValueCommand { get; set; } + + public RelayCommand Connect { get; set; } + } +} diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs index 0007af06..b1eaec92 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs @@ -90,27 +90,23 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel Json.Save(); }); - RemoveCommand = new RelayCommand((recipeCode) => { - + RemoveCommand = new RelayCommand((recipeCode) => + { var res = Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode); if (res != null) { Recipes.Remove(res); Json.Save(); } - }); } - public RelayCommand DetailsCommand { get; set; } // public RelayCommand NewSimulateRecipe { get; set; } public RelayCommand ClearAllRecipe { get; set; } - public RelayCommand NewRecipe { get; set; } - public bool IsUseLocalRecipe { get; set; } = true; - + public bool IsUseLocalRecipe { get { return _isUseLocalRecipe; } set { _isUseLocalRecipe = value; OnPropertyChanged(); } } + public bool _isUseLocalRecipe { get; set; } public RelayCommand RemoveCommand { get; set; } - public ObservableCollection Recipes { get; set; } = new ObservableCollection(); } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs index b42ffe9f..95418305 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs @@ -1,4 +1,6 @@ using BPASmartClient.CustomResource.Pages.Model; +using BPASmartClient.CustomResource.UserControls; +using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.Helper; using BPASmartClient.JXJFoodBigStation.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; @@ -32,22 +34,34 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public RecipeSendDownViewModel() { - StartCommand = new RelayCommand((recipeName) => { + StartCommand = new RelayCommand((recipeName) => + { if (recipeName != null) { - //配方下发逻辑 - var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName); - if (res != null) + if (GVL_BigStation.IsUseLocalRecipe) { - Json.Data.Recipes.Add(res); - for (int i = 0; i < Json.Data.Recipes.Count; i++) + //配方下发逻辑 + var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName); + if (res != null) { - foreach (var item in Json.Data.Recipes.ElementAt(i).RawMaterial) + //Json.Data.Recipes.Add(res); + //for (int i = 0; i < Json.Data.Recipes.Count; i++) + //{ + // foreach (var item in Json.Data.Recipes.ElementAt(i).RawMaterial) + // { + // item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName); + // } + //} + if (!ProcessControl.GetInstance.LocalRecipes.Contains(res)) { - item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName); + ProcessControl.GetInstance.LocalRecipes.Add(res); + MessageNotify.GetInstance.ShowAlarmLog($"手动下发配方:{recipeName}完成"); } } - MessageNotify.GetInstance.ShowAlarmLog("手动下发配方完成"); + } + else + { + NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"未处于本地配方模式,无法下发配方"); } } }); diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index e5787289..c658c57b 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -29,8 +29,8 @@ namespace BPASmartClient.JXJFoodSmallStation MenuInit(); DataInit(); //DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 - ProcessControl.GetInstance.Init(); MainView mv = new MainView(); + ProcessControl.GetInstance.Init(); LoginView lv = new LoginView(); var res = lv.ShowDialog(); if (res != null && res == true) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 25aee4c5..21cfd722 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -51,6 +51,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public void Init() { testData(); + Json.Data.Recipes = Json.Data.Recipes; for (int i = 0; i < 16; i++) { if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) @@ -1183,21 +1184,26 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } private void testData() { - RawMaterialsNamePos.Add("A10", 1); - RawMaterialsNamePos.Add("A20", 2); - RawMaterialsNamePos.Add("A30", 3); - RawMaterialsNamePos.Add("A40", 4); - RawMaterialsNamePos.Add("A50", 5); - RawMaterialsNamePos.Add("A60", 6); - RawMaterialsNamePos.Add("A70", 7); - RawMaterialsNamePos.Add("A80", 8); - RawMaterialsNamePos.Add("A90", 9); - RawMaterialsNamePos.Add("A100", 10); - RawMaterialsNamePos.Add("A110", 11); - RawMaterialsNamePos.Add("A120", 12); - RawMaterialsNamePos.Add("A130", 13); - RawMaterialsNamePos.Add("A140", 14); - RawMaterialsNamePos.Add("A150", 15); + RawMaterialsNamePos.Add("0041", 1); + RawMaterialsNamePos.Add("0042", 2); + RawMaterialsNamePos.Add("0043", 3); + RawMaterialsNamePos.Add("0044", 4); + RawMaterialsNamePos.Add("0045", 5); + RawMaterialsNamePos.Add("0046", 6); + RawMaterialsNamePos.Add("0047", 7); + RawMaterialsNamePos.Add("0048", 8); + RawMaterialsNamePos.Add("0049", 9); + RawMaterialsNamePos.Add("0050", 10); + RawMaterialsNamePos.Add("0051", 11); + RawMaterialsNamePos.Add("0052", 12); + RawMaterialsNamePos.Add("0053", 13); + RawMaterialsNamePos.Add("0054", 14); + RawMaterialsNamePos.Add("0055", 15); + RawMaterialsNamePos.Add("0056", 15); + RawMaterialsNamePos.Add("0057", 15); + RawMaterialsNamePos.Add("0058", 15); + RawMaterialsNamePos.Add("0059", 15); + RawMaterialsNamePos.Add("0060", 15); } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index 8b20cc97..6395d4f0 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -103,7 +103,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model //AlarmHelper.Init(); //AlarmHelper.Alarm.EStop1 = true; - //TestData(); + TestData(); IpAddressLines(); DeviceDataInit(); ThreadManage.GetInstance().StartLong(new Action(() => diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index b62daf28..76becb33 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -26,14 +26,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens var Status = this.Siemens_PLC_S7.ReadClass(2231); var Finish = this.Siemens_PLC_S7.ReadClass(2261); var DataColl = this.Siemens_PLC_S7.ReadClass(2291); - if (test) - { - for (int i = 0; i < XL_Status.Powder.Length; i++) { - - XL_Status.Powder.ElementAt(i).Powder_Name = ""+i; - } - Siemens_PLC_S7.WriteClass(XL_Status, 2231); - } if (Start != null && Start is XL_Start_DB st) { if (RTrig.GetInstance("DB2201.DBX450.0").Start(GVL_SmallStation.IsAllowSiemensSendRecipe) && GVL_SmallStation.SiemensSendRecipeStatus == 0) @@ -80,6 +72,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens } if (Status != null && Status is XL_Status_DB state) { + for (int i = 0; i < XL_Status.Powder.Length; i++) + { + XL_Status.Powder[i] = new PowderStatus(); + } XL_Status = state; if (RTrig.GetInstance("Allow_AGV_Put[0]").Start(Status.AgvRequestPut)) { diff --git a/BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml b/BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml index 00eb484a..0691373e 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/RecipeInfosView.xaml @@ -77,17 +77,17 @@ - - + + - - + + - - + + diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs index c69f18e0..a9793e67 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs @@ -28,11 +28,11 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel } }); devices = DeviceInquire.GetInstance.devices; - foreach (var device in devices) + /*foreach (var device in devices) { device.Serial = Convert.ToInt32(device.DeviceName.Substring(1, device.DeviceName.Length - 1)) / 10; } - devices = new ObservableCollection(devices.OrderBy(item => item.Serial)); + devices = new ObservableCollection(devices.OrderBy(item => item.Serial));*/ } public RelayCommand ChangeNameCommand { get; set; } diff --git a/BPASmartClient.Modbus/ModbusTcp.cs b/BPASmartClient.Modbus/ModbusTcp.cs index b18f23db..1e4164dd 100644 --- a/BPASmartClient.Modbus/ModbusTcp.cs +++ b/BPASmartClient.Modbus/ModbusTcp.cs @@ -38,7 +38,7 @@ namespace BPASmartClient.Modbus public Action Disconnect { get; set; } - public bool IsReconnect { get; set; } = true; //true=启用重连,false=禁用重连 + public bool IsReconnect { get; set; } = false; //true=启用重连,false=禁用重连 /// /// 判断是否连接成功 @@ -430,7 +430,7 @@ namespace BPASmartClient.Modbus { commandType = CommandType.Inputs; } - Show?.Invoke($"成功,地址:{address},值:{value}"); + //Show?.Invoke($"成功,地址:{address},值:{value}"); return true; } catch (Exception ex) diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index 62f22ede..085bf88e 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -13,6 +13,7 @@ using BPASmartClient.MorkF.Model; using System.Text; using System.Collections.Concurrent; using System.Windows.Documents; +using BPASmartClient.Business; namespace BPASmartClient.MorkF { @@ -29,21 +30,65 @@ namespace BPASmartClient.MorkF /// private const int sleepTime = 500; + /// + /// 菜品库while循环最大sleep次数 + /// + private const int materialSleepCount = 400; + + /// + /// 菜品库while循环每次sleep时间 + /// + private const int materialSleepTime = 100; + /// /// 初始化炒锅数量 /// private int count = 2; - // - private const int materialHigh = 40000; + /// + /// 菜品盒下移高度,相对于坐标系 + /// + private const int materialBoxHigh = 4080; + + //菜品库一层的高度 + private const int materialHigh = 34500; + + /// + /// + /// + private const int materialOne = 34500; + + /// + /// + /// + private const int materialTwo = 34500; + + /// + /// + /// + private const int materialThree = 34500; + + //传感器到菜品库的高度(坐标系) + private const int materialLaserHigh = 34500; + + //传感器到菜品库的高度(厘米) + private const int materialLaserHighCM = 29; + + /// + /// 传感器到隔板的距离(坐标系) + /// + private const int clapboardLaserHigh = 10000; //炒锅1倒菜的xy坐标 - private const int materialPutPositionXFry1 = -30000; - private const int materialPutPositionYFry1 = -20000; + private const int materialPutPositionXFry1 = 70000; + private const int materialPutPositionYFry1 = 40000; //炒锅2倒菜的xy坐标 - private const int materialPutPositionXFry2 = -30000; - private const int materialPutPositionYFry2 = -20000; + private const int materialPutPositionXFry2 = 70000; + private const int materialPutPositionYFry2 = 40000; + + //菜品库机械爪放置菜品距离 + private const int materialToFryDistance = 10000; //当前炒锅,默认为1号炒锅 private int fryIndex = 0; @@ -55,7 +100,7 @@ namespace BPASmartClient.MorkF /// /// 炒锅编号与炒锅实例 /// - Dictionary morkFs = new Dictionary();//全局对象声明 + Dictionary morkFs = new Dictionary();//全局对象声明 /// /// 菜品库对象 @@ -80,7 +125,7 @@ namespace BPASmartClient.MorkF /// /// 当前炒制菜品 /// - private OrderLocInfo nowStirFryGood = null; + private OrderLocInfo[] nowStirFryGood = new OrderLocInfo[2]; /// /// 待取菜队列 @@ -95,12 +140,8 @@ namespace BPASmartClient.MorkF public override void DoMain() { IsHealth = true; - //WriteControl("VD836", 0); - //WriteControl("VD840", 0); - //Thread.Sleep(400); - //WriteControl("M0.0", true); - for (int i = 0;i< count;i++) + for (int i = 0; i < count; i++) { morkFs.Add(i, new GVL_MorkF()); } @@ -110,7 +151,8 @@ namespace BPASmartClient.MorkF ServerInit(); DeviceProcessLogShow("MORKF 设备初始化完成"); ///初始化菜品库 - FoodLibInit(); + //FoodLibInit(); + Task2ReadMaterialData(); } /// @@ -118,11 +160,121 @@ namespace BPASmartClient.MorkF /// public override void MainTask() { + //炒锅炒制线程 MainProcessExcute(); + //菜品库操作线程 + MainProcessMaterial(); //MinorProcessExcute(); //SingleProcess(); } + private void Task2ReadMaterialData() + { + ThreadManage.GetInstance().StartLong(new Action(() => { + + //获取定位到达状态 + GetStatus("M10.0", new Action((objects) => + { + if (objects is bool[] bools) + { + + //ml_morkf.ArriveComplete = bools[i]; + //小炒定点到达上升沿信号捕获 + if (RTrig.GetInstance("SmartArriveComplete").Start(bools[0])) + { + if (isInitialArrive == false) + { + MessageLog.GetInstance.Show("到达上升沿为true,isInitialArrive is false"); + isInitialArrive = true; + } + else + { + MessageLog.GetInstance.Show("到达上升沿为true"); + ml_morkf.ArriveComplete = true; + isInitialArrive = true; + } + } + } + + }), 2); + }), "ReadMaterialSmartArriveCompleteData", true); + + ThreadManage.GetInstance().StartLong(new Action(() => { + ReadMaterialData(); + + Thread.Sleep(10); + }), "ReadMaterialData", true); + } + + private void ReadMaterialData() + { + //获取激光距离 + GetStatus("VW270", new Action((objects) => + { + if (objects is ushort[] bools) + { + for (int i = 0; i < 1; i++) + { + ml_morkf.LaserDistance = bools[i]; + } + } + }), 2); + + //获取坐标X + GetStatus("VD828", new Action((objects) => + { + if (objects is int bools) + { + ml_morkf.ArmPositionX = bools; + } + }), 2); + + //获取坐标Y + GetStatus("VD832", new Action((objects) => + { + if (objects is int bools) + { + ml_morkf.ArmPositionY = bools; + } + }), 2); + + //获取爪子到达位置 + GetStatus("M11.0", new Action((objects) => + { + if (objects is bool[] bools && bools.Length > 3) + { + ml_morkf.PawArrivePortOne = bools[0]; + ml_morkf.PawArrivePortTwo = bools[1]; + ml_morkf.PawArrivePortThree = bools[2]; + } + }), 2); + + //获取总初始化完成 + GetStatus("M10.2", new Action((objects) => + { + if (objects is bool[] bools) + { + for (int i = 0; i < 1; i++) + { + ml_morkf.InitialComplete = bools[i]; + } + } + }), 2); + + //抓手初始化完成 + GetStatus("M10.3", new Action((objects) => + { + if (objects is bool[] bools) + { + for (int i = 0; i < 1; i++) + { + ml_morkf.PawInitialComplete = bools[i]; + } + } + }), 2); + + } + public override void Stop() { IsHealth = false; @@ -155,6 +307,27 @@ namespace BPASmartClient.MorkF }), "Electromagnetism"); }), "Electromagnetism"); ActionManage.GetInstance.Register(new Action(() => + { + ThreadManage.GetInstance().Start(new Action(() => + { + PawToPoint1(); + }), "PawToPoint1"); + }), "PawToPoint1"); + ActionManage.GetInstance.Register(new Action(() => + { + ThreadManage.GetInstance().Start(new Action(() => + { + PawToPoint2(); + }), "PawToPoint2"); + }), "PawToPoint2"); + ActionManage.GetInstance.Register(new Action(() => + { + ThreadManage.GetInstance().Start(new Action(() => + { + PawToPoint3(); + }), "PawToPoint3"); + }), "PawToPoint3"); + ActionManage.GetInstance.Register(new Action(() => { ThreadManage.GetInstance().Start(new Action(() => { @@ -181,7 +354,7 @@ namespace BPASmartClient.MorkF { ThreadManage.GetInstance().Start(new Action(() => { - if(list is List list_int) + if (list is List list_int) { if (list_int.Count == 2) { @@ -251,7 +424,7 @@ namespace BPASmartClient.MorkF { Plc1Reset(fryIndex); }), "Plc1Reset"); - }) , "Plc1Reset"); + }), "Plc1Reset"); ActionManage.GetInstance.Register(new Action(() => { @@ -337,7 +510,7 @@ namespace BPASmartClient.MorkF { ThreadManage.GetInstance().Start(new Action(() => { - SetFire(o,fryIndex); + SetFire(o, fryIndex); }), "SetFire"); }), "SetFire"); @@ -353,7 +526,7 @@ namespace BPASmartClient.MorkF { ThreadManage.GetInstance().Start(new Action(() => { - SetStir(o,fryIndex); + SetStir(o, fryIndex); }), "SetStir"); }), "SetStir"); #endregion @@ -366,8 +539,8 @@ namespace BPASmartClient.MorkF /// private void StartOrder(object o) { - if(o==null) return; - if(o is int goodId) + if (o == null) return; + if (o is int goodId) { var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey == goodId);//匹配订单对应制作流程 if (res != null) @@ -412,12 +585,12 @@ namespace BPASmartClient.MorkF private void StartLocalOrder() { if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 - if (Json.Data.LocalstirFryGoods.StirPotActions.Count>0) + if (Json.Data.LocalstirFryGoods.StirPotActions.Count > 0) { StirFryGoodsQuenes.Enqueue(new OrderLocInfo() { SuborderId = Guid.NewGuid().ToString(), - StirPotActions = Json.Data.LocalstirFryGoods.StirPotActions, + StirPotActions = Json.Data.LocalstirFryGoods.StirPotActions, GoodName = "本地菜品" }); MessageLog.GetInstance.Show($"添加本地模拟的订单{Json.Data.LocalstirFryGoods.GoodsKey}"); @@ -436,12 +609,12 @@ namespace BPASmartClient.MorkF if (!morkFs.ContainsKey(num)) { //根据调试界面的当前炒锅编号停止炒制线程 - ThreadManage.GetInstance().StopTask(String.Format(striConst, fryIndex.ToString(), nowStirFryGood.GoodName), new Action(() => { Plc1Reset(fryIndex); })); + ThreadManage.GetInstance().StopTask(String.Format(striConst, fryIndex.ToString(), nowStirFryGood[fryIndex].GoodName), new Action(() => { Plc1Reset(fryIndex); })); } else { //根据炒锅编号停止炒制线程 - ThreadManage.GetInstance().StopTask(String.Format(striConst, fryIndex.ToString(), nowStirFryGood.GoodName), new Action(() => { Plc1Reset(num); })); + ThreadManage.GetInstance().StopTask(String.Format(striConst, fryIndex.ToString(), nowStirFryGood[num].GoodName), new Action(() => { Plc1Reset(num); })); } } @@ -549,130 +722,6 @@ namespace BPASmartClient.MorkF }), i); } - //获取激光距离 - GetStatus("VW270", new Action((objects) => - { - if (objects is int[] bools) - { - for (int i = 0; i < 1; i++) - { - ml_morkf.LaserDistance = bools[i]; - } - } - }), 2); - - //获取坐标X - GetStatus("VD828", new Action((objects) => - { - if (objects is int[] bools) - { - for (int i = 0; i < 1; i++) - { - ml_morkf.ArmPositionX = bools[i]; - } - } - }), 2); - - //获取坐标Y - GetStatus("VD832", new Action((objects) => - { - if (objects is int[] bools) - { - for (int i = 0; i < 1; i++) - { - ml_morkf.ArmPositionY = bools[i]; - } - } - }), 2); - - //获取爪子到达位置 - GetStatus("M11.0", new Action((objects) => - { - if (objects is bool[] bools && bools.Length > 3) - { - - //ml_morkf.PawArrivePortOne = bools[0]; - //ml_morkf.PawArrivePortTwo = bools[1]; - //ml_morkf.PawArrivePortThree = bools[2]; - - if (isInitialPaw == false) - { - isInitialArrive = true; - } - else - { - //小炒爪子到达1号位上升沿信号捕获 - if (RTrig.GetInstance("SmartGitdistance1Complete").Start(bools[0])) - { - ml_morkf.PawArrivePortOne = true; - } - //小炒爪子到达3号位上升沿信号捕获 - if (RTrig.GetInstance("SmartGitdistance2Complete").Start(bools[1])) - { - ml_morkf.PawArrivePortTwo = true; - } - //小炒爪子到达3号位上升沿信号捕获 - if (RTrig.GetInstance("SmartGitdistance3Complete").Start(bools[2])) - { - ml_morkf.PawArrivePortThree = true; - } - isInitialArrive = true; - } - } - }), 2); - - //获取定位到达状态 - GetStatus("M10.0", new Action((objects) => - { - if (objects is bool[] bools) - { - for (int i = 0; i < 1; i++) - { - //ml_morkf.ArriveComplete = bools[i]; - //小炒定点到达上升沿信号捕获 - if (RTrig.GetInstance("SmartArriveComplete").Start(bools[i])) - { - if (isInitialArrive == false) - { - MessageLog.GetInstance.Show("到达上升沿为true,isInitialArrive is false"); - isInitialArrive = true; - } - else - { - MessageLog.GetInstance.Show("到达上升沿为true"); - ml_morkf.ArriveComplete = true; - isInitialArrive = true; - } - } - } - } - - }), 2); - - //获取总初始化完成 - GetStatus("M10.2", new Action((objects) => - { - if (objects is bool[] bools) - { - for (int i = 0; i < 1; i++) - { - ml_morkf.InitialComplete = bools[i]; - } - } - }), 2); - - //抓手初始化完成 - GetStatus("M10.3", new Action((objects) => - { - if (objects is bool[] bools) - { - for (int i = 0; i < 1; i++) - { - ml_morkf.PawInitialComplete = bools[i]; - } - } - }), 2); - } #endregion @@ -683,7 +732,7 @@ namespace BPASmartClient.MorkF /// /// /// - private void MaterailLibrary_Write(string address, object value,int num = 2) + private void MaterailLibrary_Write(string address, object value, int num = 2) { WriteControlExact(address, value, num); } @@ -694,10 +743,12 @@ namespace BPASmartClient.MorkF { MaterailLibrary_Write("M0.2", true); - for (int i = 0; i < sleepCount && !ml_morkf.InitialComplete; i++) + Thread.Sleep(500); + + for (int i = 0; i < materialSleepCount && !ml_morkf.InitialComplete; i++) { - Thread.Sleep(sleepTime); - if (i >= sleepCount - 1) + Thread.Sleep(materialSleepTime); + if (i >= materialSleepCount - 1) { MessageLog.GetInstance.Show("菜品库初始化超时"); return false; @@ -723,7 +774,8 @@ namespace BPASmartClient.MorkF MaterailLibrary_Write("M1.3", bs[0]); } } - public bool GetDistance_1() + + public bool PawToPoint1() { if (!ml_morkf.InitialComplete) { @@ -732,10 +784,10 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.Show("爪子去到1号位"); MaterailLibrary_Write("M1.0", true); - for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortOne; i++) + for (int i = 0; i < materialSleepCount && !ml_morkf.PawArrivePortOne; i++) { - Thread.Sleep(sleepTime); - if (i >= sleepCount - 1) + Thread.Sleep(materialSleepTime); + if (i >= materialSleepCount - 1) { MessageLog.GetInstance.Show("爪子去到1号位超时"); return false; @@ -747,7 +799,8 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.Show("爪子去到1号位完成"); return true; } - public bool GetDistance_2() + + public bool PawToPoint2() { if (!ml_morkf.InitialComplete) { @@ -756,10 +809,10 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.Show("爪子去到2号位"); MaterailLibrary_Write("M1.1", true); - for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortTwo; i++) + for (int i = 0; i < materialSleepCount && !ml_morkf.PawArrivePortTwo; i++) { - Thread.Sleep(sleepTime); - if (i >= sleepCount - 1) + Thread.Sleep(materialSleepTime); + if (i >= materialSleepCount - 1) { MessageLog.GetInstance.Show("爪子去到2号位超时"); return false; @@ -771,7 +824,8 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.Show("爪子去到2号位完成"); return true; } - public bool GetDistance_3() + + public bool PawToPoint3() { if (!ml_morkf.InitialComplete) { @@ -780,10 +834,10 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.Show("爪子去到3号位"); MaterailLibrary_Write("M1.2", true); - for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortThree; i++) + for (int i = 0; i < materialSleepCount && !ml_morkf.PawArrivePortThree; i++) { - Thread.Sleep(sleepTime); - if (i >= sleepCount - 1) + Thread.Sleep(materialSleepTime); + if (i >= materialSleepCount - 1) { MessageLog.GetInstance.Show("爪子去到3号位超时"); return false; @@ -795,6 +849,78 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.Show("爪子去到3号位完成"); return true; } + + public bool GetDistance_1() + { + if (!ml_morkf.InitialComplete) + { + return false; + } + + MaterailLibrary_Write("M0.3", true); + MaterailLibrary_Write("M0.3", false); + Thread.Sleep(300); + + MessageLog.GetInstance.Show("1号测距开启完成"); + return true; + } + public bool GetDistance_2() + { + if (!ml_morkf.InitialComplete) + { + return false; + } + + MaterailLibrary_Write("M0.4", true); + MaterailLibrary_Write("M0.4", false); + Thread.Sleep(300); + + MessageLog.GetInstance.Show("2号测距开启完成"); + return true; + } + public bool GetDistance_3() + { + if (!ml_morkf.InitialComplete) + { + return false; + } + + MaterailLibrary_Write("M0.5", true); + MaterailLibrary_Write("M0.5", false); + Thread.Sleep(300); + + MessageLog.GetInstance.Show("3号测距开启完成"); + return true; + } + + /// + /// 根据x坐标获取传感器距离 + /// + /// + /// + public bool GetDistance(int x) + { + //是否在第一层菜品库 + if (x > 0 && x <= materialLaserHigh) + { + //获取传感器1的距离 + return GetDistance_1(); + } + //是否在第二层菜品库 + else if (x > materialLaserHigh && x <= (2 * materialLaserHigh + clapboardLaserHigh)) + { + //获取传感器1的距离 + return GetDistance_2(); + } + //是否在第三层菜品库 + else if (x > (2 * materialLaserHigh + clapboardLaserHigh) && x <= (3 * materialLaserHigh + 2 * clapboardLaserHigh)) + { + //获取传感器1的距离 + return GetDistance_3(); + } + return false; + } + public void PawTurnFront() { MaterailLibrary_Write("", true); @@ -811,7 +937,7 @@ namespace BPASmartClient.MorkF /// public bool SetArmPosition(int x, int y) { - if(!ml_morkf.InitialComplete) + if (!ml_morkf.InitialComplete) { return false; } @@ -819,6 +945,11 @@ namespace BPASmartClient.MorkF //取反 x -= 2 * x; y -= 2 * y; + if (x > 0 || y > 0) + { + MessageLog.GetInstance.Show($"机械臂移动到[{x},{y}]非法"); + return false; + } MaterailLibrary_Write("VD836", x); Thread.Sleep(100); MaterailLibrary_Write("VD840", y); @@ -826,16 +957,28 @@ namespace BPASmartClient.MorkF Thread.Sleep(200); MessageLog.GetInstance.Show($"机械臂移动到[{x},{y}]"); + + //到达置为false + ml_morkf.ArriveComplete = false; + //定位启动 MaterailLibrary_Write("M0.0", true); - for (int i = 0; i < sleepCount && !ml_morkf.ArriveComplete; i++) + Thread.Sleep(400); + + for (int i = 0; i < materialSleepCount && (!ml_morkf.ArriveComplete); i++) { - Thread.Sleep(sleepTime); - if (i >= sleepCount - 1) + Thread.Sleep(materialSleepTime); + //若是目标点与当前坐标一致,跳出循环 + if((ml_morkf.ArmPositionX == x && ml_morkf.ArmPositionY == y)) + { + MessageLog.GetInstance.Show($"机械臂已移动到[{ml_morkf.ArmPositionX},{ml_morkf.ArmPositionY}]"); + break; + } + if (i >= materialSleepCount - 1) { MessageLog.GetInstance.Show("机械臂移动操作超时"); - return false; + return false; } } @@ -911,20 +1054,57 @@ namespace BPASmartClient.MorkF /// /// 取菜x轴坐标 /// 取菜y轴坐标 - /// - public void GetMaterail(int x,int y,int fryNum = 0) + /// 炒锅编号 + public void GetMaterail(int x, int y, int fryNum = 0) { //设置到抓菜处 - if(!SetArmPosition(x, y)) + if (!SetArmPosition(x, y)) + { + return; + } + + if (!GetDistance(x)) + { + MessageLog.GetInstance.Show("错误:获取传感器数据出错"); + return; + } + + Thread.Sleep(200); + + if (!GetDistance(x)) { + MessageLog.GetInstance.Show("错误:获取传感器数据出错"); return; } - //获取传感器的距离 + Thread.Sleep(1000); + + //获取传感器的距离,转换成坐标系的点 int laserHigh = ml_morkf.LaserDistance; + MessageLog.GetInstance.Show($"传感器的距离{laserHigh}"); + + if (laserHigh > 29) + { + MessageLog.GetInstance.Show("错误:传感器获取数据大于隔板与传感器之间的距离"); + return; + } + + int moveX = 0; + if (LaserDistance2Coordinate(laserHigh, out moveX) != Laser2CoordinateState.MaterialNormal) + { + MessageLog.GetInstance.Show("错误:传感器距离转坐标值失败"); + return; + } + + if(x < moveX) + { + MessageLog.GetInstance.Show("错误:传感器距离转坐标值大于当前x轴坐标"); + return; + } + //设置到传感器感应的距离处 - if(!SetArmPosition(x+ laserHigh, y )) + if (!SetArmPosition(x - moveX, y)) { return; } @@ -933,14 +1113,16 @@ namespace BPASmartClient.MorkF //Electromagnetism(new List { true }); //Thread.Sleep(500); +#if true //爪子去1号位抓菜 - if (!GetDistance_1()) + if (!PawToPoint1()) { return; } +#endif //设置到该层菜品库最高处 - if (!SetArmPosition(x + materialHigh, y)) + if (!SetArmPosition(x - materialHigh, y)) { return; } @@ -949,85 +1131,159 @@ namespace BPASmartClient.MorkF //Electromagnetism(new List { false }); //Thread.Sleep(500); +#if true //爪子去2号位放菜 - if (!GetDistance_2()) + if (!PawToPoint2()) { return; } +#endif + ////判断炒锅是否可以放盒 + //for(int i = 0;materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut;i++) + //{ + // Thread.Sleep(materialSleepTime); + // if (i >= materialSleepCount - 1) + // { + // MessageLog.GetInstance.Show("等待炒锅允许放盒超时"); + // return; + // } + //} + + //关闭启磁吸 + MagnetOff(fryNum); + + Thread.Sleep(200); //根据炒锅不同设置不同的出菜处 - if (fryNum == 0) + if (fryNum % 2 == 0) { - //设置到炒锅1出菜处 - if (!SetArmPosition(materialPutPositionXFry1, materialPutPositionYFry1)) - { - return; - } + x = materialPutPositionXFry1; + y = materialPutPositionYFry1; } else { - //设置到炒锅2出菜处 - if (!SetArmPosition(materialPutPositionXFry1, materialPutPositionYFry1)) - { - return; - } + x = materialPutPositionXFry2; + y = materialPutPositionYFry2; + } + + //设置到炒锅1出菜处 + if (!SetArmPosition(x, y)) + { + return; } +#if true //爪子去3号位放菜 - if (!GetDistance_3()) + if (!PawToPoint3()) { return; } +#endif + + //开启磁吸 + MagnetOn(fryNum); + + Thread.Sleep(200); + //设置到炒锅1出菜处 + if (!SetArmPosition(x + materialToFryDistance, y)) + { + return; + } + +#if true + //爪子回到2号位 + if (!PawToPoint2()) + { + return; + } +#endif ////关闭电磁阀 //Electromagnetism(new List { false }); //Thread.Sleep(300); - if(morkFs.ContainsKey(fryNum)) + if (morkFs.ContainsKey(fryNum)) { morkFs[fryNum].GetMaterialComplete = true; } } /// - /// 获取菜品测试 + /// 传感器距离转为x轴坐标系 /// - /// - private void GetMaterailTest(int getNum) + /// + /// + /// + public Laser2CoordinateState LaserDistance2Coordinate(int distance,out int x) { - ThreadManage.GetInstance().Start(new Action(()=>{ - int x1 = 0, x2 = 0, y= 0; - - for (int i = 0; i < sleepCount * 2 && ml_morkf.MaterailIsWorking; i++) + x = 0; + try + { + //菜盒放多了 + if (distance<6) { - Thread.Sleep(sleepTime); - if (i >= sleepCount * 2 - 1) - { - MessageLog.GetInstance.Show("菜品库正在工作中....."); - return; - } + return Laser2CoordinateState.MaterialOverdo; } - - //if (!ml_morkf.InitialComplete) - //{ - // MessageLog.GetInstance.Show("菜品库未初始化"); - // return; - //} - if (getNum == 0) + else if (distance >= 6 && distance < 10) { - x2 = -20000; - y = 40000; - + x = 24882; + return Laser2CoordinateState.MaterialNormal; + } + else if(distance>=10 && distance < 14) + { + x = 18661; + return Laser2CoordinateState.MaterialNormal; + } + else if(distance >= 14 && distance < 19) + { + x = 12441; + return Laser2CoordinateState.MaterialNormal; + } + else if (distance >= 19 && distance < 23) + { + x = 6220; + return Laser2CoordinateState.MaterialNormal; } - else if (getNum == 1) + else if (distance >= 23 && distance < 28) { - x2 = -15000; - y = -52500; + x = 0; + return Laser2CoordinateState.MaterialNormal; } else { - MessageLog.GetInstance.Show("菜品库无效操作"); - return; + return Laser2CoordinateState.MaterialEmpty; } + } + catch(Exception ex) + { + return Laser2CoordinateState.MaterialUnkown; + } + } + + /// + /// 获取菜品测试 + /// + /// + private void GetMaterailTest(Coordinate coordinate) + { + ThreadManage.GetInstance().Start(new Action(() => { + //int x1 = 0, x2 = 0, y = 0; + + //if (getNum % 2 == 0) + //{ + // x2 = 35000; + // y = 82000; + + //} + //else if (getNum % 2 == 1) + //{ + // x2 = 35000; + // y = 9000; + //} + //else + //{ + // MessageLog.GetInstance.Show("菜品库无效操作"); + // return; + //} try { lock (lock_Materail) @@ -1035,14 +1291,14 @@ namespace BPASmartClient.MorkF ml_morkf.MaterailIsWorking = true; } //取菜操作 - GetMaterail(x2,y); + GetMaterail(coordinate.X, coordinate.Y); - //机械臂回原点 - if (!SetArmPosition(0, 0)) - { - MessageLog.GetInstance.Show("菜品库[机械臂操作失败]"); - return; - } + ////机械臂回原点 + //if (!SetArmPosition(0, 0)) + //{ + // MessageLog.GetInstance.Show("菜品库[机械臂操作失败]"); + // return; + //} } catch (Exception ex) { @@ -1056,7 +1312,7 @@ namespace BPASmartClient.MorkF } } - }),$"菜品库操作{getNum}"); + }), $"菜品库操作"); } #endregion @@ -1221,9 +1477,9 @@ namespace BPASmartClient.MorkF } int i = 0; //判断是否完成取菜 - for (i = 0; i < sleepCount*2 && !morkFs[num].GetMaterialComplete; i++) + for (i = 0; i < sleepCount * 2 && !morkFs[num].GetMaterialComplete; i++) { - if(i == 3) + if (i == 3) { //停止搅拌 StopStir(num); @@ -1284,16 +1540,9 @@ namespace BPASmartClient.MorkF } } - //while (!morkFs[num].ArmOnOrigin) - //{ - // Thread.Sleep(200); - //} FirePot_Write("LB5", false, num); Thread.Sleep(200); MessageLog.GetInstance.Show("搅拌臂到达原点位"); - - - } //搅拌臂去炒制位 @@ -1385,7 +1634,18 @@ namespace BPASmartClient.MorkF } } - #endregion + public void MagnetOn(int num) + { + FirePot_Write("LB8", false, num); + Thread.Sleep(200); + } + + public void MagnetOff(int num) + { + FirePot_Write("LB8", true, num); + Thread.Sleep(200); + } +#endregion bool isInitialArrive = false; @@ -1633,7 +1893,6 @@ namespace BPASmartClient.MorkF } #endregion - private object lock_MainProcessExcute = new object(); /// @@ -1647,7 +1906,7 @@ namespace BPASmartClient.MorkF //遍历炒锅,找到合适、空闲的炒锅 for(int i = 0;i { try { + MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}"); + + Coordinate myCoordinate = new Coordinate(); int getMaterailNum = 0; foreach (var potActions in res.StirPotActions) { - if (ThreadManage.GetInstance().IsCanncel(String.Format(striConst, i.ToString(), nowStirFryGood.GoodName))) + if (ThreadManage.GetInstance().IsCanncel(String.Format(striConst, i.ToString(), nowStirFryGood[i].GoodName))) { return; } @@ -1745,8 +2005,22 @@ namespace BPASmartClient.MorkF case nameof(StirFryPotActionEnum.取原料): //炒锅取菜状态置为未取到 morkFs[i].GetMaterialComplete = false; - materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, x = 0, y = 0 }); - getMaterailNum++; + if(getMaterailNum == 0) + { + if (NoMaterial2Coordinate("A2", out myCoordinate)) + { + materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); + getMaterailNum++; + } + } + else if(getMaterailNum == 1) + { + if (NoMaterial2Coordinate("B2", out myCoordinate)) + { + materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); + getMaterailNum++; + } + } MessageLog.GetInstance.Show(potActions.Actions); break; case nameof(StirFryPotActionEnum.开启搅拌): @@ -1795,18 +2069,11 @@ namespace BPASmartClient.MorkF } } - Plc1Reset(i);//复位 Thread.Sleep(3000); //回原点位 StirArmGoOrigin(i); - //while (!morkFs[i].ArmOnOrigin) - //{ - // Thread.Sleep(100); - //} - //出餐 - //OutMeal(i); MessageLog.GetInstance.Show($"菜品{res.GoodName}完成"); @@ -1818,12 +2085,12 @@ namespace BPASmartClient.MorkF } finally { - nowStirFryGood = null; + nowStirFryGood[i] = null; //炒完后出队列 morkFs[i].StirFryGoodsQuenes.TryDequeue(out var orderQueue); morkFs[i].FryWorking = false; } - }), String.Format(striConst, i.ToString(), nowStirFryGood.GoodName)/*$"炒锅{i}炒制{res.GoodName}线程"*/); + }), String.Format(striConst, i.ToString(), nowStirFryGood[i].GoodName)/*$"炒锅{i}炒制{res.GoodName}线程"*/); } } break; @@ -1832,6 +2099,8 @@ namespace BPASmartClient.MorkF } } + private int testNum = 0; + /// /// 菜品库主流程 /// @@ -1850,7 +2119,8 @@ namespace BPASmartClient.MorkF //ThreadManage.GetInstance().Start(new Action(()=>{ // GetMaterail(res.x, res.y, res.fryNum); //}),"菜品库操作"); - GetMaterailTest(res.fryNum); + GetMaterailTest(res.coordinate); + testNum++; } } } @@ -1862,121 +2132,131 @@ namespace BPASmartClient.MorkF private void SingleProcess() { - //if (!morkF.AutoMode) - //{ - // if (morkF.IsAuto) - // { - // Plc1Reset(); - // morkF.IsAuto = false; - // } - //} - //else morkF.IsAuto = true; + } + private void ScreenDataServer() + { + LocalMqtt.GetInstance.Init(ScreenDeviceType.大炒); + ThreadManage.GetInstance().StartLong(new Action(() => + { + List statsModels = new List(); + statsModels.Add(new StatsModel() { Name = "帝王蟹", Count = 666 }); + ScreenModelMinWok maxWok = new ScreenModelMinWok + { + IsRun = new Random().Next(0, 2) == 0 ? IsRun.运行 : IsRun.停止, //设备是否运行 + WorkStatus_1 = (WorkStatus)new Random().Next(0, 3), //设备运行状态 + WorkStatus_2 = (WorkStatus)new Random().Next(0, 3), //设备运行状态 + RobotStatu = (WorkStatus)new Random().Next(0, 3), //机器人状态 待机 1 正常 + Alarm = new List(), //告警集合 + FailuresCount = 0, //故障数 + StatsCount = statsModels, //统计菜品数量 + MinWok_Dishes_1 = "满汉全席",//当前炒制菜品名 + MinWok_Dishes_2 = "海鲜大餐", + MinWok_Task_1 = "炒制菜品",//当前任务 + MinWok_Task_2 = "热油", //当前任务 + MinWok_Process_1 = new List(), //炒锅当前任务流程 + MinWok_Process_2 = new List(), //炒锅当前任务流程 + MinWok_HeatGear_1 = new Random().Next(0, 5).ToString(), //炒锅加热档位 + MinWok_HeatGear_2 = new Random().Next(0, 5).ToString(), //炒锅加热档位 + MinWok_StirGear_1 = new Random().Next(0, 5).ToString(), //炒锅搅拌档位 + MinWok_StirGear_2 = new Random().Next(0, 5).ToString(), //炒锅搅拌档位 + MinWok_OrderCount_1 = 2, //订单数量 + MinWok_OrderCount_2 = 2, //订单数量 + MinWok_ErrorOrderCount_1 = 0, //异常订单数量 + MinWok_ErrorOrderCount_2 = 0, //异常订单数量 + + }; + LocalMqtt.GetInstance.Publish(maxWok); + Thread.Sleep(1000); + + }), "大屏数据上报"); } public override void SimOrder() { - ActionManage.GetInstance.Register(morkSim, "模拟小炒锅1订单"); + } - private void morkSim(object o) + /// + /// 菜品编号转换为坐标 + /// + /// + /// + /// + public bool NoMaterial2Coordinate(string no,out Coordinate coordinate) { - //if (o == null) return; - //if(o is List ins) - //{ - // ThreadManage.GetInstance().Start(new Action(() => - // { - // if (morkF.FryPot1_InitialComplete && morkF.AutoMode)//初始化完成&&自动模式&& 锅在原点位置 - // { - // if (!morkF.ArmOnWorking)//搅拌臂是否在工作位 - // { - // StirArmGoWork(); - - // while (!morkF.ArmOnWorking) - // { - // Thread.Sleep(500); - // } - // OutSeasoning(new List { 1, 100 });//加油500g - // while (!morkF.PassWay1_1Compelete) - // { - // Thread.Sleep(1000); - // } - // WriteControlExact(morkF.StartPassWay[ 1], false);//开启通道关闭 - // Thread.Sleep(500); - // SetFire(new List { ins[1] });//加热三档 - - // StartFire();//开始加热 - // Thread.Sleep(500); - // SetStir(new List { ins[2] });//搅拌二挡 - // Thread.Sleep(500); - // StartStir();//开始搅拌 - // Thread.Sleep(ins[0]*1000);//加热10s - - // OutSeasoning(new List { 11, 30 });//加调料1 50g - // Thread.Sleep(400); - // OutSeasoning(new List { 12, 30 });//加调料2 30g - // while (!morkF.PassWay1_11Compelete&& !morkF.PassWay1_12Compelete) - // { - // Thread.Sleep(1000); - // } - - - - - // WriteControlExact(morkF.StartPassWay[11], false);//开启通道关闭 - // Thread.Sleep(500); - // WriteControlExact(morkF.StartPassWay[12], false);//开启通道信号关闭 - - - - // Thread.Sleep(500); - - // OutFood();//倒菜品1 - // while (!morkF.FryPot1_MaterialIntoPot)//菜品1倒菜完成 - // { - // Thread.Sleep(500); - // } - // WriteControlExact("LB53", false); - // Thread.Sleep(500); - // SetFire(new List { ins[4] });//菜品1加热档 - // Thread.Sleep(500); - // SetStir(new List() { ins[5] });//菜品1搅拌挡 - // Thread.Sleep(ins[3]*1000);//菜品1炒制时间 - - // OutSeasoning(new List {3, 8 });//加调料3 20g - // while (!morkF.PassWay1_3Compelete) - // { - // Thread.Sleep(1000); - // } - // WriteControlExact(morkF.StartPassWay[3], false);//开启通道信号关闭 - // Thread.Sleep(500); - // OutFood();//倒菜菜品2 - // while (!morkF.FryPot1_MaterialIntoPot)//菜品2倒菜完成 - // { - // Thread.Sleep(500); - // } - // WriteControlExact("LB53", false); - // Thread.Sleep(500); - // SetFire(new List { ins[7] });//菜品2加热档 - // Thread.Sleep(500); - // SetStir(new List() { ins[8] });//菜品2搅拌挡 - // Thread.Sleep(ins[6] * 1000);//菜品2炒制时间 - - - - // StopStir();//停止搅拌 - // Thread.Sleep(500); - // StopFire();//停止加热 - // Thread.Sleep(2000); - // StirArmGoOrigin();//搅拌臂回原点位 - // } - // } - // }), "模拟炒锅1订单"); - //} - - + //默认返回0,0 + coordinate = new Coordinate(); + coordinate.X = 0; + coordinate.Y = 0; + + try + { + if(dicNoMaterialCoordinate.ContainsKey(no)) + { + coordinate = dicNoMaterialCoordinate[no]; + return true; + } + else + { + return false; + } + } + catch (Exception ex) + { + return false; + } + finally + { + + } + } + + /// + /// 每个取菜点的编号与坐标字典 + /// + private static Dictionary dicNoMaterialCoordinate { get; set; } = new Dictionary() + { + {"A1",new Coordinate(){ X = 34500,Y=0} }, + {"A2",new Coordinate(){ X = 34500,Y=9000} }, + {"A3",new Coordinate(){ X = 34500,Y=0} }, + {"B1",new Coordinate(){ X = 34500,Y=0} }, + {"B2",new Coordinate(){ X = 34500,Y=83000} }, + {"B3",new Coordinate(){ X = 34500,Y=0} }, + {"C1",new Coordinate(){ X = 34500,Y=0} }, + {"C2",new Coordinate(){ X = 34500,Y=0} }, + {"C3",new Coordinate(){ X = 34500,Y=0} }, + {"D1",new Coordinate(){ X = 0,Y=0} }, + {"D2",new Coordinate(){ X = 0,Y=0} }, + {"D3",new Coordinate(){ X = 0,Y=0} }, + {"E1",new Coordinate(){ X = 0,Y=0} }, + {"E2",new Coordinate(){ X = 0,Y=0} }, + {"E3",new Coordinate(){ X = 0,Y=0} }, + {"F1",new Coordinate(){ X = 0,Y=0} }, + {"F2",new Coordinate(){ X = 0,Y=0} }, + {"F3",new Coordinate(){ X = 0,Y=0} }, + {"G1",new Coordinate(){ X = 0,Y=0} }, + {"G2",new Coordinate(){ X = 0,Y=0} }, + {"G3",new Coordinate(){ X = 0,Y=0} }, + {"H1",new Coordinate(){ X = 0,Y=0} }, + {"H2",new Coordinate(){ X = 0,Y=0} }, + {"H3",new Coordinate(){ X = 0,Y=0} }, + {"I1",new Coordinate(){ X = 0,Y=0} }, + {"I2",new Coordinate(){ X = 0,Y=0} }, + {"I3",new Coordinate(){ X = 0,Y=0} }, + {"J1",new Coordinate(){ X = 0,Y=0} }, + {"J2",new Coordinate(){ X = 0,Y=0} }, + {"J3",new Coordinate(){ X = 0,Y=0} }, + }; + + public enum Laser2CoordinateState + { + MaterialOverdo = 0,//菜品过量 + MaterialNormal = 1,//菜品正常 + MaterialEmpty = 2,//菜品为空 + MaterialUnkown = 999,//菜品未知错误 } } } \ No newline at end of file diff --git a/BPASmartClient.MorkF/ML_MorkF.cs b/BPASmartClient.MorkF/ML_MorkF.cs index 74a66a0a..b7a6b624 100644 --- a/BPASmartClient.MorkF/ML_MorkF.cs +++ b/BPASmartClient.MorkF/ML_MorkF.cs @@ -43,17 +43,7 @@ namespace BPASmartClient.MorkF { get { - var ret = _ArriveComplete; - _ArriveComplete = false; - if(ret) - { - MessageLog.GetInstance.Show("到达上升沿为true"); - } - else - { - MessageLog.GetInstance.Show("到达上升沿为false"); - } - return ret; + return _ArriveComplete; } set { diff --git a/BPASmartClient.MorkF/MaterialOperation.cs b/BPASmartClient.MorkF/MaterialOperation.cs index 83b1a6d9..130546bd 100644 --- a/BPASmartClient.MorkF/MaterialOperation.cs +++ b/BPASmartClient.MorkF/MaterialOperation.cs @@ -6,19 +6,20 @@ using System.Threading.Tasks; namespace BPASmartClient.MorkF { + public class Coordinate + { + public int X { get; set; } = 0; + + public int Y { get; set; } = 0; + } + /// /// 菜品库操作类 /// internal class MaterialOperation { - /// - /// x轴坐标 - /// - public int x; - /// - /// y轴坐标 - /// - public int y; + public Coordinate coordinate { get; set; } = new Coordinate(); + /// /// 炒锅编号 /// diff --git a/BPASmartClient.MorkF/View/DebugView.xaml b/BPASmartClient.MorkF/View/DebugView.xaml index 63ad05c5..9b3ad9a5 100644 --- a/BPASmartClient.MorkF/View/DebugView.xaml +++ b/BPASmartClient.MorkF/View/DebugView.xaml @@ -89,7 +89,7 @@ diff --git a/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs index 091de4ac..575d8167 100644 --- a/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs +++ b/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs @@ -96,6 +96,9 @@ namespace BPASmartClient.MorkF.ViewModel public RelayCommand PawTurnBack { get; set; }//夹爪反转 public RelayCommand SetArmPosition { get; set; }//机器臂位置设定 public RelayCommand ArmRun { get; set; }//机械臂运动 + public RelayCommand PawToPoint1 { get; set; }//感应测距1 + public RelayCommand PawToPoint2 { get; set; }//感应测距2 + public RelayCommand PawToPoint3 { get; set; }//感应测距3 #endregion @@ -207,8 +210,11 @@ namespace BPASmartClient.MorkF.ViewModel StopElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List { true });});//电磁阀关闭 SetSpeed = new RelayCommand(() => { - ActionManage.GetInstance.Send("SetSpeed", new List { MoveSpeed }); + ActionManage.GetInstance.Send("SetSpeed", new List { MoveSpeed }); });//设定速度 + PawToPoint1 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint1"); });//爪子去1号位 + PawToPoint2 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint2"); });//爪子去2号位 + PawToPoint3 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位 GetDistance_1 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1 GetDistance_2 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2 GetDistance_3 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3 diff --git a/BPASmartClient.S7Net/EntityClassResolution.cs b/BPASmartClient.S7Net/EntityClassResolution.cs index 5e720711..b9ddd591 100644 --- a/BPASmartClient.S7Net/EntityClassResolution.cs +++ b/BPASmartClient.S7Net/EntityClassResolution.cs @@ -55,9 +55,9 @@ namespace BPASmartClient.S7Net numBytes += len; break; default: - numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true); if (type.IsClass) IncrementToEven(ref numBytes); else if (!type.IsPrimitive && !type.IsEnum && type.IsValueType) IncrementToEven(ref numBytes); + numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true); break; } @@ -221,15 +221,13 @@ namespace BPASmartClient.S7Net break; default: { - object obj2 = Activator.CreateInstance(propertyType); - numBytes = FromBytes(obj2, bytes, numBytes); - numBytes = Math.Ceiling(numBytes); if (numBytes / 2.0 - Math.Floor(numBytes / 2.0) > 0.0) { numBytes += 1.0; } - + object obj2 = Activator.CreateInstance(propertyType); + numBytes = FromBytes(obj2, bytes, numBytes); obj = obj2; break; } diff --git a/BPASmartClient.S7Net/SiemensHelper.cs b/BPASmartClient.S7Net/SiemensHelper.cs index e79ad7fb..740e7bb4 100644 --- a/BPASmartClient.S7Net/SiemensHelper.cs +++ b/BPASmartClient.S7Net/SiemensHelper.cs @@ -2,7 +2,6 @@ using System.Net; using System.Text; using BPASmartClient.S7Net; -using System.Text; namespace BPASmartClient.S7Net { @@ -106,12 +105,17 @@ namespace BPASmartClient.S7Net return $"失败,地址:{address},值:{value},断开连接"; } } - - public void WriteString(int db,string txt, int startAddress = 0) + /// + /// + /// + /// DB号 + /// 字符串 + /// 字节偏移地址 + public void WriteString(int db, string txt, int startAddress = 0) { var temp = Encoding.ASCII.GetBytes(txt); var bytes = S7.Net.Types.S7String.ToByteArray(txt, temp.Length); - myPlc.WriteBytes(DataType.DataBlock,db, startAddress, bytes); + myPlc.WriteBytes(DataType.DataBlock, db, startAddress, bytes); } public TResult ReadClass(int db, int startByteAdr = 0) where TResult : class, new() diff --git a/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj b/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj index 4c4964a1..eabbfbcd 100644 --- a/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj +++ b/BPASmartClient.ScreenLib/BPASmartClient.ScreenLib.csproj @@ -19,7 +19,7 @@ - + diff --git a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl1.xaml b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl1.xaml index 1eb12eb5..e5617d76 100644 --- a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl1.xaml +++ b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl1.xaml @@ -33,7 +33,7 @@ - + - 设备是否运行 + 设备工作状态 @@ -132,7 +132,7 @@ - + - 设备是否运行 + 设备工作状态 diff --git a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl2.xaml b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl2.xaml index 58fe2d18..94f1cbc3 100644 --- a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl2.xaml +++ b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl2.xaml @@ -33,7 +33,7 @@ - + - 设备是否运行 + 设备工作状态 @@ -131,7 +131,7 @@ - + - 设备是否运行 + 设备工作状态 diff --git a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml index 6447a3ea..5e3c1601 100644 --- a/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml +++ b/BPASmartClient.ScreenLib/分餐机/ScreenSplitMealsControl3.xaml @@ -33,7 +33,7 @@ - + - 设备是否运行 + 设备工作状态 @@ -131,7 +131,7 @@ - + - 设备是否运行 + 设备工作状态 diff --git a/BPASmartClient.ScreenLib/煮面机/ScreenMorksControl.xaml b/BPASmartClient.ScreenLib/煮面机/ScreenMorksControl.xaml index e3f23ade..35fb916c 100644 --- a/BPASmartClient.ScreenLib/煮面机/ScreenMorksControl.xaml +++ b/BPASmartClient.ScreenLib/煮面机/ScreenMorksControl.xaml @@ -203,7 +203,7 @@ - + @@ -220,7 +220,7 @@ - + @@ -244,7 +244,7 @@ - + @@ -261,7 +261,7 @@ - + @@ -285,7 +285,7 @@ - + @@ -302,7 +302,7 @@ - + @@ -345,10 +345,18 @@ - + + + + + + + + + @@ -375,7 +383,7 @@ - + diff --git a/BPASmartClient.ScreenSplitMeals/App.config b/BPASmartClient.ScreenSplitMeals/App.config index 3e5d6a52..09ca65fa 100644 --- a/BPASmartClient.ScreenSplitMeals/App.config +++ b/BPASmartClient.ScreenSplitMeals/App.config @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/BeDesignerSCADA/Converters/MathAbsConverter.cs b/BeDesignerSCADA/Converters/MathAbsConverter.cs new file mode 100644 index 00000000..4f4a2e01 --- /dev/null +++ b/BeDesignerSCADA/Converters/MathAbsConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace BeDesignerSCADA.Converters +{ + [ValueConversion(typeof(float), typeof(float))] + public class MathAbsConverter : IValueConverter + { + static MathAbsConverter() + { + Instance = new MathAbsConverter(); + } + + public static MathAbsConverter Instance + { + get; + private set; + } + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return Math.Abs((float)value); + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index 3b9a58cf..dbe281db 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -96,19 +96,19 @@ namespace BPASmartClient.DosingSystem ParSet.Add(new SubMenumodel() { - SubMenuName = "设备控制参数设置", + SubMenuName = "设备参数设置", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.DosingSystem", ToggleWindowPath = "View.CommParSetView" }); - ParSet.Add(new SubMenumodel() - { - SubMenuName = "出料口管理设置", - SubMenuPermission = new Permission[] { Permission.管理员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.OutletManagementView" - }); + //ParSet.Add(new SubMenumodel() + //{ + // SubMenuName = "出料口管理设置", + // SubMenuPermission = new Permission[] { Permission.管理员 }, + // AssemblyName = "BPASmartClient.DosingSystem", + // ToggleWindowPath = "View.OutletManagementView" + //}); MenuManage.GetInstance.menuModels.Add(new MenuModel() { @@ -186,13 +186,13 @@ namespace BPASmartClient.DosingSystem ToggleWindowPath = "Pages.View.DebugLogView" }); - InfoLog.Add(new SubMenumodel() - { - SubMenuName = "报表数据", - SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.ReportView" - }); + //InfoLog.Add(new SubMenumodel() + //{ + // SubMenuName = "报表数据", + // SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 }, + // AssemblyName = "BPASmartClient.CustomResource", + // ToggleWindowPath = "Pages.View.ReportView" + //}); MenuManage.GetInstance.menuModels.Add(new MenuModel() { @@ -255,13 +255,13 @@ namespace BPASmartClient.DosingSystem ToggleWindowPath = "Pages.View.UserManagerView" }); - UserManager.Add(new SubMenumodel() - { - SubMenuName = "NFC登录管理", - SubMenuPermission = new Permission[] { Permission.管理员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.NfcSetView" - }); + //UserManager.Add(new SubMenumodel() + //{ + // SubMenuName = "NFC登录管理", + // SubMenuPermission = new Permission[] { Permission.管理员 }, + // AssemblyName = "BPASmartClient.CustomResource", + // ToggleWindowPath = "Pages.View.NfcSetView" + //}); MenuManage.GetInstance.menuModels.Add(new MenuModel() { diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index 8d1787b0..869cb80f 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -114,7 +114,7 @@ namespace BPASmartClient.DosingSystem { if (!string.IsNullOrEmpty(Json.Data.BaseParModel.NetworkSegAddress)) IPSegment = Json.Data.BaseParModel.NetworkSegAddress; else Json.Data.BaseParModel.NetworkSegAddress = IPSegment; - //TestData(); + TestData(); IpAddressLines(); SiemensDevice.GetInstance.Connect(Json.Data.BaseParModel.DeviceAddress); DeviceDataInit(); @@ -197,12 +197,6 @@ namespace BPASmartClient.DosingSystem DeviceLists[ip].modbusTcp.IsReconnect = false; App.Current.Dispatcher.Invoke(new Action(() => { - //DeviceListViewModel.devices.Add(new Devices() - //{ - // DeviceName = DeviceName, - // IpAddress = ip - //});//加入连接的(有名称的)设备列表 - devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); if (TopDeviceCurrentStatuses.Count <= 7) @@ -244,20 +238,16 @@ namespace BPASmartClient.DosingSystem DS.modbusTcp.ConnectFail = new Action(() => { if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); - //MessageLog.GetInstance.ShowAlarmLog($"设备{ip}连接失败"); }); DS.modbusTcp.Disconnect = new Action(() => { if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip); - //var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); var res = devices.FirstOrDefault(P => P.IpAddress == ip); - //if (res != null && DeviceListViewModel.devices.Contains(res)) if (res != null && devices.Contains(res)) { App.Current.Dispatcher.Invoke(new Action(() => { - //DeviceListViewModel.devices.Remove(res); devices.Remove(res); var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName); if (item != null) Global.DeviceRawMaterials.Remove(item); @@ -307,7 +297,6 @@ namespace BPASmartClient.DosingSystem modbusTcp.ShowEx = new Action((s) => { MessageNotify.GetInstance.ShowRunLog(s); }); this.DeviceName = DeviceName; AlarmHelper.Init(); - if (modbusTcp.Connected) { ThreadManage.GetInstance().StartLong(new Action(() => @@ -353,6 +342,7 @@ namespace BPASmartClient.DosingSystem { modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量 modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 + MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}"); //配料设备参数写入 var res = Json.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); if (res != null) diff --git a/DosingSystem/View/CommParSetView.xaml b/DosingSystem/View/CommParSetView.xaml index e12528e4..7758d9d3 100644 --- a/DosingSystem/View/CommParSetView.xaml +++ b/DosingSystem/View/CommParSetView.xaml @@ -125,7 +125,10 @@ Text="{Binding CommBaseParModel.BlockCylinderCount, UpdateSourceTrigger=PropertyChanged}" /> - + @@ -146,7 +149,10 @@ Text="{Binding CommBaseParModel.PalletCylinderCount, UpdateSourceTrigger=PropertyChanged}" /> - + @@ -171,7 +177,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + Height="100" + Margin="0,0,0,15" + Background="Transparent"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DosingSystem/View/RecipeControlView.xaml b/DosingSystem/View/RecipeControlView.xaml index 752864c0..865f7c9f 100644 --- a/DosingSystem/View/RecipeControlView.xaml +++ b/DosingSystem/View/RecipeControlView.xaml @@ -880,7 +880,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" - Foreground="{Binding RecipStatus,Converter={StaticResource RecipeStatusConvert}}" + Foreground="{Binding RecipStatus, Converter={StaticResource RecipeStatusConvert}}" Text="{Binding RecipStatus}" /> + + + + - - + - + Stretch="Fill" />--> @@ -939,7 +942,9 @@ @@ -1011,6 +1016,27 @@ +