|
|
@ -1,287 +0,0 @@
|
|
|
|
using Admin.Core.Common.Helper;
|
|
|
|
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
|
|
|
|
using NetTaste;
|
|
|
|
|
|
|
|
using NPOI.Util;
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.BoxFoam.Business
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 采集发泡机数据
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public class CollectionFoamMachine
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
private static System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
|
|
|
|
|
|
|
|
public CollectionFoamMachine()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async 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
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 读取夹具箱型
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
static void ReadBoxType(HwPLc.PlcModel obj)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 读取夹具状态
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
static void ReadFixtureStatus(HwPLc.PlcModel obj)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.122", 23);
|
|
|
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
|
|
|
int temp1 = judgeStatus(ByteArrayToBinary(info.Skip(0).Take(1).ToArray()));
|
|
|
|
|
|
|
|
int temp2 = judgeStatus(ByteArrayToBinary(info.Skip(2).Take(1).ToArray()));
|
|
|
|
|
|
|
|
int temp3 = judgeStatus(ByteArrayToBinary(info.Skip(4).Take(1).ToArray()));
|
|
|
|
|
|
|
|
int temp4 = judgeStatus(ByteArrayToBinary(info.Skip(6).Take(1).ToArray()));
|
|
|
|
|
|
|
|
int temp5 = judgeStatus(ByteArrayToBinary(info.Skip(8).Take(1).ToArray()));
|
|
|
|
|
|
|
|
int temp6 = judgeStatus(ByteArrayToBinary(info.Skip(10).Take(1).ToArray()));
|
|
|
|
|
|
|
|
int temp7 = judgeStatus(ByteArrayToBinary(info.Skip(12).Take(1).ToArray()));
|
|
|
|
|
|
|
|
int temp8 = judgeStatus(ByteArrayToBinary(info.Skip(14).Take(1).ToArray()));
|
|
|
|
|
|
|
|
int temp9 = judgeStatus(ByteArrayToBinary(info.Skip(16).Take(1).ToArray()));
|
|
|
|
|
|
|
|
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()));
|
|
|
|
|
|
|
|
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}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 读取夹具产量
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
static void ReadFixtureProduction(HwPLc.PlcModel obj)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.146", 48);
|
|
|
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
|
|
|
int temp1 = int.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp2 = int.Parse(StringChange.bytesToHexStr(info.Skip(4).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp3 = int.Parse(StringChange.bytesToHexStr(info.Skip(8).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp4 = int.Parse(StringChange.bytesToHexStr(info.Skip(12).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp5 = int.Parse(StringChange.bytesToHexStr(info.Skip(16).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp6 = int.Parse(StringChange.bytesToHexStr(info.Skip(20).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp7 = int.Parse(StringChange.bytesToHexStr(info.Skip(24).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp8 = int.Parse(StringChange.bytesToHexStr(info.Skip(28).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp9 = int.Parse(StringChange.bytesToHexStr(info.Skip(32).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 固化时间设定值
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
static void ReadPlanCuringTime(HwPLc.PlcModel obj)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.194", 48);
|
|
|
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
|
|
|
int temp1 = int.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp2 = int.Parse(StringChange.bytesToHexStr(info.Skip(4).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp3 = int.Parse(StringChange.bytesToHexStr(info.Skip(8).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp4 = int.Parse(StringChange.bytesToHexStr(info.Skip(12).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp5 = int.Parse(StringChange.bytesToHexStr(info.Skip(16).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp6 = int.Parse(StringChange.bytesToHexStr(info.Skip(20).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp7 = int.Parse(StringChange.bytesToHexStr(info.Skip(24).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp8 = int.Parse(StringChange.bytesToHexStr(info.Skip(28).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp9 = int.Parse(StringChange.bytesToHexStr(info.Skip(32).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 固化时间显示值
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
static void ReadDisplayCuringTime(HwPLc.PlcModel obj)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.242", 48);
|
|
|
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
|
|
|
int temp1 = int.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp2 = int.Parse(StringChange.bytesToHexStr(info.Skip(4).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp3 = int.Parse(StringChange.bytesToHexStr(info.Skip(8).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp4 = int.Parse(StringChange.bytesToHexStr(info.Skip(12).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp5 = int.Parse(StringChange.bytesToHexStr(info.Skip(16).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp6 = int.Parse(StringChange.bytesToHexStr(info.Skip(20).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp7 = int.Parse(StringChange.bytesToHexStr(info.Skip(24).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp8 = int.Parse(StringChange.bytesToHexStr(info.Skip(28).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp9 = int.Parse(StringChange.bytesToHexStr(info.Skip(32).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 模具内外温度
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
static void ReadMoldTemperature(HwPLc.PlcModel obj)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (obj == null) return;
|
|
|
|
|
|
|
|
if (obj.plc.IsConnected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.294", 96);
|
|
|
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// float temp1 = BitConverter.ToSingle(BitConverter.GetBytes(Convert.ToInt32(StringChange.bytesToHexStr(info.Skip(0).Take(4).ToArray(), 16)), 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (BitConverter.IsLittleEndian)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// Array.Reverse(info.Skip(0).Take(4).ToArray()); // 如果系统是小端字节序,则反转字节数组的顺序
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float temp1 = float.Parse(StringChange.bytesToHexStr(info.Skip(0).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp2 = int.Parse(StringChange.bytesToHexStr(info.Skip(4).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp3 = int.Parse(StringChange.bytesToHexStr(info.Skip(8).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp4 = int.Parse(StringChange.bytesToHexStr(info.Skip(12).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp5 = int.Parse(StringChange.bytesToHexStr(info.Skip(16).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp6 = int.Parse(StringChange.bytesToHexStr(info.Skip(20).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp7 = int.Parse(StringChange.bytesToHexStr(info.Skip(24).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp8 = int.Parse(StringChange.bytesToHexStr(info.Skip(28).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
int temp9 = int.Parse(StringChange.bytesToHexStr(info.Skip(32).Take(4).ToArray(), 4), System.Globalization.NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 发泡线状态
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
static void ReadLineStatus(HwPLc.PlcModel obj)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byte[] result = obj.plc.Read("DB8.630", 1);
|
|
|
|
|
|
|
|
byte[] info = result;
|
|
|
|
|
|
|
|
int temp1 = judgeStatus(ByteArrayToBinary(info.Skip(0).Take(1).ToArray()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"发泡线状态:{temp1}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 字符工具转换方法
|
|
|
|
|
|
|
|
/// byte[]转十进制ascii码
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="bytes"></param>
|
|
|
|
|
|
|
|
static string ByteArrayToString(byte[] bytes)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string result = string.Empty;
|
|
|
|
|
|
|
|
foreach (byte b in bytes)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int decimalValue = Convert.ToInt32(b); // 将字节转换为十进制值
|
|
|
|
|
|
|
|
result += decimalValue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// byte[]转二进制
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="bytes"></param>
|
|
|
|
|
|
|
|
static string ByteArrayToBinary(byte[] bytes)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
StringBuilder binaryString = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (byte b in bytes)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
binaryString.Append(Convert.ToString(b, 2).PadLeft(8, '0'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Console.WriteLine(binaryString);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string reversedStr = new string(binaryString.ToString().Reverse().ToArray());
|
|
|
|
|
|
|
|
// Console.WriteLine(reversedStr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reversedStr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 根据二进制字符串确定夹具状态 1正常生产 2暂停生产
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
static int judgeStatus(string str1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int item1 = 0;
|
|
|
|
|
|
|
|
if (str1.Substring(0, 1) == "1")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item1 = 1; //
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (str1.Substring(1, 1) == "1")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item1 = 2; //
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return item1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|