|
|
using Admin.Core.Common;
|
|
|
using Admin.Core.IService;
|
|
|
using Admin.Core.Model;
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
using Aucma.Core.HwPLc;
|
|
|
using log4net;
|
|
|
using System.Timers;
|
|
|
|
|
|
namespace Aucma.Core.Tasks
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 钣金任务列表
|
|
|
/// </summary>
|
|
|
public class AucamTaskService : IAucamTaskService
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 老发泡线更新事件
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public delegate Task RefreshOldBoxFoamDataDelegate(List<BoxFoamData> list);
|
|
|
public static event RefreshOldBoxFoamDataDelegate RefreshOldBoxFoamDataDelegateEvent;
|
|
|
|
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(AucamTaskService));
|
|
|
|
|
|
private readonly IOldBoxFoamTypeServices _oldBoxFoamTypeServices;
|
|
|
private readonly IBoxFoamDataServices _oldBoxFoamDataServices;
|
|
|
private readonly ISysUserInfoServices _sysUserInfoServices;
|
|
|
private readonly ICurrentTeamTimeServices _currentTeamTimeServices;
|
|
|
private readonly IBoxFoamDataRecordServices _boxFoamDataRecordServices;
|
|
|
private readonly IBoxFoamPlanServices _boxFoamPlanServices;
|
|
|
private readonly IBoxDeviceInfoServices _boxDeviceInfoServices;
|
|
|
|
|
|
public AucamTaskService(IOldBoxFoamTypeServices oldBoxFoamTypeServices, IBoxFoamDataServices oldBoxFoamDataServices,
|
|
|
ISysUserInfoServices sysUserInfoServices, ICurrentTeamTimeServices currentTeamTimeServices,
|
|
|
IBoxFoamDataRecordServices boxFoamDataRecordServices, IBoxDeviceInfoServices boxDeviceInfoServices
|
|
|
)
|
|
|
{
|
|
|
_oldBoxFoamTypeServices = oldBoxFoamTypeServices;
|
|
|
_oldBoxFoamDataServices = oldBoxFoamDataServices;
|
|
|
_sysUserInfoServices = sysUserInfoServices;
|
|
|
_currentTeamTimeServices = currentTeamTimeServices;
|
|
|
_boxFoamDataRecordServices = boxFoamDataRecordServices;
|
|
|
_boxDeviceInfoServices = boxDeviceInfoServices;
|
|
|
}
|
|
|
|
|
|
System.Timers.Timer timer1 = new System.Timers.Timer(1000);
|
|
|
System.Timers.Timer timer2 = new System.Timers.Timer(1000);
|
|
|
System.Timers.Timer timer3 = new System.Timers.Timer(1000);
|
|
|
System.Timers.Timer timer4 = new System.Timers.Timer(1000);
|
|
|
|
|
|
bool qFlay=true;//前板标识
|
|
|
bool hFlay = true;//后板标识
|
|
|
|
|
|
public void AucamTaskAsync()
|
|
|
{
|
|
|
//timer1.Elapsed += new System.Timers.ElapsedEventHandler(Run1); //到达时间的时候执行事件;
|
|
|
//timer1.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
|
|
//timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
|
|
|
//timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
|
|
|
|
|
|
//timer2.Elapsed += new System.Timers.ElapsedEventHandler(Run2); //到达时间的时候执行事件;
|
|
|
//timer2.AutoReset = true;
|
|
|
//timer2.Enabled = true;
|
|
|
//timer2.Start();
|
|
|
|
|
|
//timer3.Elapsed += new System.Timers.ElapsedEventHandler(Run3);
|
|
|
//timer3.AutoReset = true;
|
|
|
//timer3.Enabled = true;
|
|
|
//timer3.Start();
|
|
|
|
|
|
//timer4.Elapsed += new System.Timers.ElapsedEventHandler(Run4);
|
|
|
//timer4.AutoReset = true;
|
|
|
//timer4.Enabled = true;
|
|
|
//timer4.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 钣金——前板
|
|
|
/// <summary>
|
|
|
/// 钣金——前板
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void Run1(object? sender, ElapsedEventArgs e)
|
|
|
{
|
|
|
if (qFlay)
|
|
|
{
|
|
|
qFlay = false;
|
|
|
try
|
|
|
{
|
|
|
GetData();
|
|
|
qFlay = true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
//List<BoxFoamData> old = _oldBoxFoamDataServices.QueryAsync().Result;
|
|
|
//RefreshOldBoxFoamDataDelegateEvent?.Invoke(old);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 钣金——前板
|
|
|
/// <summary>
|
|
|
/// 钣金——前板
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void Run2(object? sender, ElapsedEventArgs e)
|
|
|
{
|
|
|
if (qFlay)
|
|
|
{
|
|
|
qFlay = false;
|
|
|
try
|
|
|
{
|
|
|
GetData2();
|
|
|
qFlay = true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
qFlay = true;
|
|
|
throw;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
//List<BoxFoamData> old = _oldBoxFoamDataServices.QueryAsync().Result;
|
|
|
//RefreshOldBoxFoamDataDelegateEvent?.Invoke(old);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 钣金——前板
|
|
|
/// <summary>
|
|
|
/// 钣金——前板
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void Run3(object? sender, ElapsedEventArgs e)
|
|
|
{
|
|
|
if (qFlay)
|
|
|
{
|
|
|
qFlay = false;
|
|
|
try
|
|
|
{
|
|
|
GetData3();
|
|
|
qFlay = true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
qFlay = true;
|
|
|
throw;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
//List<BoxFoamData> old = _oldBoxFoamDataServices.QueryAsync().Result;
|
|
|
//RefreshOldBoxFoamDataDelegateEvent?.Invoke(old);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 钣金——前板
|
|
|
/// <summary>
|
|
|
/// 钣金——前板
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void Run4(object? sender, ElapsedEventArgs e)
|
|
|
{
|
|
|
if (qFlay)
|
|
|
{
|
|
|
qFlay = false;
|
|
|
try
|
|
|
{
|
|
|
GetData4();
|
|
|
qFlay = true;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
qFlay = true;
|
|
|
throw;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
List<BoxFoamData> old = _oldBoxFoamDataServices.QueryAsync().Result;
|
|
|
RefreshOldBoxFoamDataDelegateEvent?.Invoke(old);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public async void GetData()
|
|
|
{
|
|
|
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
|
|
|
try
|
|
|
{
|
|
|
List<BoxFoamData> bfList = new List<BoxFoamData>();
|
|
|
List<BoxFoamData> addList = new List<BoxFoamData>();
|
|
|
//var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
|
|
|
//if (obj2 == null) { return; }
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
|
|
|
if (obj == null) { return; }
|
|
|
|
|
|
byte[] arr1 = obj.plc.ReadByte("D3140", (ushort)48);
|
|
|
if (arr1 == null) return;
|
|
|
//var arr1 = ArrReverse(bt);
|
|
|
|
|
|
byte[] arr3 = obj.plc.ReadByte("D182", (ushort)24);
|
|
|
if (arr3 == null) return;
|
|
|
//var arr3 = ArrReverse(bt3);
|
|
|
byte[] arr4 = obj.plc.ReadByte("D910", (ushort)24);
|
|
|
if (arr4 == null) return;
|
|
|
//var arr4 = ArrReverse(bt4);
|
|
|
byte[] arr5 = obj.plc.ReadByte("T3", (ushort)24);
|
|
|
if (arr5 == null) return;
|
|
|
//var arr5 = ArrReverse(bt5);
|
|
|
|
|
|
|
|
|
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
|
|
|
List<BoxFoamData> fdList = _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode).Result;
|
|
|
|
|
|
var fixtureboxtype1 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList1 = fdList.SingleOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 1);
|
|
|
if (oldList1 != null)
|
|
|
{
|
|
|
//只更新小时数量
|
|
|
oldList1.Fixtureboxtype = fixtureboxtype1;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F0", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F1", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y110", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr(result1, result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr(result2, result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr(result3, result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F0");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F1");
|
|
|
bool status3 = obj.plc.ReadBool("Y110");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList1.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList1.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D182"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList1.AnHour = num - oldList1.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList1.TwoHour = num - oldList1.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList1.ThreeHour = num - oldList1.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList1.FourHour = num - oldList1.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList1.FiveHour = num - oldList1.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList1.SixHour = num - oldList1.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList1.SevenHour = num - oldList1.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList1.EightHour = num - oldList1.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList1.NineHour = num - oldList1.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList1.TenHour = num - oldList1.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList1.ElevenHour = num - oldList1.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList1.TwelveHour = num - oldList1.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList1.Production = obj.plc.ReadInt16("D182");//short.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList1.UpdatedTime = DateTime.Now;
|
|
|
oldList1.ProductLineCode = "CX_01";
|
|
|
oldList1.MainId = 1;
|
|
|
bfList.Add(oldList1);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam1 = new BoxFoamData();
|
|
|
//新增
|
|
|
boxfoam1.Fixtureboxtype = fixtureboxtype1;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F0", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F1", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y110", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F0");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F1");
|
|
|
bool status3 = obj.plc.ReadBool("Y110");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam1.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam1.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D182"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam1.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam1.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam1.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam1.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam1.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam1.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam1.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam1.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam1.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam1.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam1.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam1.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam1.Production = obj.plc.ReadInt16("D182");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam1.UpdatedTime = DateTime.Now;
|
|
|
boxfoam1.ProductLineCode = "CX_01";
|
|
|
boxfoam1.MainId = 1;
|
|
|
addList.Add(boxfoam1);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam1);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype2 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList2 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 2);
|
|
|
if (oldList2 != null)
|
|
|
{
|
|
|
oldList2.Fixtureboxtype = fixtureboxtype2;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F5", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F6", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y111", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F5");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F6");
|
|
|
bool status3 = obj.plc.ReadBool("Y111");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList2.AnHour = num - oldList2.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList2.TwoHour = num - oldList2.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList2.ThreeHour = num - oldList2.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList2.FourHour = num - oldList2.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList2.FiveHour = num - oldList2.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList2.SixHour = num - oldList2.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList2.SevenHour = num - oldList2.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList2.EightHour = num - oldList2.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList2.NineHour = num - oldList2.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList2.TenHour = num - oldList2.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList2.ElevenHour = num - oldList2.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList2.TwelveHour = num - oldList2.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList2.Production = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList2.UpdatedTime = DateTime.Now;
|
|
|
oldList2.ProductLineCode = "CX_01";
|
|
|
oldList2.MainId = 2;
|
|
|
bfList.Add(oldList2);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam2 = new BoxFoamData();
|
|
|
boxfoam2.Fixtureboxtype = fixtureboxtype2;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F5", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F6", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y111", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0F5");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F6");
|
|
|
bool status3 = obj.plc.ReadBool("Y111");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D183");//int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam2.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam2.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam2.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam2.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam2.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam2.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam2.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam2.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam2.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam2.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam2.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam2.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam2.Production = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam2.UpdatedTime = DateTime.Now;
|
|
|
boxfoam2.MainId = 2;
|
|
|
boxfoam2.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam2);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam2);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype3 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(8).Take(9).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList3 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype3 && d.MainId == 3);
|
|
|
if (oldList3 != null)
|
|
|
{
|
|
|
oldList3.Fixtureboxtype = fixtureboxtype3;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0FA", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0FB", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y112", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0FA");
|
|
|
bool status2 = obj.plc.ReadBool("Y0FB");
|
|
|
bool status3 = obj.plc.ReadBool("Y112");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList3.AnHour = num - oldList3.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList3.TwoHour = num - oldList3.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList3.ThreeHour = num - oldList3.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList3.FourHour = num - oldList3.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList3.FiveHour = num - oldList3.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList3.SixHour = num - oldList3.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList3.SevenHour = num - oldList3.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList3.EightHour = num - oldList3.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList3.NineHour = num - oldList3.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList3.TenHour = num - oldList3.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList3.ElevenHour = num - oldList3.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList3.TwelveHour = num - oldList3.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList3.Production = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 1), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList3.UpdatedTime = DateTime.Now;
|
|
|
oldList3.MainId = 3;
|
|
|
oldList3.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList3);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList3);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam3 = new BoxFoamData();
|
|
|
boxfoam3.Fixtureboxtype = fixtureboxtype3;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0FA", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0FB", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y112", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0FA");
|
|
|
bool status2 = obj.plc.ReadBool("Y0FB");
|
|
|
bool status3 = obj.plc.ReadBool("Y112");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam3.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam3.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam3.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam3.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam3.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam3.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam3.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam3.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam3.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam3.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam3.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam3.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam3.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam3.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam3.Production = obj.plc.ReadInt16("D184");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam3.UpdatedTime = DateTime.Now;
|
|
|
boxfoam3.MainId = 3;
|
|
|
boxfoam3.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam3);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam3);
|
|
|
}
|
|
|
|
|
|
|
|
|
var fixtureboxtype4 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(12).Take(13).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList4 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype4 && d.MainId == 4);
|
|
|
if (oldList4 != null)
|
|
|
{
|
|
|
oldList4.Fixtureboxtype = fixtureboxtype4;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y100", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y101", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y113", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList4.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList4.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D185"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList4.AnHour = num - oldList4.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList4.TwoHour = num - oldList4.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList4.ThreeHour = num - oldList4.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList4.FourHour = num - oldList4.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList4.FiveHour = num - oldList4.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList4.SixHour = num - oldList4.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList4.SevenHour = num - oldList4.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList4.EightHour = num - oldList4.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList4.NineHour = num - oldList4.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList4.TenHour = num - oldList4.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList4.ElevenHour = num - oldList4.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList4.TwelveHour = num - oldList4.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList4.Production = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(12).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList4.UpdatedTime = DateTime.Now;
|
|
|
oldList4.MainId = 4;
|
|
|
oldList4.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList4);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList4);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam4 = new BoxFoamData();
|
|
|
boxfoam4.Fixtureboxtype = fixtureboxtype4;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y100", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y101", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y113", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam4.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam4.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam4.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam4.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam4.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam4.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam4.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam4.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam4.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam4.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam4.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam4.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam4.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam4.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam4.Production = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam4.UpdatedTime = DateTime.Now;
|
|
|
boxfoam4.MainId = 4;
|
|
|
boxfoam4.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam4);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam4);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype5 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(16).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList5 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype5 && d.MainId == 5);
|
|
|
if (oldList5 != null)
|
|
|
{
|
|
|
oldList5.Fixtureboxtype = fixtureboxtype5;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y105", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y106", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y114", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList5.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList5.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList5.AnHour = num - oldList5.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList5.TwoHour = num - oldList5.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList5.ThreeHour = num - oldList5.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList5.FourHour = num - oldList5.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList5.FiveHour = num - oldList5.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList5.SixHour = num - oldList5.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList5.SevenHour = num - oldList5.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList5.EightHour = num - oldList5.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList5.NineHour = num - oldList5.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList5.TenHour = num - oldList5.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList5.ElevenHour = num - oldList5.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList5.TwelveHour = num - oldList5.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList5.Production = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList5.UpdatedTime = DateTime.Now;
|
|
|
oldList5.MainId = 5;
|
|
|
oldList5.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList5);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList5);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam5 = new BoxFoamData();
|
|
|
boxfoam5.Fixtureboxtype = fixtureboxtype5;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y105", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y106", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y114", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam5.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam5.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam5.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam5.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam5.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam5.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam5.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam5.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam5.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam5.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam5.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam5.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam5.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam5.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam5.Production = obj.plc.ReadInt16("D186"); int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam5.UpdatedTime = DateTime.Now;
|
|
|
boxfoam5.MainId = 5;
|
|
|
boxfoam5.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam5);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam5);
|
|
|
}
|
|
|
var fixtureboxtype6 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(20).Take(21).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList6 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype6 && d.MainId == 6);
|
|
|
if (oldList6 != null)
|
|
|
{
|
|
|
oldList6.Fixtureboxtype = fixtureboxtype6;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y10A", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y10B", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y115", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y10A");
|
|
|
bool status2 = obj.plc.ReadBool("Y10B");
|
|
|
bool status3 = obj.plc.ReadBool("Y115");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList6.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList6.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList6.AnHour = num - oldList6.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList6.TwoHour = num - oldList6.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList6.ThreeHour = num - oldList6.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList6.FourHour = num - oldList6.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList6.FiveHour = num - oldList6.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList6.SixHour = num - oldList6.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList6.SevenHour = num - oldList6.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList6.EightHour = num - oldList6.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList6.NineHour = num - oldList6.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList6.TenHour = num - oldList6.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList6.ElevenHour = num - oldList6.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList6.TwelveHour = num - oldList6.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList6.Production = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList6.UpdatedTime = DateTime.Now;
|
|
|
oldList6.MainId = 6;
|
|
|
oldList6.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList6);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList6);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam6 = new BoxFoamData();
|
|
|
boxfoam6.Fixtureboxtype = fixtureboxtype6;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y10A", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y10B", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y115", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y10A");
|
|
|
bool status2 = obj.plc.ReadBool("Y10B");
|
|
|
bool status3 = obj.plc.ReadBool("Y115");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam6.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam6.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam6.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam6.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam6.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam6.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam6.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam6.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam6.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam6.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam6.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam6.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam6.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam6.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam6.Production = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam6.UpdatedTime = DateTime.Now;
|
|
|
boxfoam6.MainId = 6;
|
|
|
boxfoam6.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam6);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam6);
|
|
|
}
|
|
|
if (bfList != null)
|
|
|
{
|
|
|
await _oldBoxFoamDataServices.UpdateAsync(bfList);
|
|
|
}
|
|
|
if (addList != null)
|
|
|
{
|
|
|
await _oldBoxFoamDataServices.AddAsync(addList);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
}
|
|
|
|
|
|
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
|
|
|
}
|
|
|
|
|
|
public async void GetData2()
|
|
|
{
|
|
|
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
|
|
|
try
|
|
|
{
|
|
|
List<BoxFoamData> bfList = new List<BoxFoamData>();
|
|
|
List<BoxFoamData> addList = new List<BoxFoamData>();
|
|
|
//var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
|
|
|
//if (obj2 == null) { return; }
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
|
|
|
if (obj == null) { return; }
|
|
|
|
|
|
byte[] arr1 = obj.plc.ReadByte("D3140", (ushort)48);
|
|
|
if (arr1 == null) return;
|
|
|
//var arr1 = ArrReverse(bt);
|
|
|
|
|
|
byte[] arr3 = obj.plc.ReadByte("D182", (ushort)24);
|
|
|
if (arr3 == null) return;
|
|
|
//var arr3 = ArrReverse(bt3);
|
|
|
byte[] arr4 = obj.plc.ReadByte("D910", (ushort)24);
|
|
|
if (arr4 == null) return;
|
|
|
//var arr4 = ArrReverse(bt4);
|
|
|
byte[] arr5 = obj.plc.ReadByte("T3", (ushort)24);
|
|
|
if (arr5 == null) return;
|
|
|
//var arr5 = ArrReverse(bt5);
|
|
|
|
|
|
|
|
|
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
|
|
|
List<BoxFoamData> fdList = _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode).Result;
|
|
|
|
|
|
var fixtureboxtype1 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList1 = fdList.SingleOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 1);
|
|
|
if (oldList1 != null)
|
|
|
{
|
|
|
//只更新小时数量
|
|
|
oldList1.Fixtureboxtype = fixtureboxtype1;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F0", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F1", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y110", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr(result1, result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr(result2, result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr(result3, result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F0");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F1");
|
|
|
bool status3 = obj.plc.ReadBool("Y110");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList1.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList1.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D182"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList1.AnHour = num - oldList1.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList1.TwoHour = num - oldList1.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList1.ThreeHour = num - oldList1.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList1.FourHour = num - oldList1.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList1.FiveHour = num - oldList1.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList1.SixHour = num - oldList1.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList1.SevenHour = num - oldList1.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList1.EightHour = num - oldList1.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList1.NineHour = num - oldList1.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList1.TenHour = num - oldList1.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList1.ElevenHour = num - oldList1.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList1.TwelveHour = num - oldList1.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList1.Production = obj.plc.ReadInt16("D182");//short.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList1.UpdatedTime = DateTime.Now;
|
|
|
oldList1.ProductLineCode = "CX_01";
|
|
|
oldList1.MainId = 1;
|
|
|
bfList.Add(oldList1);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam1 = new BoxFoamData();
|
|
|
//新增
|
|
|
boxfoam1.Fixtureboxtype = fixtureboxtype1;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F0", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F1", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y110", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F0");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F1");
|
|
|
bool status3 = obj.plc.ReadBool("Y110");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam1.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam1.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D182"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam1.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam1.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam1.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam1.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam1.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam1.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam1.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam1.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam1.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam1.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam1.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam1.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam1.Production = obj.plc.ReadInt16("D182");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam1.UpdatedTime = DateTime.Now;
|
|
|
boxfoam1.ProductLineCode = "CX_01";
|
|
|
boxfoam1.MainId = 1;
|
|
|
addList.Add(boxfoam1);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam1);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype2 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList2 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 2);
|
|
|
if (oldList2 != null)
|
|
|
{
|
|
|
oldList2.Fixtureboxtype = fixtureboxtype2;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F5", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F6", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y111", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F5");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F6");
|
|
|
bool status3 = obj.plc.ReadBool("Y111");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList2.AnHour = num - oldList2.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList2.TwoHour = num - oldList2.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList2.ThreeHour = num - oldList2.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList2.FourHour = num - oldList2.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList2.FiveHour = num - oldList2.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList2.SixHour = num - oldList2.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList2.SevenHour = num - oldList2.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList2.EightHour = num - oldList2.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList2.NineHour = num - oldList2.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList2.TenHour = num - oldList2.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList2.ElevenHour = num - oldList2.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList2.TwelveHour = num - oldList2.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList2.Production = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList2.UpdatedTime = DateTime.Now;
|
|
|
oldList2.ProductLineCode = "CX_01";
|
|
|
oldList2.MainId = 2;
|
|
|
bfList.Add(oldList2);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam2 = new BoxFoamData();
|
|
|
boxfoam2.Fixtureboxtype = fixtureboxtype2;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F5", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F6", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y111", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0F5");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F6");
|
|
|
bool status3 = obj.plc.ReadBool("Y111");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D183");//int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam2.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam2.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam2.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam2.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam2.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam2.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam2.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam2.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam2.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam2.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam2.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam2.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam2.Production = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam2.UpdatedTime = DateTime.Now;
|
|
|
boxfoam2.MainId = 2;
|
|
|
boxfoam2.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam2);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam2);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype3 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(8).Take(9).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList3 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype3 && d.MainId == 3);
|
|
|
if (oldList3 != null)
|
|
|
{
|
|
|
oldList3.Fixtureboxtype = fixtureboxtype3;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0FA", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0FB", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y112", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0FA");
|
|
|
bool status2 = obj.plc.ReadBool("Y0FB");
|
|
|
bool status3 = obj.plc.ReadBool("Y112");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList3.AnHour = num - oldList3.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList3.TwoHour = num - oldList3.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList3.ThreeHour = num - oldList3.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList3.FourHour = num - oldList3.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList3.FiveHour = num - oldList3.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList3.SixHour = num - oldList3.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList3.SevenHour = num - oldList3.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList3.EightHour = num - oldList3.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList3.NineHour = num - oldList3.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList3.TenHour = num - oldList3.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList3.ElevenHour = num - oldList3.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList3.TwelveHour = num - oldList3.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList3.Production = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 1), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList3.UpdatedTime = DateTime.Now;
|
|
|
oldList3.MainId = 3;
|
|
|
oldList3.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList3);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList3);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam3 = new BoxFoamData();
|
|
|
boxfoam3.Fixtureboxtype = fixtureboxtype3;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0FA", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0FB", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y112", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0FA");
|
|
|
bool status2 = obj.plc.ReadBool("Y0FB");
|
|
|
bool status3 = obj.plc.ReadBool("Y112");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam3.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam3.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam3.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam3.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam3.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam3.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam3.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam3.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam3.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam3.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam3.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam3.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam3.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam3.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam3.Production = obj.plc.ReadInt16("D184");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam3.UpdatedTime = DateTime.Now;
|
|
|
boxfoam3.MainId = 3;
|
|
|
boxfoam3.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam3);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam3);
|
|
|
}
|
|
|
|
|
|
|
|
|
var fixtureboxtype4 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(12).Take(13).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList4 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype4 && d.MainId == 4);
|
|
|
if (oldList4 != null)
|
|
|
{
|
|
|
oldList4.Fixtureboxtype = fixtureboxtype4;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y100", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y101", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y113", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList4.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList4.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D185"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList4.AnHour = num - oldList4.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList4.TwoHour = num - oldList4.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList4.ThreeHour = num - oldList4.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList4.FourHour = num - oldList4.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList4.FiveHour = num - oldList4.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList4.SixHour = num - oldList4.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList4.SevenHour = num - oldList4.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList4.EightHour = num - oldList4.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList4.NineHour = num - oldList4.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList4.TenHour = num - oldList4.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList4.ElevenHour = num - oldList4.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList4.TwelveHour = num - oldList4.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList4.Production = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(12).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList4.UpdatedTime = DateTime.Now;
|
|
|
oldList4.MainId = 4;
|
|
|
oldList4.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList4);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList4);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam4 = new BoxFoamData();
|
|
|
boxfoam4.Fixtureboxtype = fixtureboxtype4;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y100", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y101", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y113", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam4.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam4.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam4.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam4.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam4.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam4.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam4.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam4.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam4.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam4.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam4.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam4.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam4.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam4.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam4.Production = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam4.UpdatedTime = DateTime.Now;
|
|
|
boxfoam4.MainId = 4;
|
|
|
boxfoam4.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam4);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam4);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype5 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(16).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList5 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype5 && d.MainId == 5);
|
|
|
if (oldList5 != null)
|
|
|
{
|
|
|
oldList5.Fixtureboxtype = fixtureboxtype5;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y105", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y106", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y114", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList5.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList5.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList5.AnHour = num - oldList5.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList5.TwoHour = num - oldList5.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList5.ThreeHour = num - oldList5.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList5.FourHour = num - oldList5.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList5.FiveHour = num - oldList5.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList5.SixHour = num - oldList5.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList5.SevenHour = num - oldList5.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList5.EightHour = num - oldList5.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList5.NineHour = num - oldList5.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList5.TenHour = num - oldList5.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList5.ElevenHour = num - oldList5.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList5.TwelveHour = num - oldList5.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList5.Production = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList5.UpdatedTime = DateTime.Now;
|
|
|
oldList5.MainId = 5;
|
|
|
oldList5.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList5);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList5);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam5 = new BoxFoamData();
|
|
|
boxfoam5.Fixtureboxtype = fixtureboxtype5;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y105", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y106", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y114", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam5.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam5.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam5.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam5.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam5.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam5.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam5.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam5.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam5.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam5.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam5.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam5.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam5.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam5.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam5.Production = obj.plc.ReadInt16("D186"); int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam5.UpdatedTime = DateTime.Now;
|
|
|
boxfoam5.MainId = 5;
|
|
|
boxfoam5.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam5);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam5);
|
|
|
}
|
|
|
var fixtureboxtype6 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(20).Take(21).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList6 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype6 && d.MainId == 6);
|
|
|
if (oldList6 != null)
|
|
|
{
|
|
|
oldList6.Fixtureboxtype = fixtureboxtype6;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y10A", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y10B", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y115", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y10A");
|
|
|
bool status2 = obj.plc.ReadBool("Y10B");
|
|
|
bool status3 = obj.plc.ReadBool("Y115");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList6.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList6.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList6.AnHour = num - oldList6.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList6.TwoHour = num - oldList6.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList6.ThreeHour = num - oldList6.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList6.FourHour = num - oldList6.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList6.FiveHour = num - oldList6.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList6.SixHour = num - oldList6.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList6.SevenHour = num - oldList6.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList6.EightHour = num - oldList6.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList6.NineHour = num - oldList6.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList6.TenHour = num - oldList6.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList6.ElevenHour = num - oldList6.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList6.TwelveHour = num - oldList6.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList6.Production = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList6.UpdatedTime = DateTime.Now;
|
|
|
oldList6.MainId = 6;
|
|
|
oldList6.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList6);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList6);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam6 = new BoxFoamData();
|
|
|
boxfoam6.Fixtureboxtype = fixtureboxtype6;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y10A", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y10B", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y115", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y10A");
|
|
|
bool status2 = obj.plc.ReadBool("Y10B");
|
|
|
bool status3 = obj.plc.ReadBool("Y115");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam6.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam6.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam6.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam6.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam6.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam6.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam6.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam6.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam6.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam6.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam6.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam6.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam6.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam6.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam6.Production = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam6.UpdatedTime = DateTime.Now;
|
|
|
boxfoam6.MainId = 6;
|
|
|
boxfoam6.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam6);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam6);
|
|
|
}
|
|
|
if (bfList == null)
|
|
|
{
|
|
|
await _oldBoxFoamDataServices.UpdateAsync(oldList6);
|
|
|
}
|
|
|
if (addList == null)
|
|
|
{
|
|
|
await _oldBoxFoamDataServices.AddAsync(addList);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
}
|
|
|
|
|
|
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
|
|
|
}
|
|
|
|
|
|
public async void GetData3()
|
|
|
{
|
|
|
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
|
|
|
try
|
|
|
{
|
|
|
List<BoxFoamData> bfList = new List<BoxFoamData>();
|
|
|
List<BoxFoamData> addList = new List<BoxFoamData>();
|
|
|
//var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
|
|
|
//if (obj2 == null) { return; }
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3"));
|
|
|
if (obj == null) { return; }
|
|
|
|
|
|
byte[] arr1 = obj.plc.ReadByte("D3140", (ushort)48);
|
|
|
if (arr1 == null) return;
|
|
|
//var arr1 = ArrReverse(bt);
|
|
|
|
|
|
byte[] arr3 = obj.plc.ReadByte("D182", (ushort)24);
|
|
|
if (arr3 == null) return;
|
|
|
//var arr3 = ArrReverse(bt3);
|
|
|
byte[] arr4 = obj.plc.ReadByte("D910", (ushort)24);
|
|
|
if (arr4 == null) return;
|
|
|
//var arr4 = ArrReverse(bt4);
|
|
|
byte[] arr5 = obj.plc.ReadByte("T3", (ushort)24);
|
|
|
if (arr5 == null) return;
|
|
|
//var arr5 = ArrReverse(bt5);
|
|
|
|
|
|
|
|
|
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
|
|
|
List<BoxFoamData> fdList = _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode).Result;
|
|
|
|
|
|
var fixtureboxtype1 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList1 = fdList.SingleOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 1);
|
|
|
if (oldList1 != null)
|
|
|
{
|
|
|
//只更新小时数量
|
|
|
oldList1.Fixtureboxtype = fixtureboxtype1;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F0", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F1", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y110", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr(result1, result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr(result2, result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr(result3, result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F0");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F1");
|
|
|
bool status3 = obj.plc.ReadBool("Y110");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList1.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList1.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D182"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList1.AnHour = num - oldList1.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList1.TwoHour = num - oldList1.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList1.ThreeHour = num - oldList1.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList1.FourHour = num - oldList1.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList1.FiveHour = num - oldList1.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList1.SixHour = num - oldList1.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList1.SevenHour = num - oldList1.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList1.EightHour = num - oldList1.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList1.NineHour = num - oldList1.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList1.TenHour = num - oldList1.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList1.ElevenHour = num - oldList1.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList1.TwelveHour = num - oldList1.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList1.Production = obj.plc.ReadInt16("D182");//short.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList1.UpdatedTime = DateTime.Now;
|
|
|
oldList1.ProductLineCode = "CX_01";
|
|
|
oldList1.MainId = 1;
|
|
|
bfList.Add(oldList1);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam1 = new BoxFoamData();
|
|
|
//新增
|
|
|
boxfoam1.Fixtureboxtype = fixtureboxtype1;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F0", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F1", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y110", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F0");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F1");
|
|
|
bool status3 = obj.plc.ReadBool("Y110");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam1.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam1.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D182"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam1.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam1.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam1.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam1.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam1.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam1.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam1.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam1.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam1.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam1.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam1.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam1.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam1.Production = obj.plc.ReadInt16("D182");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam1.UpdatedTime = DateTime.Now;
|
|
|
boxfoam1.ProductLineCode = "CX_01";
|
|
|
boxfoam1.MainId = 1;
|
|
|
addList.Add(boxfoam1);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam1);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype2 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList2 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 2);
|
|
|
if (oldList2 != null)
|
|
|
{
|
|
|
oldList2.Fixtureboxtype = fixtureboxtype2;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F5", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F6", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y111", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F5");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F6");
|
|
|
bool status3 = obj.plc.ReadBool("Y111");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList2.AnHour = num - oldList2.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList2.TwoHour = num - oldList2.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList2.ThreeHour = num - oldList2.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList2.FourHour = num - oldList2.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList2.FiveHour = num - oldList2.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList2.SixHour = num - oldList2.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList2.SevenHour = num - oldList2.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList2.EightHour = num - oldList2.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList2.NineHour = num - oldList2.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList2.TenHour = num - oldList2.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList2.ElevenHour = num - oldList2.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList2.TwelveHour = num - oldList2.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList2.Production = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList2.UpdatedTime = DateTime.Now;
|
|
|
oldList2.ProductLineCode = "CX_01";
|
|
|
oldList2.MainId = 2;
|
|
|
bfList.Add(oldList2);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam2 = new BoxFoamData();
|
|
|
boxfoam2.Fixtureboxtype = fixtureboxtype2;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F5", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F6", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y111", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0F5");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F6");
|
|
|
bool status3 = obj.plc.ReadBool("Y111");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D183");//int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam2.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam2.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam2.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam2.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam2.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam2.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam2.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam2.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam2.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam2.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam2.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam2.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam2.Production = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam2.UpdatedTime = DateTime.Now;
|
|
|
boxfoam2.MainId = 2;
|
|
|
boxfoam2.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam2);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam2);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype3 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(8).Take(9).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList3 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype3 && d.MainId == 3);
|
|
|
if (oldList3 != null)
|
|
|
{
|
|
|
oldList3.Fixtureboxtype = fixtureboxtype3;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0FA", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0FB", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y112", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0FA");
|
|
|
bool status2 = obj.plc.ReadBool("Y0FB");
|
|
|
bool status3 = obj.plc.ReadBool("Y112");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList3.AnHour = num - oldList3.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList3.TwoHour = num - oldList3.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList3.ThreeHour = num - oldList3.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList3.FourHour = num - oldList3.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList3.FiveHour = num - oldList3.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList3.SixHour = num - oldList3.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList3.SevenHour = num - oldList3.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList3.EightHour = num - oldList3.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList3.NineHour = num - oldList3.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList3.TenHour = num - oldList3.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList3.ElevenHour = num - oldList3.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList3.TwelveHour = num - oldList3.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList3.Production = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 1), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList3.UpdatedTime = DateTime.Now;
|
|
|
oldList3.MainId = 3;
|
|
|
oldList3.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList3);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList3);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam3 = new BoxFoamData();
|
|
|
boxfoam3.Fixtureboxtype = fixtureboxtype3;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0FA", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0FB", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y112", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0FA");
|
|
|
bool status2 = obj.plc.ReadBool("Y0FB");
|
|
|
bool status3 = obj.plc.ReadBool("Y112");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam3.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam3.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam3.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam3.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam3.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam3.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam3.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam3.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam3.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam3.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam3.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam3.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam3.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam3.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam3.Production = obj.plc.ReadInt16("D184");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam3.UpdatedTime = DateTime.Now;
|
|
|
boxfoam3.MainId = 3;
|
|
|
boxfoam3.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam3);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam3);
|
|
|
}
|
|
|
|
|
|
|
|
|
var fixtureboxtype4 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(12).Take(13).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList4 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype4 && d.MainId == 4);
|
|
|
if (oldList4 != null)
|
|
|
{
|
|
|
oldList4.Fixtureboxtype = fixtureboxtype4;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y100", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y101", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y113", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList4.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList4.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D185"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList4.AnHour = num - oldList4.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList4.TwoHour = num - oldList4.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList4.ThreeHour = num - oldList4.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList4.FourHour = num - oldList4.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList4.FiveHour = num - oldList4.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList4.SixHour = num - oldList4.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList4.SevenHour = num - oldList4.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList4.EightHour = num - oldList4.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList4.NineHour = num - oldList4.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList4.TenHour = num - oldList4.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList4.ElevenHour = num - oldList4.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList4.TwelveHour = num - oldList4.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList4.Production = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(12).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList4.UpdatedTime = DateTime.Now;
|
|
|
oldList4.MainId = 4;
|
|
|
oldList4.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList4);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList4);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam4 = new BoxFoamData();
|
|
|
boxfoam4.Fixtureboxtype = fixtureboxtype4;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y100", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y101", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y113", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam4.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam4.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam4.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam4.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam4.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam4.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam4.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam4.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam4.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam4.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam4.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam4.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam4.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam4.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam4.Production = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam4.UpdatedTime = DateTime.Now;
|
|
|
boxfoam4.MainId = 4;
|
|
|
boxfoam4.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam4);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam4);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype5 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(16).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList5 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype5 && d.MainId == 5);
|
|
|
if (oldList5 != null)
|
|
|
{
|
|
|
oldList5.Fixtureboxtype = fixtureboxtype5;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y105", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y106", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y114", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList5.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList5.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList5.AnHour = num - oldList5.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList5.TwoHour = num - oldList5.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList5.ThreeHour = num - oldList5.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList5.FourHour = num - oldList5.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList5.FiveHour = num - oldList5.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList5.SixHour = num - oldList5.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList5.SevenHour = num - oldList5.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList5.EightHour = num - oldList5.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList5.NineHour = num - oldList5.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList5.TenHour = num - oldList5.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList5.ElevenHour = num - oldList5.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList5.TwelveHour = num - oldList5.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList5.Production = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList5.UpdatedTime = DateTime.Now;
|
|
|
oldList5.MainId = 5;
|
|
|
oldList5.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList5);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList5);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam5 = new BoxFoamData();
|
|
|
boxfoam5.Fixtureboxtype = fixtureboxtype5;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y105", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y106", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y114", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam5.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam5.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam5.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam5.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam5.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam5.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam5.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam5.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam5.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam5.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam5.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam5.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam5.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam5.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam5.Production = obj.plc.ReadInt16("D186"); int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam5.UpdatedTime = DateTime.Now;
|
|
|
boxfoam5.MainId = 5;
|
|
|
boxfoam5.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam5);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam5);
|
|
|
}
|
|
|
var fixtureboxtype6 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(20).Take(21).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList6 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype6 && d.MainId == 6);
|
|
|
if (oldList6 != null)
|
|
|
{
|
|
|
oldList6.Fixtureboxtype = fixtureboxtype6;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y10A", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y10B", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y115", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y10A");
|
|
|
bool status2 = obj.plc.ReadBool("Y10B");
|
|
|
bool status3 = obj.plc.ReadBool("Y115");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList6.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList6.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList6.AnHour = num - oldList6.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList6.TwoHour = num - oldList6.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList6.ThreeHour = num - oldList6.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList6.FourHour = num - oldList6.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList6.FiveHour = num - oldList6.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList6.SixHour = num - oldList6.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList6.SevenHour = num - oldList6.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList6.EightHour = num - oldList6.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList6.NineHour = num - oldList6.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList6.TenHour = num - oldList6.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList6.ElevenHour = num - oldList6.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList6.TwelveHour = num - oldList6.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList6.Production = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList6.UpdatedTime = DateTime.Now;
|
|
|
oldList6.MainId = 6;
|
|
|
oldList6.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList6);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList6);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam6 = new BoxFoamData();
|
|
|
boxfoam6.Fixtureboxtype = fixtureboxtype6;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y10A", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y10B", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y115", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y10A");
|
|
|
bool status2 = obj.plc.ReadBool("Y10B");
|
|
|
bool status3 = obj.plc.ReadBool("Y115");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam6.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam6.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam6.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam6.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam6.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam6.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam6.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam6.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam6.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam6.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam6.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam6.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam6.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam6.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam6.Production = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam6.UpdatedTime = DateTime.Now;
|
|
|
boxfoam6.MainId = 6;
|
|
|
boxfoam6.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam6);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam6);
|
|
|
}
|
|
|
if (bfList == null)
|
|
|
{
|
|
|
await _oldBoxFoamDataServices.UpdateAsync(oldList6);
|
|
|
}
|
|
|
if (addList == null)
|
|
|
{
|
|
|
await _oldBoxFoamDataServices.AddAsync(addList);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
}
|
|
|
|
|
|
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
|
|
|
}
|
|
|
|
|
|
public async void GetData4()
|
|
|
{
|
|
|
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
|
|
|
try
|
|
|
{
|
|
|
List<BoxFoamData> bfList = new List<BoxFoamData>();
|
|
|
List<BoxFoamData> addList = new List<BoxFoamData>();
|
|
|
//var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
|
|
|
//if (obj2 == null) { return; }
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc4"));
|
|
|
if (obj == null) { return; }
|
|
|
|
|
|
byte[] arr1 = obj.plc.ReadByte("D3140", (ushort)48);
|
|
|
if (arr1 == null) return;
|
|
|
//var arr1 = ArrReverse(bt);
|
|
|
|
|
|
byte[] arr3 = obj.plc.ReadByte("D182", (ushort)24);
|
|
|
if (arr3 == null) return;
|
|
|
//var arr3 = ArrReverse(bt3);
|
|
|
byte[] arr4 = obj.plc.ReadByte("D910", (ushort)24);
|
|
|
if (arr4 == null) return;
|
|
|
//var arr4 = ArrReverse(bt4);
|
|
|
byte[] arr5 = obj.plc.ReadByte("T3", (ushort)24);
|
|
|
if (arr5 == null) return;
|
|
|
//var arr5 = ArrReverse(bt5);
|
|
|
|
|
|
|
|
|
string productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
|
|
|
List<BoxFoamData> fdList = _oldBoxFoamDataServices.QueryAsync(d => d.ProductLineCode == productLineCode).Result;
|
|
|
|
|
|
var fixtureboxtype1 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList1 = fdList.SingleOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 1);
|
|
|
if (oldList1 != null)
|
|
|
{
|
|
|
//只更新小时数量
|
|
|
oldList1.Fixtureboxtype = fixtureboxtype1;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F0", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F1", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y110", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr(result1, result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr(result2, result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr(result3, result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F0");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F1");
|
|
|
bool status3 = obj.plc.ReadBool("Y110");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList1.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList1.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D182"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList1.AnHour = num - oldList1.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList1.TwoHour = num - oldList1.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList1.ThreeHour = num - oldList1.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList1.FourHour = num - oldList1.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList1.FiveHour = num - oldList1.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList1.SixHour = num - oldList1.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList1.SevenHour = num - oldList1.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList1.EightHour = num - oldList1.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList1.NineHour = num - oldList1.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList1.TenHour = num - oldList1.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList1.ElevenHour = num - oldList1.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList1.TwelveHour = num - oldList1.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList1.Production = obj.plc.ReadInt16("D182");//short.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList1.UpdatedTime = DateTime.Now;
|
|
|
oldList1.ProductLineCode = "CX_01";
|
|
|
oldList1.MainId = 1;
|
|
|
bfList.Add(oldList1);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam1 = new BoxFoamData();
|
|
|
//新增
|
|
|
boxfoam1.Fixtureboxtype = fixtureboxtype1;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F0", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F1", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y110", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F0");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F1");
|
|
|
bool status3 = obj.plc.ReadBool("Y110");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam1.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam1.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D182"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam1.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam1.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam1.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam1.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam1.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam1.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam1.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam1.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam1.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam1.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam1.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam1.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam1.Production = obj.plc.ReadInt16("D182");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(0).Take(3).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam1.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam1.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam1.UpdatedTime = DateTime.Now;
|
|
|
boxfoam1.ProductLineCode = "CX_01";
|
|
|
boxfoam1.MainId = 1;
|
|
|
addList.Add(boxfoam1);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam1);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype2 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(4).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList2 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype1 && d.MainId == 2);
|
|
|
if (oldList2 != null)
|
|
|
{
|
|
|
oldList2.Fixtureboxtype = fixtureboxtype2;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F5", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F6", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y111", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y0F5");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F6");
|
|
|
bool status3 = obj.plc.ReadBool("Y111");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList2.AnHour = num - oldList2.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList2.TwoHour = num - oldList2.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList2.ThreeHour = num - oldList2.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList2.FourHour = num - oldList2.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList2.FiveHour = num - oldList2.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList2.SixHour = num - oldList2.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList2.SevenHour = num - oldList2.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList2.EightHour = num - oldList2.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList2.NineHour = num - oldList2.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList2.TenHour = num - oldList2.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList2.ElevenHour = num - oldList2.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList2.TwelveHour = num - oldList2.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList2.Production = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList2.UpdatedTime = DateTime.Now;
|
|
|
oldList2.ProductLineCode = "CX_01";
|
|
|
oldList2.MainId = 2;
|
|
|
bfList.Add(oldList2);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList2);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam2 = new BoxFoamData();
|
|
|
boxfoam2.Fixtureboxtype = fixtureboxtype2;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0F5", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0F6", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y111", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0F5");
|
|
|
bool status2 = obj.plc.ReadBool("Y0F6");
|
|
|
bool status3 = obj.plc.ReadBool("Y111");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D183");//int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam2.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam2.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam2.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam2.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam2.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam2.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam2.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam2.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam2.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam2.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam2.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam2.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam2.Production = obj.plc.ReadInt16("D183"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(4).Take(7).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam2.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam2.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(3).Take(5).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam2.UpdatedTime = DateTime.Now;
|
|
|
boxfoam2.MainId = 2;
|
|
|
boxfoam2.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam2);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam2);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype3 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(8).Take(9).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList3 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype3 && d.MainId == 3);
|
|
|
if (oldList3 != null)
|
|
|
{
|
|
|
oldList3.Fixtureboxtype = fixtureboxtype3;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0FA", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0FB", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y112", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0FA");
|
|
|
bool status2 = obj.plc.ReadBool("Y0FB");
|
|
|
bool status3 = obj.plc.ReadBool("Y112");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList2.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList2.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList3.AnHour = num - oldList3.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList3.TwoHour = num - oldList3.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList3.ThreeHour = num - oldList3.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList3.FourHour = num - oldList3.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList3.FiveHour = num - oldList3.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList3.SixHour = num - oldList3.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList3.SevenHour = num - oldList3.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList3.EightHour = num - oldList3.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList3.NineHour = num - oldList3.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList3.TenHour = num - oldList3.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList3.ElevenHour = num - oldList3.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList3.TwelveHour = num - oldList3.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList3.Production = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 1), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList3.UpdatedTime = DateTime.Now;
|
|
|
oldList3.MainId = 3;
|
|
|
oldList3.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList3);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList3);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam3 = new BoxFoamData();
|
|
|
boxfoam3.Fixtureboxtype = fixtureboxtype3;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj.plc.Read("Y0FA", 1);
|
|
|
//byte[] result2 = obj.plc.Read("Y0FB", 1);
|
|
|
//byte[] result3 = obj.plc.Read("Y112", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y0FA");
|
|
|
bool status2 = obj.plc.ReadBool("Y0FB");
|
|
|
bool status3 = obj.plc.ReadBool("Y112");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam3.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam3.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D184"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam3.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam3.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam3.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam3.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam3.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam3.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam3.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam3.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam3.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam3.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam3.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam3.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam3.Production = obj.plc.ReadInt16("D184");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(8).Take(11).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam3.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam3.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(6).Take(8).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam3.UpdatedTime = DateTime.Now;
|
|
|
boxfoam3.MainId = 3;
|
|
|
boxfoam3.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam3);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam3);
|
|
|
}
|
|
|
|
|
|
|
|
|
var fixtureboxtype4 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(12).Take(13).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList4 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype4 && d.MainId == 4);
|
|
|
if (oldList4 != null)
|
|
|
{
|
|
|
oldList4.Fixtureboxtype = fixtureboxtype4;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y100", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y101", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y113", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList4.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList4.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D185"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList4.AnHour = num - oldList4.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList4.TwoHour = num - oldList4.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList4.ThreeHour = num - oldList4.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList4.FourHour = num - oldList4.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList4.FiveHour = num - oldList4.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList4.SixHour = num - oldList4.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList4.SevenHour = num - oldList4.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList4.EightHour = num - oldList4.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList4.NineHour = num - oldList4.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList4.TenHour = num - oldList4.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList4.ElevenHour = num - oldList4.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList4.TwelveHour = num - oldList4.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList4.Production = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(12).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList4.UpdatedTime = DateTime.Now;
|
|
|
oldList4.MainId = 4;
|
|
|
oldList4.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList4);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList4);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam4 = new BoxFoamData();
|
|
|
boxfoam4.Fixtureboxtype = fixtureboxtype4;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y100", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y101", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y113", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam4.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam4.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam4.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam4.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam4.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam4.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam4.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam4.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam4.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam4.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam4.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam4.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam4.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam4.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam4.Production = obj.plc.ReadInt16("D185");// int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(15).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam4.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam4.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(9).Take(11).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam4.UpdatedTime = DateTime.Now;
|
|
|
boxfoam4.MainId = 4;
|
|
|
boxfoam4.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam4);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam4);
|
|
|
}
|
|
|
|
|
|
var fixtureboxtype5 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(16).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList5 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype5 && d.MainId == 5);
|
|
|
if (oldList5 != null)
|
|
|
{
|
|
|
oldList5.Fixtureboxtype = fixtureboxtype5;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y105", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y106", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y114", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList5.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList5.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(),1), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList5.AnHour = num - oldList5.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList5.TwoHour = num - oldList5.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList5.ThreeHour = num - oldList5.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList5.FourHour = num - oldList5.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList5.FiveHour = num - oldList5.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList5.SixHour = num - oldList5.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList5.SevenHour = num - oldList5.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList5.EightHour = num - oldList5.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList5.NineHour = num - oldList5.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList5.TenHour = num - oldList5.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList5.ElevenHour = num - oldList5.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList5.TwelveHour = num - oldList5.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList5.Production = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(16).Take(19).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList5.UpdatedTime = DateTime.Now;
|
|
|
oldList5.MainId = 5;
|
|
|
oldList5.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList5);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList5);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam5 = new BoxFoamData();
|
|
|
boxfoam5.Fixtureboxtype = fixtureboxtype5;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y105", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y106", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y114", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y100");
|
|
|
bool status2 = obj.plc.ReadBool("Y101");
|
|
|
bool status3 = obj.plc.ReadBool("Y113");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam5.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam5.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
|
|
|
int num = obj.plc.ReadInt16("D186"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam5.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam5.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam5.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam5.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam5.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam5.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam5.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam5.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam5.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam5.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam5.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam5.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam5.Production = obj.plc.ReadInt16("D186"); int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam5.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam5.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(12).Take(14).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam5.UpdatedTime = DateTime.Now;
|
|
|
boxfoam5.MainId = 5;
|
|
|
boxfoam5.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam5);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam5);
|
|
|
}
|
|
|
var fixtureboxtype6 = short.Parse(UnicodeHelper.BytesToHexStr(arr1.Skip(20).Take(21).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
var oldList6 = fdList.FirstOrDefault(d => d.Fixtureboxtype == fixtureboxtype6 && d.MainId == 6);
|
|
|
if (oldList6 != null)
|
|
|
{
|
|
|
oldList6.Fixtureboxtype = fixtureboxtype6;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y10A", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y10B", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y115", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
bool status1 = obj.plc.ReadBool("Y10A");
|
|
|
bool status2 = obj.plc.ReadBool("Y10B");
|
|
|
bool status3 = obj.plc.ReadBool("Y115");
|
|
|
if (status2)
|
|
|
{
|
|
|
oldList6.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
oldList6.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(),2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
oldList6.AnHour = num - oldList6.AnHour;
|
|
|
break;
|
|
|
case 2:
|
|
|
oldList6.TwoHour = num - oldList6.TwoHour;
|
|
|
break;
|
|
|
case 3:
|
|
|
oldList6.ThreeHour = num - oldList6.ThreeHour;
|
|
|
break;
|
|
|
case 4:
|
|
|
oldList6.FourHour = num - oldList6.FourHour;
|
|
|
break;
|
|
|
case 5:
|
|
|
oldList6.FiveHour = num - oldList6.FiveHour;
|
|
|
break;
|
|
|
case 6:
|
|
|
oldList6.SixHour = num - oldList6.SixHour;
|
|
|
break;
|
|
|
case 7:
|
|
|
oldList6.SevenHour = num - oldList6.SevenHour;
|
|
|
break;
|
|
|
case 8:
|
|
|
oldList6.EightHour = num - oldList6.EightHour; ;
|
|
|
break;
|
|
|
case 9:
|
|
|
oldList6.NineHour = num - oldList6.NineHour;
|
|
|
break;
|
|
|
case 10:
|
|
|
oldList6.TenHour = num - oldList6.TenHour;
|
|
|
break;
|
|
|
case 11:
|
|
|
oldList6.ElevenHour = num - oldList6.ElevenHour;
|
|
|
break;
|
|
|
case 12:
|
|
|
oldList6.TwelveHour = num - oldList6.TwelveHour;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
oldList6.Production = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
oldList6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 3), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
oldList6.UpdatedTime = DateTime.Now;
|
|
|
oldList6.MainId = 6;
|
|
|
oldList6.ProductLineCode = "CX_01";
|
|
|
bfList.Add(oldList6);
|
|
|
//await _oldBoxFoamDataServices.UpdateAsync(oldList6);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
BoxFoamData boxfoam6 = new BoxFoamData();
|
|
|
boxfoam6.Fixtureboxtype = fixtureboxtype6;
|
|
|
|
|
|
#region 状态
|
|
|
//byte[] result1 = obj2.plc.Read("Y10A", 1);
|
|
|
//byte[] result2 = obj2.plc.Read("Y10B", 1);
|
|
|
//byte[] result3 = obj2.plc.Read("Y115", 1);
|
|
|
//int status1 = int.Parse(UnicodeHelper.BytesToHexStr((result1), result1.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status2 = int.Parse(UnicodeHelper.BytesToHexStr((result2), result2.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
//int status3 = int.Parse(UnicodeHelper.BytesToHexStr((result3), result3.Length), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
bool status1 = obj.plc.ReadBool("Y10A");
|
|
|
bool status2 = obj.plc.ReadBool("Y10B");
|
|
|
bool status3 = obj.plc.ReadBool("Y115");
|
|
|
if (status2)
|
|
|
{
|
|
|
boxfoam6.Fixturestatus = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
boxfoam6.Fixturestatus = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算每小时产量
|
|
|
int num = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
switch (GetTeamHour())
|
|
|
{
|
|
|
case 1:
|
|
|
boxfoam6.AnHour = num;
|
|
|
break;
|
|
|
case 2:
|
|
|
boxfoam6.TwoHour = num;
|
|
|
break;
|
|
|
case 3:
|
|
|
boxfoam6.ThreeHour = num;
|
|
|
break;
|
|
|
case 4:
|
|
|
boxfoam6.FourHour = num;
|
|
|
break;
|
|
|
case 5:
|
|
|
boxfoam6.FiveHour = num;
|
|
|
break;
|
|
|
case 6:
|
|
|
boxfoam6.SixHour = num;
|
|
|
break;
|
|
|
case 7:
|
|
|
boxfoam6.SevenHour = num;
|
|
|
break;
|
|
|
case 8:
|
|
|
boxfoam6.EightHour = num;
|
|
|
break;
|
|
|
case 9:
|
|
|
boxfoam6.NineHour = num;
|
|
|
break;
|
|
|
case 10:
|
|
|
boxfoam6.TenHour = num;
|
|
|
break;
|
|
|
case 11:
|
|
|
boxfoam6.ElevenHour = num;
|
|
|
break;
|
|
|
case 12:
|
|
|
boxfoam6.TwelveHour = num;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
boxfoam6.Production = obj.plc.ReadInt16("D187"); //int.Parse(UnicodeHelper.BytesToHexStr(arr3.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
boxfoam6.CuringTimeSettingValue = short.Parse(UnicodeHelper.BytesToHexStr(arr4.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam6.ActualValue = short.Parse(UnicodeHelper.BytesToHexStr(arr5.Skip(15).Take(17).ToArray(), 2), System.Globalization.NumberStyles.HexNumber).ToString();
|
|
|
boxfoam6.UpdatedTime = DateTime.Now;
|
|
|
boxfoam6.MainId = 6;
|
|
|
boxfoam6.ProductLineCode = "CX_01";
|
|
|
addList.Add(boxfoam6);
|
|
|
//await _oldBoxFoamDataServices.AddAsync(boxfoam6);
|
|
|
}
|
|
|
if (bfList == null)
|
|
|
{
|
|
|
await _oldBoxFoamDataServices.UpdateAsync(oldList6);
|
|
|
}
|
|
|
if (addList == null)
|
|
|
{
|
|
|
await _oldBoxFoamDataServices.AddAsync(addList);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
}
|
|
|
|
|
|
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss"));
|
|
|
}
|
|
|
public int GetTeamHour()
|
|
|
{
|
|
|
DateTime now = DateTime.Now;
|
|
|
var obj = _sysUserInfoServices.GetTeamData(now).Result;
|
|
|
return obj.Seq;
|
|
|
}
|
|
|
}
|
|
|
}
|