From e00fcfb97a742f4da76799283b6e266f286d6e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Mon, 4 Jul 2022 10:15:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.AGV/Feedback/AGVToUpSystem.cs | 31 +- .../Feedback/AGVToUpSystemBody.cs | 41 -- .../Feedback/Upstreamrequest.cs | 44 +- .../Feedback/UpstreamrequestBody.cs | 54 --- .../Pages/View/LoginView.xaml | 291 +------------- BPASmartClient.DosingSystem/App.xaml | 37 -- BPASmartClient.DosingSystem/App.xaml.cs | 188 --------- BPASmartClient.DosingSystem/AssemblyInfo.cs | 10 - .../BPASmartClient.DosingSystem.csproj | 28 -- .../Model/ActionMenu.cs | 28 -- .../Model/DeviceAddress.cs | 44 -- .../Model/DeviceInquire.cs | 221 ---------- BPASmartClient.DosingSystem/Model/LocaPar.cs | 15 - .../Model/RawMaterialDeviceStatus.cs | 45 --- .../Model/RawMaterialModel.cs | 88 ---- .../Model/RecipeModel.cs | 51 --- .../View/AlarmRecordView.xaml | 380 ------------------ .../View/AlarmRecordView.xaml.cs | 28 -- .../View/ChangeDeviceNameView.xaml | 122 ------ .../View/ChangeDeviceNameView.xaml.cs | 31 -- .../View/DeviceListView.xaml | 143 ------- .../View/DeviceListView.xaml.cs | 28 -- .../View/HardwareStatusView.xaml | 27 -- .../View/HardwareStatusView.xaml.cs | 28 -- .../View/MainWindow.xaml | 251 ------------ .../View/MainWindow.xaml.cs | 48 --- .../View/NewRecipeView.xaml | 222 ---------- .../View/NewRecipeView.xaml.cs | 32 -- .../View/RecipeControlView.xaml | 188 --------- .../View/RecipeControlView.xaml.cs | 28 -- .../View/RecipeSettingsView.xaml | 246 ------------ .../View/RecipeSettingsView.xaml.cs | 28 -- .../ViewModel/AlarmRecordViewModel.cs | 18 - .../ViewModel/ChangeDeviceNameViewModel.cs | 71 ---- .../ViewModel/DeviceListViewModel.cs | 45 --- .../ViewModel/HardwareStatusViewModel.cs | 18 - .../ViewModel/MainViewModel.cs | 161 -------- .../ViewModel/NewRecipeViewModel.cs | 131 ------ .../ViewModel/RecipeControlViewModel.cs | 92 ----- .../ViewModel/RecipeSettingsViewModel.cs | 63 --- BPASmartClient.DosingSystem/app.manifest | 79 ---- BPASmartClient.DosingSystem/hbl.ico | Bin 4286 -> 0 bytes FryPot_DosingSystem/App.xaml.cs | 30 +- .../Control/DosingLogicControl.cs | 38 +- FryPot_DosingSystem/View/MainWindow.xaml.cs | 2 +- HubHelper/HubHelper.cs | 7 - HubHelper/HubHelper.csproj | 9 - SmartClient.sln | 116 +++++- TestDemo/Form1.cs | 4 +- 49 files changed, 232 insertions(+), 3698 deletions(-) delete mode 100644 BPASmartClient.AGV/Feedback/AGVToUpSystemBody.cs delete mode 100644 BPASmartClient.AGV/Feedback/UpstreamrequestBody.cs delete mode 100644 BPASmartClient.DosingSystem/App.xaml delete mode 100644 BPASmartClient.DosingSystem/App.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/AssemblyInfo.cs delete mode 100644 BPASmartClient.DosingSystem/BPASmartClient.DosingSystem.csproj delete mode 100644 BPASmartClient.DosingSystem/Model/ActionMenu.cs delete mode 100644 BPASmartClient.DosingSystem/Model/DeviceAddress.cs delete mode 100644 BPASmartClient.DosingSystem/Model/DeviceInquire.cs delete mode 100644 BPASmartClient.DosingSystem/Model/LocaPar.cs delete mode 100644 BPASmartClient.DosingSystem/Model/RawMaterialDeviceStatus.cs delete mode 100644 BPASmartClient.DosingSystem/Model/RawMaterialModel.cs delete mode 100644 BPASmartClient.DosingSystem/Model/RecipeModel.cs delete mode 100644 BPASmartClient.DosingSystem/View/AlarmRecordView.xaml delete mode 100644 BPASmartClient.DosingSystem/View/AlarmRecordView.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/View/ChangeDeviceNameView.xaml delete mode 100644 BPASmartClient.DosingSystem/View/ChangeDeviceNameView.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/View/DeviceListView.xaml delete mode 100644 BPASmartClient.DosingSystem/View/DeviceListView.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/View/HardwareStatusView.xaml delete mode 100644 BPASmartClient.DosingSystem/View/HardwareStatusView.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/View/MainWindow.xaml delete mode 100644 BPASmartClient.DosingSystem/View/MainWindow.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/View/NewRecipeView.xaml delete mode 100644 BPASmartClient.DosingSystem/View/NewRecipeView.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/View/RecipeControlView.xaml delete mode 100644 BPASmartClient.DosingSystem/View/RecipeControlView.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/View/RecipeSettingsView.xaml delete mode 100644 BPASmartClient.DosingSystem/View/RecipeSettingsView.xaml.cs delete mode 100644 BPASmartClient.DosingSystem/ViewModel/AlarmRecordViewModel.cs delete mode 100644 BPASmartClient.DosingSystem/ViewModel/ChangeDeviceNameViewModel.cs delete mode 100644 BPASmartClient.DosingSystem/ViewModel/DeviceListViewModel.cs delete mode 100644 BPASmartClient.DosingSystem/ViewModel/HardwareStatusViewModel.cs delete mode 100644 BPASmartClient.DosingSystem/ViewModel/MainViewModel.cs delete mode 100644 BPASmartClient.DosingSystem/ViewModel/NewRecipeViewModel.cs delete mode 100644 BPASmartClient.DosingSystem/ViewModel/RecipeControlViewModel.cs delete mode 100644 BPASmartClient.DosingSystem/ViewModel/RecipeSettingsViewModel.cs delete mode 100644 BPASmartClient.DosingSystem/app.manifest delete mode 100644 BPASmartClient.DosingSystem/hbl.ico delete mode 100644 HubHelper/HubHelper.cs delete mode 100644 HubHelper/HubHelper.csproj diff --git a/BPASmartClient.AGV/Feedback/AGVToUpSystem.cs b/BPASmartClient.AGV/Feedback/AGVToUpSystem.cs index b3e33cd5..41315450 100644 --- a/BPASmartClient.AGV/Feedback/AGVToUpSystem.cs +++ b/BPASmartClient.AGV/Feedback/AGVToUpSystem.cs @@ -8,7 +8,34 @@ namespace BPASmartClient.AGV.Feedback { public class AGVToUpSystem { - public AGVUpReportHeader? head { get; set; } - public AGVToUpSystemBody? body { get; set; } + /// + /// 上游系统任务号,全局唯一 + /// + public string robotJobId { get; set; } + + /// + /// 仓库编号 + /// + public int warehouseId { get; set; } + + /// + /// 任务快仓系统编号 + /// + public string jobId { get; set; } + + /// + /// 任务状态 + /// + public string state { get; set; } + + /// + /// 内部任务类型 + /// + public string jobType { get; set; } + + /// + /// 数据字段 + /// + public JobData jobData { get; set; } = new JobData(); } } diff --git a/BPASmartClient.AGV/Feedback/AGVToUpSystemBody.cs b/BPASmartClient.AGV/Feedback/AGVToUpSystemBody.cs deleted file mode 100644 index f9e2f08f..00000000 --- a/BPASmartClient.AGV/Feedback/AGVToUpSystemBody.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.AGV.Feedback -{ - public class AGVToUpSystemBody - { - /// - /// 上游系统任务号,全局唯一 - /// - public string robotJobId { get; set; } - - /// - /// 仓库编号 - /// - public int warehouseId { get; set; } - - /// - /// 任务快仓系统编号 - /// - public string jobId { get; set; } - - /// - /// 任务状态 - /// - public string state { get; set; } - - /// - /// 内部任务类型 - /// - public string jobType { get; set; } - - /// - /// 数据字段 - /// - public JobData jobData { get; set; } = new JobData(); - } -} diff --git a/BPASmartClient.AGV/Feedback/Upstreamrequest.cs b/BPASmartClient.AGV/Feedback/Upstreamrequest.cs index e7850b83..411189a1 100644 --- a/BPASmartClient.AGV/Feedback/Upstreamrequest.cs +++ b/BPASmartClient.AGV/Feedback/Upstreamrequest.cs @@ -6,10 +6,48 @@ using System.Threading.Tasks; namespace BPASmartClient.AGV.Feedback { - public class UpStreamrequest + public class Upstreamrequest { - public AGVUpReportHeader? head { get; set; } + /// + /// AGV编号 + /// + public string agvCode { get; set; } - public UpstreamrequestBody? body { get; set; } + /// + /// 容器编号,如果一次上/下多个容器,则多个容器用英文逗号分隔 + /// + public string containerCode { get; set; } + + /// + /// 上游设备ID 本字段适用于只有一个辊筒设备的时候使用 + /// + public long equipmentId { get; set; } + + /// + /// 上游设备ID,多个用英文逗号分隔 本字段适用于多辊筒同时上下料的时候使用 + /// + public string equipmentIds { get; set; } + + /// + /// 快仓任务编号 + /// + public string jobId { get; set; } + + /// + /// 消息ID + /// + public string msgId { get; set; } + + /// + /// 交互阶段 + /// LOAD:上料阶段 + /// UNLOAD:下料阶段 + /// + public string command { get; set; } + + /// + /// 上游任务号 + /// + public string robotJobId { get; set; } } } diff --git a/BPASmartClient.AGV/Feedback/UpstreamrequestBody.cs b/BPASmartClient.AGV/Feedback/UpstreamrequestBody.cs deleted file mode 100644 index 79bd0184..00000000 --- a/BPASmartClient.AGV/Feedback/UpstreamrequestBody.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.AGV.Feedback -{ - public class UpstreamrequestBody - { - /// - /// AGV编号 - /// - public string agvCode { get; set; } - - /// - /// 容器编号,如果一次上/下多个容器,则多个容器用英文逗号分隔 - /// - public string containerCode { get; set; } - - /// - /// 上游设备ID 本字段适用于只有一个辊筒设备的时候使用 - /// - public long equipmentId { get; set; } - - /// - /// 上游设备ID,多个用英文逗号分隔 本字段适用于多辊筒同时上下料的时候使用 - /// - public string equipmentIds { get; set; } - - /// - /// 快仓任务编号 - /// - public string jobId { get; set; } - - /// - /// 消息ID - /// - public string msgId { get; set; } - - /// - /// 交互阶段 - /// LOAD:上料阶段 - /// UNLOAD:下料阶段 - /// - public string command { get; set; } - - /// - /// 上游任务号 - /// - public string robotJobId { get; set; } - - } -} diff --git a/BPASmartClient.CustomResource/Pages/View/LoginView.xaml b/BPASmartClient.CustomResource/Pages/View/LoginView.xaml index d4cf34ce..6ec02d16 100644 --- a/BPASmartClient.CustomResource/Pages/View/LoginView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/LoginView.xaml @@ -232,28 +232,6 @@ VerticalAlignment="Center" LoadedBehavior="Manual" /> - - @@ -279,10 +257,10 @@ Text="{Binding ErrorInfo}" /> @@ -337,271 +315,6 @@ TabIndex="3" /> - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BPASmartClient.DosingSystem/App.xaml b/BPASmartClient.DosingSystem/App.xaml deleted file mode 100644 index b4732c63..00000000 --- a/BPASmartClient.DosingSystem/App.xaml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BPASmartClient.DosingSystem/App.xaml.cs b/BPASmartClient.DosingSystem/App.xaml.cs deleted file mode 100644 index e590be97..00000000 --- a/BPASmartClient.DosingSystem/App.xaml.cs +++ /dev/null @@ -1,188 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; -using BPASmartClient.CustomResource.Pages.Enums; -using BPASmartClient.CustomResource.Pages.Model; -using BPASmartClient.CustomResource.Pages.View; -using BPASmartClient.DosingSystem.Model; -using BPASmartClient.DosingSystem.View; -using BPASmartClient.Helper; - -namespace BPASmartClient.DosingSystem -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - protected override void OnStartup(StartupEventArgs e) - { - base.OnStartup(e); - MenuInit(); - DataInit(); - - MainView mv = new MainView(); - LoginView lv = new LoginView(); - var res = lv.ShowDialog(); - if (res != null && res == true) - mv.Show(); - else - mv.Close(); - - - - //MainWindow mw = new MainWindow(); - //LoginView lv = new LoginView(); - //var res = lv.ShowDialog(); - //if (res != null && res == true) - // mw.Show(); - //else - // mw.Close(); - } - - protected override void OnExit(ExitEventArgs e) - { - base.OnExit(e); - Json.Save(); - MessageLog.GetInstance.LogSave(); - } - - private void MenuInit() - { - - #region 配方管理菜单 - ObservableCollection RecipeManage = new ObservableCollection(); - RecipeManage.Add(new SubMenumodel() - { - SubMenuName = "配方管理", - SubMenuPermission = new Permission[] { Permission.管理员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.RecipeSettingsView" - }); - - RecipeManage.Add(new SubMenumodel() - { - SubMenuName = "配方下发", - SubMenuPermission = new Permission[] { Permission.操作员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.RecipeControlView" - }); - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuName = "配方管理", - Alias = "Recipe Management", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员 }, - subMenumodels = RecipeManage, - }); - #endregion - - #region 消息日志 - ObservableCollection InfoLog = new ObservableCollection(); - InfoLog.Add(new SubMenumodel() - { - SubMenuName = "操作日志", - SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.UserLogView" - }); - - InfoLog.Add(new SubMenumodel() - { - SubMenuName = "运行日志", - SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.RunLogView" - }); - - InfoLog.Add(new SubMenumodel() - { - SubMenuName = "报警记录", - SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.AlarmView" - }); - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuName = "消息日志", - Alias = "Message Log", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - subMenumodels = InfoLog, - }); - #endregion - - #region 硬件设备监控 - ObservableCollection DeviceMonitor = new ObservableCollection(); - DeviceMonitor.Add(new SubMenumodel() - { - SubMenuName = "原料设备列表", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.DeviceListView" - }); - - DeviceMonitor.Add(new SubMenumodel() - { - SubMenuName = "设备状态", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.HardwareStatusView" - }); - - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuName = "设备监控", - Alias = "Device Monitor", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - subMenumodels = DeviceMonitor, - }); - #endregion - - #region 用户管理 - ObservableCollection UserManager = new ObservableCollection(); - UserManager.Add(new SubMenumodel() - { - SubMenuName = "用户登录", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.LoginView" - }); - - UserManager.Add(new SubMenumodel() - { - SubMenuName = "密码修改", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.PasswordChangeView" - }); - - - MenuManage.GetInstance.menuModels.Add(new MenuModel() - { - MainMenuIcon = "", - MainMenuName = "用户管理", - Alias = "User Management", - MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - subMenumodels = UserManager, - }); - #endregion - } - - private void DataInit() - { - Config.GetInstance.Init(); - Json.Read(); - } - - } -} diff --git a/BPASmartClient.DosingSystem/AssemblyInfo.cs b/BPASmartClient.DosingSystem/AssemblyInfo.cs deleted file mode 100644 index 8b5504ec..00000000 --- a/BPASmartClient.DosingSystem/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Windows; - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/BPASmartClient.DosingSystem/BPASmartClient.DosingSystem.csproj b/BPASmartClient.DosingSystem/BPASmartClient.DosingSystem.csproj deleted file mode 100644 index 37d3b321..00000000 --- a/BPASmartClient.DosingSystem/BPASmartClient.DosingSystem.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - app.manifest - hbl.ico - AnyCPU - - - - - - - - - - - - - - - - - - diff --git a/BPASmartClient.DosingSystem/Model/ActionMenu.cs b/BPASmartClient.DosingSystem/Model/ActionMenu.cs deleted file mode 100644 index 00113337..00000000 --- a/BPASmartClient.DosingSystem/Model/ActionMenu.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; -using Microsoft.Toolkit.Mvvm.Input; - -namespace BPASmartClient.DosingSystem.Model -{ - public class ActionMenu : ObservableObject - { - public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } } - private string _mCommandParameter; - - //public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } } - //private Permission[] _mpermission; - - public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } - private string _mMenuName; - - - //public string NameSpace { get { return _mNameSpace; } set { _mNameSpace = value; OnPropertyChanged(); } } - //private string _mNameSpace; - - - } -} diff --git a/BPASmartClient.DosingSystem/Model/DeviceAddress.cs b/BPASmartClient.DosingSystem/Model/DeviceAddress.cs deleted file mode 100644 index 7c57aaa8..00000000 --- a/BPASmartClient.DosingSystem/Model/DeviceAddress.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.DosingSystem.Model -{ - public class DeviceAddress - { - /// - /// 设备名称起始地址 - /// - public static string DeviceName { get; set; } = "LW0"; - - /// - /// 料仓重量反馈起始地址 - /// - public static string WeightFeedback { get; set; } = "LW204"; - - /// - /// 重量设置地址 - /// - public static string WeightSet { get; set; } = "LW200"; - - /// - /// 启动信号地址 - /// - public static string Start { get; set; } = "LW210"; - - /// - /// 下料重量反馈地址 - /// - public static string CutWeightFeedback { get; set; } = "LW202"; - - /// - /// 设备运行状态地址 - /// - public static string RunStatus { get; set; } = "LW206"; - } - - - -} diff --git a/BPASmartClient.DosingSystem/Model/DeviceInquire.cs b/BPASmartClient.DosingSystem/Model/DeviceInquire.cs deleted file mode 100644 index 181abeda..00000000 --- a/BPASmartClient.DosingSystem/Model/DeviceInquire.cs +++ /dev/null @@ -1,221 +0,0 @@ -using BPASmartClient.Helper; -using BPASmartClient.Message; -using BPASmartClient.Modbus; -using BPASmartClient.DosingSystem.ViewModel; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Net.NetworkInformation; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace BPASmartClient.DosingSystem.Model -{ - public class DeviceInquire - { - private volatile static DeviceInquire _Instance; - public static DeviceInquire GetInstance => _Instance ?? (_Instance = new DeviceInquire()); - private DeviceInquire() { } - - string IPSegment = "192.168.0."; - - ConcurrentDictionary DeviceLists = new ConcurrentDictionary(); - List InvalidIP = new List();//无效 IP 集合 - List IPLists = new List();//启动 Ping 任务IP集合 - ConcurrentQueue IPQueues = new ConcurrentQueue();//pincomplete 完成队列 - - public void Init() - { - IpAddressLines(); - ThreadManage.GetInstance().StartLong(new Action(() => - { - if (IPQueues.Count >= IPLists.Count) - IpAddressLines(); - Thread.Sleep(5000); - }), "配料机设备上线监听", true); - } - - public void Rescan() - { - InvalidIP.Clear(); - } - - public DeviceStatus GetDevice(string ip) - { - if (ip != null) - { - var res = DeviceLists.Values.FirstOrDefault(p => p.IpAddress == ip); - if (res != null) return res; - } - return new DeviceStatus(); - } - - private void IpAddressLines() - { - IPLists.Clear(); - IPQueues.Clear(); - for (int i = 1; i <= 255; i++) - { - if (!InvalidIP.Contains($"{IPSegment}{i}") && !DeviceLists.ContainsKey($"{IPSegment}{i}")) - { - IPLists.Add($"{IPSegment}{i}"); - } - } - - IPLists.ForEach((item) => - { - Ping myPing = new Ping(); - myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted); - myPing.SendAsync(item, 1000, null); - }); - } - - private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e) - { - if (e.Reply.Status == IPStatus.Success) - { - string ip = e.Reply.Address.ToString(); - if (!DeviceLists.ContainsKey(ip)) - { - DeviceStatus DS = new DeviceStatus(); - DS.modbusTcp.IsReconnect = false; - - DS.modbusTcp.ConnectOk = new Action(() => - { - string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20); - if (DeviceName.Length > 0) - { - DeviceLists.TryAdd(ip, DS); - DeviceLists[ip].Init(DeviceName); - DeviceLists[ip].modbusTcp.IsReconnect = false; - App.Current.Dispatcher.Invoke(new Action(() => - { - DeviceListViewModel.devices.Add(new Devices() - { - DeviceName = DeviceName, - IpAddress = ip - }); - - for (int i = 0; i < Json.Data.Recipes.Count; i++) - { - for (int m = 0; m < Json.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) - { - if (Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip) - { - Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; - } - } - } - - if (!NewRecipeViewModel.RawMaterialNames.Contains(DeviceName)) - NewRecipeViewModel.RawMaterialNames.Add(DeviceName); - - })); - } - else - { - if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); - } - }); - - DS.modbusTcp.ConnectFail = new Action(() => - { - if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); - MessageLog.GetInstance.Show($"{ip}连接失败"); - }); - - DS.modbusTcp.Disconnect = new Action(() => - { - if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip); - var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); - if (res != null && DeviceListViewModel.devices.Contains(res)) - App.Current.Dispatcher.Invoke(new Action(() => - { - DeviceListViewModel.devices.Remove(res); - if (!NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName)) - NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName); - })); - if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); - }); - - Task.Run(new Action(() => - { - DS.modbusTcp.ModbusTcpConnect(ip, 502); - IPQueues.Enqueue(e.Reply.Address.ToString()); - })); - } - else IPQueues.Enqueue(e.Reply.Address.ToString()); - } - else IPQueues.Enqueue(e.Reply.Address.ToString()); - } - } - - public class DeviceStatus - { - - #region 对象属性声明 - public string DeviceName = String.Empty; - public string IpAddress => modbusTcp.IPAdress; - - /// - /// 设备状态 - /// - public RawMaterialDeviceStatus deviceStatus { get; set; } = new RawMaterialDeviceStatus(); - - public ModbusTcp modbusTcp = new ModbusTcp(); - - public bool IsConnected => modbusTcp.Connected; - #endregion - - public void Init(string DeviceName) - { - this.DeviceName = DeviceName; - if (modbusTcp.Connected) - { - ThreadManage.GetInstance().StartLong(new Action(() => - { - //获取设备运行状态 - var res = this.modbusTcp.Read(DeviceAddress.RunStatus); - if (res != null && res is ushort[] ushortValue) - { - if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; - } - - //获取设备料仓剩余重量 - deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback) * 10; - - Thread.Sleep(100); - }), $"{DeviceName} 开始监听", true); - } - } - - public void SetDeviceName(string name) - { - this.modbusTcp.Write(DeviceAddress.DeviceName, new ushort[20]); - this.modbusTcp.SetString(DeviceAddress.DeviceName, name); - } - - public void StatusReset() - { - this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0); - } - - public void Dispose() - { - ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听"); - } - - public void Start(uint Value) - { - if (modbusTcp.Connected) - { - modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量 - modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 - } - } - } - -} diff --git a/BPASmartClient.DosingSystem/Model/LocaPar.cs b/BPASmartClient.DosingSystem/Model/LocaPar.cs deleted file mode 100644 index 31815e0c..00000000 --- a/BPASmartClient.DosingSystem/Model/LocaPar.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Collections.ObjectModel; -using BPASmartClient.DosingSystem.ViewModel; - -namespace BPASmartClient.DosingSystem.Model -{ - public class LocaPar - { - public ObservableCollection Recipes { get; set; } = new ObservableCollection(); - } -} diff --git a/BPASmartClient.DosingSystem/Model/RawMaterialDeviceStatus.cs b/BPASmartClient.DosingSystem/Model/RawMaterialDeviceStatus.cs deleted file mode 100644 index 1febc8a9..00000000 --- a/BPASmartClient.DosingSystem/Model/RawMaterialDeviceStatus.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.DosingSystem.Model -{ - public class RawMaterialDeviceStatus - { - - /// - /// 原料类型 - /// 1:液体 - /// 2:膏体 - /// 3:粉体 - /// - public ushort RawMaterialType { get; set; } - - /// - /// 料仓重量反馈 - /// - public float WeightFeedback { get; set; } - - /// - /// 上限反馈 - /// - public bool UpLimitFeedback { get; set; } - - /// - /// 下限反馈 - /// - public bool DownLimitFeedback { get; set; } - - /// - /// 下料重量反馈 - /// - public float CutWeightFeedback { get; set; } - - /// - /// 设备运行状态 - /// - public ushort RunStatus { get; set; } - } -} diff --git a/BPASmartClient.DosingSystem/Model/RawMaterialModel.cs b/BPASmartClient.DosingSystem/Model/RawMaterialModel.cs deleted file mode 100644 index 7b5f3eb5..00000000 --- a/BPASmartClient.DosingSystem/Model/RawMaterialModel.cs +++ /dev/null @@ -1,88 +0,0 @@ -using Microsoft.Toolkit.Mvvm.ComponentModel; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.DosingSystem.Model -{ - /// - /// 原料模块 - /// - public class RawMaterialModel : ObservableObject - { - /// - /// 原料名称 - /// - public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } - private string _mRawMaterialName; - - /// - /// 原料设备IP - /// - public string DeviceIp { get; set; } - - /// - /// 原料重量设置 - /// - public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } - private uint _mRawMaterialWeight; - - /// - /// 原料类型 MW18 - /// 1:液体 - /// 2:膏体 - /// 3:粉体 - /// - [Newtonsoft.Json.JsonIgnore] - public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } - private ushort _mRawMaterialType; - - /// - /// 料仓重量反馈 MD40 - /// - [Newtonsoft.Json.JsonIgnore] - public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } } - private float _mWeightFeedback; - - /// - /// 上限反馈 - /// - [Newtonsoft.Json.JsonIgnore] - public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } } - private bool _mUpLimtFeedback; - - /// - /// 下限反馈 - /// - [Newtonsoft.Json.JsonIgnore] - public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } } - private bool _mDownLimtFeedback; - - /// - /// 下料重量反馈 MD52 - /// - [Newtonsoft.Json.JsonIgnore] - public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } - private float _mUpLimtWeightFeedback; - - - /// - /// 原料ID - /// - public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } } - private string _mRawMaterialId; - - /// - /// 原料设备执行状态 - /// 1:空闲状态 - /// 2:下料中 - /// 3:下料完成 - /// - [Newtonsoft.Json.JsonIgnore] - public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } - private ushort _mRecipeStatus = 1; - - } -} diff --git a/BPASmartClient.DosingSystem/Model/RecipeModel.cs b/BPASmartClient.DosingSystem/Model/RecipeModel.cs deleted file mode 100644 index 203d4658..00000000 --- a/BPASmartClient.DosingSystem/Model/RecipeModel.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using BPASmartClient.DosingSystem.ViewModel; -using Microsoft.Toolkit.Mvvm.ComponentModel; - -namespace BPASmartClient.DosingSystem.Model -{ - /// - /// 配方模块 - /// - public class RecipeModel : ObservableObject - { - [Newtonsoft.Json.JsonIgnore] - public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } - private bool _mIsEnable = true; - - /// - /// 序号 - /// - public int SerialNum { get { return _mSerialNum; } set { _mSerialNum = value; OnPropertyChanged(); } } - private int _mSerialNum; - - /// - /// 配方名称 - /// - public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } - private string _mRecipeName; - - /// - /// 配方编码 - /// - public string RecipCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } - private string _mRecipCode; - - [Newtonsoft.Json.JsonIgnore] - public AutoResetEvent Are { get; set; } = new AutoResetEvent(false); - - /// - /// 原料集合 - /// - public ObservableCollection RawMaterials { get; set; } = new ObservableCollection(); - - - - } -} diff --git a/BPASmartClient.DosingSystem/View/AlarmRecordView.xaml b/BPASmartClient.DosingSystem/View/AlarmRecordView.xaml deleted file mode 100644 index bfdfa310..00000000 --- a/BPASmartClient.DosingSystem/View/AlarmRecordView.xaml +++ /dev/null @@ -1,380 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/BPASmartClient.DosingSystem/View/AlarmRecordView.xaml.cs b/BPASmartClient.DosingSystem/View/AlarmRecordView.xaml.cs deleted file mode 100644 index d30b0210..00000000 --- a/BPASmartClient.DosingSystem/View/AlarmRecordView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.DosingSystem.View -{ - /// - /// AlarmRecordView.xaml 的交互逻辑 - /// - public partial class AlarmRecordView : UserControl - { - public AlarmRecordView() - { - InitializeComponent(); - } - } -} diff --git a/BPASmartClient.DosingSystem/View/ChangeDeviceNameView.xaml b/BPASmartClient.DosingSystem/View/ChangeDeviceNameView.xaml deleted file mode 100644 index 5538aa49..00000000 --- a/BPASmartClient.DosingSystem/View/ChangeDeviceNameView.xaml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -