diff --git a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj index 3cfc14aa..75c615c0 100644 --- a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj +++ b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj @@ -1,7 +1,7 @@  - WinExe + Exe net6.0-windows enable true diff --git a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs index 1baef928..68ade063 100644 --- a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs +++ b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs @@ -121,7 +121,7 @@ namespace Aucma.Core.Palletiz.Business log.Error($"Buffer缓冲异常:{e.Message}"); } } - + /// /// 入库申请 /// @@ -129,6 +129,7 @@ namespace Aucma.Core.Palletiz.Business /// 20位是正常扫码传输的条码,手动入库传的是人工选择的成品型号 private void InStore(string spaceArea, string asciiStr) { + #region 未登录禁止入库 if (string.IsNullOrEmpty(appConfig.TeamName)) { @@ -136,6 +137,7 @@ namespace Aucma.Core.Palletiz.Business return; } #endregion + Task.Run(() => { @@ -176,7 +178,7 @@ namespace Aucma.Core.Palletiz.Business bool result = false; - SendInStoreTask(asciiStr, spaceinfo, ref result, Convert.ToInt32(prodInfo.ProductMasterModel), ref msg, out int range); + SendInStoreTask(spaceArea,asciiStr, spaceinfo, ref result, Convert.ToInt32(prodInfo.ProductMasterModel), ref msg, out int range); #region 添加入库记录 @@ -399,7 +401,7 @@ namespace Aucma.Core.Palletiz.Business /// /// /// - private void SendInStoreTask(string asciiStr, BaseSpaceInfo spaceinfo, ref bool result,int prodWeight,ref string msg,out int rangeResult) + private void SendInStoreTask(string spaceArea, string asciiStr, BaseSpaceInfo spaceinfo, ref bool result,int prodWeight,ref string msg,out int rangeResult) { int spinFlag = -1; rangeResult = 0; @@ -413,7 +415,7 @@ namespace Aucma.Core.Palletiz.Business bool isFlag = true; int spaceCode = StringChange.ParseToInt(spaceinfo.SpaceCode); - spinFlag =JudgeRotation(spaceCode, prodWeight, out int ranges); + spinFlag =JudgeRotation(spaceArea,spaceCode, prodWeight, out int ranges); rangeResult = ranges; if (spinFlag == -1) { @@ -431,7 +433,15 @@ namespace Aucma.Core.Palletiz.Business result = false; return; } - bool answerFlag = _plc.ReadBool("B1000"); + bool answerFlag = false; + if (spaceinfo.SpaceArea == "A") + { + answerFlag = _plc.ReadBool("B1000"); + } + else if (spaceinfo.SpaceArea == "B") + { + answerFlag = _plc.ReadBool("B1010"); + } if (answerFlag) { @@ -460,20 +470,31 @@ namespace Aucma.Core.Palletiz.Business else if (spaceinfo.SpaceArea == "B") { - result = false; + if (!_plc.WriteInt16("D0", spinFlag.ToString())) + { + throw new ArgumentException($"旋转角度下发至PLC失败"); + } + if (!_plc.WriteInt16("D9", spaceCode.ToString())) + { + throw new ArgumentException($"货道号下发至PLC失败"); + } + + _plc.WriteInt16("B1002", "1");//发送完成信号 + + result = true; } } /// - /// 根据货物容积确定旋转规则 转180度发1,不转发3 + /// 根据货物容积确定旋转规则 /// /// /// - public int JudgeRotation(int spaceCode,int prodWeight, out int ranges) + public int JudgeRotation(string spaceArea,int spaceCode,int prodWeight, out int ranges) { try { - List list = appConfig.GetJumpRanges(); + List list = appConfig.GetJumpRanges(spaceArea); foreach (JumpRange range in list) { if (range.MinModel <= prodWeight && range.MaxModel > prodWeight) // 找到该型号规则 diff --git a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs index 78ec4a3f..1d3eccd9 100644 --- a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs @@ -23,7 +23,7 @@ namespace Aucma.Core.Palletiz.ViewModels public IndexControlViewModel() { - + new InStoreBusiness().Init(); SelectTypeViewModel.RefreshPageEvent += Init; StatisticsPageViewModel.CountInstoreEvent += CountInstore; @@ -191,7 +191,7 @@ namespace Aucma.Core.Palletiz.ViewModels })); } - var info2 = inStoreBusiness.GetBaseSpaceinfos("A"); + var info2 = inStoreBusiness.GetBaseSpaceinfos("B"); info2 = info2.OrderBy(x => x.ObjId).ToList(); if (info2 != null) { diff --git a/Aucma.Core.Palletiz/ViewModels/SetRangeWindowViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SetRangeWindowViewModel.cs index 042b6436..64f598e4 100644 --- a/Aucma.Core.Palletiz/ViewModels/SetRangeWindowViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/SetRangeWindowViewModel.cs @@ -21,8 +21,11 @@ namespace Aucma.Core.Palletiz.ViewModels public List jumpRanges = new List(); - public SetRangeWindowViewModel() + //默认A + public string position = "A"; + public SetRangeWindowViewModel(string Position) { + position = Position; InitDataGrid(); DeleteCommand = new RelayCommand(obj => Delete(obj)); @@ -34,11 +37,16 @@ namespace Aucma.Core.Palletiz.ViewModels { string objId = obj.ToString(); Console.WriteLine(objId); - JumpRange delete = config.GetJumpRanges().FirstOrDefault(x => x.ObjId == int.Parse(objId)); + JumpRange delete = config.GetJumpRanges(position).FirstOrDefault(x => x.ObjId == int.Parse(objId)); string deleteStr = $"[{delete.MinModel}-{delete.MaxModel}-{delete.OddSpaceRange}-{delete.EvenSpaceRange}]"; - // 配置文件减去该字符串 - // string temp = config.RangeConfig; - // string result1 = temp.Replace(deleteStr, ""); + if(position== "A") + { + config.RangeConfig = config.RangeConfig.Replace(deleteStr, ""); + } + else + { + config.RangeConfigB = config.RangeConfigB.Replace(deleteStr, ""); + } config.RangeConfig = config.RangeConfig.Replace(deleteStr, ""); MessageBox.Show("删除成功"); InitDataGrid(); @@ -55,7 +63,7 @@ namespace Aucma.Core.Palletiz.ViewModels { int id = 1; ListItems.Clear(); - List list = config.GetJumpRanges(); + List list = config.GetJumpRanges(position); if (list == null || list.Count == 0) return; foreach(JumpRange jumpRange in list) { @@ -139,7 +147,14 @@ namespace Aucma.Core.Palletiz.ViewModels MessageBoxResult result = MessageBox.Show("确认保存吗?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { - config.RangeConfig = config.RangeConfig + $"[{MinModel}-{MaxModel}-{SelectedOddNumber}-{SelectedEvenNumber}]"; + if(position== "A") + { + config.RangeConfig = config.RangeConfig + $"[{MinModel}-{MaxModel}-{SelectedOddNumber}-{SelectedEvenNumber}]"; + } + else + { + config.RangeConfigB = config.RangeConfigB + $"[{MinModel}-{MaxModel}-{SelectedOddNumber}-{SelectedEvenNumber}]"; + } MessageBox.Show("保存成功"); @@ -156,7 +171,7 @@ namespace Aucma.Core.Palletiz.ViewModels { try { - List list = config.GetJumpRanges(); + List list = config.GetJumpRanges(position); foreach (JumpRange range in list) { if (range.MinModel <= prodWeight && range.MaxModel > prodWeight) // 找到该型号规则 diff --git a/Aucma.Core.Palletiz/Views/IndexPageView.xaml b/Aucma.Core.Palletiz/Views/IndexPageView.xaml index e950f088..7375d4e5 100644 --- a/Aucma.Core.Palletiz/Views/IndexPageView.xaml +++ b/Aucma.Core.Palletiz/Views/IndexPageView.xaml @@ -133,8 +133,9 @@ -