You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1336 lines
71 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Admin.Core.Common;
using Admin.Core.Common.Helper;
using Admin.Core.IService;
using Admin.Core.Model;
using Aucma.Core.HwPLc;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using NPOI.SS.Formula.Functions;
using NPOI.Util;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.DirectoryServices.Protocols;
using System.Linq;
using System.Security.RightsManagement;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Documents;
namespace Aucma.Core.DoorFoam.Business
{
/// <summary>
/// 采集发泡线数据
/// </summary>
public class DoorCollection
{
private static System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
private IDoorFoamMachineServices _doorFoamMachineServices;
/// <summary>
/// 刷新门体发泡数据
/// </summary>
/// <param name="message"></param>
public delegate void RefreshDoorFoamMachine(List<DoorFoamMachine> doorFoams);
public event RefreshDoorFoamMachine RefreshDoorFoamMachineEvent;
public DoorCollection()
{
_doorFoamMachineServices = App.ServiceProvider.GetService<IDoorFoamMachineServices>();
}
public void startCollect()
{
while (true)
{
//semaphore.WaitOne();
try
{
Thread.Sleep(5000);
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("DoorPlc"));
if (obj != null)
{
//读取所有模具状态
List<DoorFoamMachine> moldStatusList = ReadModeStatus(obj);
//读取所有模具型号
List<DoorFoamMachine> moldTypeList = ReadModeType(obj);
//读取所有模具产量
List<DoorFoamMachine> aDoorMoldOutPutList = ReadADoorModeProduct(obj);
List<DoorFoamMachine> bDoorMoldOutPutList = ReadBDoorModeProduct(obj);
#region 读取设备状态1运行 2停机 3故障、生产节拍、节拍、设备报警
byte[] info = obj.plc.Read("DB490.646", 10);
int deviceStatus = 0;
float productTakt = 0;
float taktNum = 0;
if (info != null)
{
//设备状态1运行 2停机 3故障
deviceStatus = judgeStatus(ByteArrayToBinary(info.Skip(0).Take(1).ToArray()));
// 台车节拍
productTakt = int.Parse(StringChange.bytesToHexStr(info.Skip(2).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
//整圈节拍
taktNum = int.Parse(StringChange.bytesToHexStr(info.Skip(6).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
}
int deviceAlarm = obj.plc.ReadInt32("DB490.2136");
#endregion
List<DoorFoamMachine> result = new List<DoorFoamMachine>();
var mergedCollection = from moldStatus in moldStatusList
join moldType in moldTypeList on new { moldStatus.StationTrolleyNumber } equals new { moldType.StationTrolleyNumber }
join moldOutPut_A in aDoorMoldOutPutList on new { moldStatus.StationTrolleyNumber } equals new { moldOutPut_A.StationTrolleyNumber }
join moldOutPut_B in bDoorMoldOutPutList on new { moldStatus.StationTrolleyNumber } equals new { moldOutPut_B.StationTrolleyNumber }
select new DoorFoamMachine
{
StationTrolleyNumber = moldStatus.StationTrolleyNumber,
GunNumber = moldStatus.GunNumber,
MoldStatus = moldStatus.MoldStatus,
MainId = moldStatus.MainId,
MoldType = moldType.MoldType.Replace("\b","").Replace("\u0001", "").Replace("\0", "").Trim(),
MoldProdutionA = moldOutPut_A.MoldProdutionA,
MoldProdutionB = moldOutPut_B.MoldProdutionB,
DeviceStatus = deviceStatus,
DeviceAlarm = deviceAlarm,
ProductTakt = productTakt,
Takt = taktNum,
CreateTime = DateTime.Now
};
result = mergedCollection.ToList();
if(result != null)
{
RefreshDoorFoamMachineEvent?.Invoke(result);
var addFlag = _doorFoamMachineServices.AddAsync(result).Result;
}
}
}
catch (Exception ex)
{
Console.WriteLine($"门体发泡数据采集异常:{ex.Message}");
}
}
}
/// <summary>
/// 读取模位状态
/// </summary>
static List<DoorFoamMachine> ReadModeStatus(HwPLc.PlcModel obj)
{
if (obj == null) return null;
else
{
List<DoorFoamMachine> doorFoams = new List<DoorFoamMachine>();
if (obj.plc.IsConnected)
{
byte[] info = obj.plc.Read("DB490.0", 142);
if(info != null)
{
///出模工位台车号,上料工位台车号,注料工位台车号
short tempNo1 = short.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
short tempNo2 = short.Parse(StringChange.bytesToHexStr(info.Skip(2).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
short tempNo3 = short.Parse(StringChange.bytesToHexStr(info.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
//模位状态,台车1#枪模式0不工作1A门工作2B门工作3,AB门工作
#region 读取模具状态
short temp1 = short.Parse(StringChange.bytesToHexStr(info.Skip(6).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =1,
MoldStatus = temp1.ToString(),
});
short temp2 = short.Parse(StringChange.bytesToHexStr(info.Skip(8).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =2,
MoldStatus = temp2.ToString(),
});
short temp3 = short.Parse(StringChange.bytesToHexStr(info.Skip(10).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =3,
MoldStatus = temp3.ToString(),
});
short temp4 = short.Parse(StringChange.bytesToHexStr(info.Skip(12).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =4,
MoldStatus = temp4.ToString(),
});
short temp5 = short.Parse(StringChange.bytesToHexStr(info.Skip(14).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =5,
MoldStatus = temp5.ToString(),
});
short temp6 = short.Parse(StringChange.bytesToHexStr(info.Skip(16).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =6,
MoldStatus = temp6.ToString(),
});
short temp7 = short.Parse(StringChange.bytesToHexStr(info.Skip(18).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =7,
MoldStatus = temp7.ToString(),
});
short temp8 = short.Parse(StringChange.bytesToHexStr(info.Skip(20).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =8,
MoldStatus = temp8.ToString(),
});
short temp9 = short.Parse(StringChange.bytesToHexStr(info.Skip(22).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =9,
MoldStatus = temp9.ToString(),
});
short temp10 = short.Parse(StringChange.bytesToHexStr(info.Skip(24).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =10,
MoldStatus = temp10.ToString(),
});
short temp11 = short.Parse(StringChange.bytesToHexStr(info.Skip(26).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =11,
MoldStatus = temp11.ToString(),
});
short temp12 = short.Parse(StringChange.bytesToHexStr(info.Skip(28).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =12,
MoldStatus = temp12.ToString(),
});
short temp13 = short.Parse(StringChange.bytesToHexStr(info.Skip(30).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =13,
MoldStatus = temp13.ToString(),
});
short temp14 = short.Parse(StringChange.bytesToHexStr(info.Skip(32).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =14,
MoldStatus = temp14.ToString(),
});
short temp15 = short.Parse(StringChange.bytesToHexStr(info.Skip(34).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =15,
MoldStatus = temp15.ToString(),
});
short temp16 = short.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =16,
MoldStatus = temp16.ToString(),
});
short temp17 = short.Parse(StringChange.bytesToHexStr(info.Skip(38).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =17,
MoldStatus = temp17.ToString(),
});
short temp18 = short.Parse(StringChange.bytesToHexStr(info.Skip(40).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =18,
MoldStatus = temp18.ToString(),
});
short temp19 = short.Parse(StringChange.bytesToHexStr(info.Skip(42).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =19,
MoldStatus = temp19.ToString(),
});
short temp20 = short.Parse(StringChange.bytesToHexStr(info.Skip(44).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =20,
MoldStatus = temp20.ToString(),
});
short temp21 = short.Parse(StringChange.bytesToHexStr(info.Skip(46).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =21,
MoldStatus = temp21.ToString(),
});
short temp22 = short.Parse(StringChange.bytesToHexStr(info.Skip(48).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =22,
MoldStatus = temp22.ToString(),
});
short temp23 = short.Parse(StringChange.bytesToHexStr(info.Skip(50).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =23,
MoldStatus = temp23.ToString(),
});
short temp24 = short.Parse(StringChange.bytesToHexStr(info.Skip(52).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =24,
MoldStatus = temp24.ToString(),
});
short temp25 = short.Parse(StringChange.bytesToHexStr(info.Skip(54).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =25,
MoldStatus = temp25.ToString(),
});
short temp26 = short.Parse(StringChange.bytesToHexStr(info.Skip(56).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =26,
MoldStatus = temp26.ToString(),
});
short temp27 = short.Parse(StringChange.bytesToHexStr(info.Skip(58).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =27,
MoldStatus = temp27.ToString(),
});
short temp28 = short.Parse(StringChange.bytesToHexStr(info.Skip(60).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =28,
MoldStatus = temp28.ToString(),
});
short temp29 = short.Parse(StringChange.bytesToHexStr(info.Skip(62).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =29,
MoldStatus = temp29.ToString(),
});
short temp30 = short.Parse(StringChange.bytesToHexStr(info.Skip(64).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =30,
MoldStatus = temp30.ToString(),
});
short temp31 = short.Parse(StringChange.bytesToHexStr(info.Skip(66).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =31,
MoldStatus = temp31.ToString(),
});
short temp32 = short.Parse(StringChange.bytesToHexStr(info.Skip(68).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =32,
MoldStatus = temp32.ToString(),
});
short temp33 = short.Parse(StringChange.bytesToHexStr(info.Skip(70).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =33,
MoldStatus = temp33.ToString(),
});
short temp34 = short.Parse(StringChange.bytesToHexStr(info.Skip(72).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =34,
MoldStatus = temp34.ToString(),
});
short temp35 = short.Parse(StringChange.bytesToHexStr(info.Skip(74).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =35,
MoldStatus = temp35.ToString(),
});
short temp36 = short.Parse(StringChange.bytesToHexStr(info.Skip(76).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =36,
MoldStatus = temp36.ToString(),
});
short temp37 = short.Parse(StringChange.bytesToHexStr(info.Skip(78).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =37,
MoldStatus = temp37.ToString(),
});
short temp38 = short.Parse(StringChange.bytesToHexStr(info.Skip(80).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =38,
MoldStatus = temp38.ToString(),
});
short temp39 = short.Parse(StringChange.bytesToHexStr(info.Skip(82).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber =39,
MoldStatus = temp39.ToString(),
});
short temp40 = short.Parse(StringChange.bytesToHexStr(info.Skip(84).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 40,
MoldStatus = temp40.ToString(),
});
#endregion
doorFoams.ForEach(x =>
{
if (x.StationTrolleyNumber == tempNo1)
{
x.MainId = 1;
}
else if (x.StationTrolleyNumber == tempNo2)
{
x.MainId = 2;
}
else if (x.StationTrolleyNumber == tempNo3)
{
x.MainId = 3;
}
else
{
x.MainId = 0;
}
});
}
}
return doorFoams;
}
}
/// <summary>
/// 读取模位型号读5台1-5,6-10...
/// </summary>
static List<DoorFoamMachine> ReadModeType(HwPLc.PlcModel obj)
{
if (obj == null) return null;
else
{
List<DoorFoamMachine> doorFoams = new List<DoorFoamMachine>();
if (obj.plc.IsConnected)
{
byte[] info1 = obj.plc.Read("DB490.86", 200);
//1#台车1#枪A门,1#台车1#枪B门,1#台车2#枪A门,1#台车2#枪B门
#region 1-20台车
if (info1 != null)
{
string item1 = asciiEncoding.GetString(info1.Skip(0).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 1,
MoldType = item1
});
string item2 = asciiEncoding.GetString(info1.Skip(10).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 2,
MoldType = item2
});
string item3 = asciiEncoding.GetString(info1.Skip(20).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 3,
MoldType = item3
});
string item4 = asciiEncoding.GetString(info1.Skip(30).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 4,
MoldType = item4
});
string item5 = asciiEncoding.GetString(info1.Skip(40).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 5,
MoldType = item5
});
string item6 = asciiEncoding.GetString(info1.Skip(50).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 6,
MoldType = item6
});
string item7 = asciiEncoding.GetString(info1.Skip(60).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 7,
MoldType = item7
});
string item8 = asciiEncoding.GetString(info1.Skip(70).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 8,
MoldType = item8
});
string item9 = asciiEncoding.GetString(info1.Skip(80).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 9,
MoldType = item9
});
string item10 = asciiEncoding.GetString(info1.Skip(90).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 10,
MoldType = item10
});
string item11 = asciiEncoding.GetString(info1.Skip(100).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 11,
MoldType = item11
});
string item12 = asciiEncoding.GetString(info1.Skip(110).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 12,
MoldType = item12
});
string item13 = asciiEncoding.GetString(info1.Skip(120).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 13,
MoldType = item13
});
string item14 = asciiEncoding.GetString(info1.Skip(130).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 14,
MoldType = item14
});
string item15 = asciiEncoding.GetString(info1.Skip(140).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 15,
MoldType = item15
});
string item16 = asciiEncoding.GetString(info1.Skip(150).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 16,
MoldType = item16
});
string item17 = asciiEncoding.GetString(info1.Skip(160).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 17,
MoldType = item17
});
string item18 = asciiEncoding.GetString(info1.Skip(170).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 18,
MoldType = item18
});
string item19 = asciiEncoding.GetString(info1.Skip(180).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 19,
MoldType = item19
});
string item20 = asciiEncoding.GetString(info1.Skip(190).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 20,
MoldType = item20
});
}
#endregion
byte[] info2 = obj.plc.Read("DB490.286", 200);
#region 20-40车
if(info2 != null)
{
string item1 = asciiEncoding.GetString(info2.Skip(0).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 21,
MoldType = item1
});
string item2 = asciiEncoding.GetString(info2.Skip(10).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 22,
MoldType = item2
});
string item3 = asciiEncoding.GetString(info2.Skip(20).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 23,
MoldType = item3
});
string item4 = asciiEncoding.GetString(info2.Skip(30).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 24,
MoldType = item4
});
string item5 = asciiEncoding.GetString(info2.Skip(40).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 25,
MoldType = item5
});
string item6 = asciiEncoding.GetString(info2.Skip(50).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 26,
MoldType = item6
});
string item7 = asciiEncoding.GetString(info2.Skip(60).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 27,
MoldType = item7
});
string item8 = asciiEncoding.GetString(info2.Skip(70).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 28,
MoldType = item8
});
string item9 = asciiEncoding.GetString(info2.Skip(80).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 29,
MoldType = item9
});
string item10 = asciiEncoding.GetString(info2.Skip(90).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 30,
MoldType = item10
});
string item11 = asciiEncoding.GetString(info2.Skip(100).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 31,
MoldType = item11
});
string item12 = asciiEncoding.GetString(info2.Skip(110).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 32,
MoldType = item12
});
string item13 = asciiEncoding.GetString(info2.Skip(120).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 33,
MoldType = item13
});
string item14 = asciiEncoding.GetString(info2.Skip(130).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 34,
MoldType = item14
});
string item15 = asciiEncoding.GetString(info2.Skip(140).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 35,
MoldType = item15
});
string item16 = asciiEncoding.GetString(info2.Skip(150).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 36,
MoldType = item16
});
string item17 = asciiEncoding.GetString(info2.Skip(160).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 37,
MoldType = item17
});
string item18 = asciiEncoding.GetString(info2.Skip(170).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 38,
MoldType = item18
});
string item19 = asciiEncoding.GetString(info2.Skip(180).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 39,
MoldType = item19
});
string item20 = asciiEncoding.GetString(info2.Skip(190).Take(10).ToArray()).Trim('\n');
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 40,
MoldType = item20
});
}
#endregion
}
return doorFoams;
}
}
/// <summary>
/// 读取A门模位产量
/// </summary>
private List<DoorFoamMachine> ReadADoorModeProduct(HwPLc.PlcModel obj)
{
if (obj == null) return null;
else
{
List<DoorFoamMachine> doorFoams = new List<DoorFoamMachine>();
if (obj.plc.IsConnected)
{
byte[] info = obj.plc.Read("DB490.486", 160);
#region A门产量
if (info != null)
{
//1#台车1#枪A门,1#台车1#枪B门,1#台车2#枪A门,1#台车2#枪B门
int temp1 = int.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 1,
MoldProdutionA = temp1.ToString()
});
int temp2 = int.Parse(StringChange.bytesToHexStr(info.Skip(2).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 2,
MoldProdutionA = temp2.ToString()
});
int temp3 = int.Parse(StringChange.bytesToHexStr(info.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 3,
MoldProdutionA = temp3.ToString()
});
int temp4 = int.Parse(StringChange.bytesToHexStr(info.Skip(6).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 4,
MoldProdutionA = temp4.ToString()
});
int temp5 = int.Parse(StringChange.bytesToHexStr(info.Skip(8).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 5,
MoldProdutionA = temp5.ToString()
});
int temp6 = int.Parse(StringChange.bytesToHexStr(info.Skip(10).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 6,
MoldProdutionA = temp6.ToString()
});
int temp7 = int.Parse(StringChange.bytesToHexStr(info.Skip(12).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 7,
MoldProdutionA = temp7.ToString()
});
int temp8 = int.Parse(StringChange.bytesToHexStr(info.Skip(14).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 8,
MoldProdutionA = temp8.ToString()
});
int temp9 = int.Parse(StringChange.bytesToHexStr(info.Skip(16).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 9,
MoldProdutionA = temp9.ToString()
});
int temp10 = int.Parse(StringChange.bytesToHexStr(info.Skip(18).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 10,
MoldProdutionA = temp10.ToString()
});
int temp11 = int.Parse(StringChange.bytesToHexStr(info.Skip(20).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 11,
MoldProdutionA = temp11.ToString()
});
int temp12 = int.Parse(StringChange.bytesToHexStr(info.Skip(22).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 12,
MoldProdutionA = temp12.ToString()
});
int temp13 = int.Parse(StringChange.bytesToHexStr(info.Skip(24).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 13,
MoldProdutionA = temp13.ToString()
});
int temp14 = int.Parse(StringChange.bytesToHexStr(info.Skip(26).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 14,
MoldProdutionA = temp14.ToString()
});
int temp15 = int.Parse(StringChange.bytesToHexStr(info.Skip(28).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 15,
MoldProdutionA = temp15.ToString()
});
int temp16 = int.Parse(StringChange.bytesToHexStr(info.Skip(30).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 16,
MoldProdutionA = temp16.ToString()
});
int temp17 = int.Parse(StringChange.bytesToHexStr(info.Skip(32).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 17,
MoldProdutionA = temp17.ToString()
});
int temp18 = int.Parse(StringChange.bytesToHexStr(info.Skip(34).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 18,
MoldProdutionA = temp18.ToString()
});
int temp19 = int.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 19,
MoldProdutionA = temp19.ToString()
});
int temp20 = int.Parse(StringChange.bytesToHexStr(info.Skip(38).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 20,
MoldProdutionA = temp20.ToString()
});
int temp21 = int.Parse(StringChange.bytesToHexStr(info.Skip(40).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 21,
MoldProdutionA = temp21.ToString()
});
int temp22 = int.Parse(StringChange.bytesToHexStr(info.Skip(42).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 22,
MoldProdutionA = temp22.ToString()
});
int temp23 = int.Parse(StringChange.bytesToHexStr(info.Skip(44).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 23,
MoldProdutionA = temp23.ToString()
});
int temp24 = int.Parse(StringChange.bytesToHexStr(info.Skip(46).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 24,
MoldProdutionA = temp24.ToString()
});
int temp25 = int.Parse(StringChange.bytesToHexStr(info.Skip(48).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 25,
MoldProdutionA = temp25.ToString()
});
int temp26 = int.Parse(StringChange.bytesToHexStr(info.Skip(50).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 26,
MoldProdutionA = temp26.ToString()
});
int temp27 = int.Parse(StringChange.bytesToHexStr(info.Skip(52).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 27,
MoldProdutionA = temp27.ToString()
});
int temp28 = int.Parse(StringChange.bytesToHexStr(info.Skip(54).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 28,
MoldProdutionA = temp28.ToString()
});
int temp29 = int.Parse(StringChange.bytesToHexStr(info.Skip(56).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 29,
MoldProdutionA = temp29.ToString()
});
int temp30 = int.Parse(StringChange.bytesToHexStr(info.Skip(58).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 30,
MoldProdutionA = temp30.ToString()
});
int temp31 = int.Parse(StringChange.bytesToHexStr(info.Skip(60).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 31,
MoldProdutionA = temp31.ToString()
});
int temp32 = int.Parse(StringChange.bytesToHexStr(info.Skip(62).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 32,
MoldProdutionA = temp32.ToString()
});
int temp33 = int.Parse(StringChange.bytesToHexStr(info.Skip(64).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 33,
MoldProdutionA = temp33.ToString()
});
int temp34 = int.Parse(StringChange.bytesToHexStr(info.Skip(66).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 34,
MoldProdutionA = temp34.ToString()
});
int temp35 = int.Parse(StringChange.bytesToHexStr(info.Skip(68).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 35,
MoldProdutionA = temp35.ToString()
});
int temp36 = int.Parse(StringChange.bytesToHexStr(info.Skip(70).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 36,
MoldProdutionA = temp36.ToString()
});
int temp37 = int.Parse(StringChange.bytesToHexStr(info.Skip(72).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 37,
MoldProdutionA = temp37.ToString()
});
int temp38 = int.Parse(StringChange.bytesToHexStr(info.Skip(74).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 38,
MoldProdutionA = temp38.ToString()
});
int temp39 = int.Parse(StringChange.bytesToHexStr(info.Skip(76).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 39,
MoldProdutionA = temp39.ToString()
});
int temp40 = int.Parse(StringChange.bytesToHexStr(info.Skip(78).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 40,
MoldProdutionA = temp40.ToString()
});
}
#endregion
}
return doorFoams;
}
}
/// <summary>
/// 读取B门模位产量
/// </summary>
private List<DoorFoamMachine> ReadBDoorModeProduct(HwPLc.PlcModel obj)
{
if (obj == null) return null;
else
{
List<DoorFoamMachine> doorFoams = new List<DoorFoamMachine>();
if (obj.plc.IsConnected)
{
byte[] info = obj.plc.Read("DB490.566", 160);
#region B门产量
if (info != null)
{
//1#台车1#枪A门,1#台车1#枪B门,1#台车2#枪A门,1#台车2#枪B门
int temp1 = int.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 1,
MoldProdutionB = temp1.ToString()
});
int temp2 = int.Parse(StringChange.bytesToHexStr(info.Skip(2).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 2,
MoldProdutionB = temp2.ToString()
});
int temp3 = int.Parse(StringChange.bytesToHexStr(info.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 3,
MoldProdutionB = temp3.ToString()
});
int temp4 = int.Parse(StringChange.bytesToHexStr(info.Skip(6).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 4,
MoldProdutionB = temp4.ToString()
});
int temp5 = int.Parse(StringChange.bytesToHexStr(info.Skip(8).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 5,
MoldProdutionB = temp5.ToString()
});
int temp6 = int.Parse(StringChange.bytesToHexStr(info.Skip(10).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 6,
MoldProdutionB = temp6.ToString()
});
int temp7 = int.Parse(StringChange.bytesToHexStr(info.Skip(12).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 7,
MoldProdutionB = temp7.ToString()
});
int temp8 = int.Parse(StringChange.bytesToHexStr(info.Skip(14).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 8,
MoldProdutionB = temp8.ToString()
});
int temp9 = int.Parse(StringChange.bytesToHexStr(info.Skip(16).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 9,
MoldProdutionB = temp9.ToString()
});
int temp10 = int.Parse(StringChange.bytesToHexStr(info.Skip(18).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 10,
MoldProdutionB = temp10.ToString()
});
int temp11 = int.Parse(StringChange.bytesToHexStr(info.Skip(20).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 11,
MoldProdutionB = temp11.ToString()
});
int temp12 = int.Parse(StringChange.bytesToHexStr(info.Skip(22).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 12,
MoldProdutionB = temp12.ToString()
});
int temp13 = int.Parse(StringChange.bytesToHexStr(info.Skip(24).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 13,
MoldProdutionB = temp13.ToString()
});
int temp14 = int.Parse(StringChange.bytesToHexStr(info.Skip(26).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 14,
MoldProdutionB = temp14.ToString()
});
int temp15 = int.Parse(StringChange.bytesToHexStr(info.Skip(28).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 15,
MoldProdutionB = temp15.ToString()
});
int temp16 = int.Parse(StringChange.bytesToHexStr(info.Skip(30).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 16,
MoldProdutionB = temp16.ToString()
});
int temp17 = int.Parse(StringChange.bytesToHexStr(info.Skip(32).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 17,
MoldProdutionB = temp17.ToString()
});
int temp18 = int.Parse(StringChange.bytesToHexStr(info.Skip(34).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 18,
MoldProdutionB = temp18.ToString()
});
int temp19 = int.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 19,
MoldProdutionB = temp19.ToString()
});
int temp20 = int.Parse(StringChange.bytesToHexStr(info.Skip(38).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 20,
MoldProdutionB = temp20.ToString()
});
int temp21 = int.Parse(StringChange.bytesToHexStr(info.Skip(40).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 21,
MoldProdutionB = temp21.ToString()
});
int temp22 = int.Parse(StringChange.bytesToHexStr(info.Skip(42).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 22,
MoldProdutionB = temp22.ToString()
});
int temp23 = int.Parse(StringChange.bytesToHexStr(info.Skip(44).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 23,
MoldProdutionB = temp23.ToString()
});
int temp24 = int.Parse(StringChange.bytesToHexStr(info.Skip(46).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 24,
MoldProdutionB = temp24.ToString()
});
int temp25 = int.Parse(StringChange.bytesToHexStr(info.Skip(48).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 25,
MoldProdutionB = temp25.ToString()
});
int temp26 = int.Parse(StringChange.bytesToHexStr(info.Skip(50).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 26,
MoldProdutionB = temp26.ToString()
});
int temp27 = int.Parse(StringChange.bytesToHexStr(info.Skip(52).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 27,
MoldProdutionB = temp27.ToString()
});
int temp28 = int.Parse(StringChange.bytesToHexStr(info.Skip(54).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 28,
MoldProdutionB = temp28.ToString()
});
int temp29 = int.Parse(StringChange.bytesToHexStr(info.Skip(56).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 29,
MoldProdutionB = temp29.ToString()
});
int temp30 = int.Parse(StringChange.bytesToHexStr(info.Skip(58).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 30,
MoldProdutionB = temp30.ToString()
});
int temp31 = int.Parse(StringChange.bytesToHexStr(info.Skip(60).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 31,
MoldProdutionB = temp31.ToString()
});
int temp32 = int.Parse(StringChange.bytesToHexStr(info.Skip(62).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 32,
MoldProdutionB = temp32.ToString()
});
int temp33 = int.Parse(StringChange.bytesToHexStr(info.Skip(64).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 33,
MoldProdutionB = temp33.ToString()
});
int temp34 = int.Parse(StringChange.bytesToHexStr(info.Skip(66).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 34,
MoldProdutionB = temp34.ToString()
});
int temp35 = int.Parse(StringChange.bytesToHexStr(info.Skip(68).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 35,
MoldProdutionB = temp35.ToString()
});
int temp36 = int.Parse(StringChange.bytesToHexStr(info.Skip(70).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 36,
MoldProdutionB = temp36.ToString()
});
int temp37 = int.Parse(StringChange.bytesToHexStr(info.Skip(72).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 37,
MoldProdutionB = temp37.ToString()
});
int temp38 = int.Parse(StringChange.bytesToHexStr(info.Skip(74).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 38,
MoldProdutionB = temp38.ToString()
});
int temp39 = int.Parse(StringChange.bytesToHexStr(info.Skip(76).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 39,
MoldProdutionB = temp39.ToString()
});
int temp40 = int.Parse(StringChange.bytesToHexStr(info.Skip(78).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
doorFoams.Add(new DoorFoamMachine()
{
StationTrolleyNumber = 40,
MoldProdutionB = temp40.ToString()
});
}
#endregion
}
return doorFoams;
}
}
/// <summary>
/// 读取设备报警信息
/// </summary>
static void ReadWarnInfo(HwPLc.PlcModel obj, List<string> boxTypeList)
{
if (obj == null) return;
else
{
if (obj.plc.IsConnected)
{
byte[] info = obj.plc.Read("DB490.2136", 4);
if (info == null) return;
//1-主驱动报警 2-枪1X轴伺服异常 3-枪2X轴伺服异常 4-换模位门打开 5-枪1急停被激活 6-枪2急停被激活 7-枪1发泡机报警 8-枪2发泡机报警
int temp1 = judgeStatus(ByteArrayToBinary(info.Skip(0).Take(1).ToArray()));
Console.WriteLine(temp1);
}
}
}
#region 字符工具转换方法
/// <summary>
/// byte数组转换为float
/// </summary>
static float byteToFloat(byte[] list)
{
float result = 0.00f;
Array.Reverse(list);
result = BitConverter.ToSingle(list, 0);
return result;
}
/// <summary>
/// byte[]转二进制,读两字节截取1字节 00000000 (00100000)
/// </summary>
/// <param name="bytes"></param>
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;
}
/// <summary>
/// 根据二进制字符串确定夹具状态 1正常生产 2暂停生产
/// </summary>
static int judgeStatus(string str1)
{
int item1 = 0;
if (str1.Substring(0, 1) == "1")
{
item1 = 1; //
}
else if (str1.Substring(1, 1) =="1")
{
item1 = 2; //
}
else if (str1.Substring(2, 1) =="1")
{
item1 = 3; //
}
else if (str1.Substring(3, 1) =="1")
{
item1 = 4; //
}
else if (str1.Substring(4, 1) =="1")
{
item1 = 5; //
}
else if (str1.Substring(5, 1) =="1")
{
item1 = 6; //
}
else if (str1.Substring(6, 1) =="1")
{
item1 = 7; //
}
else if (str1.Substring(7, 1) =="1")
{
item1 = 8; //
}
return item1;
}
}
#endregion
}