liulb@mesnac.com 1 year ago
commit c896eaf245

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -12,6 +13,9 @@ namespace Aucma.Core.OldBoxFoam.Business
public class Collection public class Collection
{ {
public HwPLc.PlcModel plc1 = null; public HwPLc.PlcModel plc1 = null;
public HwPLc.PlcModel plc2 = null;
public HwPLc.PlcModel plc3 = null;
public HwPLc.PlcModel plc4 = null;
public Collection() { public Collection() {
startCollect(); startCollect();
@ -21,12 +25,43 @@ namespace Aucma.Core.OldBoxFoam.Business
Task.Run(() => Task.Run(() =>
{ {
Thread.Sleep(3000); Thread.Sleep(3000);
plc1 = HwPLc.PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1")); 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)
{ {
ReadBoxType(plc1); ReadBoxType(plc1);
ReadBoxType(plc2);
ReadBoxType(plc3);
ReadBoxType(plc4);
Thread.Sleep(1000); ReadHolderStatus(plc1);
ReadHolderStatus(plc2);
ReadHolderStatus(plc3);
ReadHolderStatus(plc4);
ReadHolderOutPut(plc1);
ReadHolderOutPut(plc2);
ReadHolderOutPut(plc3);
ReadHolderOutPut(plc4);
ReadSolidifyTime(plc1);
ReadSolidifyTime(plc2);
ReadSolidifyTime(plc3);
ReadSolidifyTime(plc4);
ReadStoreType(plc1);
ReadStoreType(plc2);
ReadStoreType(plc3);
ReadStoreType(plc4);
ReadStoreAmount(plc1);
ReadStoreAmount(plc2);
ReadStoreAmount(plc3);
ReadStoreAmount(plc4);
Thread.Sleep(100000);
} }
}); });
} }
@ -51,7 +86,7 @@ namespace Aucma.Core.OldBoxFoam.Business
/// <summary> /// <summary>
/// 读取夹具状态 /// 读取夹具状态
/// </summary> /// </summary>
static void ReadHolderStatus(PlcModel obj1, PlcModel obj2) static void ReadHolderStatus(PlcModel obj1)
{ {
byte[] result = obj1.plc.Read("YF0", 1); byte[] result = obj1.plc.Read("YF0", 1);
//输出二进制字符串,1#-3#手动、自动数据 //输出二进制字符串,1#-3#手动、自动数据
@ -103,7 +138,7 @@ namespace Aucma.Core.OldBoxFoam.Business
item3 = 3; item3 = 3;
} }
byte[] result3 = obj2.plc.Read("Y100", 1); byte[] result3 = obj1.plc.Read("Y100", 1);
string str3 = ByteArrayToBinary(array(result3)); string str3 = ByteArrayToBinary(array(result3));
int item4 = 0; int item4 = 0;
@ -197,7 +232,29 @@ namespace Aucma.Core.OldBoxFoam.Business
int temp4 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(60).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber); int temp4 = short.Parse(StringChange.bytesToHexStr(array(info.Skip(60).Take(2).ToArray()), 2), System.Globalization.NumberStyles.HexNumber);
Console.WriteLine($"读取泡前库箱型,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4}"); Console.WriteLine($"读取泡前库箱型,1#:{temp1};2#{temp2};3#:{temp3};4#:{temp4}");
} }
/// <summary>
/// 读取泡前库库存
/// </summary>
static void ReadStoreAmount(PlcModel obj)
{
byte[] result = obj.plc.Read("L101", 1);
string str1 = ByteArrayToBinary(array(result)).Substring(0, 3);
int item1 = Regex.Matches(str1, "1").Count;
byte[] result2 = obj.plc.Read("L201", 1);
string str2 = ByteArrayToBinary(array(result2)).Substring(0, 3);
int item2 = Regex.Matches(str2, "1").Count;
byte[] result3 = obj.plc.Read("L301", 1);
string str3 = ByteArrayToBinary(array(result3)).Substring(0, 3);
int item3 = Regex.Matches(str3, "1").Count;
byte[] result4 = obj.plc.Read("L401", 1);
string str4 = ByteArrayToBinary(array(result4)).Substring(0, 3);
int item4 = Regex.Matches(str4, "1").Count;
Console.WriteLine($"读取泡前库库存,1#:{item1};2#{item2};3#:{item3};4#:{item4}");
}
/// <param name="data"></param> /// <param name="data"></param>
@ -227,10 +284,10 @@ namespace Aucma.Core.OldBoxFoam.Business
binaryString.Append(Convert.ToString(b, 2).PadLeft(8, '0')); binaryString.Append(Convert.ToString(b, 2).PadLeft(8, '0'));
} }
Console.WriteLine(binaryString); // Console.WriteLine(binaryString);
string reversedStr = new string(binaryString.ToString().Reverse().ToArray()); string reversedStr = new string(binaryString.ToString().Reverse().ToArray());
Console.WriteLine(reversedStr); // Console.WriteLine(reversedStr);
return reversedStr; return reversedStr;
} }

@ -0,0 +1,54 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.OldBoxFoam.Models
{
/// <summary>
/// plc夹具状态
/// </summary>
public class FixtureStatus
{
/// <summary>
/// 夹具箱型
/// </summary>
public string FixtureBoxType { get; set; }
/// <summary>
/// 夹具状态
/// </summary>
public string Status { get; set; }
/// <summary>
/// 夹具产量
/// </summary>
public string Yield { get; set; }
/// <summary>
/// 固化时间设定值
/// </summary>
public string PlanCuringTime { get; set; }
/// <summary>
/// 固化时间实际值
/// </summary>
public string RealCuringTime { get; set; }
///// <summary>
///// 生产节拍
///// </summary>
public string ProductionCycle { get; set; }
/// <summary>
/// 泡前库箱型
/// </summary>
public string BeforeBoxType { get; set; }
/// <summary>
/// 泡前库库存数
/// </summary>
public string Inventory { get; set; }
}
}

@ -214,12 +214,16 @@
}, },
{ {
"Id": 3, "Id": 3,
"PlcType": "Melsec",
"Enabled": true,
"EquipName": "OldMelsecPlc3", "EquipName": "OldMelsecPlc3",
"IP": "10.10.93.153", "IP": "10.10.93.153",
"Port": 5002 "Port": 5002
}, },
{ {
"Id": 4, "Id": 4,
"PlcType": "Melsec",
"Enabled": true,
"EquipName": "OldMelsecPlc4", "EquipName": "OldMelsecPlc4",
"IP": "10.10.93.154", "IP": "10.10.93.154",
"Port": 5002 "Port": 5002

Loading…
Cancel
Save