From a97d4951d23d67b1aaf1f562ccda7e1bad661e82 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: Thu, 15 Jun 2023 18:32:00 +0800 Subject: [PATCH] 1 --- BPASmartClient.Business/Plugin/ConfigMgr.cs | 5 +- BPASmartClient.Business/Plugin/DeviceMgr.cs | 5 +- BPASmartClient.Business/Plugin/OrderProxy.cs | 4 +- BPASmartClient.Business/Plugin/StatusMgr.cs | 6 +- .../Pages/Model/NfcServer.cs | 7 +- .../Pages/Model/VoiceAPI.cs | 1 + .../Pages/ViewModel/MainViewModel.cs | 46 ++--- .../Model/ViewModelBase.cs | 10 +- .../ViewModel/ChangeDeviceNameViewModel.cs | 4 +- .../ViewModel/CommparSetViewModel.cs | 4 +- .../ViewModel/DeviceListViewModel.cs | 4 +- .../ViewModel/DeviceMaterialParViewModel.cs | 12 +- .../ViewModel/HardwareStatusViewModel.cs | 8 +- .../ViewModel/ManualControlViewModel.cs | 16 +- .../ViewModel/NewMaterialViewModel.cs | 8 +- .../ViewModel/NewOutletViewModel.cs | 8 +- .../ViewModel/NewRecipeViewModel.cs | 12 +- .../ViewModel/OutletManagementViewModel.cs | 8 +- .../ViewModel/RecipeControlViewModel.cs | 12 +- .../ViewModel/RecipeSettingsViewModel.cs | 22 +-- BPASmartClient.Http/APIHelper.cs | 186 +++++++++--------- BPASmartClient.IoT/DataVClient.cs | 7 +- BPASmartClient.IoT/Model/DataVReport.cs | 6 +- BPASmartClient.IoT/Model/FileUpload.cs | 24 +-- BPASmartClient.IoT/Model/IOT/IOTDevServer.cs | 5 +- BPASmartClient.Model/LocaPath.cs | 29 +++ BPASmartClient.MorkM/Control_MORKM.cs | 13 +- BPASmartClient.MorkMV1/Control_MorkMV1.cs | 5 +- BPASmartClient.MorkMV1/DataServer.cs | 17 +- BPASmartClient.MorkMV1/GlobalUsing.cs | 3 - BPASmartClient.MorkMW/Control_MorkMW.cs | 2 +- BPASmartClient.MorkS/Control_Morks.cs | 3 +- BPASmartClient.MorkS/DataServer.cs | 16 +- .../Control_MorkSUpgradedVer.cs | 51 ++--- BPASmartClient.MorkSUpgradedVer/DataServer.cs | 16 +- .../GlobalUsing.cs | 3 - .../Control_MORKJC2.cs | 1 + BPASmartClient.MorkT/Control_MorkT.cs | 34 ++-- BPASmartClient.MorkTSingle/Control_MORKJC.cs | 20 +- .../Control_MorkT_BarCounter.cs | 55 +++--- .../Control_MorkT_Container.cs | 1 + BPASmartClient.MorkT_HQ/Control_MorkTHQ.cs | 58 +++--- .../Control_MORKJC.cs | 22 +-- .../CustomerControls/TheAPI.xaml.cs | 6 +- BPASmartClient.ScreenLib/Helper/Main.cs | 2 +- .../BPASmartClient.SerialPort.csproj | 2 +- BPASmartClient.ViewModel/AlarmViewModel.cs | 11 +- BPASmartClient.ViewModel/DataVViewModel.cs | 11 +- .../LogOrAlarmIOTViewModel.cs | 4 +- .../NewShopWindowModel.cs | 3 - .../OrderListDialogViewModel.cs | 29 ++- .../ShopDeviceConfigViewModel.cs | 10 +- BPASmartClient/Control/AdminstratorsView.xaml | 122 +++++++----- BPASmartClient/OrderListDialogView.xaml.cs | 17 +- DosingSystem/App.xaml.cs | 2 +- DosingSystem/Model/ViewModelBase.cs | 10 +- .../ViewModel/ChangeDeviceNameViewModel.cs | 4 +- DosingSystem/ViewModel/CommparSetViewModel.cs | 4 +- DosingSystem/ViewModel/DeviceListViewModel.cs | 4 +- .../ViewModel/DeviceMaterialParViewModel.cs | 12 +- .../ViewModel/HardwareStatusViewModel.cs | 8 +- .../ViewModel/ManualControlViewModel.cs | 16 +- .../ViewModel/NewMaterialViewModel.cs | 8 +- DosingSystem/ViewModel/NewOutletViewModel.cs | 8 +- DosingSystem/ViewModel/NewRecipeViewModel.cs | 12 +- .../ViewModel/OutletManagementViewModel.cs | 8 +- .../ViewModel/RecipeControlViewModel.cs | 12 +- .../ViewModel/RecipeSettingsViewModel.cs | 22 +-- TestDemo/Form1.cs | 2 +- 69 files changed, 611 insertions(+), 517 deletions(-) create mode 100644 BPASmartClient.Model/LocaPath.cs diff --git a/BPASmartClient.Business/Plugin/ConfigMgr.cs b/BPASmartClient.Business/Plugin/ConfigMgr.cs index 9686a1a6..208e9bc3 100644 --- a/BPASmartClient.Business/Plugin/ConfigMgr.cs +++ b/BPASmartClient.Business/Plugin/ConfigMgr.cs @@ -1,7 +1,6 @@ using BPA.ApolloClient; -using BPA.Message; using BPA.Helper; - + using BPASmartClient.Model; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; @@ -45,7 +44,7 @@ namespace BPASmartClient.Business public void Initialize() { var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig"); - string path = $"{LocaPath.GetInstance().GetDeviceConfigPath}{text}.json"; + string path = $"{LocaPath.GetDeviceConfigPath}{text}.json"; if (File.Exists(path)) { string JsonString = File.ReadAllText(path); diff --git a/BPASmartClient.Business/Plugin/DeviceMgr.cs b/BPASmartClient.Business/Plugin/DeviceMgr.cs index e943ee05..c3bc92cb 100644 --- a/BPASmartClient.Business/Plugin/DeviceMgr.cs +++ b/BPASmartClient.Business/Plugin/DeviceMgr.cs @@ -2,8 +2,7 @@ using BPASmartClient.Device; using BPA.Helper; -using BPASmartClient.Http; - + using BPASmartClient.Model; using BPASmartClient.Model.小炒机; using BPASmartClient.Model.调酒机; @@ -105,7 +104,7 @@ namespace BPASmartClient.Business var jsondata = new { clientId, PushType }; string header = $"[/stock/GetItemInfo]_[{DateTime.Now.Ticks}]".AESEncrypt(); string url = $"{InternetInfo.StockServer}GetItemInfo"; - result = APIHelper.GetInstance.HttpRequest(url, header, jsondata, RequestType.POST); + result = APIHelper.GetInstance.HttpRequest(url, jsondata, header, RequestType.POST); if (PushType == 1) { diff --git a/BPASmartClient.Business/Plugin/OrderProxy.cs b/BPASmartClient.Business/Plugin/OrderProxy.cs index f23a5761..59459893 100644 --- a/BPASmartClient.Business/Plugin/OrderProxy.cs +++ b/BPASmartClient.Business/Plugin/OrderProxy.cs @@ -5,7 +5,7 @@ using BPA.Models; using BPASmartClient.Device; using BPA.Helper; -using BPASmartClient.Http; + using BPASmartClient.Model; using BPASmartClient.Model.小炒机; @@ -186,7 +186,7 @@ namespace BPASmartClient.Business { string header = $"[{InternetInfo.OrderServer}/order/robotstatuschange]_[{DateTime.Now.Ticks}]".AESEncrypt(); string url = $"{InternetInfo.OrderServer}order/robotstatuschange"; - result = APIHelper.GetInstance.HttpRequest(url, header, orderStatusChange, RequestType.POST); + result = APIHelper.GetInstance.HttpRequest(url, orderStatusChange, header, RequestType.POST); } catch (Exception ex) { diff --git a/BPASmartClient.Business/Plugin/StatusMgr.cs b/BPASmartClient.Business/Plugin/StatusMgr.cs index e2ad2522..fcdee593 100644 --- a/BPASmartClient.Business/Plugin/StatusMgr.cs +++ b/BPASmartClient.Business/Plugin/StatusMgr.cs @@ -44,7 +44,7 @@ namespace BPASmartClient.Business } Thread.Sleep(50); } - }, "设备状态收集", true); + }, "设备状态收集", isRestart: true); deviceStatus.BatchingInfo = new List(); @@ -59,13 +59,13 @@ namespace BPASmartClient.Business deviceStatus.Healthy = device.IsHealth ? BPA.Message.Enum.DeviceHealthy.Health : BPA.Message.Enum.DeviceHealthy.UnHealth; deviceStatus.DeviceType = device.DeviceType; - deviceStatus.BatchingInfo = device.BatchingInfos; + deviceStatus.BatchingInfo = device.BatchingInfos; var msg = BPAPackage.Make(deviceStatus, device.DeviceId, device.DeviceType); mqttMgr.Publish(TopicDefine.GetInstance().PushHeartbeatTopics[device.DeviceType], msg.Serialize()); } Thread.Sleep(1000); } - }, "设备心跳上报", true); + }, "设备心跳上报", isRestart: true); } public void Dispose() diff --git a/BPASmartClient.CustomResource/Pages/Model/NfcServer.cs b/BPASmartClient.CustomResource/Pages/Model/NfcServer.cs index c6f7e40d..104b687b 100644 --- a/BPASmartClient.CustomResource/Pages/Model/NfcServer.cs +++ b/BPASmartClient.CustomResource/Pages/Model/NfcServer.cs @@ -1,4 +1,5 @@ -using BPASmartClient.CustomResource.Pages.ViewModel; +using BPA.Helper; +using BPASmartClient.CustomResource.Pages.ViewModel; using BPASmartClient.Nfc; using System; using System.Collections.Generic; @@ -28,10 +29,10 @@ namespace BPASmartClient.CustomResource.Pages.Model if (NFCHelper.GetInstance.GetReadResult?.CardNum.Length > 0) { string id = NFCHelper.GetInstance.GetReadResult?.CardNum; - var res = Global.userManager.userInfos.FirstOrDefault(p => p.CardId == id) ; + var res = Global.userManager.userInfos.FirstOrDefault(p => p.CardId == id); if (res != null) { - BPASmartClient.Message.MessageLog.GetInstance.ShowDebugLog("NFC卡登录"); + MessageLog.GetInstance.Show("NFC卡登录"); LoginViewModel.NfcLogin(id); } } diff --git a/BPASmartClient.CustomResource/Pages/Model/VoiceAPI.cs b/BPASmartClient.CustomResource/Pages/Model/VoiceAPI.cs index 06e910fc..a669cccd 100644 --- a/BPASmartClient.CustomResource/Pages/Model/VoiceAPI.cs +++ b/BPASmartClient.CustomResource/Pages/Model/VoiceAPI.cs @@ -1,4 +1,5 @@  +using BPA.Helper; using System; using System.Collections.Concurrent; using System.Collections.Generic; diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs index 09eed3ef..378cb5f2 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs @@ -12,7 +12,7 @@ using BPASmartClient.CustomResource.Pages.Model; using BPA.Helper; using BPASmartClient.Model; using BPA.Helper; - + namespace BPASmartClient.CustomResource.Pages.ViewModel { @@ -21,24 +21,24 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel public MainViewModel() { NavChangedCommand = new BPARelayCommand(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); - }); - }); + 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) => + MessageLog.GetInstance.ExInfoNotify = new Action((o) => { Application.Current?.Dispatcher?.Invoke(() => { @@ -98,9 +98,9 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel ActionManage.GetInstance.Register(new Action((c) => { - if(c!=null) - IsAlarm = Convert.ToBoolean(c); - }),"HeartBeatCheck"); + if (c != null) + IsAlarm = Convert.ToBoolean(c); + }), "HeartBeatCheck"); } private void PermissionChange() @@ -160,14 +160,14 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel OnPropertyChanged(); } } - private bool _isAlarm=true; + private bool _isAlarm = true; /// /// 心跳检测报警 /// public bool IsAlarm { get { return _isAlarm; } - set { _isAlarm = value;OnPropertyChanged(); } + set { _isAlarm = value; OnPropertyChanged(); } } /// /// 开机自启 diff --git a/BPASmartClient.DosingSystemSingle/Model/ViewModelBase.cs b/BPASmartClient.DosingSystemSingle/Model/ViewModelBase.cs index e93d4861..797a183a 100644 --- a/BPASmartClient.DosingSystemSingle/Model/ViewModelBase.cs +++ b/BPASmartClient.DosingSystemSingle/Model/ViewModelBase.cs @@ -12,11 +12,11 @@ namespace BPASmartClient.DosingSystemSingle public class ViewModelBase : NotifyBase { public int Index { get; set; } = -1; - public BPABPARelayCommand AddCommand { get; set; }//添加 - public BPABPARelayCommand CancelCommand { get; set; }//取消 - public BPABPARelayCommand SaveCommand { get; set; }//保存 - public BPABPARelayCommand RemoveCommand { get; set; }//移除 - public BPABPARelayCommand DetailsCommand { get; set; }//编辑 + public BPARelayCommand AddCommand { get; set; }//添加 + public BPARelayCommand CancelCommand { get; set; }//取消 + public BPARelayCommand SaveCommand { get; set; }//保存 + public BPARelayCommand RemoveCommand { get; set; }//移除 + public BPARelayCommand DetailsCommand { get; set; }//编辑 /// /// 错误信息 diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/ChangeDeviceNameViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/ChangeDeviceNameViewModel.cs index dd56510d..9f615e03 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/ChangeDeviceNameViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/ChangeDeviceNameViewModel.cs @@ -17,8 +17,8 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel if (o != null && o is string str) IpAddress = str; }), "ChangeDeviceNameViewOpen"); - CancelCommand = new BPABPARelayCommand(() => { ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); }); - AddCommand = new BPABPARelayCommand(() => + CancelCommand = new BPARelayCommand(() => { ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); }); + AddCommand = new BPARelayCommand(() => { if (string.IsNullOrEmpty(DeviceName)) { diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/CommparSetViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/CommparSetViewModel.cs index 6360eab2..4a7a55d1 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/CommparSetViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/CommparSetViewModel.cs @@ -14,7 +14,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel { public CommparSetViewModel() { - SaveCommand = new BPABPARelayCommand(() => + SaveCommand = new BPARelayCommand(() => { if (!string.IsNullOrEmpty(CommBaseParModel.NetworkSegAddress)) { @@ -38,7 +38,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel public BasePar CommBaseParModel { get { return Json.Data.BaseParModel; } set { Json.Data.BaseParModel = value; OnPropertyChanged(); } } //private BasePar _mCommBaseParModel; - public BPABPARelayCommand SaveCommand { get; set; } + public BPARelayCommand SaveCommand { get; set; } } } diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/DeviceListViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/DeviceListViewModel.cs index b30a4e3a..56027426 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/DeviceListViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/DeviceListViewModel.cs @@ -16,7 +16,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel { public DeviceListViewModel() { - DetailsCommand = new BPABPARelayCommand((o) => + DetailsCommand = new BPARelayCommand((o) => { if (o != null && o is string str) { @@ -28,7 +28,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel devices = DeviceInquire.GetInstance.devices; } - //public BPABPARelayCommand ChangeNameCommand { get; set; } + //public BPARelayCommand ChangeNameCommand { get; set; } //public static ObservableCollection devices { get; set; } = new ObservableCollection(); public ObservableCollection devices { get; set; } diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/DeviceMaterialParViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/DeviceMaterialParViewModel.cs index 89889f0b..5837d6ff 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/DeviceMaterialParViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/DeviceMaterialParViewModel.cs @@ -16,15 +16,15 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel public DeviceMaterialParViewModel() { deviceParModels = Json.Data.deviceParModels; - RemoveCommand = new BPABPARelayCommand((o) => + RemoveCommand = new BPARelayCommand((o) => { var res = deviceParModels.FirstOrDefault(p => p.MaterialName == o?.ToString()); if (res != null) deviceParModels.Remove(res); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{o.ToString()}:原料删除成功!"); }); - AddCommand = new BPABPARelayCommand(() => { deviceParModels.Add(new DeviceParModel()); }); - SaveCommand = new BPABPARelayCommand(() => + AddCommand = new BPARelayCommand(() => { deviceParModels.Add(new DeviceParModel()); }); + SaveCommand = new BPARelayCommand(() => { if (deviceParModels == null || deviceParModels.Count <= 0) { @@ -57,10 +57,10 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel public ObservableCollection deviceParModels { get; set; } - //public BPABPARelayCommand RemoveCommand { get; set; } + //public BPARelayCommand RemoveCommand { get; set; } - //public BPABPARelayCommand AddCommand { get; set; } - //public BPABPARelayCommand SaveCommand { get; set; } + //public BPARelayCommand AddCommand { get; set; } + //public BPARelayCommand SaveCommand { get; set; } } } diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/HardwareStatusViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/HardwareStatusViewModel.cs index 137a558c..1d01dfd5 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/HardwareStatusViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/HardwareStatusViewModel.cs @@ -23,7 +23,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel // ConveyerBeltModels.Add(new ConveyerBeltModel() { Name = $"输送带{i}", Num = i++ }); //} - //ConveyerBeltControlCommand = new BPABPARelayCommand(o => + //ConveyerBeltControlCommand = new BPARelayCommand(o => //{ // if (o != null && o is int tempCount) // { @@ -62,7 +62,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel Thread.Sleep(100); }), "输送带料仓状态监控"); - RecipeControlCommand = new BPABPARelayCommand((o) => + RecipeControlCommand = new BPARelayCommand((o) => { if (o != null && o is DeviceCurrentStatus currentStatus) { @@ -109,9 +109,9 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel public ObservableCollection ConveyerBeltModels { get; set; } = new ObservableCollection(); - public BPABPARelayCommand ConveyerBeltControlCommand { get; set; } + public BPARelayCommand ConveyerBeltControlCommand { get; set; } - public BPABPARelayCommand RecipeControlCommand { get; set; } + public BPARelayCommand RecipeControlCommand { get; set; } /// /// 输送带状态 diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/ManualControlViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/ManualControlViewModel.cs index 29144113..c0a5ebb1 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/ManualControlViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/ManualControlViewModel.cs @@ -51,7 +51,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel OtherHandCylinders.Add(new CylinderModel() { Name = "上桶工位气缸" }); OtherHandCylinders.Add(new CylinderModel() { Name = "下桶工位气缸" }); - Open = new BPABPARelayCommand((o) => + Open = new BPARelayCommand((o) => { if (o != null) { @@ -76,7 +76,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel }); - Close = new BPABPARelayCommand((o) => + Close = new BPARelayCommand((o) => { if (o != null) { @@ -100,13 +100,13 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel } }); - SystemStart = new BPABPARelayCommand(() => + SystemStart = new BPARelayCommand(() => { SiemensDevice.GetInstance.MySiemens.Write("M10.0", SystemControlText == "停止" ? false : true); /*var res = SiemensDevice.GetInstance.MySiemens.Read("M10.0"); SystemControlText = res ? "停止" : "启动";*/ }); - ModelSwitch = new BPABPARelayCommand(() => + ModelSwitch = new BPARelayCommand(() => { SiemensDevice.GetInstance.MySiemens.Write("M10.1", ModelSwitchText == "手动" ? true : false); /*var res = SiemensDevice.GetInstance.MySiemens.Read("M10.1"); @@ -166,12 +166,12 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel /// public ObservableCollection OtherHandCylinders { get; set; } = new ObservableCollection(); - public BPABPARelayCommand Open { get; set; } + public BPARelayCommand Open { get; set; } - public BPABPARelayCommand Close { get; set; } + public BPARelayCommand Close { get; set; } - public BPABPARelayCommand SystemStart { get; set; } - public BPABPARelayCommand ModelSwitch { get; set; } + public BPARelayCommand SystemStart { get; set; } + public BPARelayCommand ModelSwitch { get; set; } public string SystemControlText { get { return _mSystemControlText; } set { _mSystemControlText = value; OnPropertyChanged(); } } diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/NewMaterialViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/NewMaterialViewModel.cs index 999efd8d..9e885a16 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/NewMaterialViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/NewMaterialViewModel.cs @@ -22,9 +22,9 @@ public class NewMaterialViewModel : ViewModelBase //public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } //private string _mErrorInfo; - //public BPABPARelayCommand RemoveCommand { get; set; } + //public BPARelayCommand RemoveCommand { get; set; } - //public BPABPARelayCommand SaveCommand { get; set; } + //public BPARelayCommand SaveCommand { get; set; } @@ -42,9 +42,9 @@ public class NewMaterialViewModel : ViewModelBase public NewMaterialViewModel() { - RemoveCommand = new BPABPARelayCommand(Remove); + RemoveCommand = new BPARelayCommand(Remove); - SaveCommand = new BPABPARelayCommand(() => + SaveCommand = new BPARelayCommand(() => { if (MaterialName == String.Empty) { ErrorInfo = "原料名称不能为空"; return; } if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == MaterialName) != null) { ErrorInfo = "设备中已存在该原料名称"; return; } diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/NewOutletViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/NewOutletViewModel.cs index b45c974b..8f888131 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/NewOutletViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/NewOutletViewModel.cs @@ -29,9 +29,9 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel Index = Array.FindIndex(Json.Data.OutletInfoModels.ToArray(), p => p.OutletName == tempOutletInfo.OutletName); } }), "OpenNewOutlet", true); - AddCommand = new BPABPARelayCommand(() => { SiloInfos.Add(new RawMaterialInfo()); }); - CancelCommand = new BPABPARelayCommand(() => { ActionManage.GetInstance.Send("NewOutletViewClose"); }); - SaveCommand = new BPABPARelayCommand(() => + AddCommand = new BPARelayCommand(() => { SiloInfos.Add(new RawMaterialInfo()); }); + CancelCommand = new BPARelayCommand(() => { ActionManage.GetInstance.Send("NewOutletViewClose"); }); + SaveCommand = new BPARelayCommand(() => { ObservableCollection SileNames = new ObservableCollection(); SiloInfos.ToList()?.ForEach(item => { SileNames.Add(item.RawMaterialName); }); @@ -82,7 +82,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel } ActionManage.GetInstance.Send("NewOutletViewClose"); }); - RemoveCommand = new BPABPARelayCommand((o) => + RemoveCommand = new BPARelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/NewRecipeViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/NewRecipeViewModel.cs index 33054929..a0b6503d 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/NewRecipeViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/NewRecipeViewModel.cs @@ -41,7 +41,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel } }), "Details", true); - AddCommand = new BPABPARelayCommand(() => + AddCommand = new BPARelayCommand(() => { if (RawMaterials.Count >= DeviceInquire.GetInstance.devices.Count) { @@ -62,7 +62,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel else goto p; }); - RemoveCommand = new BPABPARelayCommand((obj) => + RemoveCommand = new BPARelayCommand((obj) => { if (obj is string rm) { @@ -71,7 +71,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel } }); - SaveCommand = new BPABPARelayCommand(() => + SaveCommand = new BPARelayCommand(() => { if (string.IsNullOrEmpty(RecipeName)) { MessageNotify.GetInstance.ShowDialog("请输入配方名称!", DialogType.Warning); ErrorInfo = "请输入配方名称"; return; } var tempRes = RawMaterials.GroupBy(p => p.RawMaterialName); @@ -196,11 +196,11 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel //public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } //private string _mErrorInfo; - //public BPABPARelayCommand AddCommand { get; set; } + //public BPARelayCommand AddCommand { get; set; } - //public BPABPARelayCommand RemoveCommand { get; set; } + //public BPARelayCommand RemoveCommand { get; set; } - //public BPABPARelayCommand SaveCommand { get; set; } + //public BPARelayCommand SaveCommand { get; set; } public ObservableCollection RawMaterials { get; set; } = new ObservableCollection(); diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/OutletManagementViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/OutletManagementViewModel.cs index 94620375..f46b8598 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/OutletManagementViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/OutletManagementViewModel.cs @@ -14,14 +14,14 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel { public OutletManagementViewModel() { - AddCommand = new BPABPARelayCommand(() => + AddCommand = new BPARelayCommand(() => { NewOutletView newOutletView = new NewOutletView(); newOutletView.ShowDialog(); }); - SaveCommand = new BPABPARelayCommand(() => { Json.Save(); }); + SaveCommand = new BPARelayCommand(() => { Json.Save(); }); OutletInfoModels = Json.Data.OutletInfoModels; - RemoveCommand = new BPABPARelayCommand((o) => + RemoveCommand = new BPARelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { @@ -34,7 +34,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel } }); - DetailsCommand = new BPABPARelayCommand((o) => + DetailsCommand = new BPARelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/RecipeControlViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/RecipeControlViewModel.cs index e5b43f13..6d0b2869 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/RecipeControlViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/RecipeControlViewModel.cs @@ -26,9 +26,9 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel static ObservableCollection RawMaterialReset = new ObservableCollection(); public RecipeControlViewModel() { - StartCommand = new BPABPARelayCommand(RecipeIssued); - ChangeRecipeStateCommand = new BPABPARelayCommand(ChangeRecipeState); - CancelRecipeCommand = new BPABPARelayCommand(CancelRecipe); + StartCommand = new BPARelayCommand(RecipeIssued); + ChangeRecipeStateCommand = new BPARelayCommand(ChangeRecipeState); + CancelRecipeCommand = new BPARelayCommand(CancelRecipe); RecipeRun(); RecipeStatusInquire(); } @@ -247,11 +247,11 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel }), "RecipeControlViewModelStatusInquire"); } - public BPABPARelayCommand StartCommand { get; set; } + public BPARelayCommand StartCommand { get; set; } - public BPABPARelayCommand ChangeRecipeStateCommand { get; set; } + public BPARelayCommand ChangeRecipeStateCommand { get; set; } - public BPABPARelayCommand CancelRecipeCommand { get; set; } + public BPARelayCommand CancelRecipeCommand { get; set; } public static ObservableCollection Recipes { get; set; } = Json.Data.Recipes; diff --git a/BPASmartClient.DosingSystemSingle/ViewModel/RecipeSettingsViewModel.cs b/BPASmartClient.DosingSystemSingle/ViewModel/RecipeSettingsViewModel.cs index a8e5b66d..1c6d7519 100644 --- a/BPASmartClient.DosingSystemSingle/ViewModel/RecipeSettingsViewModel.cs +++ b/BPASmartClient.DosingSystemSingle/ViewModel/RecipeSettingsViewModel.cs @@ -26,24 +26,24 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel { Recipes = Json.Data.Recipes; - NewMaterital = new BPABPARelayCommand(() => + NewMaterital = new BPARelayCommand(() => { NewMaterialView newMateritalView = new NewMaterialView(); newMateritalView.ShowDialog(); }); - NewRecipe = new BPABPARelayCommand(() => + NewRecipe = new BPARelayCommand(() => { NewRecipeView nrv = new NewRecipeView(); nrv.ShowDialog(); MessageNotify.GetInstance.ShowUserLog("新建配方"); }); - SaveRecipe = new BPABPARelayCommand(() => + SaveRecipe = new BPARelayCommand(() => { Json.Save(); MessageNotify.GetInstance.ShowUserLog("保存配方"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!"); }); - RemoveCommand = new BPABPARelayCommand((o) => + RemoveCommand = new BPARelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { @@ -65,7 +65,7 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel } }); - DetailsCommand = new BPABPARelayCommand((o) => + DetailsCommand = new BPARelayCommand((o) => { if (!string.IsNullOrEmpty(o?.ToString())) { @@ -82,17 +82,17 @@ namespace BPASmartClient.DosingSystemSingle.ViewModel } - public BPABPARelayCommand NewMaterital { get; set; } + public BPARelayCommand NewMaterital { get; set; } - public BPABPARelayCommand NewRecipe { get; set; } + public BPARelayCommand NewRecipe { get; set; } - public BPABPARelayCommand SaveRecipe { get; set; } + public BPARelayCommand SaveRecipe { get; set; } - public BPABPARelayCommand EditCommand { get; set; } + public BPARelayCommand EditCommand { get; set; } - public BPABPARelayCommand DetailsCommand { get; set; } + public BPARelayCommand DetailsCommand { get; set; } - public BPABPARelayCommand RemoveCommand { get; set; } + public BPARelayCommand RemoveCommand { get; set; } public ObservableCollection Recipes { get; set; } } diff --git a/BPASmartClient.Http/APIHelper.cs b/BPASmartClient.Http/APIHelper.cs index ae51dca4..9dccf787 100644 --- a/BPASmartClient.Http/APIHelper.cs +++ b/BPASmartClient.Http/APIHelper.cs @@ -1,101 +1,101 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; -using System.Web; -using Newtonsoft.Json; -using System.Net.Http; +//using Newtonsoft.Json.Linq; +//using System; +//using System.Collections.Generic; +//using System.IO; +//using System.Linq; +//using System.Net; +//using System.Text; +//using System.Threading.Tasks; +//using System.Web; +//using Newtonsoft.Json; +//using System.Net.Http; -namespace BPASmartClient.Http -{ - public class APIHelper - { +//namespace BPASmartClient.Http +//{ +// public class APIHelper +// { - private volatile static APIHelper _Instance; - public static APIHelper GetInstance => _Instance ?? (_Instance = new APIHelper()); - private APIHelper() { } +// private volatile static APIHelper _Instance; +// public static APIHelper GetInstance => _Instance ?? (_Instance = new APIHelper()); +// private APIHelper() { } - /// - /// POST 数据请求 - /// - /// 地址 - /// 参数数据 - /// 请求头 - /// - public string PostData(string url, string data, string head) - { - byte[] b = Encoding.UTF8.GetBytes(data);//把字符串转换为二进制 - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); - request.Proxy = null; - request.ContentType = "application/json"; - request.Method = "POST"; //设置请求方法 - request.ContentLength = b.Length; //设置长度 - request.Headers["Authorize"] = head; - Stream postStream = request.GetRequestStream(); //requst流 - postStream.Write(b, 0, b.Length); //写入POST数据,二进制类型的 - postStream.Close(); //关闭 - HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //获取response - Stream stream = response.GetResponseStream(); // 得到response响应流 - StreamReader sr = new StreamReader(stream); - string str = sr.ReadToEnd(); //读取流 +// /// +// /// POST 数据请求 +// /// +// /// 地址 +// /// 参数数据 +// /// 请求头 +// /// +// public string PostData(string url, string data, string head) +// { +// byte[] b = Encoding.UTF8.GetBytes(data);//把字符串转换为二进制 +// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); +// request.Proxy = null; +// request.ContentType = "application/json"; +// request.Method = "POST"; //设置请求方法 +// request.ContentLength = b.Length; //设置长度 +// request.Headers["Authorize"] = head; +// Stream postStream = request.GetRequestStream(); //requst流 +// postStream.Write(b, 0, b.Length); //写入POST数据,二进制类型的 +// postStream.Close(); //关闭 +// HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //获取response +// Stream stream = response.GetResponseStream(); // 得到response响应流 +// StreamReader sr = new StreamReader(stream); +// string str = sr.ReadToEnd(); //读取流 - sr.Close(); - stream.Close(); - return str; - } +// sr.Close(); +// stream.Close(); +// return str; +// } - public string GetData(string url, string head) - { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); - request.Method = "GET"; - request.Accept = "text/html, application/xhtml+xml, */*"; - request.ContentType = "application/json"; - request.Headers["Authorize"] = head; - byte[] buffer = Encoding.UTF8.GetBytes(head); - request.ContentLength = buffer.Length; - request.GetRequestStream().Write(buffer, 0, buffer.Length); - HttpWebResponse response = (HttpWebResponse)request.GetResponse(); - using (StreamReader myStreamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) - { - return myStreamReader.ReadToEnd(); - } - } +// public string GetData(string url, string head) +// { +// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); +// request.Method = "GET"; +// request.Accept = "text/html, application/xhtml+xml, */*"; +// request.ContentType = "application/json"; +// request.Headers["Authorize"] = head; +// byte[] buffer = Encoding.UTF8.GetBytes(head); +// request.ContentLength = buffer.Length; +// request.GetRequestStream().Write(buffer, 0, buffer.Length); +// HttpWebResponse response = (HttpWebResponse)request.GetResponse(); +// using (StreamReader myStreamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) +// { +// return myStreamReader.ReadToEnd(); +// } +// } - public string HttpRequest(string url, string head, object data, RequestType requestType) - { - if (requestType == RequestType.POST) - { - return PostData(url, JsonConvert.SerializeObject(data), head); - } - else - { - StringBuilder sb = new StringBuilder(); - sb.Append("?"); - foreach (System.Reflection.PropertyInfo p in data.GetType().GetProperties()) - { - if (sb.ToString().Last() != '?') - { - sb.Append("&"); - } - sb.Append(p.Name); - sb.Append("="); - sb.Append(p.GetValue(data)); - } - return GetData(url + sb.ToString(), head); - } - } +// public string HttpRequest(string url, string head, object data, RequestType requestType) +// { +// if (requestType == RequestType.POST) +// { +// return PostData(url, JsonConvert.SerializeObject(data), head); +// } +// else +// { +// StringBuilder sb = new StringBuilder(); +// sb.Append("?"); +// foreach (System.Reflection.PropertyInfo p in data.GetType().GetProperties()) +// { +// if (sb.ToString().Last() != '?') +// { +// sb.Append("&"); +// } +// sb.Append(p.Name); +// sb.Append("="); +// sb.Append(p.GetValue(data)); +// } +// return GetData(url + sb.ToString(), head); +// } +// } - } +// } - public enum RequestType - { - POST, - PUT, - DELETE, - GET - } -} +// public enum RequestType +// { +// POST, +// PUT, +// DELETE, +// GET +// } +//} diff --git a/BPASmartClient.IoT/DataVClient.cs b/BPASmartClient.IoT/DataVClient.cs index a6ed1064..86612fb7 100644 --- a/BPASmartClient.IoT/DataVClient.cs +++ b/BPASmartClient.IoT/DataVClient.cs @@ -5,7 +5,7 @@ using BPASmartClient.Business; using BPASmartClient.Device; using BPA.Helper; using BPASmartClient.IoT.Model; - + using BPASmartDatavDeviceClient.IoT; using System; using System.Collections.Generic; @@ -100,7 +100,8 @@ namespace BPASmartClient.IoT if (DeviceDataV != null && DeviceDataV.GetIsConnected() && DeviceDataV.deviceTable != null) { string api = DataVApiAddress + "/api/Device/FlushedDevice"; - HttpRequestHelper.HttpGetRequest(api, 1000); + // APIHelper.GetInstance.GetRequest(api, 1000); + APIHelper.GetInstance.GetRequest(api); //DeviceDataV.IOT_Publish(BroadcastPubTopic, Tools.JsonConvertTools("刷新店铺列表")); } } @@ -212,7 +213,7 @@ namespace BPASmartClient.IoT } }); } - if (DeviceDataV.Initialize(DataVApiAddress, ClientId, ListDeviceId.Count==0?"": ListDeviceId?.First().ToString(), ref message)) + if (DeviceDataV.Initialize(DataVApiAddress, ClientId, ListDeviceId.Count == 0 ? "" : ListDeviceId?.First().ToString(), ref message)) { ProductKey = DeviceDataV.deviceTable.productkey; DeviceName = DeviceDataV.deviceTable.devicename; diff --git a/BPASmartClient.IoT/Model/DataVReport.cs b/BPASmartClient.IoT/Model/DataVReport.cs index 365603ec..543696c9 100644 --- a/BPASmartClient.IoT/Model/DataVReport.cs +++ b/BPASmartClient.IoT/Model/DataVReport.cs @@ -193,9 +193,11 @@ namespace BPASmartDatavDeviceClient.IoT { string json = string.Empty; if (string.IsNullOrEmpty(deviceId)) - json = HttpRequestHelper.HttpGetRequest($"{url}/api/Device/Query?clientId={clientId}", 1000); + //json = APIHelper.GetInstance.GetRequest($"{url}/api/Device/Query?clientId={clientId}", 1000); + json = APIHelper.GetInstance.GetRequest($"{url}/api/Device/Query?clientId={clientId}"); else - json = HttpRequestHelper.HttpGetRequest($"{url}/api/Device/Query?clientId={clientId}&deviceId={deviceId}"); + //json = APIHelper.GetInstance.GetRequest($"{url}/api/Device/Query?clientId={clientId}&deviceId={deviceId}"); + json = APIHelper.GetInstance.GetRequest($"{url}/api/Device/Query?clientId={clientId}&deviceId={deviceId}"); JsonMsg> jsonMsg = Tools.JsonToObjectTools>>(json); if (jsonMsg.obj != null && jsonMsg.obj.data != null) { diff --git a/BPASmartClient.IoT/Model/FileUpload.cs b/BPASmartClient.IoT/Model/FileUpload.cs index 43a299ab..f20a8c94 100644 --- a/BPASmartClient.IoT/Model/FileUpload.cs +++ b/BPASmartClient.IoT/Model/FileUpload.cs @@ -1,5 +1,5 @@ using BPA.Helper; - + using BPASmartDatavDeviceClient.IoT; using DataVAPI.Tool.IOT; using System; @@ -27,7 +27,7 @@ namespace BPASmartClient.IoT.Model /// /// 请求反馈信息 /// - public static FileUploadModelResult modelResult=null; + public static FileUploadModelResult modelResult = null; /// /// 文件请求上传 /// @@ -37,8 +37,8 @@ namespace BPASmartClient.IoT.Model { try { - List queryDeviceFiles= Sample.FileQueryALL(DataVClient.GetInstance().DeviceName); - QueryDeviceFileResponseBodyData _data= queryDeviceFiles?.Find(par => par.Name == FileName); + List queryDeviceFiles = Sample.FileQueryALL(DataVClient.GetInstance().DeviceName); + QueryDeviceFileResponseBodyData _data = queryDeviceFiles?.Find(par => par.Name == FileName); if (_data != null)//删除文件 { MessageLog.GetInstance.Show("阿里云设备下文件已存在,准备删除续传..."); @@ -66,12 +66,12 @@ namespace BPASmartClient.IoT.Model FileUploadModel fileUpload = new FileUploadModel(); fileUpload.@params.fileName = FileName; - fileUpload.@params.fileSize =-1; + fileUpload.@params.fileSize = -1; - fileUpload.@params.conflictStrategy = length>130000 ? "append":"overwrite"; + fileUpload.@params.conflictStrategy = length > 130000 ? "append" : "overwrite"; //fileUpload.@params.conflictStrategy = "append";// "overwrite";//覆盖模式 - //fileUpload.@params.ficMode = "crc64"; - //fileUpload.@params.ficValue = CRC.ToCRC16(FileBlock); + //fileUpload.@params.ficMode = "crc64"; + //fileUpload.@params.ficValue = CRC.ToCRC16(FileBlock); fileUpload.@params.initUid = $"ab{RandomHelper.GenerateRandomCode()}"; //上传到阿里云物联网平台的OSS存储空间中 @@ -92,7 +92,7 @@ namespace BPASmartClient.IoT.Model if (count > 5) { MessageLog.GetInstance.Show($"[阿里云上传]:超时上传、未知原因、退出线程."); - + return; } Thread.Sleep(3000); count++; @@ -116,19 +116,19 @@ namespace BPASmartClient.IoT.Model { MessageLog.GetInstance.ShowEx(ex.ToString()); } - }), "文件请求上传", false); + }), "文件请求上传", isRestart: false); } /// /// 文件上传 /// - public static void FileSend(DataVReport dataV, string uploadId,long offset) + public static void FileSend(DataVReport dataV, string uploadId, long offset) { FileSendModel fileSend = new FileSendModel(); fileSend.@params.uploadId = uploadId; fileSend.@params.offset = offset; fileSend.@params.bSize = FileBlock.Count(); - fileSend.@params.isComplete = FileBlock.Count()==130000?false:true; + fileSend.@params.isComplete = FileBlock.Count() == 130000 ? false : true; //结构如下图 //Header.length(高 低) + Header(字节数组UTF-8) + 文件分片的字节数组 + "分片校验值CrC16 低 高" byte[] Header = Encoding.UTF8.GetBytes(Tools.JsonConvertTools(fileSend)); diff --git a/BPASmartClient.IoT/Model/IOT/IOTDevServer.cs b/BPASmartClient.IoT/Model/IOT/IOTDevServer.cs index db8d5a44..19f01a5e 100644 --- a/BPASmartClient.IoT/Model/IOT/IOTDevServer.cs +++ b/BPASmartClient.IoT/Model/IOT/IOTDevServer.cs @@ -154,9 +154,10 @@ namespace DataVAPI.Tool.IOT try { //http://localhost:9092/api/Device/Query?chid=2 - string json = HttpRequestHelper.HttpGetRequest($"{APIurl}/api/Device/Query?clientId={ClientId}"); + //string json = APIHelper.GetInstance.GetRequest($"{APIurl}/api/Device/Query?clientId={ClientId}"); + string json = APIHelper.GetInstance.GetRequest($"{APIurl}/api/Device/Query?clientId={ClientId}"); JsonMsg> jsonMsg = Tools.JsonToObjectTools>>(json); - if (jsonMsg.obj != null && jsonMsg.obj.data!=null) + if (jsonMsg.obj != null && jsonMsg.obj.data != null) { device = jsonMsg.obj.data.FirstOrDefault(); if (device == null) return false; diff --git a/BPASmartClient.Model/LocaPath.cs b/BPASmartClient.Model/LocaPath.cs new file mode 100644 index 00000000..70044dc1 --- /dev/null +++ b/BPASmartClient.Model/LocaPath.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public class LocaPath + { + public static string FilePath { get; set; } = string.Empty; + + public static string Getpath(string name) + { + Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{FilePath}\\JSON")); + return $"{AppDomain.CurrentDomain.BaseDirectory}{FilePath}JSON\\{name}.json"; + } + + public static string GetDeviceConfigPath + { + get + { + Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DeviceConfig")); + return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\DeviceConfig\\"; + } + } + + } +} diff --git a/BPASmartClient.MorkM/Control_MORKM.cs b/BPASmartClient.MorkM/Control_MORKM.cs index b2f12992..55311ea6 100644 --- a/BPASmartClient.MorkM/Control_MORKM.cs +++ b/BPASmartClient.MorkM/Control_MORKM.cs @@ -16,6 +16,7 @@ using System.Collections.ObjectModel; using BPASmartClient.Model.PLC; using BPASmartClient.MorkM.ViewModel; using BPA.Message; +using static BPA.Helper.EventBus; namespace BPASmartClient.MorkM { @@ -59,7 +60,7 @@ namespace BPASmartClient.MorkM Loc = 11, SuborderId = subId, MakeType = false - }) ; + }); mORKS.DishNumber = orders.Count;//订单中配菜的数量 while (orders.Count > 0) { @@ -161,7 +162,7 @@ namespace BPASmartClient.MorkM List locs = new List(); foreach (var item in order.MorkOrder.GoodBatchings) { - var res =orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); if (res != null) { if (ushort.TryParse(res.BatchingLoc, out ushort loc)) @@ -269,7 +270,7 @@ namespace BPASmartClient.MorkM TakeBowlControl(orderLocInfo.Loc); SetRecipeNumber(orderLocInfo.RecipeNumber); OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING); - DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]"); + DeviceProcessLogShow($"订单【{mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]"); } mORKS.TakeBowlInterlock = true; } @@ -386,13 +387,13 @@ namespace BPASmartClient.MorkM { values.Add(2);//分 values.Add(0);//秒 - EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = $"VW{ 116 + (loc * 6) }", Value = values.ToArray() }); + EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = $"VW{116 + (loc * 6)}", Value = values.ToArray() }); } else //荤菜 { values.Add(4);//分 values.Add(0);//秒 - EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = $"VW{ 116 + (loc * 6) }", Value = values.ToArray() }); + EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = $"VW{116 + (loc * 6)}", Value = values.ToArray() }); } @@ -813,7 +814,7 @@ namespace BPASmartClient.MorkM } }); } - + public override void DoMain() { MonitorViewModel.DeviceId = DeviceId; diff --git a/BPASmartClient.MorkMV1/Control_MorkMV1.cs b/BPASmartClient.MorkMV1/Control_MorkMV1.cs index 236428d9..9125d970 100644 --- a/BPASmartClient.MorkMV1/Control_MorkMV1.cs +++ b/BPASmartClient.MorkMV1/Control_MorkMV1.cs @@ -8,7 +8,7 @@ using BPASmartClient.Peripheral; using BPA.Helper; using System.Threading; - + using BPA.Message; using System.Linq; using BPASmartClient.Model.PLC; @@ -24,6 +24,7 @@ using System.Windows.Forms; using System.Media; using BPASmartClient.CustomResource; using Microsoft.EntityFrameworkCore.Metadata.Internal; +using static BPA.Helper.EventBus; //using BPA.Helper; namespace BPASmartClient.MorkMV1 @@ -291,7 +292,7 @@ namespace BPASmartClient.MorkMV1 { if (obj is ushort[] ushorts && ushorts.Length > 0 && ushorts.Length <= 1) { - var tt = ushorts.UshortsToBytes(true).BytesToUshorts(); + var tt = ushorts.ToBytes(true).ToUshorts(); for (byte i = 0; i < 6; i++) { diff --git a/BPASmartClient.MorkMV1/DataServer.cs b/BPASmartClient.MorkMV1/DataServer.cs index 515a8ec2..df8c5da9 100644 --- a/BPASmartClient.MorkMV1/DataServer.cs +++ b/BPASmartClient.MorkMV1/DataServer.cs @@ -4,9 +4,10 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using BPASmartClient.MQTT; using BPA.Message; using BPASmartClient.Model; +using BPA.Communication; + namespace BPASmartClient.MorkMV1 { @@ -19,10 +20,10 @@ namespace BPASmartClient.MorkMV1 public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS(); - MQTTProxy mQTTProxy = new MQTTProxy(); + MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.Connected = new Action(() => + mQTTProxy.ConnectOk = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); ThreadManage.GetInstance().StartLong(new Action(() => @@ -35,7 +36,15 @@ namespace BPASmartClient.MorkMV1 Thread.Sleep(100); }), "海科食堂大屏监听"); }); - mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + //mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + mQTTProxy.Connect(new BPA.Communication.Base.ConfigurationOptions() + { + UserName = "UserName", + Password = "Password", + IpAddress = "Host", + Port = 1883, + ClientId = $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}" + }); } //订单信息(正在制作,等待制作,制作完成) diff --git a/BPASmartClient.MorkMV1/GlobalUsing.cs b/BPASmartClient.MorkMV1/GlobalUsing.cs index ea1dff3f..f5c11c73 100644 --- a/BPASmartClient.MorkMV1/GlobalUsing.cs +++ b/BPASmartClient.MorkMV1/GlobalUsing.cs @@ -2,13 +2,10 @@ global using System.Collections.Generic; global using BPA.Message.Enum; global using BPASmartClient.Device; -global global using BPASmartClient.Model; global using BPASmartClient.Peripheral; -global global using BPA.Helper; global using System.Threading; -global global using BPA.Message; global using System.Linq; global using BPASmartClient.Model.PLC; diff --git a/BPASmartClient.MorkMW/Control_MorkMW.cs b/BPASmartClient.MorkMW/Control_MorkMW.cs index e87daed6..28c2f481 100644 --- a/BPASmartClient.MorkMW/Control_MorkMW.cs +++ b/BPASmartClient.MorkMW/Control_MorkMW.cs @@ -20,7 +20,7 @@ using System.Net.Http.Json; using System.Reflection; using System.Threading; using System.Windows.Documents; - +using static BPA.Helper.EventBus; namespace BPASmartClient.MorkMW { diff --git a/BPASmartClient.MorkS/Control_Morks.cs b/BPASmartClient.MorkS/Control_Morks.cs index fa6fede7..4fa8aa12 100644 --- a/BPASmartClient.MorkS/Control_Morks.cs +++ b/BPASmartClient.MorkS/Control_Morks.cs @@ -8,7 +8,7 @@ using BPASmartClient.Peripheral; using BPA.Helper; using System.Threading; - + using BPA.Message; using System.Linq; using BPASmartClient.Model.PLC; @@ -24,6 +24,7 @@ using System.Speech.Synthesis; using System.Windows.Forms; using System.Media; using BPASmartClient.CustomResource; +using static BPA.Helper.EventBus; namespace BPASmartClient.MorkS { diff --git a/BPASmartClient.MorkS/DataServer.cs b/BPASmartClient.MorkS/DataServer.cs index 6197e9b2..6d7e01db 100644 --- a/BPASmartClient.MorkS/DataServer.cs +++ b/BPASmartClient.MorkS/DataServer.cs @@ -5,9 +5,9 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using BPA.Helper; -using BPASmartClient.MQTT; using BPA.Message; using BPASmartClient.Model; +using BPA.Communication; namespace BPASmartClient.MorkS { @@ -20,10 +20,10 @@ namespace BPASmartClient.MorkS public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS(); - MQTTProxy mQTTProxy = new MQTTProxy(); + MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.Connected = new Action(() => + mQTTProxy.ConnectOk = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); ThreadManage.GetInstance().StartLong(new Action(() => @@ -36,7 +36,15 @@ namespace BPASmartClient.MorkS Thread.Sleep(100); }), "海科食堂大屏监听"); }); - mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + //mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + mQTTProxy.Connect(new BPA.Communication.Base.ConfigurationOptions() + { + UserName = "UserName", + Password = "Password", + IpAddress = "Host", + Port = 1883, + ClientId = $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}" + }); } //订单信息(正在制作,等待制作,制作完成) diff --git a/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs b/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs index 2bdaea8e..cca244e3 100644 --- a/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs +++ b/BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs @@ -8,7 +8,7 @@ using BPASmartClient.Peripheral; using BPA.Helper; using System.Threading; - + using BPA.Message; using System.Linq; using BPASmartClient.Model.PLC; @@ -23,6 +23,7 @@ using BPA.Models; using System.Windows.Forms; using System.Media; using BPASmartClient.CustomResource; +using static BPA.Helper.EventBus; //using BPA.Helper; namespace BPASmartClient.MorkSUpgradedVer @@ -343,7 +344,7 @@ namespace BPASmartClient.MorkSUpgradedVer { if (obj is ushort[] ushorts && ushorts.Length > 0 && ushorts.Length <= 1) { - var tt = ushorts.UshortsToBytes(true).BytesToUshorts(); + var tt = ushorts.ToBytes(true).ToUshorts(); for (byte i = 0; i < 6; i++) { @@ -656,9 +657,11 @@ namespace BPASmartClient.MorkSUpgradedVer //values.Add(Json.Data.parSets.ElementAt(loc).Minute); //values.Add(Json.Data.parSets.ElementAt(loc).Second); //WriteData($"VW{324 + (loc * 4)}", values.ToArray()); - if (mORKS.CurrentFeedbackLoc >= 1 && mORKS.CurrentFeedbackLoc <= 5) { + if (mORKS.CurrentFeedbackLoc >= 1 && mORKS.CurrentFeedbackLoc <= 5) + { var x = Json.Data.DishLibraryParSets.FirstOrDefault(p => p.TextBlockContext == mORKS.CurrentFeedbackLoc.ToString()); - if (x != null) { + if (x != null) + { List values = new List(); values.Add(x.Minute); values.Add(x.Second); @@ -711,24 +714,26 @@ namespace BPASmartClient.MorkSUpgradedVer //} #endregion - for (int loc = 0; loc < mORKS.CookNodelId.Length; loc++) { - - if (mORKS.CookNoodleCom[loc]&&!mORKS.RobotOutDinnigLock) { - SetTakeNoodleLoc((ushort)(loc + 1)); - mORKS.NoodleCookerStatus[loc] = false; - WriteData($"VW260", (ushort)0);//设置出汤时间 - OrderChange(mORKS.CookNodelId[loc], ORDER_STATUS.COMPLETED_COOK); - DeviceProcessLogShow($"订单【{mORKS.CookNodelId[loc]}】制作完成"); - mORKS.CookCompleteFlatBit = true; - mORKS.OutMealId = mORKS.CookNodelId[loc]; - mORKS.OutMealName = mORKS.IngredientsCompleteName; - mORKS.OutMealSortNum = mORKS.IngredientsCompleteSortNum; - mORKS.IngredientsCompleteId = string.Empty; - mORKS.CookNodelId[loc] = string.Empty; - DeviceProcessLogShow($"{loc + 1} 号位置出餐控制,订单ID:{mORKS.OutMealId}"); - mORKS.CookNoodleCom[loc] = false; - mORKS.RobotOutDinnigLock = true; - } + for (int loc = 0; loc < mORKS.CookNodelId.Length; loc++) + { + + if (mORKS.CookNoodleCom[loc] && !mORKS.RobotOutDinnigLock) + { + SetTakeNoodleLoc((ushort)(loc + 1)); + mORKS.NoodleCookerStatus[loc] = false; + WriteData($"VW260", (ushort)0);//设置出汤时间 + OrderChange(mORKS.CookNodelId[loc], ORDER_STATUS.COMPLETED_COOK); + DeviceProcessLogShow($"订单【{mORKS.CookNodelId[loc]}】制作完成"); + mORKS.CookCompleteFlatBit = true; + mORKS.OutMealId = mORKS.CookNodelId[loc]; + mORKS.OutMealName = mORKS.IngredientsCompleteName; + mORKS.OutMealSortNum = mORKS.IngredientsCompleteSortNum; + mORKS.IngredientsCompleteId = string.Empty; + mORKS.CookNodelId[loc] = string.Empty; + DeviceProcessLogShow($"{loc + 1} 号位置出餐控制,订单ID:{mORKS.OutMealId}"); + mORKS.CookNoodleCom[loc] = false; + mORKS.RobotOutDinnigLock = true; + } } } } @@ -760,7 +765,7 @@ namespace BPASmartClient.MorkSUpgradedVer DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成"); WriteData("M10.1", false); - var orderEvent= mORKS.doOrderEvents.FirstOrDefault(order => order.MorkOrder.SuborderId == mORKS.OutMealId); + var orderEvent = mORKS.doOrderEvents.FirstOrDefault(order => order.MorkOrder.SuborderId == mORKS.OutMealId); mORKS.OutMealSortNum = orderEvent?.MorkOrder.SortNum ?? 0; DeviceProcessLogShow($"出餐订单序号【{mORKS.OutMealSortNum}】"); diff --git a/BPASmartClient.MorkSUpgradedVer/DataServer.cs b/BPASmartClient.MorkSUpgradedVer/DataServer.cs index 2e8a97a7..bb23b186 100644 --- a/BPASmartClient.MorkSUpgradedVer/DataServer.cs +++ b/BPASmartClient.MorkSUpgradedVer/DataServer.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using BPASmartClient.MQTT; using BPA.Message; using BPASmartClient.Model; +using BPA.Communication; namespace BPASmartClient.MorkSUpgradedVer { @@ -19,10 +19,10 @@ namespace BPASmartClient.MorkSUpgradedVer public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS(); - MQTTProxy mQTTProxy = new MQTTProxy(); + MqttHelper mQTTProxy = new MqttHelper(); public void Init() { - mQTTProxy.Connected = new Action(() => + mQTTProxy.ConnectOk = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); ThreadManage.GetInstance().StartLong(new Action(() => @@ -35,7 +35,15 @@ namespace BPASmartClient.MorkSUpgradedVer Thread.Sleep(100); }), "海科食堂大屏监听"); }); - mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + //mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + mQTTProxy.Connect(new BPA.Communication.Base.ConfigurationOptions() + { + UserName = "UserName", + Password = "Password", + IpAddress = "Host", + Port = 1883, + ClientId = $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}" + }); } //订单信息(正在制作,等待制作,制作完成) diff --git a/BPASmartClient.MorkSUpgradedVer/GlobalUsing.cs b/BPASmartClient.MorkSUpgradedVer/GlobalUsing.cs index 01f8a5af..922041f5 100644 --- a/BPASmartClient.MorkSUpgradedVer/GlobalUsing.cs +++ b/BPASmartClient.MorkSUpgradedVer/GlobalUsing.cs @@ -2,13 +2,10 @@ global using System.Collections.Generic; global using BPA.Message.Enum; global using BPASmartClient.Device; -global global using BPASmartClient.Model; global using BPASmartClient.Peripheral; -global global using BPA.Helper; global using System.Threading; -global global using BPA.Message; global using System.Linq; global using BPASmartClient.Model.PLC; diff --git a/BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs b/BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs index 8145957b..fd73432b 100644 --- a/BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs +++ b/BPASmartClient.MorkT.Lebai.JC/Control_MORKJC2.cs @@ -17,6 +17,7 @@ using BPASmartClient.Model; using BPASmartClient.Model.乐白机器人; using BPASmartClient.Model.单片机; +using static BPA.Helper.EventBus; namespace BPASmartClient.MorkTLebaiJC { diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs index 20a5a38f..4abd8e12 100644 --- a/BPASmartClient.MorkT/Control_MorkT.cs +++ b/BPASmartClient.MorkT/Control_MorkT.cs @@ -6,7 +6,7 @@ using BPASmartClient.GSIceCream; using BPA.Helper; using BPASmartClient.Lebai; using BPASmartClient.LebaiRobot; - + using BPASmartClient.Model; using BPASmartClient.Model.乐白机器人; using BPASmartClient.Model.乐白机器人.Enum; @@ -22,7 +22,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; - +using static BPA.Helper.EventBus; namespace BPASmartClient.MorkT { @@ -208,7 +208,7 @@ namespace BPASmartClient.MorkT morkT.IceCreamError = error; } })); - + GetStatus("IceCreamDLCompleted", new Action((o) => { if (o is bool b) @@ -420,7 +420,7 @@ namespace BPASmartClient.MorkT EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_接咖啡后回原点 }); //接咖啡后回原点 Wait(); EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); - EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() {DeviceId = DeviceId, DrinkCode = (BPASmartClient.Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) });//接咖啡控制 + EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (BPASmartClient.Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) });//接咖啡控制 DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!"); morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc; } @@ -469,9 +469,9 @@ namespace BPASmartClient.MorkT /// private void GetAndCheeckCoffe(OrderLocInfo order) { - EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 },(o)=>{ }); + EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { }); OrderChange(order.SuborderId, ORDER_STATUS.COOKING); - EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_取咖啡杯 }); //SENCE_取咖啡杯 + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_取咖啡杯 }); //SENCE_取咖啡杯 Wait(); // EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 @@ -489,10 +489,10 @@ namespace BPASmartClient.MorkT int count = 1; bool result = true; p: - EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_咖啡杯检测 }); //SENCE_咖啡杯检测 + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_咖啡杯检测 }); //SENCE_咖啡杯检测 Wait(); EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); - EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o)=> + EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o) => { if (o != null && o.Length > 0 && o[0] is bool resultValue) { @@ -506,14 +506,14 @@ namespace BPASmartClient.MorkT { //退出循环回到初始位置 DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!"); - EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_咖啡杯回原点 }); //SENCE_咖啡杯回原点 + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_咖啡杯回原点 }); //SENCE_咖啡杯回原点 Wait(); EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); morkT.GetCoffeeCup = false; return; } DeviceProcessLogShow("执行二次取咖啡杯"); - EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_二次取咖啡杯 }); //SENCE_二次取咖啡杯 + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_二次取咖啡杯 }); //SENCE_二次取咖啡杯 Wait(); EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); @@ -619,22 +619,22 @@ namespace BPASmartClient.MorkT bool result = true; EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); p: - EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_冰淇淋杯检测 }); //SENCE_冰淇淋杯检测 + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_冰淇淋杯检测 }); //SENCE_冰淇淋杯检测 Wait(); Thread.Sleep(500); - EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => + EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { if (o != null && o.Length > 0 && o[0] is SignalResult res) { MessageLog.GetInstance.Show(res.ToString()); } }); - while((int)peripheralStatus["RobotValue"] != 0) + while ((int)peripheralStatus["RobotValue"] != 0) { Thread.Sleep(10); } MessageLog.GetInstance.Show($"乐白机器人信号值{peripheralStatus["RobotValue"].ToString()}"); - + //while ((ELebaiRModel)peripheralStatus["RobotMode"] !=ELebaiRModel.空闲状态) //{ // EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); @@ -656,12 +656,12 @@ namespace BPASmartClient.MorkT DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!"); EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_冰淇淋杯回原点 }); //SENCE_冰淇淋杯回原点 Wait(); - EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 },(o) => { }); + EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); morkT.GetIceCreamCup = false; return; } DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); - EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_二次取冰淇淋杯 }); //SENCE_二次取冰淇淋杯 + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_二次取冰淇淋杯 }); //SENCE_二次取冰淇淋杯 EventBus.GetInstance().Equals(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_ICECREAM });//落碗控制 Wait(); EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); @@ -742,7 +742,7 @@ namespace BPASmartClient.MorkT }); Thread.Sleep(500); } - + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = Lebai_qsqdCode.SENCE_放冰淇淋位置 }); //SENCE_放冰淇淋位置 Wait(); EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); diff --git a/BPASmartClient.MorkTSingle/Control_MORKJC.cs b/BPASmartClient.MorkTSingle/Control_MORKJC.cs index 5c31a059..16f73c4f 100644 --- a/BPASmartClient.MorkTSingle/Control_MORKJC.cs +++ b/BPASmartClient.MorkTSingle/Control_MORKJC.cs @@ -18,7 +18,8 @@ using BPASmartClient.Model.PLC; using BPASmartClient.Model.单片机; using BPASmartClient.Business; using BPASmartClient.KLMCoffee.Protocal; - +using static BPA.Helper.EventBus; + namespace BPASmartClient.MorkTSingle { /* @@ -58,7 +59,7 @@ namespace BPASmartClient.MorkTSingle } ConcurrentQueue morkOrderPushes = new ConcurrentQueue(); - + /// /// /// @@ -83,7 +84,7 @@ namespace BPASmartClient.MorkTSingle } } DateTime delayTimeOut_Coffee; - private void DoCoffee() + private void DoCoffee() { if (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsCoffeeMake /*&& morkT.coffeeState== K95SysTemStatus.空闲状态*/) { @@ -93,13 +94,13 @@ namespace BPASmartClient.MorkTSingle { new KLMCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, KLMDrinkFaultCode = (KLMDrinkFaultType)(morkT.morkOrderPushesCoffee.ElementAt(0).Loc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水 } - else + else { new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); } morkT.IsCoffeeMake = true; } - else if (morkT.MakeCoffeeFinish && IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && morkT.IsCoffeeMake) + else if (morkT.MakeCoffeeFinish && IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && morkT.IsCoffeeMake) { OrderChange(morkT.morkOrderPushesCoffee.ElementAt(0).SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); DeviceProcessLogShow($"{morkT.morkOrderPushesCoffee.ElementAt(0).GoodName}制作完成"); @@ -171,7 +172,7 @@ namespace BPASmartClient.MorkTSingle { //验证商品是做的某种饮料 if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER) - { + { //获取当前物料所属商品类型 currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); } @@ -235,7 +236,8 @@ namespace BPASmartClient.MorkTSingle morkT.KLMCoffeeIsConnected = b; } })); - if ( morkT.morkOrderPushesCoffee.Count > 0) { + if (morkT.morkOrderPushesCoffee.Count > 0) + { if (morkT.KLMCoffeeIsConnected) { if (morkT.IsCoffeeMake) @@ -248,7 +250,7 @@ namespace BPASmartClient.MorkTSingle morkT.MakeCoffeeFinish = true; }); } - else + else { EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) { @@ -297,7 +299,7 @@ namespace BPASmartClient.MorkTSingle }); /*string aa = calLrcCommon("01" + "01" + "0001"); string bb = ":01010001" + aa + "\r\n";*/ - + } public static string calLrcCommon(string data) { diff --git a/BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs b/BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs index 93e27518..9e1e9bca 100644 --- a/BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs +++ b/BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs @@ -14,7 +14,7 @@ using BPASmartClient.Model.咖啡机.Enum; using BPASmartClient.Model; - + using BPASmartClient.Model.乐白机器人; using BPASmartClient.Model.单片机; using BPASmartClient.Model.PLC; @@ -23,6 +23,7 @@ using BPASmartClient.LebaiRobot; using BPASmartClient.RobotGripper; using BPASmartClient.Model.电夹爪; using BPASmartClient.Model.奶茶味魔方; +using static BPA.Helper.EventBus; namespace BPASmartClient.MorkT_BarCounter { @@ -45,7 +46,7 @@ namespace BPASmartClient.MorkT_BarCounter private string mainMaterialLoc; public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKT; } } - GVL_MorkT morkT =new GVL_MorkT(); + GVL_MorkT morkT = new GVL_MorkT(); /// /// 果汁机做法,true:热饮,false:冷饮 /// @@ -81,7 +82,7 @@ namespace BPASmartClient.MorkT_BarCounter } private void DataParse() { - + EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) { if (@event == null) return; @@ -117,14 +118,14 @@ namespace BPASmartClient.MorkT_BarCounter switch (currentGoodsType) { case GOODS_TYPE.COFFEE: - + if (morkT.morkOrderPushesCoffee.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) { morkT.morkOrderPushesCoffee.Enqueue(new OrderLocInfo() { SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId, - Loc = ushort.Parse( mainMaterialLoc), + Loc = ushort.Parse(mainMaterialLoc), GoodName = order.MorkOrder.GoodsName, }); morkT.morkOrderPushesAll.Enqueue(new OrderLocInfo() @@ -134,7 +135,7 @@ namespace BPASmartClient.MorkT_BarCounter Loc = ushort.Parse(mainMaterialLoc), GoodName = order.MorkOrder.GoodsName, }); - + } break; //case GOODS_TYPE.JUICE: @@ -194,7 +195,7 @@ namespace BPASmartClient.MorkT_BarCounter /// 将空杯放好到接饮料的地方的标志位 /// private bool bFirstTrig_MilkTea = false; - private bool bFirstTrig_Coffee = false; + private bool bFirstTrig_Coffee = false; /// /// 延迟的超时时间 /// @@ -206,7 +207,7 @@ namespace BPASmartClient.MorkT_BarCounter { if (morkT.IsHaveCoffeeCup && morkT.MakeCoffeeEnd != true) morkT.MakeCoffeeEnd = true; - bFirstTrig_Coffee = false; + bFirstTrig_Coffee = false; }); if (morkT.IsHaveCoffeeCup && morkT.MakeCoffeeEnd != true) { @@ -215,7 +216,7 @@ namespace BPASmartClient.MorkT_BarCounter bFirstTrig_Coffee = true; delayTimeOut_Coffee = DateTime.Now; } - else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 && bFirstTrig_Coffee == true) + else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 && bFirstTrig_Coffee == true) { DeviceProcessLogShow("接咖啡超时,接咖啡结束,等待取咖啡"); bFirstTrig_Coffee = false; @@ -235,9 +236,9 @@ namespace BPASmartClient.MorkT_BarCounter DeviceProcessLogShow("接茶或水延迟时间结束"); morkT.MakeMilkTeaEnd = true; } - if ( GetStatus("Get_MilkTeaCubeStatus") == true) + if (GetStatus("Get_MilkTeaCubeStatus") == true) { - while(GetStatus("Get_MilkTeaCubeDosingStatus") == true) + while (GetStatus("Get_MilkTeaCubeDosingStatus") == true) { if (morkT.IsHaveTeaMilkTeaCup && morkT.MakeMilkTeaEnd != true) { @@ -284,9 +285,9 @@ namespace BPASmartClient.MorkT_BarCounter /// /// /// - private void Output(bool value,int pin) + private void Output(bool value, int pin) { - new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Pin = pin,Value=value }.Publish(); + new LebaiRobot_SetOutPutEvent { DeviceId = DeviceId, Pin = pin, Value = value }.Publish(); } private T GetStatus(string key) { @@ -304,14 +305,14 @@ namespace BPASmartClient.MorkT_BarCounter /// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确 /// int bSensorInput; - + /// /// 判断是否有咖啡订单 /// /// - private bool IsMakeCoffee() + private bool IsMakeCoffee() { - bool bMake = (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsHaveCoffeeCup && morkT.morkOrderPushesAll.ElementAt(0).SuborderId == morkT.morkOrderPushesCoffee.ElementAt(0).SuborderId) ? true : false; + bool bMake = (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsHaveCoffeeCup && morkT.morkOrderPushesAll.ElementAt(0).SuborderId == morkT.morkOrderPushesCoffee.ElementAt(0).SuborderId) ? true : false; return bMake; } /// @@ -320,7 +321,7 @@ namespace BPASmartClient.MorkT_BarCounter /// private bool IsMakeJuice() { - bool bMake = (IsHealth && morkT.morkOrderPushesJuicer.Count > 0 && !morkT.IsHaveJuiceCup && morkT.morkOrderPushesAll.ElementAt(0).SuborderId == morkT.morkOrderPushesCoffee.ElementAt(0).SuborderId) ? true : false; + bool bMake = (IsHealth && morkT.morkOrderPushesJuicer.Count > 0 && !morkT.IsHaveJuiceCup && morkT.morkOrderPushesAll.ElementAt(0).SuborderId == morkT.morkOrderPushesCoffee.ElementAt(0).SuborderId) ? true : false; return bMake; } /// @@ -338,20 +339,20 @@ namespace BPASmartClient.MorkT_BarCounter /// private bool IsMakeWater() { - bool bMake = (IsHealth && morkT.morkOrderPushesWater.Count > 0 && !morkT.IsHaveTeaMilkTeaCup) ? true : false; + bool bMake = (IsHealth && morkT.morkOrderPushesWater.Count > 0 && !morkT.IsHaveTeaMilkTeaCup) ? true : false; return bMake; } /// /// 做咖啡流程 /// - private void DoCoffee() + private void DoCoffee() { if (IsMakeCoffee()) { Discharge_Control(Kind.咖啡);//接咖啡 morkT.IsHaveCoffeeCup = true; } - else if(morkT.MakeCoffeeEnd) + else if (morkT.MakeCoffeeEnd) { try { @@ -368,7 +369,7 @@ namespace BPASmartClient.MorkT_BarCounter } } } - private void DoMilkTea() + private void DoMilkTea() { if (IsMakeMilkTea()) { @@ -414,7 +415,7 @@ namespace BPASmartClient.MorkT_BarCounter { if (kind == Kind.咖啡) { - new WriteJaka() { DeviceId =DeviceId, TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯位_接咖啡位 }.Publish(); + new WriteJaka() { DeviceId = DeviceId, TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯位_接咖啡位 }.Publish(); JakaWait(int.Parse(JakaModel.SENCE_取杯位_接咖啡位)); new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)(morkT.morkOrderPushesCoffee.ElementAt(0).Loc) }.Publish(); //控制咖啡出料 @@ -426,7 +427,7 @@ namespace BPASmartClient.MorkT_BarCounter //DeviceProcessLogShow("接咖啡杯动作完成"); } - else + else { new WriteJaka() { DeviceId = DeviceId, TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯位_接奶茶位 }.Publish(); JakaWait(int.Parse(JakaModel.SENCE_取杯位_接奶茶位)); @@ -608,7 +609,7 @@ namespace BPASmartClient.MorkT_BarCounter JakaWait(int.Parse(JakaModel.SENCE_初始位_取杯位)); int cnt = 0; - p: new WriteJaka() { DeviceId = DeviceId, TagName = "JaKaProgramName", Value = JakaModel.SENCE_落杯 }.Publish(); + p: new WriteJaka() { DeviceId = DeviceId, TagName = "JaKaProgramName", Value = JakaModel.SENCE_落杯 }.Publish(); JakaWait(int.Parse(JakaModel.SENCE_落杯)); cnt = cnt + 1; if (!GetStatus("Get_JakaRobotDI5")) @@ -647,7 +648,7 @@ namespace BPASmartClient.MorkT_BarCounter } public void SimOrder(T simOrder) { - + } private void JakaWait(int value) { @@ -897,11 +898,11 @@ namespace BPASmartClient.MorkT_BarCounter DeviceProcessLogShow("----开始模拟订单----"); if (msm.OrderNum == 1) { - morkT.morkOrderPushesCoffee.Enqueue(new OrderLocInfo() { Loc =(ushort)msm.DrinkCode, SuborderId = guid, GoodName="模拟咖啡订单" }); + morkT.morkOrderPushesCoffee.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.DrinkCode, SuborderId = guid, GoodName = "模拟咖啡订单" }); } else if (msm.OrderNum == 2) { - morkT.morkOrderPushesJuicer.Enqueue(new OrderLocInfo() { Loc = (ushort) (msm.JuiceList + 51), makeID = msm.JuiceMakeID, SuborderId = guid, GoodName = "模拟果汁订单" }); + morkT.morkOrderPushesJuicer.Enqueue(new OrderLocInfo() { Loc = (ushort)(msm.JuiceList + 51), makeID = msm.JuiceMakeID, SuborderId = guid, GoodName = "模拟果汁订单" }); } else if (msm.OrderNum == 3) { diff --git a/BPASmartClient.MorkT_Container/Control_MorkT_Container.cs b/BPASmartClient.MorkT_Container/Control_MorkT_Container.cs index a72e6e89..0795653b 100644 --- a/BPASmartClient.MorkT_Container/Control_MorkT_Container.cs +++ b/BPASmartClient.MorkT_Container/Control_MorkT_Container.cs @@ -21,6 +21,7 @@ using BPASmartClient.Model.PLC; using BPASmartClient.DRCoffee; using BPASmartClient.LebaiRobot; using System.Text.RegularExpressions; +using static BPA.Helper.EventBus; namespace BPASmartClient.MorkT_Container { diff --git a/BPASmartClient.MorkT_HQ/Control_MorkTHQ.cs b/BPASmartClient.MorkT_HQ/Control_MorkTHQ.cs index 3befebcc..7c6f4bf0 100644 --- a/BPASmartClient.MorkT_HQ/Control_MorkTHQ.cs +++ b/BPASmartClient.MorkT_HQ/Control_MorkTHQ.cs @@ -8,7 +8,7 @@ using BPA.Helper; using BPASmartClient.KLMCoffee.Protocal; using BPASmartClient.Lebai; using BPASmartClient.LebaiRobot; - + using BPASmartClient.Model; using BPASmartClient.Model.乐白机器人; using BPASmartClient.Model.冰淇淋.Enum; @@ -22,7 +22,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; - +using static BPA.Helper.EventBus; namespace BPASmartClient.MorkTHQ { @@ -35,7 +35,7 @@ namespace BPASmartClient.MorkTHQ public override void DoMain() { - if(Json.Data.IsVerify) + if (Json.Data.IsVerify) { IsHealth = true; } @@ -74,7 +74,7 @@ namespace BPASmartClient.MorkTHQ public override void MainTask() { - //制作咖啡 + //制作咖啡 MakeCoffeeProcess(); //制作果汁 MakeJuiceProcess(); @@ -82,7 +82,7 @@ namespace BPASmartClient.MorkTHQ MakeIceCreamProcess(); //制作完取咖啡 MakeCoffeeComplete(); - + } @@ -99,7 +99,7 @@ namespace BPASmartClient.MorkTHQ GetStatus("RobotMode", new Action((o) => { - if (o is ELebaiRModel eLebaiRModel) + if (o is ELebaiRModel eLebaiRModel) { morkT.RobotMode = eLebaiRModel; } @@ -287,7 +287,7 @@ namespace BPASmartClient.MorkTHQ morkT.batchings = PolymerBatching.BuildAll(); //商品类型 GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER; - + foreach (var item in order.MorkOrder.GoodBatchings) { var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); @@ -333,7 +333,7 @@ namespace BPASmartClient.MorkTHQ } break; case GOODS_TYPE.JUICE: - if(morkT.morkOrderPushesIceCream.FirstOrDefault(p=>p.SuborderId == order?.MorkOrder.SuborderId) == null) + if (morkT.morkOrderPushesIceCream.FirstOrDefault(p => p.SuborderId == order?.MorkOrder.SuborderId) == null) { morkT.GuMake = order.MorkOrder.MakeID == "2"; morkT.morkOrderPushesJuice.Enqueue(new OrderLocInfo() @@ -351,7 +351,7 @@ namespace BPASmartClient.MorkTHQ break; } } - + } } } @@ -367,9 +367,9 @@ namespace BPASmartClient.MorkTHQ return morkT.batchings[batchingLoc].GoodsType; return GOODS_TYPE.NEITHER; } - - + + private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) { @@ -408,16 +408,16 @@ namespace BPASmartClient.MorkTHQ DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); GetAndCheeckCoffe(orderLoc);//取咖啡杯 if (!morkT.GetCoffeeCup) return; - EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点 + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051 }); //接咖啡后回原点 Wait(); EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); - EventBus.GetInstance().Publish(new KLMCoffee_MakeCoffeeEvent() {DeviceId = DeviceId, DrinkCode = (Model.咖啡机.Enum.DrinkType)int.Parse(orderLoc.Loc) });//接咖啡控制 + EventBus.GetInstance().Publish(new KLMCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (Model.咖啡机.Enum.DrinkType)int.Parse(orderLoc.Loc) });//接咖啡控制 DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!"); morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc; } } - + } @@ -461,13 +461,13 @@ namespace BPASmartClient.MorkTHQ /// private void GetAndCheeckCoffe(OrderLocInfo order) { - EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 },(o)=>{ }); + EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }, (o) => { }); OrderChange(order.SuborderId, ORDER_STATUS.COOKING); EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10031 }); //SENCE_取咖啡杯 Wait(); Thread.Sleep(500); EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); - + morkT.GetCoffeeCup = true; DeviceProcessLogShow("取咖啡杯完成"); } @@ -535,7 +535,7 @@ namespace BPASmartClient.MorkTHQ //CheckICeCreaCup(); GetIceCream(order); PutIceCream(order); - + } /// @@ -564,19 +564,19 @@ namespace BPASmartClient.MorkTHQ EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10034 }); //SENCE_冰淇淋杯检测 Wait(); Thread.Sleep(500); - EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => + EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { if (o != null && o.Length > 0 && o[0] is SignalResult res) { MessageLog.GetInstance.Show(res.ToString()); } }); - while((int)peripheralStatus["RobotValue"] != 0) + while ((int)peripheralStatus["RobotValue"] != 0) { Thread.Sleep(10); } MessageLog.GetInstance.Show($"乐白机器人信号值{peripheralStatus["RobotValue"].ToString()}"); - + //while ((ELebaiRModel)peripheralStatus["RobotMode"] !=ELebaiRModel.空闲状态) //{ // EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); @@ -598,7 +598,7 @@ namespace BPASmartClient.MorkTHQ DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!"); EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点 Wait(); - EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 },(o) => { }); + EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); morkT.GetIceCreamCup = false; return; } @@ -637,7 +637,7 @@ namespace BPASmartClient.MorkTHQ //DeviceProcessLogShow("开始等待6s"); //Thread.Sleep(5000); - // 出料 + // 出料 EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId }, (o) => { doItResult = (bool)o[0]; @@ -680,7 +680,7 @@ namespace BPASmartClient.MorkTHQ }); Thread.Sleep(500); } - + EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10056 }); //SENCE_放冰淇淋位置 Wait(); EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); @@ -700,7 +700,7 @@ namespace BPASmartClient.MorkTHQ bool result = false; int retry = 3; DateTime beginTime = DateTime.Now; - + while (!result) { EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => @@ -718,7 +718,7 @@ namespace BPASmartClient.MorkTHQ if (DateTime.Now.Subtract(beginTime).TotalSeconds > 5) { DeviceProcessLogShow("超时未出料,重新发送打料指令"); - EventBus.GetInstance().Publish( new GSIceCream_ModeSetEvent() { DeviceId =DeviceId, Mode = MORKI_MODE.打料 }); + EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent() { DeviceId = DeviceId, Mode = MORKI_MODE.打料 }); beginTime = DateTime.Now; retry--; } @@ -736,7 +736,7 @@ namespace BPASmartClient.MorkTHQ /// private void MakeJuiceProcess() { - if(morkT.morkOrderPushesJuice.TryDequeue(out OrderLocInfo order)) + if (morkT.morkOrderPushesJuice.TryDequeue(out OrderLocInfo order)) { OrderChange(order.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING); EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 11111 });//SENCE_取果汁杯位置 @@ -840,9 +840,9 @@ namespace BPASmartClient.MorkTHQ MessageLog.GetInstance.Show("果汁制作完成"); } } - - + + } private T GetDeviceStatus(string key) @@ -859,7 +859,7 @@ namespace BPASmartClient.MorkTHQ #endregion public override void SimOrder() { - + } } } diff --git a/BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs b/BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs index 574a8441..7fb95d79 100644 --- a/BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs +++ b/BPASmartClient.Morkt.JAKA.JC/Control_MORKJC.cs @@ -16,7 +16,7 @@ using BPASmartClient.Model; using BPASmartClient.Model.PLC; using BPASmartClient.Model.单片机; - +using static BPA.Helper.EventBus; namespace BPASmartClient.MorktJAKAJC { @@ -252,7 +252,7 @@ namespace BPASmartClient.MorktJAKAJC return batchings[batchingLoc].GoodsType; return GOODS_TYPE.NEITHER; } - + private AutoResetEvent are = new AutoResetEvent(false); private T GetStatus(string key) @@ -731,7 +731,7 @@ namespace BPASmartClient.MorktJAKAJC Wait(0); new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); Wait(int.Parse(JakaModel.SENCE_初始位)); - new WriteJaka() { TagName = "JakaDOutput", DO_Index=0, Value = true }.Publish(); + new WriteJaka() { TagName = "JakaDOutput", DO_Index = 0, Value = true }.Publish(); Thread.Sleep(100); new WriteJaka() { TagName = "Set_RobotAO1", Value = 0 }.Publish(); Wait(0); @@ -739,7 +739,7 @@ namespace BPASmartClient.MorktJAKAJC Wait(int.Parse(JakaModel.SENCE_取杯位检测_取杯位)); //取杯到位,使用落杯器 new WriteJaka() { TagName = "JakaDOutput", DO_Index = 1, Value = true }.Publish(); - if (sensor_Sign(1)==1 ) + if (sensor_Sign(1) == 1) { new WriteJaka() { TagName = "JakaDOutput", DO_Index = 1, Value = false }.Publish(); Thread.Sleep(2000); @@ -788,7 +788,7 @@ namespace BPASmartClient.MorktJAKAJC } } } - + return 1; } catch (Exception ex) @@ -899,8 +899,8 @@ namespace BPASmartClient.MorktJAKAJC if (num == 0) { bSensorInput = GetStatus("Get_RobotDI0") ? 1 : 2; - } - else if (num == 1) + } + else if (num == 1) { bSensorInput = GetStatus("Get_RobotDI1") ? 1 : 2; } @@ -945,11 +945,11 @@ namespace BPASmartClient.MorktJAKAJC public void SimOrder(T simOrder) { - + } - - + + public override void Stop() { @@ -957,7 +957,7 @@ namespace BPASmartClient.MorktJAKAJC public override void ReadData() { - + } diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs index 02b1ab39..5f6240b7 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheAPI.xaml.cs @@ -96,7 +96,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls if (!string.IsNullOrEmpty(DataSouceInformation)) { Direction = 1; - FDataSouce = HttpRequestHelper.HttpPostRequest(DataSouceInformation,InterfaceParameters); + FDataSouce = APIHelper.GetInstance.HttpRequest(DataSouceInformation,InterfaceParameters); } break; @@ -105,7 +105,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls { Direction = 1; string returndata=string.Empty; - string obj_data= HttpRequestHelper.HttpGetRequest(DataSouceInformation); + string obj_data= APIHelper.GetInstance.GetRequest(DataSouceInformation); Dictionary obj = JsonConvert.DeserializeObject>(obj_data); if (obj.ContainsKey("data")) { @@ -132,7 +132,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls if (!string.IsNullOrEmpty(DataSouceInformation)) { Direction = 1; - //string data = HttpRequestHelper.HttpPostRequest(DataSouceInformation,InterfaceParameters); + //string data = APIHelper.GetInstance.HttpRequest(DataSouceInformation,InterfaceParameters); } break; default: diff --git a/BPASmartClient.ScreenLib/Helper/Main.cs b/BPASmartClient.ScreenLib/Helper/Main.cs index 8636109d..f7d2ce58 100644 --- a/BPASmartClient.ScreenLib/Helper/Main.cs +++ b/BPASmartClient.ScreenLib/Helper/Main.cs @@ -293,7 +293,7 @@ namespace BPASmartClient.ScreenLib try { string SaasRoute = System.Configuration.ConfigurationManager.AppSettings["SaasRoute"].ToString(); - string res = HttpRequestHelper.HttpGetRequest(SaasRoute); + string res = APIHelper.GetInstance.GetRequest(SaasRoute); if (!string.IsNullOrEmpty(res)) { HttpReturn httpReturn= JsonConvert.DeserializeObject(res); diff --git a/BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj b/BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj index 58e2b5f0..8f58c3f6 100644 --- a/BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj +++ b/BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj @@ -6,7 +6,7 @@ - + diff --git a/BPASmartClient.ViewModel/AlarmViewModel.cs b/BPASmartClient.ViewModel/AlarmViewModel.cs index f2ee54c6..5b868cdd 100644 --- a/BPASmartClient.ViewModel/AlarmViewModel.cs +++ b/BPASmartClient.ViewModel/AlarmViewModel.cs @@ -3,13 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - + using System.Collections.ObjectModel; using System.Windows; using System.Threading; using BPA.Helper; using BPASmartClient.Device; -using BPA.Helper; using BPASmartClient.Business; using BPASmartClient.Model; @@ -27,7 +26,7 @@ namespace BPASmartClient.ViewModel } if (ControlButText == "开始查询") { - var lists = Sqlite.GetInstance.GetData(); + var lists = Sqlite.GetInstance.GetData(); var res = lists.Where(p => Convert.ToDateTime(p.Date) >= StartDateTime && Convert.ToDateTime(p.Date) <= EndDateTime).ToList(); if (res != null) { @@ -90,7 +89,7 @@ namespace BPASmartClient.ViewModel private void GetHistoryAlarm() { - var data = Sqlite.GetInstance.GetData(); + var data = Sqlite.GetInstance.GetData(); if (data != null) { HistoryAlarm.Clear(); @@ -150,9 +149,9 @@ namespace BPASmartClient.ViewModel private DateTime _mEndDateTime = DateTime.Now; - public ObservableCollection AlarmInfos { get; set; } = new ObservableCollection(); + public ObservableCollection AlarmInfos { get; set; } = new(); - public ObservableCollection HistoryAlarm { get; set; } = new ObservableCollection(); + public ObservableCollection HistoryAlarm { get; set; } = new(); } } diff --git a/BPASmartClient.ViewModel/DataVViewModel.cs b/BPASmartClient.ViewModel/DataVViewModel.cs index c884df27..b55c6f97 100644 --- a/BPASmartClient.ViewModel/DataVViewModel.cs +++ b/BPASmartClient.ViewModel/DataVViewModel.cs @@ -3,7 +3,6 @@ using BPASmartClient.Business; using BPA.Helper; using BPASmartClient.IoT; using DataVAPI.Tool.IOT; -using BPA.Helper; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -99,7 +98,7 @@ namespace BPASmartClient.ViewModel { string url = ApiURL + "/api/Device/Query"; if (!string.IsNullOrEmpty(clientId)) url = ApiURL + "/api/Device/Query?clientId=" + clientId; - string json = HttpRequestHelper.HttpGetRequest(url); + string json = APIHelper.GetInstance.GetRequest(url); JsonMsg> jsonMsg = Tools.JsonToObjectTools>>(json); return jsonMsg.obj.data; } @@ -119,7 +118,7 @@ namespace BPASmartClient.ViewModel try { string url = ApiURL + "/api/Device/Modify"; - string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(device)); + string json = APIHelper.GetInstance.HttpRequest(url, device); Refresh(); return true; } @@ -139,7 +138,7 @@ namespace BPASmartClient.ViewModel try { string url = ApiURL + "/api/Device/Create"; - string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(device)); + string json = APIHelper.GetInstance.HttpRequest(url, device); Refresh(); return true; } @@ -155,7 +154,7 @@ namespace BPASmartClient.ViewModel try { string url = ApiURL + "/api/Device/Create"; - string json = HttpRequestHelper.HttpPostRequest(url, Tools.JsonConvertTools(deviceTable)); + string json = APIHelper.GetInstance.HttpRequest(url, Tools.JsonConvertTools(deviceTable)); Refresh(); return true; } @@ -175,7 +174,7 @@ namespace BPASmartClient.ViewModel try { string url = ApiURL + "/api/Device/DeleteDate?id=" + device.Id; - string json = HttpRequestHelper.HttpGetRequest(url); + string json = APIHelper.GetInstance.GetRequest(url); Refresh(); return true; } diff --git a/BPASmartClient.ViewModel/LogOrAlarmIOTViewModel.cs b/BPASmartClient.ViewModel/LogOrAlarmIOTViewModel.cs index 1b8d27c3..3fd236be 100644 --- a/BPASmartClient.ViewModel/LogOrAlarmIOTViewModel.cs +++ b/BPASmartClient.ViewModel/LogOrAlarmIOTViewModel.cs @@ -5,7 +5,7 @@ using BPA.Helper; using BPASmartClient.IoT; using DataVAPI.Tool.IOT; using BPA.Helper; - + using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -70,7 +70,7 @@ namespace BPASmartClient.ViewModel { LogDataFile.Clear(); api = $"{DataVApiAddress}/api/Log/QueryLogFile?DeviceName={DataVClient.GetInstance().DeviceDataV.deviceTable.devicename}"; ; - string json = HttpRequestHelper.HttpGetRequest(api, 1000); + string json = APIHelper.GetInstance.GetRequest(api); JsonMsg> jsonMsg = Tools.JsonToObjectTools>>(json); jsonMsg.obj?.data?.ForEach(file => { diff --git a/BPASmartClient.ViewModel/NewShopWindowModel.cs b/BPASmartClient.ViewModel/NewShopWindowModel.cs index ec6bb72b..e8100931 100644 --- a/BPASmartClient.ViewModel/NewShopWindowModel.cs +++ b/BPASmartClient.ViewModel/NewShopWindowModel.cs @@ -4,9 +4,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using BPA.Helper; -using BPA.Helper; - -using Microsoft.Toolkit.Mvvm.Messaging; using System.Windows; using System.IO; diff --git a/BPASmartClient.ViewModel/OrderListDialogViewModel.cs b/BPASmartClient.ViewModel/OrderListDialogViewModel.cs index 03ac522c..d2eac418 100644 --- a/BPASmartClient.ViewModel/OrderListDialogViewModel.cs +++ b/BPASmartClient.ViewModel/OrderListDialogViewModel.cs @@ -6,9 +6,6 @@ using BPA.Message; using BPA.Message.Enum; using BPA.Helper; using BPASmartClient.Model; -using BPA.Helper; - -using Microsoft.Toolkit.Mvvm.Messaging; namespace BPASmartClient.ViewModel { @@ -27,11 +24,11 @@ namespace BPASmartClient.ViewModel ConfirmButton(); if (Json.Data.orderLists.Count > 0) { - Message.MessageLog.GetInstance.Show($"ǰʣ{Json.Data.orderLists.Count}"); + MessageLog.GetInstance.Show($"ǰʣ{Json.Data.orderLists.Count}"); ThreadManage.GetInstance().Start(new Action(() => { Thread.Sleep(10000); - if (!IsAutoClose) WeakReferenceMessenger.Default.Send("false", "Close"); + if (!IsAutoClose) ActionManage.GetInstance.Send("Close", false); }), "ʱ˳"); } } @@ -44,7 +41,7 @@ namespace BPASmartClient.ViewModel CloseCommand = new BPARelayCommand(() => { Json.Data.orderLists.Clear(); - WeakReferenceMessenger.Default.Send("false", "Close"); + ActionManage.GetInstance.Send("Close", false); Json.Save(); }); } @@ -57,7 +54,7 @@ namespace BPASmartClient.ViewModel CancelCommand = new BPARelayCommand(() => { Json.Data.orderLists.Clear(); - WeakReferenceMessenger.Default.Send("false", "Close"); + ActionManage.GetInstance.Send("Close", false); Json.Save(); }); } @@ -89,17 +86,17 @@ namespace BPASmartClient.ViewModel IsAllSelect = item.IsAllSelect, morkOrderPushes = morkOrders, }); -/* - foreach (var mo in morkOrders) - { - DoOrderEvent de = new DoOrderEvent(); - de.DeviceId = int.Parse(item.DeviceId); - de.MorkOrder = mo.OrderPush; - EventBus.GetInstance().Publish(de); - }*/ + /* + foreach (var mo in morkOrders) + { + DoOrderEvent de = new DoOrderEvent(); + de.DeviceId = int.Parse(item.DeviceId); + de.MorkOrder = mo.OrderPush; + EventBus.GetInstance().Publish(de); + }*/ } } - WeakReferenceMessenger.Default.Send("true", "Close"); + ActionManage.GetInstance.Send("Close", true); }); } diff --git a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs index 69ed8af5..88dc9f39 100644 --- a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs +++ b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using BPA.Helper; using BPA.Helper; - + using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; @@ -64,7 +64,7 @@ namespace BPASmartClient.ViewModel deviceConfig.ElementAt(0).deviceModels.ElementAt(i).communicationDevcies.ElementAt(m).CommunicationNamespace = IPeripherals.FirstOrDefault(p => p.Contains(comName)); } } - File.WriteAllText($"{LocaPath.GetInstance().GetDeviceConfigPath}{FileName}.json", JsonConvert.SerializeObject(deviceConfig)); + File.WriteAllText($"{LocaPath.GetDeviceConfigPath}{FileName}.json", JsonConvert.SerializeObject(deviceConfig)); } }); } @@ -87,7 +87,7 @@ namespace BPASmartClient.ViewModel } } } - + } private void NewCommunication(object? obj) @@ -111,7 +111,7 @@ namespace BPASmartClient.ViewModel CommunicationName = $"Communication_{num}", DeviceModelId = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == dm.DeviceName)?.Id, communicationPar = new CommunicationPar() { IsNetworkPort = false }, - + }); break; @@ -250,7 +250,7 @@ namespace BPASmartClient.ViewModel }); Shops.Clear(); - DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath); + DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetDeviceConfigPath); var files = directoryInfo.GetFiles(); foreach (var item in files) { diff --git a/BPASmartClient/Control/AdminstratorsView.xaml b/BPASmartClient/Control/AdminstratorsView.xaml index a228acef..19ec506b 100644 --- a/BPASmartClient/Control/AdminstratorsView.xaml +++ b/BPASmartClient/Control/AdminstratorsView.xaml @@ -35,51 +35,83 @@ - - - - - - - -