|
|
|
@ -18,8 +18,8 @@ namespace Aucma.Core.OldBoxFoam.Business
|
|
|
|
|
public HwPLc.PlcModel plc2 = null;
|
|
|
|
|
public HwPLc.PlcModel plc3 = null;
|
|
|
|
|
public HwPLc.PlcModel plc4 = null;
|
|
|
|
|
public static List<FixtureStatus> listFixtureStatus = new List<FixtureStatus>();
|
|
|
|
|
public static List<SpaceDetailModel> spaceDetailModel = new List<SpaceDetailModel>();
|
|
|
|
|
public List<FixtureStatus> listFixtureStatus = new List<FixtureStatus>();
|
|
|
|
|
public List<SpaceDetailModel> spaceDetailModel = new List<SpaceDetailModel>();
|
|
|
|
|
|
|
|
|
|
public List<int> BoxTypeList = new List<int>();
|
|
|
|
|
public List<int> HolderStatusList = new List<int>();
|
|
|
|
@ -31,87 +31,107 @@ namespace Aucma.Core.OldBoxFoam.Business
|
|
|
|
|
|
|
|
|
|
public Collection() {
|
|
|
|
|
|
|
|
|
|
startCollect();
|
|
|
|
|
}
|
|
|
|
|
public void startCollect()
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
///Task.Run(() =>
|
|
|
|
|
//{
|
|
|
|
|
plc1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
|
|
|
|
|
plc2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc2"));
|
|
|
|
|
plc3 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3"));
|
|
|
|
|
plc4 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc4"));
|
|
|
|
|
while (true)
|
|
|
|
|
//while (true)
|
|
|
|
|
//{
|
|
|
|
|
BoxTypeList.Clear();
|
|
|
|
|
HolderStatusList.Clear();
|
|
|
|
|
HolderOutPutList.Clear();
|
|
|
|
|
SolidifyTimeList.Clear();
|
|
|
|
|
listFixtureStatus.Clear();//夹具集合
|
|
|
|
|
spaceDetailModel.Clear();//货道集合
|
|
|
|
|
//夹具箱型
|
|
|
|
|
|
|
|
|
|
ReadBoxType(plc1, BoxTypeList);
|
|
|
|
|
ReadBoxType(plc2, BoxTypeList);
|
|
|
|
|
ReadBoxType(plc3, BoxTypeList);
|
|
|
|
|
ReadBoxType(plc4, BoxTypeList);
|
|
|
|
|
|
|
|
|
|
ReadHolderStatus(plc1, HolderStatusList);
|
|
|
|
|
ReadHolderStatus(plc2, HolderStatusList);
|
|
|
|
|
ReadHolderStatus(plc3, HolderStatusList);
|
|
|
|
|
ReadHolderStatus(plc4, HolderStatusList);
|
|
|
|
|
|
|
|
|
|
ReadHolderOutPut(plc1, HolderOutPutList);
|
|
|
|
|
ReadHolderOutPut(plc2, HolderOutPutList);
|
|
|
|
|
ReadHolderOutPut(plc3, HolderOutPutList);
|
|
|
|
|
ReadHolderOutPut(plc4, HolderOutPutList);
|
|
|
|
|
|
|
|
|
|
ReadSolidifyTime(plc1, SolidifyTimeList);
|
|
|
|
|
ReadSolidifyTime(plc2, SolidifyTimeList);
|
|
|
|
|
ReadSolidifyTime(plc3, SolidifyTimeList);
|
|
|
|
|
ReadSolidifyTime(plc4, SolidifyTimeList);
|
|
|
|
|
|
|
|
|
|
ReadStoreType(plc1, StoreTypeList);
|
|
|
|
|
ReadStoreType(plc2, StoreTypeList);
|
|
|
|
|
ReadStoreType(plc3, StoreTypeList);
|
|
|
|
|
ReadStoreType(plc4, StoreTypeList);
|
|
|
|
|
|
|
|
|
|
ReadStoreAmount(plc1, StoreAmountList);
|
|
|
|
|
ReadStoreAmount(plc2, StoreAmountList);
|
|
|
|
|
ReadStoreAmount(plc3, StoreAmountList);
|
|
|
|
|
ReadStoreAmount(plc4, StoreAmountList);
|
|
|
|
|
for (int i = 0; i < 24; i++)
|
|
|
|
|
{
|
|
|
|
|
BoxTypeList.Clear();
|
|
|
|
|
HolderStatusList.Clear();
|
|
|
|
|
HolderOutPutList.Clear();
|
|
|
|
|
SolidifyTimeList.Clear();
|
|
|
|
|
|
|
|
|
|
//夹具箱型
|
|
|
|
|
|
|
|
|
|
ReadBoxType(plc1, BoxTypeList);
|
|
|
|
|
ReadBoxType(plc2, BoxTypeList);
|
|
|
|
|
ReadBoxType(plc3, BoxTypeList);
|
|
|
|
|
ReadBoxType(plc4, BoxTypeList);
|
|
|
|
|
|
|
|
|
|
ReadHolderStatus(plc1, HolderStatusList);
|
|
|
|
|
ReadHolderStatus(plc2, HolderStatusList);
|
|
|
|
|
ReadHolderStatus(plc3, HolderStatusList);
|
|
|
|
|
ReadHolderStatus(plc4, HolderStatusList);
|
|
|
|
|
|
|
|
|
|
ReadHolderOutPut(plc1,HolderOutPutList);
|
|
|
|
|
ReadHolderOutPut(plc2,HolderOutPutList);
|
|
|
|
|
ReadHolderOutPut(plc3,HolderOutPutList);
|
|
|
|
|
ReadHolderOutPut(plc4,HolderOutPutList);
|
|
|
|
|
|
|
|
|
|
ReadSolidifyTime(plc1,SolidifyTimeList);
|
|
|
|
|
ReadSolidifyTime(plc2,SolidifyTimeList);
|
|
|
|
|
ReadSolidifyTime(plc3,SolidifyTimeList);
|
|
|
|
|
ReadSolidifyTime(plc4,SolidifyTimeList);
|
|
|
|
|
|
|
|
|
|
ReadStoreType(plc1, StoreTypeList);
|
|
|
|
|
ReadStoreType(plc2, StoreTypeList);
|
|
|
|
|
ReadStoreType(plc3, StoreTypeList);
|
|
|
|
|
ReadStoreType(plc4, StoreTypeList);
|
|
|
|
|
|
|
|
|
|
ReadStoreAmount(plc1, StoreAmountList);
|
|
|
|
|
ReadStoreAmount(plc2, StoreAmountList);
|
|
|
|
|
ReadStoreAmount(plc3, StoreAmountList);
|
|
|
|
|
ReadStoreAmount(plc4, StoreAmountList);
|
|
|
|
|
for(int i = 0; i < 24; i++)
|
|
|
|
|
if (listFixtureStatus.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
FixtureStatus model = new FixtureStatus();
|
|
|
|
|
model.ObjId = i + 1;
|
|
|
|
|
if (BoxTypeList.Count>0) model.FixtureBoxType = BoxTypeList[i].ToString();
|
|
|
|
|
if (BoxTypeList.Count > 0) model.FixtureBoxType = BoxTypeList[i].ToString();
|
|
|
|
|
if (HolderStatusList.Count > 0) model.Status = HolderStatusList[i];
|
|
|
|
|
if (HolderOutPutList.Count > 0) model.Yield = HolderOutPutList[i];
|
|
|
|
|
if (SolidifyTimeList.Count > 0) model.PlanCuringTime = SolidifyTimeList[i];
|
|
|
|
|
|
|
|
|
|
listFixtureStatus.Add(model);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SpaceDetailModel model = new SpaceDetailModel();
|
|
|
|
|
FixtureStatus model = new FixtureStatus();
|
|
|
|
|
model.ObjId = i + 1;
|
|
|
|
|
if (StoreTypeList.Count > 0) model.StoreType = StoreTypeList[i].ToString();
|
|
|
|
|
if (StoreAmountList.Count > 0) model.StoreAmount =Convert.ToInt32(StoreAmountList[i]);
|
|
|
|
|
spaceDetailModel.Add(model);
|
|
|
|
|
if (BoxTypeList.Count > 0) model.FixtureBoxType = BoxTypeList[i].ToString();
|
|
|
|
|
if (HolderStatusList.Count > 0) model.Status = HolderStatusList[i];
|
|
|
|
|
if (HolderOutPutList.Count > 0) model.Yield = HolderOutPutList[i];
|
|
|
|
|
if (SolidifyTimeList.Count > 0) model.PlanCuringTime = SolidifyTimeList[i];
|
|
|
|
|
|
|
|
|
|
listFixtureStatus.Add(model);
|
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(10000);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
|
{
|
|
|
|
|
SpaceDetailModel model = new SpaceDetailModel();
|
|
|
|
|
model.ObjId = i + 1;
|
|
|
|
|
if (StoreTypeList.Count > 0) model.StoreType = StoreTypeList[i].ToString();
|
|
|
|
|
if (StoreAmountList.Count > 0) model.StoreAmount = Convert.ToInt32(StoreAmountList[i]);
|
|
|
|
|
spaceDetailModel.Add(model);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// Thread.Sleep(10000);
|
|
|
|
|
//}
|
|
|
|
|
//});
|
|
|
|
|
}catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取夹具箱型
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadBoxType(HwPLc.PlcModel obj, List<int> BoxTypeList)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
byte[] result = obj.plc.Read("D3140", 48);
|
|
|
|
|
if (result == null) return;
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(4).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
@ -134,9 +154,8 @@ namespace Aucma.Core.OldBoxFoam.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadHolderStatus(PlcModel obj1, List<int> HolderStatusList)
|
|
|
|
|
{
|
|
|
|
|
if (obj1 == null) return;
|
|
|
|
|
if (obj1.plc.IsConnected == false) return;
|
|
|
|
|
byte[] result = obj1.plc.Read("YF0", 1);
|
|
|
|
|
if (result == null) return;
|
|
|
|
|
//输出二进制字符串,1#-3#手动、自动数据
|
|
|
|
|
string str1 = ByteArrayToBinary(array(result));
|
|
|
|
|
byte[] result2 = obj1.plc.Read("Y110", 1);
|
|
|
|
@ -242,9 +261,8 @@ namespace Aucma.Core.OldBoxFoam.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadHolderOutPut(PlcModel obj,List<int> HolderOutPutList)
|
|
|
|
|
{
|
|
|
|
|
if (obj==null) return;
|
|
|
|
|
if (obj.plc.IsConnected == false) return;
|
|
|
|
|
byte[] result = obj.plc.Read("D182", 24);
|
|
|
|
|
if (result == null) return;
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(2).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
@ -267,9 +285,8 @@ namespace Aucma.Core.OldBoxFoam.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadSolidifyTime(PlcModel obj,List<int> SolidifyTimeList)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected == false) return;
|
|
|
|
|
byte[] result = obj.plc.Read("D910", 24);
|
|
|
|
|
if (result == null) return;
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(2).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
@ -291,10 +308,9 @@ namespace Aucma.Core.OldBoxFoam.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadStoreType(PlcModel obj, List<string> storeType)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected == false) return;
|
|
|
|
|
//夹具箱型
|
|
|
|
|
byte[] result = obj.plc.Read("D2010", 40);
|
|
|
|
|
if (result == null) return;
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
int temp1 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(0).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
int temp2 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(20).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
@ -312,9 +328,8 @@ namespace Aucma.Core.OldBoxFoam.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
static void ReadStoreAmount(PlcModel obj, List<string> storeAmount)
|
|
|
|
|
{
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
if (obj.plc.IsConnected == false) return;
|
|
|
|
|
byte[] result = obj.plc.Read("L101", 1);
|
|
|
|
|
if (result == null) return;
|
|
|
|
|
string str1 = ByteArrayToBinary(array(result)).Substring(0, 3);
|
|
|
|
|
int item1 = Regex.Matches(str1, "1").Count;
|
|
|
|
|
|
|
|
|
|