From 38ed7dc1d75d96feee317ade004db845bad1db75 Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 29 Dec 2023 22:54:28 +0800 Subject: [PATCH] =?UTF-8?q?change-=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.Core.Api/Admin.Core.Model.xml | 20 ++++++ .../Aucma.Core.OldBoxFoam.csproj | 2 +- Aucma.Core.OldBoxFoam/Business/Collection.cs | 69 +++++++++++++++++-- Aucma.Core.OldBoxFoam/Models/FixtureStatus.cs | 54 +++++++++++++++ Aucma.Core.OldBoxFoam/appsettings.json | 4 ++ 5 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 Aucma.Core.OldBoxFoam/Models/FixtureStatus.cs diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index 59aaf9de..37c7bc2a 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -546,6 +546,16 @@ 更新时间 + + + 产品型号 + + + + + 产品名称 + + SAP BOM 信息 @@ -1366,11 +1376,21 @@ 物料名称 + + + SAP订单编码 + + 计划数量 + + + 产线 + + 更新时间 diff --git a/Aucma.Core.OldBoxFoam/Aucma.Core.OldBoxFoam.csproj b/Aucma.Core.OldBoxFoam/Aucma.Core.OldBoxFoam.csproj index afffdecb..a4a39d03 100644 --- a/Aucma.Core.OldBoxFoam/Aucma.Core.OldBoxFoam.csproj +++ b/Aucma.Core.OldBoxFoam/Aucma.Core.OldBoxFoam.csproj @@ -1,7 +1,7 @@  - WinExe + Exe net6.0-windows enable true diff --git a/Aucma.Core.OldBoxFoam/Business/Collection.cs b/Aucma.Core.OldBoxFoam/Business/Collection.cs index ccce99d1..de2874f6 100644 --- a/Aucma.Core.OldBoxFoam/Business/Collection.cs +++ b/Aucma.Core.OldBoxFoam/Business/Collection.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -12,6 +13,9 @@ namespace Aucma.Core.OldBoxFoam.Business public class Collection { public HwPLc.PlcModel plc1 = null; + public HwPLc.PlcModel plc2 = null; + public HwPLc.PlcModel plc3 = null; + public HwPLc.PlcModel plc4 = null; public Collection() { startCollect(); @@ -21,12 +25,43 @@ namespace Aucma.Core.OldBoxFoam.Business Task.Run(() => { Thread.Sleep(3000); - plc1 = HwPLc.PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + plc1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); + plc2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2")); + plc3 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3")); + plc4 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc4")); while (true) { ReadBoxType(plc1); + ReadBoxType(plc2); + ReadBoxType(plc3); + ReadBoxType(plc4); - Thread.Sleep(1000); + ReadHolderStatus(plc1); + ReadHolderStatus(plc2); + ReadHolderStatus(plc3); + ReadHolderStatus(plc4); + + ReadHolderOutPut(plc1); + ReadHolderOutPut(plc2); + ReadHolderOutPut(plc3); + ReadHolderOutPut(plc4); + + ReadSolidifyTime(plc1); + ReadSolidifyTime(plc2); + ReadSolidifyTime(plc3); + ReadSolidifyTime(plc4); + + ReadStoreType(plc1); + ReadStoreType(plc2); + ReadStoreType(plc3); + ReadStoreType(plc4); + + ReadStoreAmount(plc1); + ReadStoreAmount(plc2); + ReadStoreAmount(plc3); + ReadStoreAmount(plc4); + + Thread.Sleep(100000); } }); } @@ -51,7 +86,7 @@ namespace Aucma.Core.OldBoxFoam.Business /// /// 读取夹具状态 /// - static void ReadHolderStatus(PlcModel obj1, PlcModel obj2) + static void ReadHolderStatus(PlcModel obj1) { byte[] result = obj1.plc.Read("YF0", 1); //输出二进制字符串,1#-3#手动、自动数据 @@ -103,7 +138,7 @@ namespace Aucma.Core.OldBoxFoam.Business item3 = 3; } - byte[] result3 = obj2.plc.Read("Y100", 1); + byte[] result3 = obj1.plc.Read("Y100", 1); string str3 = ByteArrayToBinary(array(result3)); int item4 = 0; @@ -197,7 +232,29 @@ namespace Aucma.Core.OldBoxFoam.Business int temp4 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(60).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); Console.WriteLine($"读取泡前库箱型,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4}"); } + /// + /// 读取泡前库库存 + /// + static void ReadStoreAmount(PlcModel obj) + { + byte[] result = obj.plc.Read("L101", 1); + string str1 = ByteArrayToBinary(array(result)).Substring(0, 3); + int item1 = Regex.Matches(str1, "1").Count; + + byte[] result2 = obj.plc.Read("L201", 1); + string str2 = ByteArrayToBinary(array(result2)).Substring(0, 3); + int item2 = Regex.Matches(str2, "1").Count; + byte[] result3 = obj.plc.Read("L301", 1); + string str3 = ByteArrayToBinary(array(result3)).Substring(0, 3); + int item3 = Regex.Matches(str3, "1").Count; + + byte[] result4 = obj.plc.Read("L401", 1); + string str4 = ByteArrayToBinary(array(result4)).Substring(0, 3); + int item4 = Regex.Matches(str4, "1").Count; + + Console.WriteLine($"读取泡前库库存,1#:{item1};2#{item2};3#:{item3};4#:{item4}"); + } /// @@ -227,10 +284,10 @@ namespace Aucma.Core.OldBoxFoam.Business binaryString.Append(Convert.ToString(b, 2).PadLeft(8, '0')); } - Console.WriteLine(binaryString); + // Console.WriteLine(binaryString); string reversedStr = new string(binaryString.ToString().Reverse().ToArray()); - Console.WriteLine(reversedStr); + // Console.WriteLine(reversedStr); return reversedStr; } diff --git a/Aucma.Core.OldBoxFoam/Models/FixtureStatus.cs b/Aucma.Core.OldBoxFoam/Models/FixtureStatus.cs new file mode 100644 index 00000000..f2566232 --- /dev/null +++ b/Aucma.Core.OldBoxFoam/Models/FixtureStatus.cs @@ -0,0 +1,54 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.OldBoxFoam.Models +{ + /// + /// plc夹具状态 + /// + public class FixtureStatus + { + /// + /// 夹具箱型 + /// + public string FixtureBoxType { get; set; } + /// + /// 夹具状态 + /// + public string Status { get; set; } + /// + /// 夹具产量 + /// + public string Yield { get; set; } + /// + /// 固化时间设定值 + /// + public string PlanCuringTime { get; set; } + + /// + /// 固化时间实际值 + /// + public string RealCuringTime { get; set; } + + ///// + ///// 生产节拍 + ///// + //public string ProductionCycle { get; set; } + + /// + /// 泡前库箱型 + /// + public string BeforeBoxType { get; set; } + + /// + /// 泡前库库存数 + /// + public string Inventory { get; set; } + + + } +} diff --git a/Aucma.Core.OldBoxFoam/appsettings.json b/Aucma.Core.OldBoxFoam/appsettings.json index ee789b85..67566a56 100644 --- a/Aucma.Core.OldBoxFoam/appsettings.json +++ b/Aucma.Core.OldBoxFoam/appsettings.json @@ -189,12 +189,16 @@ }, { "Id": 3, + "PlcType": "Melsec", + "Enabled": true, "EquipName": "OldMelsecPlc3", "IP": "10.10.93.153", "Port": 5002 }, { "Id": 4, + "PlcType": "Melsec", + "Enabled": true, "EquipName": "OldMelsecPlc4", "IP": "10.10.93.154", "Port": 5002