diff --git a/Aucma.Core.BoxFoam/Business/Collection.cs b/Aucma.Core.BoxFoam/Business/Collection.cs new file mode 100644 index 00000000..9417a960 --- /dev/null +++ b/Aucma.Core.BoxFoam/Business/Collection.cs @@ -0,0 +1,383 @@ +//using Admin.Core.Common.Helper; +//using Aucma.Core.HwPLc; +//using Aucma.Core.OldBoxFoam.Models; +//using NetTaste; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using System.Text.RegularExpressions; +//using System.Threading; +//using System.Threading.Tasks; + +//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 List listFixtureStatus = new List(); +// public List spaceDetailModel = new List(); + +// public List BoxTypeList = new List(); +// public List HolderStatusList = new List(); +// public List HolderOutPutList = new List(); +// public List SolidifyTimeList = new List(); +// public List StoreTypeList = new List(); +// public List StoreAmountList = new List(); + + +// public Collection() { + +// } +// public void startCollect() +// { +// try +// { +// ///Task.Run(() => +// //{ +// // Thread.Sleep(3000); +// 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) +// //{ +// BoxTypeList.Clear(); +// HolderStatusList.Clear(); +// HolderOutPutList.Clear(); +// SolidifyTimeList.Clear(); +// listFixtureStatus.Clear();//夹具集合 +// spaceDetailModel.Clear();//货道集合 +// //夹具箱型 + +// ReadBoxType(plc1, BoxTypeList); +// ReadBoxType(plc2, BoxTypeList); +// ReadBoxType(plc3, BoxTypeList); +// ReadBoxType(plc4, BoxTypeList); + +// ReadHolderStatus(plc1, HolderStatusList); +// ReadHolderStatus(plc2, HolderStatusList); +// ReadHolderStatus(plc3, HolderStatusList); +// ReadHolderStatus(plc4, HolderStatusList); + +// ReadHolderOutPut(plc1, HolderOutPutList); +// ReadHolderOutPut(plc2, HolderOutPutList); +// ReadHolderOutPut(plc3, HolderOutPutList); +// ReadHolderOutPut(plc4, HolderOutPutList); + +// ReadSolidifyTime(plc1, SolidifyTimeList); +// ReadSolidifyTime(plc2, SolidifyTimeList); +// ReadSolidifyTime(plc3, SolidifyTimeList); +// ReadSolidifyTime(plc4, SolidifyTimeList); + +// ReadStoreType(plc1, StoreTypeList); +// ReadStoreType(plc2, StoreTypeList); +// ReadStoreType(plc3, StoreTypeList); +// ReadStoreType(plc4, StoreTypeList); + +// ReadStoreAmount(plc1, StoreAmountList); +// ReadStoreAmount(plc2, StoreAmountList); +// ReadStoreAmount(plc3, StoreAmountList); +// ReadStoreAmount(plc4, StoreAmountList); +// for (int i = 0; i < 24; i++) +// { +// //if (listFixtureStatus.Count > 0) +// //{ +// FixtureStatus model = new FixtureStatus(); +// model.ObjId = i + 1; +// if (BoxTypeList!=null &&BoxTypeList.Count > 0) model.FixtureBoxType = BoxTypeList[i].ToString(); +// if (HolderStatusList!=null &&HolderStatusList.Count > 0) model.Status = HolderStatusList[i]; +// if (HolderOutPutList!=null && HolderOutPutList.Count > 0) model.Yield = HolderOutPutList[i]; +// if (SolidifyTimeList!=null &&SolidifyTimeList.Count > 0) model.PlanCuringTime = SolidifyTimeList[i]; +// listFixtureStatus.Add(model); + + +// } +// for (int i = 0; i < 8; i++) +// { +// SpaceDetailModel model = new SpaceDetailModel(); +// model.ObjId = i + 1; +// if (StoreTypeList.Count > 0) model.StoreType = StoreTypeList[i].ToString(); +// if (StoreAmountList.Count > 0) model.StoreAmount = Convert.ToInt32(StoreAmountList[i]); +// spaceDetailModel.Add(model); +// } +// // Thread.Sleep(10000); +// //} +// //}); +// }catch(Exception ex) +// { +// Console.WriteLine(ex.Message); +// } +// } +// /// +// /// 读取夹具箱型 +// /// +// static void ReadBoxType(HwPLc.PlcModel obj, List BoxTypeList) +// { +// if (obj == null) return; + +// if (obj.plc.IsConnected) +// { +// byte[] result = obj.plc.Read("D3140", 48); +// if (result == null) return; +// byte[] info = result; +// int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(4).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp3 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(8).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp4 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(12).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp5 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(16).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp6 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(18).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// BoxTypeList.Add(temp1); +// BoxTypeList.Add(temp2); +// BoxTypeList.Add(temp3); +// BoxTypeList.Add(temp4); +// BoxTypeList.Add(temp5); +// BoxTypeList.Add(temp6); +// Console.WriteLine($"读取夹具箱型,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}"); +// } +// } + +// /// +// /// 读取夹具状态 +// /// +// static void ReadHolderStatus(PlcModel obj1, List HolderStatusList) +// { +// if (obj1 == null) return; +// byte[] result = obj1.plc.Read("YF0", 1); +// if (result == null) return; +// //输出二进制字符串,1#-3#手动、自动数据 +// string str1 = ByteArrayToBinary(array(result)); +// byte[] result2 = obj1.plc.Read("Y110", 1); +// string str2 = ByteArrayToBinary(array(result2)); +// //1# +// int item1 = 0; +// if (str1.Substring(0, 1) == "1") +// { +// item1 = 1; +// } +// else if (str1.Substring(1, 1) == "1") +// { +// item1 = 2; +// } +// else if (str2.Substring(0, 1) == "1") +// { +// item1 = 3; +// } + +// //2# +// int item2 = 0; +// if (str1.Substring(5, 1) == "1") +// { +// item2 = 1; +// } +// else if (str1.Substring(6, 1) == "1") +// { +// item2 = 2; +// } +// else if (str2.Substring(1, 1) == "1") +// { +// item2 = 3; +// } + +// //3# +// int item3 = 0; +// if (str1.Substring(10, 1) == "1") +// { +// item3 = 1; +// } +// else if (str1.Substring(11, 1) == "1") +// { +// item3 = 2; +// } +// else if (str2.Substring(2, 1) == "1") +// { +// item3 = 3; +// } + +// byte[] result3 = obj1.plc.Read("Y100", 1); +// string str3 = ByteArrayToBinary(array(result3)); + +// int item4 = 0; +// if (str3.Substring(0, 1) == "1") +// { +// item4 = 1; +// } +// else if (str3.Substring(1, 1) == "1") +// { +// item4 = 2; +// } +// else if (str2.Substring(3, 1) == "1") +// { +// item4 = 3; +// } +// int item5 = 0; +// if (str3.Substring(5, 1) == "1") +// { +// item5 = 1; +// } +// else if (str3.Substring(6, 1) == "1") +// { +// item5 = 2; +// } +// else if (str2.Substring(4, 1) == "1") +// { +// item5 = 3; +// } +// int item6 = 0; +// if (str3.Substring(10, 1) == "1") +// { +// item6 = 1; +// } +// else if (str3.Substring(11, 1) == "1") +// { +// item6 = 2; +// } +// else if (str2.Substring(5, 1) == "1") +// { +// item6 = 3; +// } +// HolderStatusList.Add(item1); +// HolderStatusList.Add(item2); +// HolderStatusList.Add(item3); +// HolderStatusList.Add(item4); +// HolderStatusList.Add(item5); +// HolderStatusList.Add(item6); +// Console.WriteLine($"读取夹具状态,1#:{item1};2#:{item2};3#:{item3};4#:{item4};5#:{item5};6#:{item6}"); +// } + +// /// +// /// 读取夹具产量 +// /// +// static void ReadHolderOutPut(PlcModel obj,List HolderOutPutList) +// { +// if (obj == null) return; +// byte[] result = obj.plc.Read("D182", 24); +// if (result == null) return; +// byte[] info = result; +// int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(2).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp3 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(4).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp4 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(6).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp5 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(8).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp6 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(10).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// HolderOutPutList.Add(temp1); +// HolderOutPutList.Add(temp2); +// HolderOutPutList.Add(temp3); +// HolderOutPutList.Add(temp4); +// HolderOutPutList.Add(temp5); +// HolderOutPutList.Add(temp6); + +// Console.WriteLine($"读取夹具产量,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}"); +// } + +// /// +// /// 读取固化时间 +// /// +// static void ReadSolidifyTime(PlcModel obj,List SolidifyTimeList) +// { +// if (obj == null) return; +// byte[] result = obj.plc.Read("D910", 24); +// if (result == null) return; +// byte[] info = result; +// int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(2).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp3 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(4).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp4 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(6).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp5 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(8).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp6 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(10).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// SolidifyTimeList.Add(temp1); +// SolidifyTimeList.Add(temp2); +// SolidifyTimeList.Add(temp3); +// SolidifyTimeList.Add(temp4); +// SolidifyTimeList.Add(temp5); +// SolidifyTimeList.Add(temp6); +// Console.WriteLine($"读取固化时间,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}"); +// } + +// /// +// /// 读取泡前库箱型 +// /// +// static void ReadStoreType(PlcModel obj, List storeType) +// { +// if (obj == null) return; +// //夹具箱型 +// byte[] result = obj.plc.Read("D2010", 40); +// if (result == null) return; +// byte[] info = result; +// int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(20).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp3 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(40).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); +// int temp4 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(60).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); + +// storeType.Add(temp1.ToString()); +// storeType.Add(temp2.ToString()); +// storeType.Add(temp2.ToString()); +// storeType.Add(temp2.ToString()); +// Console.WriteLine($"读取泡前库箱型,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4}"); +// } +// /// +// /// 读取泡前库库存 +// /// +// static void ReadStoreAmount(PlcModel obj, List storeAmount) +// { +// if (obj == null) return; +// byte[] result = obj.plc.Read("L101", 1); +// if (result == null) return; +// 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}"); +// } + + +// /// +// /// +// static byte[] array(byte[] data) +// { +// for (int i = 0; i < data.Length; i += 2) +// { +// byte temp = data[i]; +// data[i] = data[i + 1]; +// data[i + 1] = temp; +// } + +// return data; +// } + +// /// +// /// byte[]转二进制 +// /// +// /// +// static string ByteArrayToBinary(byte[] bytes) +// { +// StringBuilder binaryString = new StringBuilder(); + +// foreach (byte b in bytes) +// { +// binaryString.Append(Convert.ToString(b, 2).PadLeft(8, '0')); +// } + +// // Console.WriteLine(binaryString); + +// string reversedStr = new string(binaryString.ToString().Reverse().ToArray()); +// // Console.WriteLine(reversedStr); + +// return reversedStr; +// } +// } +//} diff --git a/Aucma.Core.BoxFoam/Business/CollectionFoamLine.cs b/Aucma.Core.BoxFoam/Business/CollectionFoamLine.cs new file mode 100644 index 00000000..f3a3f830 --- /dev/null +++ b/Aucma.Core.BoxFoam/Business/CollectionFoamLine.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.BoxFoam.Business +{ + /// + /// 采集发泡线数据 + /// + public class CollectionFoamLine + { + + } +}