|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
using Admin.Core.Common.Helper;
|
|
|
|
|
using Aucma.Core.BoxFoam.Models;
|
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
|
using NetTaste;
|
|
|
|
|
using NPOI.Util;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.RightsManagement;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
@ -17,58 +19,157 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CollectionFoamLine
|
|
|
|
|
{
|
|
|
|
|
public delegate Task RefreshBoxFoamDataDelegate(List<FixtureStatus> list);
|
|
|
|
|
public static event RefreshBoxFoamDataDelegate RefreshBoxFoamDataDelegateEvent;
|
|
|
|
|
|
|
|
|
|
private static System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
|
|
|
|
|
|
|
|
|
|
public static List<FixtureStatus> listFixtureStatus = new List<FixtureStatus>();
|
|
|
|
|
|
|
|
|
|
public static List<string> BoxTypeList = new List<string>();
|
|
|
|
|
public static List<int> HolderStatusList = new List<int>();
|
|
|
|
|
public static List<int> HolderOutPutList = new List<int>();
|
|
|
|
|
public static List<int> SolidifyTimeList = new List<int>();
|
|
|
|
|
public static List<int> ActualTimeList = new List<int>();
|
|
|
|
|
public static List<double> MoldTemperatureList = new List<double>();
|
|
|
|
|
Semaphore semaphore = new Semaphore(1, 1);
|
|
|
|
|
public CollectionFoamLine()
|
|
|
|
|
{
|
|
|
|
|
startCollect();
|
|
|
|
|
}
|
|
|
|
|
public async void startCollect()
|
|
|
|
|
|
|
|
|
|
public void startCollect()
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(6000);
|
|
|
|
|
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc"));
|
|
|
|
|
ReadBoxType(obj); // ok
|
|
|
|
|
// ReadFixtureStatus(obj); //ok
|
|
|
|
|
// ReadFixtureProduction(obj); //ok
|
|
|
|
|
// ReadPlanCuringTime(obj); //ok
|
|
|
|
|
// ReadDisplayCuringTime(obj); //ok
|
|
|
|
|
// ReadMoldTemperature(obj);
|
|
|
|
|
// ReadLineStatus(obj); //ok
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
semaphore.WaitOne();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc"));
|
|
|
|
|
|
|
|
|
|
if (obj != null)
|
|
|
|
|
{
|
|
|
|
|
BoxTypeList.Clear();
|
|
|
|
|
HolderStatusList.Clear();
|
|
|
|
|
HolderOutPutList.Clear();
|
|
|
|
|
SolidifyTimeList.Clear();
|
|
|
|
|
ActualTimeList.Clear();
|
|
|
|
|
listFixtureStatus.Clear();
|
|
|
|
|
ReadBoxType(obj, BoxTypeList); // ok
|
|
|
|
|
ReadFixtureStatus(obj, HolderStatusList); //ok
|
|
|
|
|
ReadFixtureProduction(obj, HolderOutPutList); //ok
|
|
|
|
|
ReadPlanCuringTime(obj, SolidifyTimeList); //ok
|
|
|
|
|
ReadDisplayCuringTime(obj, ActualTimeList); //ok
|
|
|
|
|
//ReadMoldTemperature(obj,MoldTemperatureList);
|
|
|
|
|
//ReadLineStatus(obj); //ok
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 12; i++)
|
|
|
|
|
{
|
|
|
|
|
FixtureStatus model = new FixtureStatus();
|
|
|
|
|
model.ObjId = i + 1;
|
|
|
|
|
if (BoxTypeList.Count > 0 && BoxTypeList != null)
|
|
|
|
|
{
|
|
|
|
|
model.FixtureBoxType = BoxTypeList[i].ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
model.FixtureBoxType = "";
|
|
|
|
|
}
|
|
|
|
|
if (HolderStatusList.Count > 0 && HolderStatusList != null)
|
|
|
|
|
{
|
|
|
|
|
model.Status = HolderStatusList[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
model.Status = HolderStatusList[i];
|
|
|
|
|
}
|
|
|
|
|
if (HolderOutPutList.Count > 0 && HolderOutPutList != null)
|
|
|
|
|
{
|
|
|
|
|
model.Yield = HolderOutPutList[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
model.Yield = 0;
|
|
|
|
|
}
|
|
|
|
|
if (SolidifyTimeList.Count > 0 && HolderOutPutList != null)
|
|
|
|
|
{
|
|
|
|
|
model.PlanCuringTime = SolidifyTimeList[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
model.PlanCuringTime = 0;
|
|
|
|
|
}
|
|
|
|
|
listFixtureStatus.Add(model);
|
|
|
|
|
}
|
|
|
|
|
RefreshBoxFoamDataDelegateEvent?.Invoke(listFixtureStatus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
semaphore.Release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取夹具箱型
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadBoxType(HwPLc.PlcModel obj)
|
|
|
|
|
static void ReadBoxType(HwPLc.PlcModel obj, List<string> boxTypeList)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.0", 124);
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
|
|
|
|
|
if (result == null) return;
|
|
|
|
|
int str0 = int.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
string str1 = asciiEncoding.GetString(result.Skip(4).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str2 = asciiEncoding.GetString(result.Skip(14).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str3 = asciiEncoding.GetString(result.Skip(24).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str4 = asciiEncoding.GetString(result.Skip(34).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str5 = asciiEncoding.GetString(result.Skip(44).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str6 = asciiEncoding.GetString(result.Skip(54).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str7 = asciiEncoding.GetString(result.Skip(64).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str8 = asciiEncoding.GetString(result.Skip(74).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str9 = asciiEncoding.GetString(result.Skip(84).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str10 = asciiEncoding.GetString(result.Skip(94).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str11 = asciiEncoding.GetString(result.Skip(104).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str12 = asciiEncoding.GetString(result.Skip(114).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.0", 124);
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
|
|
|
|
|
if (result == null) return;
|
|
|
|
|
int str0 = int.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
string str1 = asciiEncoding.GetString(result.Skip(4).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str2 = asciiEncoding.GetString(result.Skip(14).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str3 = asciiEncoding.GetString(result.Skip(24).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str4 = asciiEncoding.GetString(result.Skip(34).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str5 = asciiEncoding.GetString(result.Skip(44).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str6 = asciiEncoding.GetString(result.Skip(54).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str7 = asciiEncoding.GetString(result.Skip(64).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str8 = asciiEncoding.GetString(result.Skip(74).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str9 = asciiEncoding.GetString(result.Skip(84).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str10 = asciiEncoding.GetString(result.Skip(94).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str11 = asciiEncoding.GetString(result.Skip(104).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
string str12 = asciiEncoding.GetString(result.Skip(114).Take(10).ToArray()).Trim('\n');
|
|
|
|
|
boxTypeList.Add(str1);
|
|
|
|
|
boxTypeList.Add(str2);
|
|
|
|
|
boxTypeList.Add(str3);
|
|
|
|
|
boxTypeList.Add(str4);
|
|
|
|
|
boxTypeList.Add(str5);
|
|
|
|
|
boxTypeList.Add(str6);
|
|
|
|
|
boxTypeList.Add(str7);
|
|
|
|
|
boxTypeList.Add(str8);
|
|
|
|
|
boxTypeList.Add(str9);
|
|
|
|
|
boxTypeList.Add(str10);
|
|
|
|
|
boxTypeList.Add(str11);
|
|
|
|
|
boxTypeList.Add(str12);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取夹具状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadFixtureStatus(HwPLc.PlcModel obj)
|
|
|
|
|
static void ReadFixtureStatus(HwPLc.PlcModel obj, List<int> HolderStatusList)
|
|
|
|
|
{
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.122", 23);
|
|
|
|
|
byte[] info = result;
|
|
|
|
@ -84,6 +185,19 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
int temp10 = judgeStatus(ByteArrayToBinary(info.Skip(18).Take(1).ToArray()));
|
|
|
|
|
int temp11 = judgeStatus(ByteArrayToBinary(info.Skip(20).Take(1).ToArray()));
|
|
|
|
|
int temp12 = judgeStatus(ByteArrayToBinary(info.Skip(22).Take(1).ToArray()));
|
|
|
|
|
|
|
|
|
|
HolderStatusList.Add(temp1);
|
|
|
|
|
HolderStatusList.Add(temp2);
|
|
|
|
|
HolderStatusList.Add(temp3);
|
|
|
|
|
HolderStatusList.Add(temp4);
|
|
|
|
|
HolderStatusList.Add(temp5);
|
|
|
|
|
HolderStatusList.Add(temp6);
|
|
|
|
|
HolderStatusList.Add(temp7);
|
|
|
|
|
HolderStatusList.Add(temp8);
|
|
|
|
|
HolderStatusList.Add(temp9);
|
|
|
|
|
HolderStatusList.Add(temp10);
|
|
|
|
|
HolderStatusList.Add(temp11);
|
|
|
|
|
HolderStatusList.Add(temp11);
|
|
|
|
|
Console.WriteLine($"读取夹具状态,1#:{temp1};2#:{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}");
|
|
|
|
|
Console.WriteLine($"读取夹具状态,7#:{temp7};8#:{temp8};9#:{temp9};10#:{temp10};11#:{temp11};12#:{temp12}");
|
|
|
|
|
|
|
|
|
@ -92,7 +206,7 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取夹具产量
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadFixtureProduction(HwPLc.PlcModel obj)
|
|
|
|
|
static void ReadFixtureProduction(HwPLc.PlcModel obj, List<int> HolderOutPutList)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
@ -111,6 +225,19 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
int temp10 = int.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp11 = int.Parse(StringChange.bytesToHexStr(info.Skip(40).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp12 = int.Parse(StringChange.bytesToHexStr(info.Skip(44).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
HolderOutPutList.Add(temp1);
|
|
|
|
|
HolderOutPutList.Add(temp2);
|
|
|
|
|
HolderOutPutList.Add(temp3);
|
|
|
|
|
HolderOutPutList.Add(temp4);
|
|
|
|
|
HolderOutPutList.Add(temp5);
|
|
|
|
|
HolderOutPutList.Add(temp6);
|
|
|
|
|
HolderOutPutList.Add(temp7);
|
|
|
|
|
HolderOutPutList.Add(temp8);
|
|
|
|
|
HolderOutPutList.Add(temp9);
|
|
|
|
|
HolderOutPutList.Add(temp10);
|
|
|
|
|
HolderOutPutList.Add(temp11);
|
|
|
|
|
HolderOutPutList.Add(temp12);
|
|
|
|
|
Console.WriteLine($"读取夹具产量,1#:{temp1};2#:{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}");
|
|
|
|
|
Console.WriteLine($"读取夹具产量,7#:{temp7};8#:{temp8};9#:{temp9};10#:{temp10};11#:{temp11};12#:{temp12}");
|
|
|
|
|
}
|
|
|
|
@ -119,7 +246,7 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 固化时间设定值
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadPlanCuringTime(HwPLc.PlcModel obj)
|
|
|
|
|
static void ReadPlanCuringTime(HwPLc.PlcModel obj, List<int> SolidifyTimeList)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
@ -138,6 +265,20 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
int temp10 = int.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp11 = int.Parse(StringChange.bytesToHexStr(info.Skip(40).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp12 = int.Parse(StringChange.bytesToHexStr(info.Skip(44).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SolidifyTimeList.Add(temp1);
|
|
|
|
|
SolidifyTimeList.Add(temp2);
|
|
|
|
|
SolidifyTimeList.Add(temp3);
|
|
|
|
|
SolidifyTimeList.Add(temp4);
|
|
|
|
|
SolidifyTimeList.Add(temp5);
|
|
|
|
|
SolidifyTimeList.Add(temp6);
|
|
|
|
|
SolidifyTimeList.Add(temp7);
|
|
|
|
|
SolidifyTimeList.Add(temp8);
|
|
|
|
|
SolidifyTimeList.Add(temp9);
|
|
|
|
|
SolidifyTimeList.Add(temp10);
|
|
|
|
|
SolidifyTimeList.Add(temp11);
|
|
|
|
|
SolidifyTimeList.Add(temp12);
|
|
|
|
|
Console.WriteLine($"读取固化时间设定值,1#:{temp1};2#:{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}");
|
|
|
|
|
Console.WriteLine($"读取固化时间设定值,7#:{temp7};8#:{temp8};9#:{temp9};10#:{temp10};11#:{temp11};12#:{temp12}");
|
|
|
|
|
}
|
|
|
|
@ -146,7 +287,7 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 固化时间显示值
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadDisplayCuringTime(HwPLc.PlcModel obj)
|
|
|
|
|
static void ReadDisplayCuringTime(HwPLc.PlcModel obj, List<int> ActualTimeList)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
@ -165,6 +306,20 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
int temp10 = int.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp11 = int.Parse(StringChange.bytesToHexStr(info.Skip(40).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp12 = int.Parse(StringChange.bytesToHexStr(info.Skip(44).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
ActualTimeList.Add(temp1);
|
|
|
|
|
ActualTimeList.Add(temp2);
|
|
|
|
|
ActualTimeList.Add(temp3);
|
|
|
|
|
ActualTimeList.Add(temp4);
|
|
|
|
|
ActualTimeList.Add(temp5);
|
|
|
|
|
ActualTimeList.Add(temp6);
|
|
|
|
|
ActualTimeList.Add(temp7);
|
|
|
|
|
ActualTimeList.Add(temp8);
|
|
|
|
|
ActualTimeList.Add(temp9);
|
|
|
|
|
ActualTimeList.Add(temp10);
|
|
|
|
|
ActualTimeList.Add(temp11);
|
|
|
|
|
ActualTimeList.Add(temp12);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"读取固化时间显示值,1#:{temp1};2#:{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}");
|
|
|
|
|
Console.WriteLine($"读取固化时间显示值,7#:{temp7};8#:{temp8};9#:{temp9};10#:{temp10};11#:{temp11};12#:{temp12}");
|
|
|
|
|
}
|
|
|
|
@ -174,7 +329,7 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 模具内外温度
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadMoldTemperature(HwPLc.PlcModel obj)
|
|
|
|
|
static void ReadMoldTemperature(HwPLc.PlcModel obj, List<double> MoldTemperatureList)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
@ -201,6 +356,20 @@ namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
int temp10 = int.Parse(StringChange.bytesToHexStr(info.Skip(36).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp11 = int.Parse(StringChange.bytesToHexStr(info.Skip(40).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp12 = int.Parse(StringChange.bytesToHexStr(info.Skip(44).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
MoldTemperatureList.Add(temp1);
|
|
|
|
|
MoldTemperatureList.Add(temp2);
|
|
|
|
|
MoldTemperatureList.Add(temp3);
|
|
|
|
|
MoldTemperatureList.Add(temp4);
|
|
|
|
|
MoldTemperatureList.Add(temp5);
|
|
|
|
|
MoldTemperatureList.Add(temp6);
|
|
|
|
|
MoldTemperatureList.Add(temp7);
|
|
|
|
|
MoldTemperatureList.Add(temp8);
|
|
|
|
|
MoldTemperatureList.Add(temp9);
|
|
|
|
|
MoldTemperatureList.Add(temp10);
|
|
|
|
|
MoldTemperatureList.Add(temp11);
|
|
|
|
|
MoldTemperatureList.Add(temp12);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"读取固化时间显示值,1#:{temp1};2#:{temp2};3#:{temp3};4#:{temp4};5#:{temp5};6#:{temp6}");
|
|
|
|
|
Console.WriteLine($"读取固化时间显示值,7#:{temp7};8#:{temp8};9#:{temp9};10#:{temp10};11#:{temp11};12#:{temp12}");
|
|
|
|
|
}
|
|
|
|
|