diff --git a/BPASmartClient.AgvApi/Controllers/robotjobController.cs b/BPASmartClient.AgvApi/Controllers/robotjobController.cs index a0c6865d..7126cb11 100644 --- a/BPASmartClient.AgvApi/Controllers/robotjobController.cs +++ b/BPASmartClient.AgvApi/Controllers/robotjobController.cs @@ -2,6 +2,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Newtonsoft.Json; +using System.Diagnostics; +using System.Text; namespace BPASmartClient.AgvApi.Controllers { @@ -9,31 +11,44 @@ namespace BPASmartClient.AgvApi.Controllers [Route("apicallback/quicktron/[Controller]")] public class robotjobController : ControllerBase { + /// /// 搬运任务状态上报 /// /// /// [HttpPost("report")] - public string report(string sign) + public async Task report() { - if (sign != null) + //if (sign != null) + //{ + try { - try + using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { - var res = JsonConvert.DeserializeObject(sign); - if (res != null) + string body = await reader.ReadToEndAsync(); + + AGVToUpSystem s = JsonConvert.DeserializeObject(body); + if (s != null) { - Factory.GetInstance.SendReport(res); + Factory.GetInstance.SendReport(s); return "SUCCESS"; } - } - catch (Exception ex) - { - return ex.ToString(); - } + } + //var res = JsonConvert.DeserializeObject(sign); + //if (res != null) + //{ + // Factory.GetInstance.SendReport(res); + // return "SUCCESS"; + //} + } + catch (Exception ex) + { + return ex.ToString(); } + + // } return "Error"; } @@ -43,25 +58,29 @@ namespace BPASmartClient.AgvApi.Controllers /// /// [HttpPost("upstreamrequest")] - public string upstreamrequest(string sign) + public async Task upstreamrequest() { - if (sign != null) + //if (sign != null) + //{ + try { - try + using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { - var res = JsonConvert.DeserializeObject(sign); + string body = await reader.ReadToEndAsync(); + var res = JsonConvert.DeserializeObject(body); if (res != null) { - Factory.GetInstance.SendUpstreamrequest(sign); + Factory.GetInstance.SendUpstreamrequest(res); return "SUCCESS"; } } - catch (Exception ex) - { - return ex.ToString(); - } - } + catch (Exception ex) + { + return ex.ToString(); + } + + // } return "Error"; } diff --git a/BPASmartClient.CustomResource/Pages/View/UserManageView.xaml b/BPASmartClient.CustomResource/Pages/View/UserManageView.xaml index 3a2e5bfc..f5b91482 100644 --- a/BPASmartClient.CustomResource/Pages/View/UserManageView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/UserManageView.xaml @@ -385,7 +385,7 @@ - + diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/NfcSetViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/NfcSetViewModel.cs index d764d809..98808520 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/NfcSetViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/NfcSetViewModel.cs @@ -20,8 +20,9 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel { NfcServer.GetInstance.EnableLogin = true; permissions.Clear(); - Enum.GetNames(typeof(Permission)).ToList()?.ForEach(item => { - if(item !="管理员") permissions.Add(new PermissionSelect() { PermissionName = item }); + Enum.GetNames(typeof(Permission)).ToList()?.ForEach(item => + { + if (item != "管理员") permissions.Add(new PermissionSelect() { PermissionName = item }); }); UserAddCommand = new RelayCommand(() => @@ -29,12 +30,12 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel if (permissions?.FirstOrDefault(p => p.PermissionSelected == true) == null) { Info = "Error:请选择一个权限;"; - return ; + return; } if (CardNum == null || CardNum?.Length <= 0) { Info = "Error:请将卡放到刷卡区;"; - return ; + return; } var per = Global.userManager.userInfos.FirstOrDefault(p => p.CardId == CardNum); if (per != null) @@ -54,7 +55,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel return; } - var name = Global.userManager.userInfos.FirstOrDefault(p =>p.UserName == UserName); + var name = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == UserName); if (name != null) { Info = "Error:用户名已存在!;"; @@ -80,33 +81,41 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel } else Info = $"Info:ID {NFCHelper.GetInstance.GetReadResult.CardNum} 已存在;"; - + } }); UserCancelCommand = new RelayCommand(() => { - var res = Global.userManager.userInfos.FirstOrDefault(p=>p.CardId == CardNum); - if(res != null) + if (CardNum != null && CardNum != string.Empty) { - Global.userManager.userInfos.Remove(res); - Config.GetInstance.SaveUser(); - Info = $"Info:ID {CardNum} 注销成功;"; - MessageLog.GetInstance.ShowRunLog($"ID {CardNum} 用户注销成功"); - Thread.Sleep(1000); - ActionManage.GetInstance.Send("Exit"); + var res = Global.userManager.userInfos.FirstOrDefault(p => p.CardId == CardNum); + + if (res != null) + { + Global.userManager.userInfos.Remove(res); + Config.GetInstance.SaveUser(); + Info = $"Info:ID {CardNum} 注销成功;"; + MessageLog.GetInstance.ShowRunLog($"ID {CardNum} 用户注销成功"); + Thread.Sleep(1000); + ActionManage.GetInstance.Send("Exit"); + } + else + { + Info = "Info:当前卡在系统中不存在;"; + return; + } } else { - Info = "Info:当前卡在系统中不存在;"; - return; + Info = "Error:请将卡放到刷卡区;"; } }); NfcServer.GetInstance.Update = new Action(() => { CardNum = NFCHelper.GetInstance.GetReadResult.CardNum; - + }); } @@ -133,7 +142,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel public string Info { get { return _mInfo; } set { _mInfo = value; OnPropertyChanged(); } } private string _mInfo; - public string UserName { get { return _userName; } set { _userName = value; OnPropertyChanged(); } } + public string UserName { get { return _userName; } set { _userName = value; OnPropertyChanged(); } } private string _userName = string.Empty; public string CurrentPassword { get { return _currentPassword; } set { _currentPassword = value; OnPropertyChanged(); } } diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index 297fb690..11233b4b 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -107,6 +107,7 @@ namespace BPASmartClient.MorkF stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T9, PotActions = new List() { StirFryPotAction.中火持续, StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 30 }); stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T10, PotActions = new List() { StirFryPotAction.停止火力, StirFryPotAction.停止旋转, StirFryPotAction.搅拌臂上位 } }); stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List() { StirFryRobotAction.灶取锅 } }); + morkF.listStirBom.Add(stirFryBom); } /// /// 盐煎肉流程 @@ -319,14 +320,23 @@ namespace BPASmartClient.MorkF /// private void InitialData() { - //单个订单 string subId = Guid.NewGuid().ToString(); - morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 1 } });//A料 - morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 2 } });//B料 - morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 3 } });//C料 - morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId }); - resultorder.AddRange(new int[] { 1, 2, 3 }); - morkF.listStirBom.Add(stirFryBom); + //单个订单 + //string subId = Guid.NewGuid().ToString(); + //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 1 } });//A料 + //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 2 } });//B料 + //morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId, MaterialLoc = new List() { 3 } });//C料 + //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId }); + //resultorder.AddRange(new int[] { 1, 2, 3 }); + + for (int i = 0; i < morkF.listStirBom.Count; i++) + { + morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 1 } });//A料 + morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 2 } });//B料 + morkF.TakeMaterialQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i, MaterialLoc = new List() { 3 } });//C料 + morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+i }); + //resultorder.AddRange(new int[] { 1, 2, 3 }); + } //多个订单 //string subId = Guid.NewGuid().ToString(); @@ -340,8 +350,7 @@ namespace BPASmartClient.MorkF //morkF.TakePlateQueue.Enqueue(new OrderLocInfo() { SuborderId = subId+1 }); //resultorder.AddRange(new int[] { 1, 2, 3 }); //resultorder.AddRange(new int[] { 1, 2, 3 }); - //morkF.listStirBom.Add(stirFryBom); - //morkF.listStirBom.Add(stirFryBom); + } #endregion @@ -707,6 +716,7 @@ namespace BPASmartClient.MorkF { if (morkF.MainHasTakeMaterial) { + } else { @@ -913,15 +923,11 @@ namespace BPASmartClient.MorkF //模拟订单 if (morkF.TakeMaterialQueue.Count > 0 && !morkF.TurnTableLock && General_Config.SimOrderAllow) { - - if (resultorder != null) + if (morkF.TakeMaterialQueue.TryDequeue(out OrderLocInfo info)) { - - TurnMaterialStore(resultorder[0]); - DeviceProcessLogShow($"转台转到【{resultorder[0]}】位置"); - resultorder.RemoveAt(0); - morkF.TurnTableLock = true; //取料完成后置false - + TurnMaterialStore(info.MaterialLoc[0]); + DeviceProcessLogShow($"转台转到【{info.MaterialLoc[0]}】位置"); + morkF.TurnTableLock = true; } else { diff --git a/BPASmartClient.MorkF/View/DebugView.xaml b/BPASmartClient.MorkF/View/DebugView.xaml index 9bac5ef9..b498f462 100644 --- a/BPASmartClient.MorkF/View/DebugView.xaml +++ b/BPASmartClient.MorkF/View/DebugView.xaml @@ -35,7 +35,7 @@ - + diff --git a/FryPot_DosingSystem/App.xaml.cs b/FryPot_DosingSystem/App.xaml.cs index 1b669855..e6c2189a 100644 --- a/FryPot_DosingSystem/App.xaml.cs +++ b/FryPot_DosingSystem/App.xaml.cs @@ -144,23 +144,47 @@ namespace FryPot_DosingSystem subMenumodels = InfoLog, }); #endregion - - #region 硬件设备监控 - ObservableCollection DeviceMonitor = new ObservableCollection(); - DeviceMonitor.Add(new SubMenumodel() + #region 参数设置 + ObservableCollection ParamSet = new ObservableCollection(); + ParamSet.Add(new SubMenumodel() { SubMenuName = "PLC通讯设置", SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, AssemblyName = "FryPot_DosingSystem", ToggleWindowPath = "View.DeviceListVIew" }); - DeviceMonitor.Add(new SubMenumodel() + ParamSet.Add(new SubMenumodel() { SubMenuName = "PLC变量配置", SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.VariableConfigView" }); + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "参数设置", + Alias = "Parameters Set", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 }, + subMenumodels = ParamSet, + }); + #endregion + #region 硬件设备监控 + ObservableCollection DeviceMonitor = new ObservableCollection(); + //DeviceMonitor.Add(new SubMenumodel() + //{ + // SubMenuName = "PLC通讯设置", + // SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, + // AssemblyName = "FryPot_DosingSystem", + // ToggleWindowPath = "View.DeviceListVIew" + //}); + //DeviceMonitor.Add(new SubMenumodel() + //{ + // SubMenuName = "PLC变量配置", + // SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 }, + // AssemblyName = "BPASmartClient.CustomResource", + // ToggleWindowPath = "Pages.View.VariableConfigView" + //}); DeviceMonitor.Add(new SubMenumodel() { @@ -216,7 +240,7 @@ namespace FryPot_DosingSystem }); UserManager.Add(new SubMenumodel() { - SubMenuName = "账号管理", + SubMenuName = "用户管理", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.UserManageView" diff --git a/FryPot_DosingSystem/ViewModel/DebugViewModel.cs b/FryPot_DosingSystem/ViewModel/DebugViewModel.cs index 836717cd..3fb27c54 100644 --- a/FryPot_DosingSystem/ViewModel/DebugViewModel.cs +++ b/FryPot_DosingSystem/ViewModel/DebugViewModel.cs @@ -8,6 +8,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; namespace FryPot_DosingSystem.ViewModel { @@ -80,6 +81,8 @@ namespace FryPot_DosingSystem.ViewModel public RelayCommand LineTwoEmptyRollerCleanTaskRestart { get; set; } public RelayCommand LineThreeEmptyRollerCleanTaskRestart { get; set; } + + public DebugViewModel() { AgvDebug = new RelayCommand(new Action(() => diff --git a/TestDemo/Form1.cs b/TestDemo/Form1.cs index ab65440e..67636e60 100644 --- a/TestDemo/Form1.cs +++ b/TestDemo/Form1.cs @@ -16,16 +16,18 @@ namespace TestDemo private void button1_Click(object sender, EventArgs e) { AGVToUpSystem aGVToUpSystem = new AGVToUpSystem(); - string value = JsonConvert.SerializeObject(aGVToUpSystem); - string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/report?sign={value}"; + //string value = JsonConvert.SerializeObject(aGVToUpSystem); + //string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/report?sign={value}"; + string url = "http://192.168.1.40:8089/apicallback/quicktron/robotjob/report"; var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST); } private void button2_Click(object sender, EventArgs e) { - Upstreamrequest aGVToUpSystem = new Upstreamrequest(); - string value = JsonConvert.SerializeObject(aGVToUpSystem); - string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}"; + Upstreamrequest aGVToUpSystem = new Upstreamrequest() { agvCode="123" }; + // string value = JsonConvert.SerializeObject(aGVToUpSystem); + // string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/upstreamrequest?sign={value}"; + string url = $"http://192.168.1.40:8089/apicallback/quicktron/robotjob/upstreamrequest"; var res = APIHelper.GetInstance.HttpRequest(url, "", aGVToUpSystem, RequestType.POST); }