2634 lines
155 KiB
C#
2634 lines
155 KiB
C#
|
||||
|
|
using JinYuan.Helper;
|
|||
|
|
using JinYuan.MES.Enums;
|
|||
|
|
using JinYuan.Models;
|
|||
|
|
using JinYuan.VirtualDataLibrary;
|
|||
|
|
using Language;
|
|||
|
|
using PLCCommunication;
|
|||
|
|
using PLCCommunication.Common;
|
|||
|
|
using PLCCommunication.Common.DataConvert;
|
|||
|
|
using SqlSugar;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Diagnostics;
|
|||
|
|
using System.Diagnostics.Eventing.Reader;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Runtime.InteropServices.ComTypes;
|
|||
|
|
using System.Runtime.Remoting.Messaging;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Text.RegularExpressions;
|
|||
|
|
using System.Threading;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|||
|
|
|
|||
|
|
namespace JinYuan.ControlCenters
|
|||
|
|
{
|
|||
|
|
public partial class ControlCenter
|
|||
|
|
{
|
|||
|
|
public object FileLock = new object();//文件锁
|
|||
|
|
|
|||
|
|
#region 上料工位(数据处理)
|
|||
|
|
/// <summary>
|
|||
|
|
/// 上料工位A
|
|||
|
|
/// </summary>
|
|||
|
|
//int JXCount = 0;
|
|||
|
|
//上料解析
|
|||
|
|
private async Task FeedingStationA(JYResult<byte[]> bArrays, object plcModel)
|
|||
|
|
{
|
|||
|
|
PlcGroup pf = plcModel as PlcGroup;
|
|||
|
|
var swTotal = new Stopwatch();
|
|||
|
|
var swSegment = new Stopwatch();
|
|||
|
|
|
|||
|
|
if (bArrays.IsSuccess && bArrays.Content != null)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
swTotal.Start();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】开始处理, 时间={DateTime.Now:HH:mm:ss.fff}", "A进站性能");
|
|||
|
|
|
|||
|
|
#region 数据初始化
|
|||
|
|
swSegment.Start();
|
|||
|
|
//解析数据
|
|||
|
|
List<AGearEntity> list = new List<AGearEntity>();//实体
|
|||
|
|
List<short> listRes = GetList<short>(4, 2);//默认为1,良品
|
|||
|
|
List<bool> listMark = GetList<bool>(4, false);//有料标志
|
|||
|
|
List<string> listCode = GetList<string>(4, "");//电芯码
|
|||
|
|
List<string> listRemark = GetList<string>(4, "");//备注
|
|||
|
|
List<string> listFlag = GetList<string>(4, "0");//是否上传标志
|
|||
|
|
List<string> listResult = GetList<string>(4, "OK");//结果
|
|||
|
|
List<string> listMesage = GetList<string>(4, "");//mesMesage
|
|||
|
|
List<MesResType> listMesResType = GetList<MesResType>(4, MesResType.B);//mesType
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】数据初始化耗时: {swSegment.ElapsedMilliseconds}ms", "A进站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
// 从D2021开始
|
|||
|
|
#region 数据解析
|
|||
|
|
swSegment.Restart();
|
|||
|
|
byte[] bytes = bArrays.Content.ByteReverse();//高低位转换
|
|||
|
|
|
|||
|
|
//有料标志
|
|||
|
|
for (int i = 0; i < listMark.Count; i++)
|
|||
|
|
{
|
|||
|
|
listMark[i] = ShortLib.GetShortFromByteArray(bArrays.Content, (i * 2)) == 1 ? true : false;// 从D2021开始
|
|||
|
|
if (listMark[i])
|
|||
|
|
{
|
|||
|
|
#region 数据读取
|
|||
|
|
//条码长度
|
|||
|
|
int codeLength = ShortLib.GetShortFromByteArray(bArrays.Content, (i * 2) + (20 * 2));// 从D2041开始
|
|||
|
|
if (codeLength > 0)
|
|||
|
|
{
|
|||
|
|
//条码
|
|||
|
|
listCode[i] = StringLib.GetStringFromByteArrayByEncoding(bytes, (i * 50) + (79 * 2), codeLength, System.Text.Encoding.ASCII).// 从D2100开始
|
|||
|
|
Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
listCode[i] = "ERROR";
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据保存
|
|||
|
|
AGearEntity m = new AGearEntity();
|
|||
|
|
m.BarCode = listCode[i];
|
|||
|
|
m.ChannelNo = (i + 1).ToString();
|
|||
|
|
m.TestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|||
|
|
list.Add(m);
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, "进站上料工位A有料标志为0".Translated() + "通道号".Translated() + $":{i}");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】数据解析耗时: {swSegment.ElapsedMilliseconds}ms, 解析条数: {list.Count}", "A进站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 上传MES
|
|||
|
|
if (list.Count > 0 && CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
swSegment.Restart();
|
|||
|
|
var allMesMessages = new List<string>();
|
|||
|
|
var allMesResTypes = new List<MesResType>();
|
|||
|
|
var allFlags = new List<string>();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < list.Count; i++)
|
|||
|
|
{
|
|||
|
|
var swSegment1 = new Stopwatch();
|
|||
|
|
swSegment1.Start();
|
|||
|
|
// 每次只上传一个条码(封装为List)
|
|||
|
|
var singleCodeList = new List<string> { list[i].BarCode };
|
|||
|
|
var (success1, mesage1, mesResType1) = await CommonMethods.hbgMes.ManyCellInStationAsync(
|
|||
|
|
CommonMethods.mesConfig.ProductInStation,
|
|||
|
|
CommonMethods.mesConfig.siteCode,
|
|||
|
|
CommonMethods.mesConfig.lineCode,
|
|||
|
|
CommonMethods.mesConfig.equipNum,
|
|||
|
|
CommonMethods.mesConfig.MaterialCode,
|
|||
|
|
CommonMethods.mesConfig.mesUserName,
|
|||
|
|
singleCodeList);
|
|||
|
|
|
|||
|
|
if (success1)
|
|||
|
|
{
|
|||
|
|
// 收集结果而不是覆盖
|
|||
|
|
allMesMessages.AddRange(mesage1);
|
|||
|
|
allMesResTypes.AddRange(mesResType1);
|
|||
|
|
allFlags.Add("1");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// 收集失败结果
|
|||
|
|
allMesMessages.AddRange(mesage1);
|
|||
|
|
allMesResTypes.AddRange(mesResType1);
|
|||
|
|
allFlags.Add("2");
|
|||
|
|
// 记录失败状态
|
|||
|
|
listRes[i] = 3;
|
|||
|
|
listRemark[i] = "";
|
|||
|
|
if (mesage1.Count > 0 && mesage1[0].Contains("一个或多个错误"))
|
|||
|
|
{
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue("D80", 1, PLC.DataType.Short);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
swSegment1.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】单条{i}上传mes耗时: {swSegment1.ElapsedMilliseconds}ms", "A进站性能");
|
|||
|
|
}
|
|||
|
|
// 将收集的结果赋给主列表
|
|||
|
|
listMesage = allMesMessages;
|
|||
|
|
listMesResType = allMesResTypes;
|
|||
|
|
listFlag = allFlags;
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】MES上传总耗时: {swSegment.ElapsedMilliseconds}ms, 上传条数: {list.Count}", "A进站性能");
|
|||
|
|
}
|
|||
|
|
else if (list.Count > 0 && (!CommonMethods.sysConfig.MesModeSwitching || !CommonMethods.mesConfig.isConnected))
|
|||
|
|
{
|
|||
|
|
swSegment.Restart();
|
|||
|
|
listRes = GetList<short>(4, 3);
|
|||
|
|
listRemark = GetList<string>(4, "MES未连接".Translated());
|
|||
|
|
listFlag = GetList<string>(4, "2");
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue("D80", 1, PLC.DataType.Short);
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】MES未连接处理耗时: {swSegment.ElapsedMilliseconds}ms", "A进站性能");
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据组合
|
|||
|
|
swSegment.Restart();
|
|||
|
|
for (int i = 0; i < list.Count; i++)
|
|||
|
|
{
|
|||
|
|
if (String.IsNullOrEmpty(list[i].BarCode) || list[i].BarCode.Trim() == "ERROR" || !IsAlphaNumeric(list[i].BarCode))
|
|||
|
|
{
|
|||
|
|
listRes[i] = 2;
|
|||
|
|
listResult[i] = "NG";
|
|||
|
|
listRemark[i] = "电芯码不良".Translated();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
int codeIndex = i;
|
|||
|
|
listResult[i] = "OK,";
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching)
|
|||
|
|
{
|
|||
|
|
switch (listMesResType[codeIndex])
|
|||
|
|
{
|
|||
|
|
case MesResType.A:// 停线,设备报警停机
|
|||
|
|
listResult[i] += "MES NG";
|
|||
|
|
listRemark[i] += listMesage[codeIndex];
|
|||
|
|
listRes[i] = 3;//10
|
|||
|
|
break;
|
|||
|
|
case MesResType.B:// 排出
|
|||
|
|
listResult[i] += "MES NG";
|
|||
|
|
listRemark[i] += listMesage[codeIndex];
|
|||
|
|
listRes[i] = 3;//2
|
|||
|
|
break;
|
|||
|
|
case MesResType.C:// 警示
|
|||
|
|
case MesResType.D:// 条码上传OK
|
|||
|
|
listResult[i] += "MES OK";//MES认为是可以当成良品流下去的
|
|||
|
|
listRemark[i] += listMesage[codeIndex];
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
listResult[i] += "MES NG";
|
|||
|
|
listRemark[i] += listMesage[codeIndex];
|
|||
|
|
listRes[i] = 3;//2
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
list[i].Result = listResult[i].TrimStart(',').TrimEnd(',');
|
|||
|
|
list[i].Remark = listRemark[i].TrimStart(',').TrimEnd(',');
|
|||
|
|
list[i].Flag = listFlag[i];
|
|||
|
|
}
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】数据组合耗时: {swSegment.ElapsedMilliseconds}ms, 组合条数: {list.Count}", "A进站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
//读取结果显示
|
|||
|
|
//数据存储 -异步处理
|
|||
|
|
#region 数据反馈&保存
|
|||
|
|
|
|||
|
|
swSegment.Restart();
|
|||
|
|
_ = Task.Run(async ()=>
|
|||
|
|
{
|
|||
|
|
try { await SaveFeedingDataAsync(list); }
|
|||
|
|
catch(Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"【进站A】SaveFeedingDataAsync: {ex.Message}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】数据存储耗时: {swSegment.ElapsedMilliseconds}ms, 存储条数: {list.Count}", "A进站性能");
|
|||
|
|
|
|||
|
|
swSegment.Restart();
|
|||
|
|
//写入结果反馈
|
|||
|
|
JYResult result = CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue(pf.VarList[1].VarAddress, listRes.ToArray(), PLC.DataType.ArrShort);
|
|||
|
|
if (result != null)
|
|||
|
|
{
|
|||
|
|
string strres = "进站A工位发送给PLC".Translated() + $",[{pf.VarList[1].VarAddress}]:{string.Join(",", listRes)}";
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, strres);
|
|||
|
|
LogHelper.Instance.WriteError($"【进站A】工位发送给PLC:{strres}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】 反馈PLC,耗时{swSegment.ElapsedMilliseconds}ms, 结果:{string.Join(",", listRes)}", "A进站性能");
|
|||
|
|
swSegment.Restart();
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, 0);
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】PLC 清0耗时: {swSegment.ElapsedMilliseconds}ms", "A进站性能");
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"电芯进站A线程数据处理:{ex}", "SysErrorLog");
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, 0);
|
|||
|
|
}
|
|||
|
|
swTotal.Stop();
|
|||
|
|
long cost = swTotal.ElapsedMilliseconds;
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站A】总耗时: {cost}ms", "A进站性能");
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, "卷芯进站A共耗时".Translated() + $":{cost}ms");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"【进站A】 数据无效", "SysErrorLog");
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 上料工位B
|
|||
|
|
/// </summary>
|
|||
|
|
//上料解析
|
|||
|
|
private async Task FeedingStationB(JYResult<byte[]> bArrays, object plcModel)
|
|||
|
|
{
|
|||
|
|
PlcGroup pf = plcModel as PlcGroup;
|
|||
|
|
var swTotal = new Stopwatch();
|
|||
|
|
var swSegment = new Stopwatch();
|
|||
|
|
|
|||
|
|
if (bArrays.IsSuccess && bArrays.Content != null)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
swTotal.Start();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】开始处理, 时间={DateTime.Now:HH:mm:ss.fff}", "B进站性能");
|
|||
|
|
|
|||
|
|
#region 数据初始化
|
|||
|
|
swSegment.Start();
|
|||
|
|
//解析数据
|
|||
|
|
List<AGearEntity> list = new List<AGearEntity>();//实体
|
|||
|
|
List<short> listRes = GetList<short>(4, 2);//默认为1,良品
|
|||
|
|
List<bool> listMark = GetList<bool>(4, false);//有料标志
|
|||
|
|
List<string> listCode = GetList<string>(4, "");//电芯码
|
|||
|
|
List<string> listRemark = GetList<string>(4, "");//备注
|
|||
|
|
List<string> listFlag = GetList<string>(4, "0");//是否上传标志
|
|||
|
|
List<string> listResult = GetList<string>(4, "OK");//结果
|
|||
|
|
List<string> listMesage = GetList<string>(4, "");//mesMesage
|
|||
|
|
List<MesResType> listMesResType = GetList<MesResType>(4, MesResType.B);//mesType
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】数据初始化耗时: {swSegment.ElapsedMilliseconds}ms", "B进站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
// 从D3021开始
|
|||
|
|
#region 数据解析
|
|||
|
|
swSegment.Restart();
|
|||
|
|
byte[] bytes = bArrays.Content.ByteReverse();//高低位转换
|
|||
|
|
|
|||
|
|
//有料标志
|
|||
|
|
for (int i = 0; i < listMark.Count; i++)
|
|||
|
|
{
|
|||
|
|
listMark[i] = ShortLib.GetShortFromByteArray(bArrays.Content, (i * 2)) == 1 ? true : false;// 从D3021开始
|
|||
|
|
if (listMark[i])
|
|||
|
|
{
|
|||
|
|
#region 数据读取
|
|||
|
|
//条码长度
|
|||
|
|
int codeLength = ShortLib.GetShortFromByteArray(bArrays.Content, (i * 2) + (20 * 2));// 从D3041开始
|
|||
|
|
if (codeLength > 0)
|
|||
|
|
{
|
|||
|
|
//条码
|
|||
|
|
listCode[i] = StringLib.GetStringFromByteArrayByEncoding(bytes, (i * 50) + (79 * 2), codeLength, System.Text.Encoding.ASCII).// 从D3100开始
|
|||
|
|
Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
listCode[i] = "ERROR";
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据保存
|
|||
|
|
AGearEntity m = new AGearEntity();
|
|||
|
|
m.BarCode = listCode[i];
|
|||
|
|
m.ChannelNo = (i + 1).ToString();
|
|||
|
|
m.TestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|||
|
|
|
|||
|
|
list.Add(m);
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, "进站上料工位B有料标志为0".Translated() + "通道号".Translated() + $":{i}");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】数据解析耗时: {swSegment.ElapsedMilliseconds}ms, 解析条数: {list.Count}", "B进站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 上传MES
|
|||
|
|
if (list.Count > 0 && CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
swSegment.Restart();
|
|||
|
|
|
|||
|
|
// 创建临时列表收集所有结果
|
|||
|
|
var allMesMessages = new List<string>();
|
|||
|
|
var allMesResTypes = new List<MesResType>();
|
|||
|
|
var allFlags = new List<string>();
|
|||
|
|
//foreach (var item in list)
|
|||
|
|
for (int i = 0; i < list.Count; i++)
|
|||
|
|
{
|
|||
|
|
var swSegment1 = new Stopwatch();
|
|||
|
|
swSegment1.Start();
|
|||
|
|
// 每次只上传一个条码(封装为List)
|
|||
|
|
var singleCodeList = new List<string> { list[i].BarCode };
|
|||
|
|
|
|||
|
|
var (success1, mesage1, mesResType1) = await CommonMethods.hbgMes.ManyCellInStationAsync(
|
|||
|
|
CommonMethods.mesConfig.ProductInStation,
|
|||
|
|
CommonMethods.mesConfig.siteCode,
|
|||
|
|
CommonMethods.mesConfig.lineCode,
|
|||
|
|
CommonMethods.mesConfig.equipNum,
|
|||
|
|
CommonMethods.mesConfig.MaterialCode,
|
|||
|
|
CommonMethods.mesConfig.mesUserName,
|
|||
|
|
singleCodeList); // 单条码列表
|
|||
|
|
if (success1)
|
|||
|
|
{
|
|||
|
|
// 收集结果而不是覆盖
|
|||
|
|
allMesMessages.AddRange(mesage1);
|
|||
|
|
allMesResTypes.AddRange(mesResType1);
|
|||
|
|
allFlags.Add("1");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// 收集失败结果
|
|||
|
|
allMesMessages.AddRange(mesage1);
|
|||
|
|
allMesResTypes.AddRange(mesResType1);
|
|||
|
|
allFlags.Add("2");
|
|||
|
|
|
|||
|
|
// 记录失败状态
|
|||
|
|
listRes[i] = 3;
|
|||
|
|
listRemark[i] = "";
|
|||
|
|
if (mesage1.Count > 0 && mesage1[0].Contains("一个或多个错误"))
|
|||
|
|
{
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue("D80", 1, PLC.DataType.Short); // 反馈PLC结果
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
swSegment1.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】MES上传{i}单条耗时: {swSegment1.ElapsedMilliseconds}ms", "B进站性能");
|
|||
|
|
}
|
|||
|
|
// 将收集的结果赋给主列表
|
|||
|
|
listMesage = allMesMessages;
|
|||
|
|
listMesResType = allMesResTypes;
|
|||
|
|
listFlag = allFlags;
|
|||
|
|
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】MES上传总耗时: {swSegment.ElapsedMilliseconds}ms, 上传条数: {list.Count}", "B进站性能");
|
|||
|
|
}
|
|||
|
|
else if (list.Count > 0 && (!CommonMethods.sysConfig.MesModeSwitching || !CommonMethods.mesConfig.isConnected))
|
|||
|
|
{
|
|||
|
|
swSegment.Restart();
|
|||
|
|
listRes = GetList<short>(4, 3);
|
|||
|
|
listRemark = GetList<string>(4, "MES断连".Translated());
|
|||
|
|
listFlag = GetList<string>(4, "2");
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue("D80", 1, PLC.DataType.Short);
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】MES未连接处理耗时: {swSegment.ElapsedMilliseconds}ms", "B进站性能");
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据组合
|
|||
|
|
swSegment.Restart();
|
|||
|
|
for (int i = 0; i < list.Count; i++)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(list[i].BarCode) || list[i].BarCode.Trim() == "ERROR" || !IsAlphaNumeric(list[i].BarCode))
|
|||
|
|
{
|
|||
|
|
listRes[i] = 2;
|
|||
|
|
listResult[i] = "NG";
|
|||
|
|
listRemark[i] = "电芯码不良".Translated();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
int codeIndex = i;
|
|||
|
|
listResult[i] = "OK,";
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching)
|
|||
|
|
{
|
|||
|
|
switch (listMesResType[codeIndex])
|
|||
|
|
{
|
|||
|
|
case MesResType.A:// 停线,设备报警停机
|
|||
|
|
listResult[i] += "MES NG";
|
|||
|
|
listRemark[i] += listMesage[codeIndex];
|
|||
|
|
listRes[i] = 3;
|
|||
|
|
break;
|
|||
|
|
case MesResType.B:// 排出
|
|||
|
|
listResult[i] += "MES NG";
|
|||
|
|
listRemark[i] += listMesage[codeIndex];
|
|||
|
|
listRes[i] = 3;
|
|||
|
|
break;
|
|||
|
|
case MesResType.C:// 警示
|
|||
|
|
case MesResType.D:// 条码上传OK
|
|||
|
|
listResult[i] += "MES OK";//MES认为是可以当成良品流下去的
|
|||
|
|
listRemark[i] += listMesage[codeIndex];
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
listResult[i] += "MES NG";
|
|||
|
|
listRemark[i] += listMesage[codeIndex];
|
|||
|
|
listRes[i] = 3;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
list[i].Result = listResult[i].TrimStart(',').TrimEnd(',');
|
|||
|
|
list[i].Remark = listRemark[i].TrimStart(',').TrimEnd(',');
|
|||
|
|
list[i].Flag = listFlag[i];
|
|||
|
|
}
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】数据组合耗时: {swSegment.ElapsedMilliseconds}ms, 组合条数: {list.Count}", "B进站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据反馈&保存
|
|||
|
|
|
|||
|
|
swSegment.Restart();
|
|||
|
|
_ = Task.Run(async () =>
|
|||
|
|
{
|
|||
|
|
try { await SaveFeedingDataAsync(list); }
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"【进站B】SaveFeedingDataAsync: {ex.Message}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】数据存储耗时: {swSegment.ElapsedMilliseconds}ms", "B进站性能");
|
|||
|
|
|
|||
|
|
|
|||
|
|
//写入·结果反馈
|
|||
|
|
JYResult result = CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue(pf.VarList[1].VarAddress, listRes.ToArray(), PLC.DataType.ArrShort);//判断结果写入PLC
|
|||
|
|
if (result != null)
|
|||
|
|
{
|
|||
|
|
string strres = "进站B工位发送给PLC".Translated() + $",[{pf.VarList[1].VarAddress}]:{string.Join(",", listRes)}";
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, strres);
|
|||
|
|
LogHelper.Instance.WriteError($"进站B工位发送给PLC:{strres}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
|||
|
|
|
|||
|
|
//读取结果显示
|
|||
|
|
//数据存储 -异步处理
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】反馈PLC+置0组合耗时: {swSegment.ElapsedMilliseconds}ms", "B进站性能");
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"电芯进站B线程数据处理:{ex}", "SysErrorLog");
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, 0);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
swTotal.Stop();
|
|||
|
|
long cost = swTotal.ElapsedMilliseconds;
|
|||
|
|
LogHelper.Instance.WriteLog($"【进站B】总耗时: {cost}ms", "B进站性能");
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, "卷芯进站B共耗时".Translated() + $":{cost}ms");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"【进站B】 数据无效", "SysErrorLog");
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region 保存上料数据
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存上料数据到数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="list"></param>
|
|||
|
|
private async Task SaveFeedingDataAsync(List<AGearEntity> list)
|
|||
|
|
{
|
|||
|
|
//数据的保存
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (list != null && list.Count > 0)
|
|||
|
|
{
|
|||
|
|
bool b = await CommonMethods.db.AddReturnBoolAsync<AGearEntity>(list);
|
|||
|
|
//数据显示
|
|||
|
|
CommonMethods.ShowFeedingDelegate.Invoke(list);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"卷芯上料保存处理异常:{ex}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 下料工位(数据处理)
|
|||
|
|
/// <summary>
|
|||
|
|
/// 电芯出站A
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="bArrays"></param>
|
|||
|
|
/// <param name="plcModel"></param>
|
|||
|
|
private async Task BlankingStationA(JYResult<byte[]> bArrays, object plcModel)
|
|||
|
|
{
|
|||
|
|
PlcGroup pf = plcModel as PlcGroup;
|
|||
|
|
var swTotal = new Stopwatch();
|
|||
|
|
var swSegment = new Stopwatch();
|
|||
|
|
string logName = "A出站";
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"[{logName}] 开始处理", logName);
|
|||
|
|
|
|||
|
|
if (bArrays.IsSuccess && bArrays.Content != null)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
swTotal.Start();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】开始处理, 时间={DateTime.Now:HH:mm:ss.fff}", "A出站性能");
|
|||
|
|
|
|||
|
|
#region 初始化数据
|
|||
|
|
swSegment.Restart();
|
|||
|
|
|
|||
|
|
List<BGearEntity> list = new List<BGearEntity>();
|
|||
|
|
List<short> listRes = GetList<short>(8, 2);//默认为1,良品
|
|||
|
|
List<bool> listMark = GetList<bool>(8, false);//有料标志
|
|||
|
|
List<string> listCode = GetList<string>(8, "");//电芯码
|
|||
|
|
List<string> listRemark = GetList<string>(8, "");//备注
|
|||
|
|
List<string> listFlag = GetList<string>(8, "0");//是否上传标志
|
|||
|
|
List<string> listResult = GetList<string>(8, "OK");//结果
|
|||
|
|
List<string> listMesMesage = GetList<string>(8, "");//mesMesage
|
|||
|
|
List<MesResType> listMesResType = GetList<MesResType>(8, MesResType.B);//mesType
|
|||
|
|
List<short> listFutou = GetList<short>(8, 0);//复投
|
|||
|
|
//ushort listRes = 1; // 默认为1,良品
|
|||
|
|
string lst_RFIDCodes = ""; // 托杯码
|
|||
|
|
string lst_BarCodes = ""; // 条码
|
|||
|
|
|
|||
|
|
string windSpeed = "";// 风速
|
|||
|
|
string ccdFaceTestDeviceNum1;// 端面检测设备号1
|
|||
|
|
string ccdFaceTestDeviceNum2;// 端面检测设备号2
|
|||
|
|
string ccdFaceTestDeviceNum3;// 端面检测设备号3
|
|||
|
|
string ccdFaceTestDeviceNum4;// 端面检测设备号4
|
|||
|
|
string ccdCylinderTestDeviceNum1;// 柱面检测设备号1
|
|||
|
|
string ccdCylinderTestDeviceNum2;// 柱面检测设备号2
|
|||
|
|
string ccdCylinderTestDeviceNum3;// 柱面检测设备号3
|
|||
|
|
|
|||
|
|
int ccdNegativeTerminalWeldingZone2DInspectionResult = 0; //负极焊接区2D检测结果
|
|||
|
|
int ccdNegativeTerminalWeldingZone2DInspectionNGReasons = 0; //负极焊接区2D检测NG原因(脏污)
|
|||
|
|
int ccdNegativeTerminalWeldingZone2DInspectionNGReasons1 = 0; //负极焊接区2D检测NG原因(划伤)
|
|||
|
|
int ccdNegativeTerminalWeldingZone2DInspectionNGReasons2 = 0; //负极焊接区2D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
int ccdCoverPlate2DInspectionResult = 0; //盖板2D检测结果
|
|||
|
|
int ccdCoverPlate2DInspectionNGReasons = 0; //盖板2D检测NG原因(脏污)
|
|||
|
|
int ccdCoverPlate2DInspectionNGReasons1 = 0; //盖板2D检测NG原因(划伤)
|
|||
|
|
int ccdCoverPlate2DInspectionNGReasons2 = 0; //盖板2D检测NG原因(凹点)
|
|||
|
|
int ccdCoverPlate2DInspectionNGReasons3 = 0; //盖板2D检测NG原因(生锈)
|
|||
|
|
|
|||
|
|
int ccdNegativeTerminalWeldingZone25DInspectionResult = 0; //负极焊接区2.5D检测结果
|
|||
|
|
int ccdNegativeTerminalWeldingZone25DInspectionNGReasons = 0; //负极焊接区2.5D检测NG原因(脏污)
|
|||
|
|
int ccdNegativeTerminalWeldingZone25DInspectionNGReasons1 = 0; //负极焊接区2.5D检测NG原因(划伤)
|
|||
|
|
int ccdNegativeTerminalWeldingZone25DInspectionNGReasons2 = 0; //负极焊接区2.5D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdCoverPlate25DInspectionResult = 0; //盖板2.5D检测结果
|
|||
|
|
int ccdCoverPlate25DInspectionNGReasons = 0; //盖板2.5D检测NG原因(脏污)
|
|||
|
|
int ccdCoverPlate25DInspectionNGReasons1 = 0; //盖板2.5D检测NG原因(划伤)
|
|||
|
|
int ccdCoverPlate25DInspectionNGReasons2 = 0; //盖板2.5D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdTerminalPost2DInspectionResult = 0; //极柱2D检测结果
|
|||
|
|
int ccdTerminalPost2DInspectionNGReasons = 0; //极柱2D检测NG原因(脏污)
|
|||
|
|
int ccdTerminalPost2DInspectionNGReasons1 = 0; //极柱2D检测NG原因(划伤)
|
|||
|
|
int ccdTerminalPost2DInspectionNGReasons2 = 0; //极柱2D检测NG原因(凹点)
|
|||
|
|
int ccdTerminalPost2DInspectionNGReasons3 = 0; //极柱2D检测NG原因(残缺)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdTerminalPost3DInspectionResult = 0; //极柱3D检测结果
|
|||
|
|
int ccdTerminalPost3DInspectionNGReasons = 0; //极柱3D检测NG原因(脏污)
|
|||
|
|
int ccdTerminalPost3DInspectionNGReasons1 = 0; //极柱3D检测NG原因(划伤)
|
|||
|
|
int ccdTerminalPost3DInspectionNGReasons2 = 0; //极柱3D检测NG原因(凹点)
|
|||
|
|
int ccdTerminalPost3DInspectionNGReasons3 = 0; //极柱3D检测NG原因(残缺)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdSealingNail2DInspectionResult = 0; //密封钉2D检测结果
|
|||
|
|
int ccdSealingNail2DInspectionNGReasons = 0; //密封钉2D检测NG原因(铝钉焊接)
|
|||
|
|
|
|||
|
|
int ccdSealingNail3DInspectionResult = 0; //密封钉3D检测结果
|
|||
|
|
int ccdSealingNail3DInspectionNGReasons = 0; //密封钉3D检测NG原因(铝钉焊接)
|
|||
|
|
|
|||
|
|
int ccdTopFillet25DInspectionResult = 0; //上部R角2.5D检测结果
|
|||
|
|
int ccdTopFillet25DInspectionNGReasons = 0; //上部R角2.5D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
int ccdBottomFillet25DInspectionResult = 0; //底部R角2.5D检测结果
|
|||
|
|
int ccdBottomFillet25DInspectionNGReasons = 0; //底部R角2.5D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
int ccdCylindricalSurface25DInspectionResult = 0; //柱面2.5D检测结果
|
|||
|
|
int ccdCylindricalSurface25DInspectionNGReasons = 0; //柱面2.5D检测NG原因(生锈)
|
|||
|
|
int ccdCylindricalSurface25DInspectionNGReasons1 = 0; //柱面2.5D检测NG原因(划伤)
|
|||
|
|
int ccdCylindricalSurface25DInspectionNGReasons2 = 0; //柱面2.5D检测NG原因(凹点)
|
|||
|
|
int ccdCylindricalSurface25DInspectionNGReasons3 = 0; //柱面2.5D检测NG原因(模糊)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdCylindricalSurface3DInspectionResult = 0; //柱面3D检测结果
|
|||
|
|
int ccdCylindricalSurface3DInspectionNGReasons = 0; //柱面3D检测NG原因(生锈)
|
|||
|
|
int ccdCylindricalSurface3DInspectionNGReasons1 = 0; //柱面3D检测NG原因(划伤)
|
|||
|
|
int ccdCylindricalSurface3DInspectionNGReasons2 = 0; //柱面3D检测NG原因(凹点)
|
|||
|
|
int ccdCylindricalSurface3DInspectionNGReasons3 = 0; //柱面3D检测NG原因(模糊)
|
|||
|
|
|
|||
|
|
int ccdPositiveTerminaJYQ2DInspectionResult = 0; //正极绝缘圈2D检测结果
|
|||
|
|
int ccdPositiveTerminaJYQ2DInspectionNGReasons = 0; //正极绝缘圈2D检测NG原因(变形)
|
|||
|
|
|
|||
|
|
int ccdNegativeTerminaJYQ2DInspectionResult = 0; //负极绝缘圈2D检测结果
|
|||
|
|
int ccdNegativeTerminaJYQ2DInspectionNGReasons = 0; //负极绝缘圈2D检测NG原因(变形)
|
|||
|
|
|
|||
|
|
int[] ccdTestResult = new int[12];//ccd检测结果
|
|||
|
|
|
|||
|
|
string result = "";//总结果
|
|||
|
|
string info = "";//NG详情
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】数据初始化耗时: {swSegment.ElapsedMilliseconds}ms", "A出站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据解析
|
|||
|
|
swSegment.Restart();
|
|||
|
|
byte[] bytes = bArrays.Content.ByteReverse();
|
|||
|
|
|
|||
|
|
//有料标志
|
|||
|
|
for (int i = 0; i < listMark.Count; i++)
|
|||
|
|
{
|
|||
|
|
BGearEntity m2 = new BGearEntity();
|
|||
|
|
|
|||
|
|
listMark[i] = ShortLib.GetShortFromByteArray(bArrays.Content, (i * 2)) == 1 ? true : false;// 从D4021开始
|
|||
|
|
if (listMark[i])//无料标志只提示
|
|||
|
|
{
|
|||
|
|
#region 数据读取
|
|||
|
|
//条码长度
|
|||
|
|
int codeLength = ShortLib.GetShortFromByteArray(bArrays.Content, (i * 2) + (20 * 2));// 从D4041开始
|
|||
|
|
if (codeLength > 0)
|
|||
|
|
{
|
|||
|
|
//条码
|
|||
|
|
listCode[i] = StringLib.GetStringFromByteArrayByEncoding(bytes, (i * 50) + (79 * 2), codeLength, System.Text.Encoding.ASCII).// 从D4100开始
|
|||
|
|
Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
|||
|
|
LogHelper.Instance.WriteLog($"电芯出站A条码:{listCode[i]}", "A出站");
|
|||
|
|
}
|
|||
|
|
else { listCode[i] = "ERROR"; }
|
|||
|
|
|
|||
|
|
windSpeed = GetValueFromByteArray(bArrays.Content, "windSpeed", i * 4); // 风速 D4600 579
|
|||
|
|
ccdFaceTestDeviceNum1 = GetValueFromByteArray(bArrays.Content, "ccdFaceTestDeviceNum1", (i * 8) * 2); // 端面检测设备号1 D4616 595
|
|||
|
|
ccdFaceTestDeviceNum2 = GetValueFromByteArray(bArrays.Content, "ccdFaceTestDeviceNum2", (i * 8) * 2); // 端面检测设备号2 D4618 597
|
|||
|
|
ccdFaceTestDeviceNum3 = GetValueFromByteArray(bArrays.Content, "ccdFaceTestDeviceNum3", (i * 8) * 2); // 端面检测设备号3 D4620 599
|
|||
|
|
ccdFaceTestDeviceNum4 = GetValueFromByteArray(bArrays.Content, "ccdFaceTestDeviceNum4", (i * 8) * 2); // 端面检测设备号4 D4622 601
|
|||
|
|
|
|||
|
|
ccdCylinderTestDeviceNum1 = GetValueFromByteArray(bArrays.Content, "ccdCylinderTestDeviceNum1", (i * 8) * 2); // 柱面检测设备号1 D4680 659
|
|||
|
|
ccdCylinderTestDeviceNum2 = GetValueFromByteArray(bArrays.Content, "ccdCylinderTestDeviceNum2", (i * 8) * 2); // 柱面检测设备号2 D4682 661
|
|||
|
|
ccdCylinderTestDeviceNum3 = GetValueFromByteArray(bArrays.Content, "ccdCylinderTestDeviceNum3", (i * 8) * 2); // 柱面检测设备号3 D4684 663
|
|||
|
|
|
|||
|
|
ccdNegativeTerminalWeldingZone2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone2DInspectionResult", (i * 2))); // 负极焊接区2D检测结果
|
|||
|
|
ccdNegativeTerminalWeldingZone2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone2DInspectionNGReasons", (i * 2))); // 负极焊接区2D检测NG原因
|
|||
|
|
ccdNegativeTerminalWeldingZone2DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone2DInspectionNGReasons1", (i * 2))); // 负极焊接区2D检测NG原因
|
|||
|
|
ccdNegativeTerminalWeldingZone2DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone2DInspectionNGReasons2", (i * 2))); // 负极焊接区2D检测NG原因
|
|||
|
|
|
|||
|
|
ccdCoverPlate2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionResult", (i * 2))); // 盖板2D检测结果
|
|||
|
|
ccdCoverPlate2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionNGReasons", (i * 2))); // 盖板2D检测NG原因
|
|||
|
|
ccdCoverPlate2DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionNGReasons1", (i * 2))); // 盖板2D检测NG原因
|
|||
|
|
ccdCoverPlate2DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionNGReasons2", (i * 2))); // 盖板2D检测NG原因
|
|||
|
|
ccdCoverPlate2DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionNGReasons3", (i * 2))); // 盖板2D检测NG原因
|
|||
|
|
|
|||
|
|
ccdNegativeTerminalWeldingZone25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone25DInspectionResult", (i * 2))); // 负极焊接区2.5D检测结果
|
|||
|
|
ccdNegativeTerminalWeldingZone25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone25DInspectionNGReasons", (i * 2))); // 负极焊接区2.5D检测NG原因
|
|||
|
|
ccdNegativeTerminalWeldingZone25DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone25DInspectionNGReasons1", (i * 2))); // 负极焊接区2.5D检测NG原因
|
|||
|
|
ccdNegativeTerminalWeldingZone25DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone25DInspectionNGReasons2", (i * 2))); // 负极焊接区2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdCoverPlate25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate25DInspectionResult", (i * 2))); // 盖板2.5D检测结果
|
|||
|
|
ccdCoverPlate25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate25DInspectionNGReasons", (i * 2))); // 盖板2.5D检测NG原因
|
|||
|
|
ccdCoverPlate25DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate25DInspectionNGReasons1", (i * 2))); // 盖板2.5D检测NG原因
|
|||
|
|
ccdCoverPlate25DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate25DInspectionNGReasons2", (i * 2))); // 盖板2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdTerminalPost2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionResult", (i * 2))); // 极柱2D检测结果
|
|||
|
|
ccdTerminalPost2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionNGReasons", (i * 2))); // 极柱2D检测NG原因
|
|||
|
|
ccdTerminalPost2DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionNGReasons1", (i * 2))); // 极柱2D检测NG原因
|
|||
|
|
ccdTerminalPost2DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionNGReasons2", (i * 2))); // 极柱2D检测NG原因
|
|||
|
|
ccdTerminalPost2DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionNGReasons3", (i * 2))); // 极柱2D检测NG原因
|
|||
|
|
|
|||
|
|
ccdTerminalPost3DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionResult", (i * 2))); // 极柱3D检测结果
|
|||
|
|
ccdTerminalPost3DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionNGReasons", (i * 2))); // 极柱3D检测NG原因
|
|||
|
|
ccdTerminalPost3DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionNGReasons1", (i * 2))); // 极柱3D检测NG原因
|
|||
|
|
ccdTerminalPost3DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionNGReasons2", (i * 2))); // 极柱3D检测NG原因
|
|||
|
|
ccdTerminalPost3DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionNGReasons3", (i * 2))); // 极柱3D检测NG原因
|
|||
|
|
|
|||
|
|
ccdSealingNail2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdSealingNail2DInspectionResult", (i * 2))); // 密封钉2D检测结果
|
|||
|
|
ccdSealingNail2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdSealingNail2DInspectionNGReasons", (i * 2))); // 密封钉2D检测NG原因
|
|||
|
|
|
|||
|
|
ccdSealingNail3DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdSealingNail3DInspectionResult", (i * 2))); // 密封钉3D检测结果
|
|||
|
|
ccdSealingNail3DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdSealingNail3DInspectionNGReasons", (i * 2))); // 密封钉3D检测NG原因
|
|||
|
|
|
|||
|
|
ccdTopFillet25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTopFillet25DInspectionResult", (i * 2))); // 上部R角2.5D检测结果
|
|||
|
|
ccdTopFillet25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTopFillet25DInspectionNGReasons", (i * 2))); // 上部R角2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdBottomFillet25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdBottomFillet25DInspectionResult", (i * 2))); // 底部R角2.5D检测结果
|
|||
|
|
ccdBottomFillet25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdBottomFillet25DInspectionNGReasons", (i * 2))); // 底部R角2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdCylindricalSurface25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionResult", (i * 2))); // 柱面2.5D检测结果
|
|||
|
|
ccdCylindricalSurface25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionNGReasons", (i * 2))); // 柱面2.5D检测NG原因
|
|||
|
|
ccdCylindricalSurface25DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionNGReasons1", (i * 2))); // 柱面2.5D检测NG原因
|
|||
|
|
ccdCylindricalSurface25DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionNGReasons2", (i * 2))); // 柱面2.5D检测NG原因
|
|||
|
|
ccdCylindricalSurface25DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionNGReasons3", (i * 2))); // 柱面2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdCylindricalSurface3DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionResult", (i * 2))); // 柱面3D检测结果
|
|||
|
|
ccdCylindricalSurface3DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionNGReasons", (i * 2))); // 柱面3D检测NG原因
|
|||
|
|
ccdCylindricalSurface3DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionNGReasons1", (i * 2))); // 柱面3D检测NG原因
|
|||
|
|
ccdCylindricalSurface3DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionNGReasons2", (i * 2))); // 柱面3D检测NG原因
|
|||
|
|
ccdCylindricalSurface3DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionNGReasons3", (i * 2))); // 柱面3D检测NG原因
|
|||
|
|
|
|||
|
|
ccdPositiveTerminaJYQ2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdPositiveTerminaJYQ2DInspectionResult", (i * 2))); // 正极绝缘圈2D检测结果
|
|||
|
|
ccdPositiveTerminaJYQ2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdPositiveTerminaJYQ2DInspectionNGReasons", (i * 2))); // 正极绝缘圈2D检测NG原因(变形)
|
|||
|
|
ccdNegativeTerminaJYQ2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminaJYQ2DInspectionResult", (i * 2))); // 负极绝缘圈2D检测结果
|
|||
|
|
ccdNegativeTerminaJYQ2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminaJYQ2DInspectionNGReasons", (i * 2))); // 负极绝缘圈2D检测NG原因(变形)
|
|||
|
|
ccdTestResult[0] = ccdNegativeTerminalWeldingZone2DInspectionResult;//D4728 // 负极焊接区2D检测结果
|
|||
|
|
ccdTestResult[1] = ccdCoverPlate2DInspectionResult;//D4760 // 盖板2D检测结果
|
|||
|
|
ccdTestResult[2] = ccdNegativeTerminalWeldingZone25DInspectionResult;//D4808 // 负极焊接区2.5D检测结果
|
|||
|
|
ccdTestResult[3] = ccdCoverPlate25DInspectionResult;//D4840 // 盖板2.5D检测结果
|
|||
|
|
ccdTestResult[4] = ccdTerminalPost2DInspectionResult;//D4872 // 极柱2D检测结果
|
|||
|
|
ccdTestResult[5] = ccdTerminalPost3DInspectionResult;//D4912 // 极柱3D检测结果
|
|||
|
|
ccdTestResult[6] = ccdSealingNail2DInspectionResult;//D4952 // 密封钉2D检测结果
|
|||
|
|
ccdTestResult[7] = ccdSealingNail3DInspectionResult;//D4968 // 密封钉3D检测结果
|
|||
|
|
ccdTestResult[8] = ccdTopFillet25DInspectionResult;//D4984 // 上部R角2.5D检测结果
|
|||
|
|
ccdTestResult[9] = ccdBottomFillet25DInspectionResult;//D5000 // 底部R角2.5D检测结果
|
|||
|
|
ccdTestResult[10] = ccdCylindricalSurface25DInspectionResult;//D5016 // 柱面2.5D检测结果
|
|||
|
|
ccdTestResult[11] = ccdCylindricalSurface3DInspectionResult;//D5056 // 柱面3D检测结果
|
|||
|
|
|
|||
|
|
//string resultPLC = GetValueFromByteArray(bArrays.Content, "result", (i * 2));// 总结果 D4768 747
|
|||
|
|
result = int.Parse(GetValueFromByteArray(bArrays.Content, "result", (i * 2))) == 1 ? "OK" : "NG";
|
|||
|
|
//LogHelper.Instance.WriteError($"A出站总结果1:result:"+ result + ", resultPLC:" + resultPLC, "电芯出站A");
|
|||
|
|
|
|||
|
|
string strErr = "";
|
|||
|
|
short a = (short)GetResult(ccdTestResult, ref strErr);
|
|||
|
|
info = strErr;
|
|||
|
|
//result = a == 12 ? "OK" : "NG";
|
|||
|
|
LogHelper.Instance.WriteLog($"A出站总结果:result:" + result + ", info:" + info, "A出站");
|
|||
|
|
//info = GetValueFromByteArray(bArrays.Content, "info", (i * 2));// NG详情 D4776 755
|
|||
|
|
|
|||
|
|
lst_RFIDCodes = "";//StringLib.GetStringFromByteArrayByEncoding(bytes, 0, 39, Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim(); // RFID D3200-3219
|
|||
|
|
lst_BarCodes = listCode[i];
|
|||
|
|
|
|||
|
|
listFutou[i] = 0; // todo add 20260425
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据保存
|
|||
|
|
BGearEntity m = new BGearEntity
|
|||
|
|
{
|
|||
|
|
ChannelNo = (i + 1).ToString(),
|
|||
|
|
TestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|||
|
|
RFID = lst_RFIDCodes,
|
|||
|
|
BarCode = lst_BarCodes,
|
|||
|
|
WindSpeed = windSpeed,
|
|||
|
|
WindDeviceNum = "A",
|
|||
|
|
CCDFaceTestDeviceNum1 = "A",
|
|||
|
|
CCDFaceTestDeviceNum2 = "A",
|
|||
|
|
CCDFaceTestDeviceNum3 = "A",
|
|||
|
|
CCDFaceTestDeviceNum4 = "A",
|
|||
|
|
|
|||
|
|
CCDCylinderTestDeviceNum1 = "A",
|
|||
|
|
CCDCylinderTestDeviceNum2 = "A",
|
|||
|
|
CCDCylinderTestDeviceNum3 = "A",
|
|||
|
|
|
|||
|
|
CCDNegativeTerminalWeldingZone2DInspectionResult = ccdNegativeTerminalWeldingZone2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDNegativeTerminalWeldingZone2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdNegativeTerminalWeldingZone2DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdNegativeTerminalWeldingZone2DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdNegativeTerminalWeldingZone2DInspectionNGReasons2, "UI127")),
|
|||
|
|
CCDCoverPlate2DInspectionResult = ccdCoverPlate2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDCoverPlate2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCoverPlate2DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdCoverPlate2DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdCoverPlate2DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdCoverPlate2DInspectionNGReasons3, "UI298")),
|
|||
|
|
CCDNegativeTerminalWeldingZone25DInspectionResult = ccdNegativeTerminalWeldingZone25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDNegativeTerminalWeldingZone25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdNegativeTerminalWeldingZone25DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdNegativeTerminalWeldingZone25DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdNegativeTerminalWeldingZone25DInspectionNGReasons2, "UI127")),
|
|||
|
|
CCDCoverPlate25DInspectionResult = ccdCoverPlate25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDCoverPlate25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCoverPlate25DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdCoverPlate25DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdCoverPlate25DInspectionNGReasons2, "UI127")),
|
|||
|
|
CCDTerminalPost2DInspectionResult = ccdTerminalPost2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDTerminalPost2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCoverPlate25DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdTerminalPost2DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdTerminalPost2DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdTerminalPost2DInspectionNGReasons3, "UI125")),
|
|||
|
|
CCDTerminalPost3DInspectionResult = ccdTerminalPost3DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDTerminalPost3DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdTerminalPost3DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdTerminalPost3DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdTerminalPost3DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdTerminalPost3DInspectionNGReasons3, "UI125")),
|
|||
|
|
CCDSealingNail2DInspectionResult = ccdSealingNail2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDSealingNail2DInspectionNGReasons = "",
|
|||
|
|
|
|||
|
|
CCDSealingNail3DInspectionResult = ccdSealingNail3DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDSealingNail3DInspectionNGReasons = "",
|
|||
|
|
|
|||
|
|
CCDTopFillet25DInspectionResult = ccdTopFillet25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDTopFillet25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdTopFillet25DInspectionNGReasons, "UI127")),
|
|||
|
|
|
|||
|
|
CCDBottomFillet25DInspectionResult = ccdBottomFillet25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDBottomFillet25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdBottomFillet25DInspectionNGReasons, "UI127")),
|
|||
|
|
|
|||
|
|
CCDCylindricalSurface25DInspectionResult = ccdCylindricalSurface25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDCylindricalSurface25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCylindricalSurface25DInspectionNGReasons, "UI128"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface25DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface25DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface25DInspectionNGReasons3, "UI00404")),
|
|||
|
|
|
|||
|
|
CCDCylindricalSurface3DInspectionResult = ccdCylindricalSurface3DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDCylindricalSurface3DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCylindricalSurface3DInspectionNGReasons, "UI128"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface3DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface3DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface3DInspectionNGReasons3, "UI00404")),
|
|||
|
|
|
|||
|
|
CCDPositiveTerminaJYQ2DInspectionResult = ccdPositiveTerminaJYQ2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDPositiveTerminaJYQ2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdPositiveTerminaJYQ2DInspectionNGReasons, "UI15301")),
|
|||
|
|
|
|||
|
|
CCDNegativeTerminaJYQ2DInspectionResult = ccdNegativeTerminaJYQ2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDNegativeTerminaJYQ2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdNegativeTerminaJYQ2DInspectionNGReasons, "UI15302")),
|
|||
|
|
|
|||
|
|
Flag = "0",
|
|||
|
|
Flag1 = "2",
|
|||
|
|
Result = result,
|
|||
|
|
Info = info,
|
|||
|
|
MaterialCode = CommonMethods.mesConfig.MaterialCode,
|
|||
|
|
Futou = listFutou[i],
|
|||
|
|
};
|
|||
|
|
m2 = m;
|
|||
|
|
//list.Add(m);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, "出站下料工位A有料标志为0".Translated() + "通道号".Translated() + $":{i}");
|
|||
|
|
}
|
|||
|
|
list.Add(m2);
|
|||
|
|
}
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】数据解析耗时: {swSegment.ElapsedMilliseconds}ms, 解析条数: {list.Count}", "A出站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据上传MES
|
|||
|
|
if (list.Count > 0 && CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
swSegment.Restart();
|
|||
|
|
// 初始化结果收集列表
|
|||
|
|
var tempMesMessages = new List<string>();
|
|||
|
|
var tempMesResTypes = new List<MesResType>();
|
|||
|
|
var tempFlags = new List<string>();
|
|||
|
|
foreach (var item in list)
|
|||
|
|
{
|
|||
|
|
// 创建单个电池的列表
|
|||
|
|
var singleBatteryList = new List<BGearEntity> { item };
|
|||
|
|
|
|||
|
|
// 调用MES接口(每次只传一个电池)
|
|||
|
|
var (success, mesage, mesResType) = await CommonMethods.hbgMes.ManyCellOutStationAsync(
|
|||
|
|
CommonMethods.mesConfig.ProductOutStation,
|
|||
|
|
CommonMethods.mesConfig.siteCode,
|
|||
|
|
CommonMethods.mesConfig.lineCode,
|
|||
|
|
CommonMethods.mesConfig.equipNum,
|
|||
|
|
CommonMethods.mesConfig.MaterialCode,
|
|||
|
|
CommonMethods.mesConfig.ModelName,
|
|||
|
|
CommonMethods.mesConfig.mesUserName,
|
|||
|
|
singleBatteryList,
|
|||
|
|
1,
|
|||
|
|
CommonMethods.mesConfig.materialLotCodeLocator);
|
|||
|
|
if (success)
|
|||
|
|
{
|
|||
|
|
// 收集成功结果
|
|||
|
|
tempMesMessages.AddRange(mesage);
|
|||
|
|
tempMesResTypes.AddRange(mesResType);
|
|||
|
|
tempFlags.Add("1");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// 收集失败结果
|
|||
|
|
tempMesMessages.AddRange(mesage);
|
|||
|
|
tempMesResTypes.AddRange(mesResType);
|
|||
|
|
tempFlags.Add("2");
|
|||
|
|
|
|||
|
|
// 记录失败状态
|
|||
|
|
listRes = GetList<short>(8, 3);
|
|||
|
|
listRemark = GetList<string>(8, "");
|
|||
|
|
if (mesage.Count > 0 && mesage[0].Contains("一个或多个错误"))
|
|||
|
|
{
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue("D80", 1, PLC.DataType.Short); // 反馈PLC结果
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// 将收集的结果赋给主列表
|
|||
|
|
listMesMesage = tempMesMessages;
|
|||
|
|
listMesResType = tempMesResTypes;
|
|||
|
|
listFlag = tempFlags;
|
|||
|
|
//LogHelper.Instance.WriteError($"A出站是否上传mes参数:{listFlag}", "电芯出站A是否上传mes");
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】MES上传总耗时: {swSegment.ElapsedMilliseconds}ms", "A出站性能");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】MES未连接或未开启, MesModeSwitching={CommonMethods.sysConfig.MesModeSwitching}, isConnected={CommonMethods.mesConfig.isConnected}, 时间={DateTime.Now:HH:mm:ss.fff}", "A出站");
|
|||
|
|
listRes = GetList<short>(8, 3);
|
|||
|
|
listRemark = GetList<string>(8, "MES断连".Translated() + ",");
|
|||
|
|
listFlag = GetList<string>(8, "2");
|
|||
|
|
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue("D80", 1, PLC.DataType.Short);//反馈MES结果
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 上传产品结果参数
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
swSegment.Restart();
|
|||
|
|
_ = Task.Run(async () =>
|
|||
|
|
{
|
|||
|
|
try { await UpProducResultParamAsync(list); }
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"【出站A】UpProducResultParamAsync: {ex.Message}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】产品结果参数上传耗时: {swSegment.ElapsedMilliseconds}ms", "A出站性能");
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据组合
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】开始数据组合, list.Count={list.Count}, listMesResType.Count={listMesResType.Count}, 时间={DateTime.Now:HH:mm:ss.fff}", "A出站");
|
|||
|
|
for (int i = 0; i < list.Count; i++)
|
|||
|
|
{
|
|||
|
|
if (String.IsNullOrEmpty(list[i].BarCode) || list[i].BarCode.Trim() == "ERROR" || !IsAlphaNumeric(list[i].BarCode))
|
|||
|
|
{
|
|||
|
|
listRes[i] = 2;
|
|||
|
|
listResult[i] = "NG";
|
|||
|
|
list[i].Info = "电芯码不良".Translated();
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
listResult[i] = list[i].Result;
|
|||
|
|
//list[i].Info = list[i].Info;
|
|||
|
|
|
|||
|
|
// 本地判断OK,MES判断OK
|
|||
|
|
if (listResult[i] == "OK" && listMesResType[i] == MesResType.D)
|
|||
|
|
{
|
|||
|
|
listResult[i] += ",MES OK";
|
|||
|
|
list[i].Info = "良品".Translated();
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
listFlag[i] = "1";
|
|||
|
|
}
|
|||
|
|
// 本地判断OK,MES判断NG listMesResType 默认 B
|
|||
|
|
else if (listResult[i] == "OK" && listMesResType[i] != MesResType.D)
|
|||
|
|
{
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
switch (listMesResType[i])
|
|||
|
|
{
|
|||
|
|
case MesResType.A: // 停线,设备报警停机
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += $"A,{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 3;//10
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
break;
|
|||
|
|
case MesResType.B: // MES不良
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += $"B,{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 3;//9
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
break;
|
|||
|
|
case MesResType.C: // 警示
|
|||
|
|
listResult[i] += ",MES OK"; // MES认为是可以当成良品流下去的
|
|||
|
|
listRemark[i] += $"Alarm:{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
listFlag[i] = "1";
|
|||
|
|
break;
|
|||
|
|
case MesResType.D: // 条码上传OK
|
|||
|
|
listResult[i] += ",MES OK";
|
|||
|
|
listRemark[i] += $"D,{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
listFlag[i] = "1";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += $"{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 3;//9
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// 本地判断NG,MES判断OK
|
|||
|
|
else if (listResult[i] == "NG" && listMesResType[i] == MesResType.D)
|
|||
|
|
{
|
|||
|
|
listResult[i] += ",MES OK";
|
|||
|
|
listRemark[i] += $"D,{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
listFlag[i] = "1";
|
|||
|
|
}
|
|||
|
|
// 本地判断NG,MES判断NG
|
|||
|
|
else if (listResult[i] == "NG" && listMesResType[i] != MesResType.D)
|
|||
|
|
{
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += $"{listMesResType[i].ToString()},{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 3;//9
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
listRes[i] = 4;// CCD ng
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// 其他情况
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += listMesMesage[i];
|
|||
|
|
listRes[i] = 3;//9
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
listRes[i] = 4;// CCD ng
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
list[i].Result = listResult[i].TrimStart(',').TrimEnd(',');
|
|||
|
|
list[i].Remark = listRemark[i].TrimStart(',').TrimEnd(',');
|
|||
|
|
list[i].Flag = listFlag[i];
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
var listBGearEntity = new List<BGearEntity>();
|
|||
|
|
for (int i = 0; i < listMark.Count; i++)
|
|||
|
|
{
|
|||
|
|
if (listMark[i])
|
|||
|
|
{
|
|||
|
|
listBGearEntity.Add(list[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region 数据反馈
|
|||
|
|
swSegment.Restart();
|
|||
|
|
_ = Task.Run(async () =>
|
|||
|
|
{
|
|||
|
|
try { await SaveBlankingDataAsync(listBGearEntity); }
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"【出站A】SaveBlankingDataAsync: {ex.Message}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】数据存储耗时: {swSegment.ElapsedMilliseconds}ms", "A出站性能");
|
|||
|
|
|
|||
|
|
swSegment.Restart();
|
|||
|
|
if (pf.IsFeedbackPlc)
|
|||
|
|
{
|
|||
|
|
//写入·结果反馈
|
|||
|
|
JYResult result1 = CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue(pf.VarList[1].VarAddress, listRes.ToArray(), PLC.DataType.ArrShort);//判断结果写入PLC
|
|||
|
|
if (result1 != null)
|
|||
|
|
{
|
|||
|
|
string strres = "出站A工位发送给PLC".Translated() + $",[{pf.VarList[1].VarAddress}]:{string.Join(",", listRes)}";
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, strres);
|
|||
|
|
LogHelper.Instance.WriteLog($"出站A工位发送给PLC:{string.Join(",", listCode)}======{string.Join(",", listRes)}", "A出站");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, (short)0); // 置位0
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】PLC反馈耗时: {swSegment.ElapsedMilliseconds}ms", "A出站性能");
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, (short)0); // 置位0
|
|||
|
|
LogHelper.Instance.WriteLog($"出站A工位置位0", "A出站");
|
|||
|
|
LogHelper.Instance.WriteError($"电芯出站A线程数据处理:{ex}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
swTotal.Stop();
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, "电芯出站A共耗时".Translated() + $":{swTotal.ElapsedMilliseconds}ms");
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站A】总耗时: {swTotal.ElapsedMilliseconds}ms", "A出站性能");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 电芯出站B
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="bArrays"></param>
|
|||
|
|
/// <param name="plcModel"></param>
|
|||
|
|
private async Task BlankingStationB(JYResult<byte[]> bArrays, object plcModel)
|
|||
|
|
{
|
|||
|
|
PlcGroup pf = plcModel as PlcGroup;
|
|||
|
|
var swTotal = new Stopwatch();
|
|||
|
|
var swSegment = new Stopwatch();
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (bArrays.IsSuccess && bArrays.Content != null)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
swTotal.Start();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】开始处理, 时间={DateTime.Now:HH:mm:ss.fff}", "B出站性能");
|
|||
|
|
|
|||
|
|
#region 初始化数据
|
|||
|
|
swSegment.Restart();
|
|||
|
|
|
|||
|
|
List<BGearEntity> list = new List<BGearEntity>();
|
|||
|
|
List<short> listRes = GetList<short>(8, 2);//默认为1,良品
|
|||
|
|
List<bool> listMark = GetList<bool>(8, false);//有料标志
|
|||
|
|
List<string> listCode = GetList<string>(8, "");//电芯码
|
|||
|
|
List<string> listRemark = GetList<string>(8, "");//备注
|
|||
|
|
List<string> listFlag = GetList<string>(8, "0");//是否上传标志
|
|||
|
|
List<string> listResult = GetList<string>(8, "OK");//结果
|
|||
|
|
List<string> listMesMesage = GetList<string>(8, "");//mesMesage
|
|||
|
|
List<MesResType> listMesResType = GetList<MesResType>(8, MesResType.B);//mesType
|
|||
|
|
List<short> listFutou = GetList<short>(8, 0);//复投
|
|||
|
|
|
|||
|
|
string lst_RFIDCodes = ""; // 托杯码
|
|||
|
|
string lst_BarCodes = ""; // 条码
|
|||
|
|
string windSpeed = "";// 风速
|
|||
|
|
string ccdFaceTestDeviceNum1;// 端面检测设备号1
|
|||
|
|
string ccdFaceTestDeviceNum2;// 端面检测设备号2
|
|||
|
|
string ccdFaceTestDeviceNum3;// 端面检测设备号3
|
|||
|
|
string ccdFaceTestDeviceNum4;// 端面检测设备号4
|
|||
|
|
string ccdCylinderTestDeviceNum1;// 柱面检测设备号1
|
|||
|
|
string ccdCylinderTestDeviceNum2;// 柱面检测设备号2
|
|||
|
|
string ccdCylinderTestDeviceNum3;// 柱面检测设备号3
|
|||
|
|
|
|||
|
|
int ccdNegativeTerminalWeldingZone2DInspectionResult = 0; //负极焊接区2D检测结果
|
|||
|
|
int ccdNegativeTerminalWeldingZone2DInspectionNGReasons = 0; //负极焊接区2D检测NG原因(脏污)
|
|||
|
|
int ccdNegativeTerminalWeldingZone2DInspectionNGReasons1 = 0; //负极焊接区2D检测NG原因(划伤)
|
|||
|
|
int ccdNegativeTerminalWeldingZone2DInspectionNGReasons2 = 0; //负极焊接区2D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
int ccdCoverPlate2DInspectionResult = 0; //盖板2D检测结果
|
|||
|
|
int ccdCoverPlate2DInspectionNGReasons = 0; //盖板2D检测NG原因(脏污)
|
|||
|
|
int ccdCoverPlate2DInspectionNGReasons1 = 0; //盖板2D检测NG原因(划伤)
|
|||
|
|
int ccdCoverPlate2DInspectionNGReasons2 = 0; //盖板2D检测NG原因(凹点)
|
|||
|
|
int ccdCoverPlate2DInspectionNGReasons3 = 0; //盖板2D检测NG原因(生锈)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdNegativeTerminalWeldingZone25DInspectionResult = 0; //负极焊接区2.5D检测结果
|
|||
|
|
int ccdNegativeTerminalWeldingZone25DInspectionNGReasons = 0; //负极焊接区2.5D检测NG原因(脏污)
|
|||
|
|
int ccdNegativeTerminalWeldingZone25DInspectionNGReasons1 = 0; //负极焊接区2.5D检测NG原因(划伤)
|
|||
|
|
int ccdNegativeTerminalWeldingZone25DInspectionNGReasons2 = 0; //负极焊接区2.5D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdCoverPlate25DInspectionResult = 0; //盖板2.5D检测结果
|
|||
|
|
int ccdCoverPlate25DInspectionNGReasons = 0; //盖板2.5D检测NG原因(脏污)
|
|||
|
|
int ccdCoverPlate25DInspectionNGReasons1 = 0; //盖板2.5D检测NG原因(划伤)
|
|||
|
|
int ccdCoverPlate25DInspectionNGReasons2 = 0; //盖板2.5D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdTerminalPost2DInspectionResult = 0; //极柱2D检测结果
|
|||
|
|
int ccdTerminalPost2DInspectionNGReasons = 0; //极柱2D检测NG原因(脏污)
|
|||
|
|
int ccdTerminalPost2DInspectionNGReasons1 = 0; //极柱2D检测NG原因(划伤)
|
|||
|
|
int ccdTerminalPost2DInspectionNGReasons2 = 0; //极柱2D检测NG原因(凹点)
|
|||
|
|
int ccdTerminalPost2DInspectionNGReasons3 = 0; //极柱2D检测NG原因(残缺)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdTerminalPost3DInspectionResult = 0; //极柱3D检测结果
|
|||
|
|
int ccdTerminalPost3DInspectionNGReasons = 0; //极柱3D检测NG原因(脏污)
|
|||
|
|
int ccdTerminalPost3DInspectionNGReasons1 = 0; //极柱3D检测NG原因(划伤)
|
|||
|
|
int ccdTerminalPost3DInspectionNGReasons2 = 0; //极柱3D检测NG原因(凹点)
|
|||
|
|
int ccdTerminalPost3DInspectionNGReasons3 = 0; //极柱3D检测NG原因(残缺)
|
|||
|
|
|
|||
|
|
int ccdSealingNail2DInspectionResult = 0; //密封钉2D检测结果
|
|||
|
|
int ccdSealingNail2DInspectionNGReasons = 0; //密封钉2D检测NG原因(铝钉焊接)
|
|||
|
|
|
|||
|
|
int ccdSealingNail3DInspectionResult = 0; //密封钉3D检测结果
|
|||
|
|
int ccdSealingNail3DInspectionNGReasons = 0; //密封钉3D检测NG原因(铝钉焊接)
|
|||
|
|
|
|||
|
|
int ccdTopFillet25DInspectionResult = 0; //上部R角2.5D检测结果
|
|||
|
|
int ccdTopFillet25DInspectionNGReasons = 0; //上部R角2.5D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
int ccdBottomFillet25DInspectionResult = 0; //底部R角2.5D检测结果
|
|||
|
|
int ccdBottomFillet25DInspectionNGReasons = 0; //底部R角2.5D检测NG原因(凹点)
|
|||
|
|
|
|||
|
|
int ccdCylindricalSurface25DInspectionResult = 0; //柱面2.5D检测结果
|
|||
|
|
int ccdCylindricalSurface25DInspectionNGReasons = 0; //柱面2.5D检测NG原因(生锈)
|
|||
|
|
int ccdCylindricalSurface25DInspectionNGReasons1 = 0; //柱面2.5D检测NG原因(划伤)
|
|||
|
|
int ccdCylindricalSurface25DInspectionNGReasons2 = 0; //柱面2.5D检测NG原因(凹点)
|
|||
|
|
int ccdCylindricalSurface25DInspectionNGReasons3 = 0; //柱面2.5D检测NG原因(模糊)
|
|||
|
|
|
|||
|
|
|
|||
|
|
int ccdCylindricalSurface3DInspectionResult = 0; //柱面3D检测结果
|
|||
|
|
int ccdCylindricalSurface3DInspectionNGReasons = 0; //柱面3D检测NG原因(生锈)
|
|||
|
|
int ccdCylindricalSurface3DInspectionNGReasons1 = 0; //柱面3D检测NG原因(划伤)
|
|||
|
|
int ccdCylindricalSurface3DInspectionNGReasons2 = 0; //柱面3D检测NG原因(凹点)
|
|||
|
|
int ccdCylindricalSurface3DInspectionNGReasons3 = 0; //柱面3D检测NG原因(模糊)
|
|||
|
|
|
|||
|
|
int ccdPositiveTerminaJYQ2DInspectionResult = 0; //正极绝缘圈2D检测结果
|
|||
|
|
int ccdPositiveTerminaJYQ2DInspectionNGReasons = 0; //正极绝缘圈2D检测NG原因(变形)
|
|||
|
|
|
|||
|
|
int ccdNegativeTerminaJYQ2DInspectionResult = 0; //负极绝缘圈2D检测结果
|
|||
|
|
int ccdNegativeTerminaJYQ2DInspectionNGReasons = 0; //负极绝缘圈2D检测NG原因(变形)
|
|||
|
|
|
|||
|
|
int[] ccdTestResult = new int[12];//ccd检测结果
|
|||
|
|
|
|||
|
|
string result = "";//总结果
|
|||
|
|
string info = "";//NG详情
|
|||
|
|
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】数据初始化耗时: {swSegment.ElapsedMilliseconds}ms", "B出站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据解析
|
|||
|
|
swSegment.Restart();
|
|||
|
|
byte[] bytes = bArrays.Content.ByteReverse();
|
|||
|
|
|
|||
|
|
//有料标志
|
|||
|
|
for (int i = 0; i < listMark.Count; i++)
|
|||
|
|
{
|
|||
|
|
BGearEntity m2 = new BGearEntity();
|
|||
|
|
listMark[i] = ShortLib.GetShortFromByteArray(bArrays.Content, (i * 2)) == 1 ? true : false;// 从D6021开始
|
|||
|
|
if (listMark[i])
|
|||
|
|
{
|
|||
|
|
#region 数据读取
|
|||
|
|
//条码长度
|
|||
|
|
int codeLength = ShortLib.GetShortFromByteArray(bArrays.Content, (i * 2) + (20 * 2));// 从D6041开始
|
|||
|
|
if (codeLength > 0)
|
|||
|
|
{
|
|||
|
|
//条码
|
|||
|
|
listCode[i] = StringLib.GetStringFromByteArrayByEncoding(bytes, (i * 50) + (79 * 2), codeLength, System.Text.Encoding.ASCII).// 从D4100开始
|
|||
|
|
Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
|||
|
|
LogHelper.Instance.WriteLog($"电芯出站B条码:{listCode[i]}", "BarCode");
|
|||
|
|
}
|
|||
|
|
else { listCode[i] = "ERROR"; }
|
|||
|
|
|
|||
|
|
windSpeed = GetValueFromByteArray(bArrays.Content, "windSpeed", i == 0 ? 0 : (int)Math.Pow(2, i + 1)); // 风速 D6600 579
|
|||
|
|
ccdFaceTestDeviceNum1 = GetValueFromByteArray(bArrays.Content, "ccdFaceTestDeviceNum1", (i * 8) * 2); // 端面检测设备号1 D6616 595
|
|||
|
|
ccdFaceTestDeviceNum2 = GetValueFromByteArray(bArrays.Content, "ccdFaceTestDeviceNum2", (i * 8) * 2); // 端面检测设备号2 D6618 597
|
|||
|
|
ccdFaceTestDeviceNum3 = GetValueFromByteArray(bArrays.Content, "ccdFaceTestDeviceNum3", (i * 8) * 2); // 端面检测设备号3 D6620 599
|
|||
|
|
ccdFaceTestDeviceNum4 = GetValueFromByteArray(bArrays.Content, "ccdFaceTestDeviceNum4", (i * 8) * 2); // 端面检测设备号4 D6622 601
|
|||
|
|
|
|||
|
|
ccdCylinderTestDeviceNum1 = GetValueFromByteArray(bArrays.Content, "ccdCylinderTestDeviceNum1", (i * 8) * 2); // 柱面检测设备号1 D6680 659
|
|||
|
|
ccdCylinderTestDeviceNum2 = GetValueFromByteArray(bArrays.Content, "ccdCylinderTestDeviceNum2", (i * 8) * 2); // 柱面检测设备号2 D6682 661
|
|||
|
|
ccdCylinderTestDeviceNum3 = GetValueFromByteArray(bArrays.Content, "ccdCylinderTestDeviceNum3", (i * 8) * 2); // 柱面检测设备号3 D6684 663
|
|||
|
|
|
|||
|
|
//ccdPosFaceTestResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdPosFaceTestResult", (i * 2)));// 正极端面检测结果 D6728 707
|
|||
|
|
//ccdNegFaceTestResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegFaceTestResult", (i * 2)));// 负极端面检测结果 D6736 715
|
|||
|
|
//ccdBeforeCoatedCylinderTestResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdBeforeCoatedCylinderTestResult", (i * 2)));// 包膜前圆柱面检测结果 D6744 723
|
|||
|
|
//ccdPosCylinderTestResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdPosCylinderTestResult", (i * 2)));// 正极柱检测结果 D6752 731
|
|||
|
|
//ccdNegCylinderTestResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegCylinderTestResult", (i * 2)));// 负极柱检测结果 D6760 739
|
|||
|
|
|
|||
|
|
ccdNegativeTerminalWeldingZone2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone2DInspectionResult", (i * 2))); // 负极焊接区2D检测结果
|
|||
|
|
ccdNegativeTerminalWeldingZone2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone2DInspectionNGReasons", (i * 2))); // 负极焊接区2D检测NG原因
|
|||
|
|
ccdNegativeTerminalWeldingZone2DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone2DInspectionNGReasons1", (i * 2))); // 负极焊接区2D检测NG原因
|
|||
|
|
ccdNegativeTerminalWeldingZone2DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone2DInspectionNGReasons2", (i * 2))); // 负极焊接区2D检测NG原因
|
|||
|
|
|
|||
|
|
ccdCoverPlate2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionResult", (i * 2))); // 盖板2D检测结果
|
|||
|
|
ccdCoverPlate2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionNGReasons", (i * 2))); // 盖板2D检测NG原因
|
|||
|
|
ccdCoverPlate2DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionNGReasons1", (i * 2))); // 盖板2D检测NG原因
|
|||
|
|
ccdCoverPlate2DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionNGReasons2", (i * 2))); // 盖板2D检测NG原因
|
|||
|
|
ccdCoverPlate2DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate2DInspectionNGReasons3", (i * 2))); // 盖板2D检测NG原因
|
|||
|
|
|
|||
|
|
ccdNegativeTerminalWeldingZone25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone25DInspectionResult", (i * 2))); // 负极焊接区2.5D检测结果
|
|||
|
|
ccdNegativeTerminalWeldingZone25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone25DInspectionNGReasons", (i * 2))); // 负极焊接区2.5D检测NG原因
|
|||
|
|
ccdNegativeTerminalWeldingZone25DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone25DInspectionNGReasons1", (i * 2))); // 负极焊接区2.5D检测NG原因
|
|||
|
|
ccdNegativeTerminalWeldingZone25DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminalWeldingZone25DInspectionNGReasons2", (i * 2))); // 负极焊接区2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdCoverPlate25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate25DInspectionResult", (i * 2))); // 盖板2.5D检测结果
|
|||
|
|
ccdCoverPlate25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate25DInspectionNGReasons", (i * 2))); // 盖板2.5D检测NG原因
|
|||
|
|
ccdCoverPlate25DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate25DInspectionNGReasons1", (i * 2))); // 盖板2.5D检测NG原因
|
|||
|
|
ccdCoverPlate25DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCoverPlate25DInspectionNGReasons2", (i * 2))); // 盖板2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdTerminalPost2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionResult", (i * 2))); // 极柱2D检测结果
|
|||
|
|
ccdTerminalPost2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionNGReasons", (i * 2))); // 极柱2D检测NG原因
|
|||
|
|
ccdTerminalPost2DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionNGReasons1", (i * 2))); // 极柱2D检测NG原因
|
|||
|
|
ccdTerminalPost2DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionNGReasons2", (i * 2))); // 极柱2D检测NG原因
|
|||
|
|
ccdTerminalPost2DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost2DInspectionNGReasons3", (i * 2))); // 极柱2D检测NG原因
|
|||
|
|
|
|||
|
|
ccdTerminalPost3DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionResult", (i * 2))); // 极柱3D检测结果
|
|||
|
|
ccdTerminalPost3DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionNGReasons", (i * 2))); // 极柱3D检测NG原因
|
|||
|
|
ccdTerminalPost3DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionNGReasons1", (i * 2))); // 极柱3D检测NG原因
|
|||
|
|
ccdTerminalPost3DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionNGReasons2", (i * 2))); // 极柱3D检测NG原因
|
|||
|
|
ccdTerminalPost3DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTerminalPost3DInspectionNGReasons3", (i * 2))); // 极柱3D检测NG原因
|
|||
|
|
|
|||
|
|
ccdSealingNail2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdSealingNail2DInspectionResult", (i * 2))); // 密封钉2D检测结果
|
|||
|
|
ccdSealingNail2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdSealingNail2DInspectionNGReasons", (i * 2))); // 密封钉2D检测NG原因
|
|||
|
|
|
|||
|
|
ccdSealingNail3DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdSealingNail3DInspectionResult", (i * 2))); // 密封钉3D检测结果
|
|||
|
|
ccdSealingNail3DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdSealingNail3DInspectionNGReasons", (i * 2))); // 密封钉3D检测NG原因
|
|||
|
|
|
|||
|
|
ccdTopFillet25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTopFillet25DInspectionResult", (i * 2))); // 上部R角2.5D检测结果
|
|||
|
|
ccdTopFillet25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdTopFillet25DInspectionNGReasons", (i * 2))); // 上部R角2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdBottomFillet25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdBottomFillet25DInspectionResult", (i * 2))); // 底部R角2.5D检测结果
|
|||
|
|
ccdBottomFillet25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdBottomFillet25DInspectionNGReasons", (i * 2))); // 底部R角2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdCylindricalSurface25DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionResult", (i * 2))); // 柱面2.5D检测结果
|
|||
|
|
ccdCylindricalSurface25DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionNGReasons", (i * 2))); // 柱面2.5D检测NG原因
|
|||
|
|
ccdCylindricalSurface25DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionNGReasons1", (i * 2))); // 柱面2.5D检测NG原因
|
|||
|
|
ccdCylindricalSurface25DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionNGReasons2", (i * 2))); // 柱面2.5D检测NG原因
|
|||
|
|
ccdCylindricalSurface25DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface25DInspectionNGReasons3", (i * 2))); // 柱面2.5D检测NG原因
|
|||
|
|
|
|||
|
|
ccdCylindricalSurface3DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionResult", (i * 2))); // 柱面3D检测结果
|
|||
|
|
ccdCylindricalSurface3DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionNGReasons", (i * 2))); // 柱面3D检测NG原因
|
|||
|
|
ccdCylindricalSurface3DInspectionNGReasons1 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionNGReasons1", (i * 2))); // 柱面3D检测NG原因
|
|||
|
|
ccdCylindricalSurface3DInspectionNGReasons2 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionNGReasons2", (i * 2))); // 柱面3D检测NG原因
|
|||
|
|
ccdCylindricalSurface3DInspectionNGReasons3 = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdCylindricalSurface3DInspectionNGReasons3", (i * 2))); // 柱面3D检测NG原因
|
|||
|
|
|
|||
|
|
ccdPositiveTerminaJYQ2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdPositiveTerminaJYQ2DInspectionResult", (i * 2))); // 正极绝缘圈2D检测结果
|
|||
|
|
ccdPositiveTerminaJYQ2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdPositiveTerminaJYQ2DInspectionNGReasons", (i * 2))); // 正极绝缘圈2D检测NG原因(变形)
|
|||
|
|
ccdNegativeTerminaJYQ2DInspectionResult = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminaJYQ2DInspectionResult", (i * 2))); // 负极绝缘圈2D检测结果
|
|||
|
|
ccdNegativeTerminaJYQ2DInspectionNGReasons = int.Parse(GetValueFromByteArray(bArrays.Content, "ccdNegativeTerminaJYQ2DInspectionNGReasons", (i * 2))); // 负极绝缘圈2D检测NG原因(变形)
|
|||
|
|
|
|||
|
|
ccdTestResult[0] = ccdNegativeTerminalWeldingZone2DInspectionResult; // 负极焊接区2D检测结果
|
|||
|
|
ccdTestResult[1] = ccdCoverPlate2DInspectionResult; // 盖板2D检测结果
|
|||
|
|
ccdTestResult[2] = ccdNegativeTerminalWeldingZone25DInspectionResult;// 负极焊接区2.5D检测结果
|
|||
|
|
ccdTestResult[3] = ccdCoverPlate25DInspectionResult; // 盖板2.5D检测结果
|
|||
|
|
ccdTestResult[4] = ccdTerminalPost2DInspectionResult; // 极柱2D检测结果
|
|||
|
|
ccdTestResult[5] = ccdTerminalPost3DInspectionResult; // 极柱3D检测结果
|
|||
|
|
ccdTestResult[6] = ccdSealingNail2DInspectionResult; // 密封钉2D检测结果
|
|||
|
|
ccdTestResult[7] = ccdSealingNail3DInspectionResult; // 密封钉3D检测结果
|
|||
|
|
ccdTestResult[8] = ccdTopFillet25DInspectionResult; // 上部R角2.5D检测结果
|
|||
|
|
ccdTestResult[9] = ccdBottomFillet25DInspectionResult; // 底部R角2.5D检测结果
|
|||
|
|
ccdTestResult[10] = ccdCylindricalSurface25DInspectionResult; // 柱面2.5D检测结果
|
|||
|
|
ccdTestResult[11] = ccdCylindricalSurface3DInspectionResult; // 柱面3D检测结果
|
|||
|
|
|
|||
|
|
//string resultPLC = GetValueFromByteArray(bArrays.Content, "result", (i * 2));// 总结果 D4768 747
|
|||
|
|
result = int.Parse(GetValueFromByteArray(bArrays.Content, "result", (i * 2))) == 1 ? "OK" : "NG";
|
|||
|
|
|
|||
|
|
string strErr = "";
|
|||
|
|
short a = (short)GetResult(ccdTestResult, ref strErr);
|
|||
|
|
info = strErr;
|
|||
|
|
//result = a == 12 ? "OK" : "NG";
|
|||
|
|
LogHelper.Instance.WriteError($"B出站总结果:result:" + result + ", info:" + info, "电芯出站B");
|
|||
|
|
|
|||
|
|
lst_RFIDCodes = "";//StringLib.GetStringFromByteArrayByEncoding(bytes, 0, 39, Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim(); // RFID D3200-3219
|
|||
|
|
lst_BarCodes = listCode[i];
|
|||
|
|
listFutou[i] = 0; // todo add 20260425
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据保存
|
|||
|
|
BGearEntity m = new BGearEntity
|
|||
|
|
{
|
|||
|
|
ChannelNo = (i + 1).ToString(),
|
|||
|
|
TestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|||
|
|
RFID = lst_RFIDCodes,
|
|||
|
|
BarCode = lst_BarCodes,
|
|||
|
|
WindSpeed = windSpeed,
|
|||
|
|
WindDeviceNum = "B",
|
|||
|
|
CCDFaceTestDeviceNum1 = "B",
|
|||
|
|
CCDFaceTestDeviceNum2 = "B",
|
|||
|
|
CCDFaceTestDeviceNum3 = "B",
|
|||
|
|
CCDFaceTestDeviceNum4 = "B",
|
|||
|
|
CCDCylinderTestDeviceNum1 = "B",
|
|||
|
|
CCDCylinderTestDeviceNum2 = "B",
|
|||
|
|
CCDCylinderTestDeviceNum3 = "B",
|
|||
|
|
CCDNegativeTerminalWeldingZone2DInspectionResult = ccdNegativeTerminalWeldingZone2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDNegativeTerminalWeldingZone2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdNegativeTerminalWeldingZone2DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdNegativeTerminalWeldingZone2DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdNegativeTerminalWeldingZone2DInspectionNGReasons2, "UI127")),
|
|||
|
|
CCDCoverPlate2DInspectionResult = ccdCoverPlate2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDCoverPlate2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCoverPlate2DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdCoverPlate2DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdCoverPlate2DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdCoverPlate2DInspectionNGReasons3, "UI298")),
|
|||
|
|
CCDNegativeTerminalWeldingZone25DInspectionResult = ccdNegativeTerminalWeldingZone25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDNegativeTerminalWeldingZone25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdNegativeTerminalWeldingZone25DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdNegativeTerminalWeldingZone25DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdNegativeTerminalWeldingZone25DInspectionNGReasons2, "UI127")),
|
|||
|
|
CCDCoverPlate25DInspectionResult = ccdCoverPlate25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDCoverPlate25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCoverPlate25DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdCoverPlate25DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdCoverPlate25DInspectionNGReasons2, "UI127")),
|
|||
|
|
CCDTerminalPost2DInspectionResult = ccdTerminalPost2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDTerminalPost2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCoverPlate25DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdTerminalPost2DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdTerminalPost2DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdTerminalPost2DInspectionNGReasons3, "UI125")),
|
|||
|
|
CCDTerminalPost3DInspectionResult = ccdTerminalPost3DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDTerminalPost3DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdTerminalPost3DInspectionNGReasons, "UI20801"),
|
|||
|
|
GetNGReasons(ccdTerminalPost3DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdTerminalPost3DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdTerminalPost3DInspectionNGReasons3, "UI125")),
|
|||
|
|
CCDSealingNail2DInspectionResult = ccdSealingNail2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDSealingNail2DInspectionNGReasons = "",
|
|||
|
|
CCDSealingNail3DInspectionResult = ccdSealingNail3DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDSealingNail3DInspectionNGReasons = "",
|
|||
|
|
CCDTopFillet25DInspectionResult = ccdTopFillet25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDTopFillet25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdTopFillet25DInspectionNGReasons, "UI127")),
|
|||
|
|
CCDBottomFillet25DInspectionResult = ccdBottomFillet25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDBottomFillet25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdBottomFillet25DInspectionNGReasons, "UI127")),
|
|||
|
|
CCDCylindricalSurface25DInspectionResult = ccdCylindricalSurface25DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDCylindricalSurface25DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCylindricalSurface25DInspectionNGReasons, "UI128"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface25DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface25DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface25DInspectionNGReasons3, "UI00404")),
|
|||
|
|
CCDCylindricalSurface3DInspectionResult = ccdCylindricalSurface3DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDCylindricalSurface3DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdCylindricalSurface3DInspectionNGReasons, "UI128"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface3DInspectionNGReasons1, "UI21301"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface3DInspectionNGReasons2, "UI127"),
|
|||
|
|
GetNGReasons(ccdCylindricalSurface3DInspectionNGReasons3, "UI00404")),
|
|||
|
|
|
|||
|
|
CCDPositiveTerminaJYQ2DInspectionResult = ccdPositiveTerminaJYQ2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDPositiveTerminaJYQ2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdPositiveTerminaJYQ2DInspectionNGReasons, "UI15301")),
|
|||
|
|
|
|||
|
|
CCDNegativeTerminaJYQ2DInspectionResult = ccdNegativeTerminaJYQ2DInspectionResult == 1 ? "OK" : "NG",
|
|||
|
|
CCDNegativeTerminaJYQ2DInspectionNGReasons = CombineNGReasons
|
|||
|
|
(GetNGReasons(ccdNegativeTerminaJYQ2DInspectionNGReasons, "UI15302")),
|
|||
|
|
|
|||
|
|
Flag = "0",
|
|||
|
|
Flag1 = "2",
|
|||
|
|
Result = result,
|
|||
|
|
Info = info,
|
|||
|
|
MaterialCode = CommonMethods.mesConfig.MaterialCode,
|
|||
|
|
Futou = listFutou[i],
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
m2 = m;
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, "出站下料工位B有料标志为0".Translated() + "通道号".Translated() + $":{i}");
|
|||
|
|
}
|
|||
|
|
list.Add(m2);
|
|||
|
|
}
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】数据解析耗时: {swSegment.ElapsedMilliseconds}ms, 解析条数: {list.Count}", "B出站性能");
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据上传MES
|
|||
|
|
if (list.Count > 0 && CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
swSegment.Restart();
|
|||
|
|
|
|||
|
|
var tempMesMessages = new List<string>();
|
|||
|
|
var tempMesResTypes = new List<MesResType>();
|
|||
|
|
var tempFlags = new List<string>();
|
|||
|
|
foreach (var item in list)
|
|||
|
|
{
|
|||
|
|
// 创建单个电池的列表
|
|||
|
|
var singleBatteryList = new List<BGearEntity> { item };
|
|||
|
|
|
|||
|
|
// 调用MES接口(每次只传一个电池)
|
|||
|
|
var (success, mesage, mesResType) = await CommonMethods.hbgMes.ManyCellOutStationAsync(
|
|||
|
|
CommonMethods.mesConfig.ProductOutStation,
|
|||
|
|
CommonMethods.mesConfig.siteCode,
|
|||
|
|
CommonMethods.mesConfig.lineCode,
|
|||
|
|
CommonMethods.mesConfig.equipNum,
|
|||
|
|
CommonMethods.mesConfig.MaterialCode,
|
|||
|
|
CommonMethods.mesConfig.ModelName,
|
|||
|
|
CommonMethods.mesConfig.mesUserName,
|
|||
|
|
singleBatteryList,
|
|||
|
|
1,
|
|||
|
|
CommonMethods.mesConfig.materialLotCodeLocator);
|
|||
|
|
if (success)
|
|||
|
|
{
|
|||
|
|
// 收集成功结果
|
|||
|
|
tempMesMessages.AddRange(mesage);
|
|||
|
|
tempMesResTypes.AddRange(mesResType);
|
|||
|
|
tempFlags.Add("1");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// 收集失败结果
|
|||
|
|
tempMesMessages.AddRange(mesage);
|
|||
|
|
tempMesResTypes.AddRange(mesResType);
|
|||
|
|
tempFlags.Add("2");
|
|||
|
|
|
|||
|
|
// 记录失败状态
|
|||
|
|
listRes = GetList<short>(8, 3);
|
|||
|
|
listRemark = GetList<string>(8, "");
|
|||
|
|
if (mesage.Count > 0 && mesage[0].Contains("一个或多个错误"))
|
|||
|
|
{
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue("D80", 1, PLC.DataType.Short); // 反馈PLC结果
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// 将收集的结果赋给主列表
|
|||
|
|
listMesMesage = tempMesMessages;
|
|||
|
|
listMesResType = tempMesResTypes;
|
|||
|
|
listFlag = tempFlags;
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】MES上传总耗时: {swSegment.ElapsedMilliseconds}ms", "B出站性能");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】MES未连接或未开启, MesModeSwitching={CommonMethods.sysConfig.MesModeSwitching}, isConnected={CommonMethods.mesConfig.isConnected}, 时间={DateTime.Now:HH:mm:ss.fff}", "B出站");
|
|||
|
|
listRes = GetList<short>(8, 3);
|
|||
|
|
listRemark = GetList<string>(8, "MES断连".Translated() + ",");
|
|||
|
|
listFlag = GetList<string>(8, "2");
|
|||
|
|
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue("D80", 1, PLC.DataType.Short);//反馈MES结果
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 上传产品结果参数
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
swSegment.Restart();
|
|||
|
|
_ = Task.Run(async () =>
|
|||
|
|
{
|
|||
|
|
try { await UpProducResultParamAsync(list); }
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"【出站B】UpProducResultParamAsync: {ex.Message}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
swSegment.Stop();
|
|||
|
|
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】产品结果参数上传耗时: {swSegment.ElapsedMilliseconds}ms", "B出站性能");
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据组合
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】开始数据组合, list.Count={list.Count}, listMesResType.Count={listMesResType.Count}, 时间={DateTime.Now:HH:mm:ss.fff}", "B出站");
|
|||
|
|
for (int i = 0; i < list.Count; i++)
|
|||
|
|
{
|
|||
|
|
if (String.IsNullOrEmpty(list[i].BarCode) || list[i].BarCode.Trim() == "ERROR" || !IsAlphaNumeric(list[i].BarCode))
|
|||
|
|
{
|
|||
|
|
listRes[i] = 2;
|
|||
|
|
listResult[i] = "NG";
|
|||
|
|
list[i].Info = "电芯码不良".Translated();
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//string strErr = "";
|
|||
|
|
//short a = (short)GetResult(ccdTestResult, ref strErr);
|
|||
|
|
//listResult[i] = a == 12 ? "OK" : "NG";
|
|||
|
|
listResult[i] = list[i].Result;
|
|||
|
|
//list[i].Info = strErr;
|
|||
|
|
|
|||
|
|
// 本地判断OK,MES判断OK
|
|||
|
|
if (listResult[i] == "OK" && listMesResType[i] == MesResType.D)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
listResult[i] += ",MES OK";
|
|||
|
|
listFlag[i] = "1";
|
|||
|
|
list[i].Info = "良品".Translated();
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
// 本地判断OK,MES判断NG
|
|||
|
|
else if (listResult[i] == "OK" && listMesResType[i] != MesResType.D)
|
|||
|
|
{
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
//listMesResType 默认值 是B
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
switch (listMesResType[i])
|
|||
|
|
{
|
|||
|
|
case MesResType.A: // 停线,设备报警停机
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += $"A,{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 3;//10
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
break;
|
|||
|
|
case MesResType.B: // MES不良
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += $"B,{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 3;//9
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
break;
|
|||
|
|
case MesResType.C: // 警示
|
|||
|
|
listResult[i] += ",MES OK"; // MES认为是可以当成良品流下去的
|
|||
|
|
listRemark[i] += $"Alarm:{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
listFlag[i] = "1";
|
|||
|
|
break;
|
|||
|
|
case MesResType.D: // 条码上传OK
|
|||
|
|
listResult[i] += ",MES OK";
|
|||
|
|
listRemark[i] += $"D,{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
listFlag[i] = "1";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += $"{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 3;//9
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// 本地判断NG,MES判断OK
|
|||
|
|
else if (listResult[i] == "NG" && listMesResType[i] == MesResType.D)
|
|||
|
|
{
|
|||
|
|
listResult[i] += ",MES OK";
|
|||
|
|
listRemark[i] += $"D,{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
listFlag[i] = "1";
|
|||
|
|
}
|
|||
|
|
// 本地判断NG,MES判断NG listMesResType 默认值是B
|
|||
|
|
else if (listResult[i] == "NG" && listMesResType[i] != MesResType.D)
|
|||
|
|
{
|
|||
|
|
//if 1
|
|||
|
|
//futou >=1
|
|||
|
|
//开了 mes =mesng =3
|
|||
|
|
// 没开么事 = ng =3
|
|||
|
|
//else 需要复投
|
|||
|
|
// =4 CCD NG
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += $"{listMesResType[i].ToString()},{listMesMesage[i]}";
|
|||
|
|
listRes[i] = 3;//9
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
listRes[i] = 4;//CCD NG
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// 其他情况
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
listResult[i] += ",MES NG";
|
|||
|
|
listRemark[i] += listMesMesage[i];
|
|||
|
|
listRes[i] = 3;//9
|
|||
|
|
listFlag[i] = "2";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
listRes[i] = 4;//CCD NG
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
list[i].Result = listResult[i].TrimStart(',').TrimEnd(',');
|
|||
|
|
list[i].Remark = listRemark[i].TrimStart(',').TrimEnd(',');
|
|||
|
|
list[i].Flag = listFlag[i];
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据保存&上传
|
|||
|
|
var listBGearEntity = new List<BGearEntity>();
|
|||
|
|
for (int i = 0; i < listMark.Count; i++)
|
|||
|
|
{
|
|||
|
|
if (listMark[i])
|
|||
|
|
{
|
|||
|
|
listBGearEntity.Add(list[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
swSegment.Restart();
|
|||
|
|
_ = Task.Run(async () =>
|
|||
|
|
{
|
|||
|
|
try { await SaveBlankingDataAsync(listBGearEntity); }
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"【出站B】SaveBlankingDataAsync: {ex.Message}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】数据存储耗时: {swSegment.ElapsedMilliseconds}ms", "B出站性能");
|
|||
|
|
|
|||
|
|
swSegment.Restart();
|
|||
|
|
if (pf.IsFeedbackPlc)
|
|||
|
|
{
|
|||
|
|
//写入·结果反馈
|
|||
|
|
JYResult result1 = CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue(pf.VarList[1].VarAddress, listRes.ToArray(), PLC.DataType.ArrShort);
|
|||
|
|
if (result1 != null)
|
|||
|
|
{
|
|||
|
|
string strres = "出站B工位发送给PLC".Translated() + $",[{pf.VarList[1].VarAddress}]:{string.Join(",", listRes)}";
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, strres);
|
|||
|
|
LogHelper.Instance.WriteLog($"出站B工位发送给PLC:{string.Join(",", listCode)}======{string.Join(",", listRes)}", "B出站");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, (short)0); // 置位0
|
|||
|
|
swSegment.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】PLC反馈耗时: {swSegment.ElapsedMilliseconds}ms", "B出站性能");
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
CommonMethods.plcDevices[pf.PlcNum - 1].WriteInt16(pf.VarList[0].VarAddress, (short)0);
|
|||
|
|
LogHelper.Instance.WriteLog($"出站B工位异常,触发地址置位0", "B出站");
|
|||
|
|
LogHelper.Instance.WriteError($"电芯出站B线程数据处理:{ex}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
swTotal.Stop();
|
|||
|
|
|
|||
|
|
// 输出上料数据处理耗时:
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, "电芯出站B共耗时".Translated() + $":{swTotal.ElapsedMilliseconds}ms");
|
|||
|
|
LogHelper.Instance.WriteLog($"【出站B】总耗时: {swTotal.ElapsedMilliseconds}ms", "B出站性能");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 保存下料数据
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存下料数据到数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="list"></param>
|
|||
|
|
private async Task SaveBlankingDataAsync(List<BGearEntity> list)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"SaveBlankingData-enter", "A出站");
|
|||
|
|
//数据的保存
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (list != null && list.Count > 0)
|
|||
|
|
{
|
|||
|
|
//数据显示
|
|||
|
|
bool b = await CommonMethods.db.AddReturnBoolAsync<BGearEntity>(list);
|
|||
|
|
|
|||
|
|
//数据显示
|
|||
|
|
CommonMethods.ShowBlankingDelegate.Invoke(list);
|
|||
|
|
|
|||
|
|
//数据保存本地
|
|||
|
|
//string strData = string.Empty;//数据字符串,本地保存
|
|||
|
|
//foreach (BGearEntity m in list)
|
|||
|
|
//{
|
|||
|
|
// string strData = string.Empty;
|
|||
|
|
// foreach (var item in m.GetType().GetProperties())
|
|||
|
|
// {
|
|||
|
|
// strData += item.GetValue(m).ToString() + ",";
|
|||
|
|
// }
|
|||
|
|
// strData = strData.TrimEnd(',');
|
|||
|
|
// BlankingDataSaveLocal(strData);
|
|||
|
|
//}
|
|||
|
|
var lines = list.Select(m =>
|
|||
|
|
{
|
|||
|
|
var values = m.GetType().GetProperties()
|
|||
|
|
.Select(p => p.GetValue(m)?.ToString() ?? "");
|
|||
|
|
return string.Join(",", values);
|
|||
|
|
}).ToList();
|
|||
|
|
|
|||
|
|
// 批量写本地文件
|
|||
|
|
await Task.Run(() => BlankingDataSaveLocalBatch(lines));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"电芯出站数据List为空", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"电芯出站数据保存异常A:{ex}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
LogHelper.Instance.WriteError($"SaveBlankingData-end", "A出站");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private async Task SaveReInData(List<ReInBGearEntity> list)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (list != null && list.Count > 0)
|
|||
|
|
{
|
|||
|
|
bool b = await CommonMethods.db.AddReturnBoolAsync<ReInBGearEntity>(list);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"电芯复投数据保存异常:{ex}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 电池结果判断
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private ushort GetResult(int[] res, ref string strErr)
|
|||
|
|
{
|
|||
|
|
strErr = "";
|
|||
|
|
int resNum = 0;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < res.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (i == 0)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "负极焊接区2D检测结果不良".Translated() + ",";
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "负极焊接区2D检测结果未知".Translated() + ",";
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 1)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "盖板2D检测结果不良".Translated() + ",";
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "盖板2D检测结果未知".Translated() + ",";
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 2)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "负极焊接区2.5D检测结果不良".Translated() + ",";
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "负极焊接区2.5D检测结果未知".Translated() + ",";
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 3)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "盖板2.5D检测结果不良".Translated() + ",";
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "盖板2.5D检测结果未知".Translated() + ",";
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 4)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "极柱2D检测结果不良".Translated();
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "极柱2D检测结果未知".Translated();
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 5)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "极柱3D检测结果不良".Translated();
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "极柱3D检测结果未知".Translated();
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 6)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "密封钉2D检测结果不良".Translated();
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "密封钉2D检测结果未知".Translated();
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 7)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "密封钉3D检测结果不良".Translated();
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "密封钉3D检测结果未知".Translated();
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 8)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "上部R角2.5D检测结果不良".Translated();
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "上部R角2.5D检测结果未知".Translated();
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 9)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "底部R角2.5D检测结果不良".Translated();
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "底部R角2.5D检测结果未知".Translated();
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 10)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "柱面2.5D检测结果不良".Translated();
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "柱面2.5D检测结果未知".Translated();
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (i == 11)
|
|||
|
|
{
|
|||
|
|
switch (res[i])
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
strErr += "";
|
|||
|
|
resNum++;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
strErr += "柱面3D检测结果不良".Translated();
|
|||
|
|
resNum = resNum + 2;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
strErr += "柱面3D检测结果未知".Translated();
|
|||
|
|
resNum = resNum + 4;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
strErr = strErr.TrimEnd(',');
|
|||
|
|
return (ushort)resNum;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 结果数据上传
|
|||
|
|
/// <summary>
|
|||
|
|
/// 结果数据上传
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="list"></param>
|
|||
|
|
private async Task UpProducResultParamAsync(List<BGearEntity> listBger)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var swTotal = Stopwatch.StartNew();
|
|||
|
|
LogHelper.Instance.WriteLog($"UpProducResultParam-enter", "A出站");
|
|||
|
|
if (listBger != null && listBger.Count > 0)
|
|||
|
|
{
|
|||
|
|
foreach (BGearEntity m in listBger)
|
|||
|
|
{
|
|||
|
|
if (m.BarCode != "NG" && m.BarCode != "ERROR" && m.BarCode != "")
|
|||
|
|
{
|
|||
|
|
var sw2 = Stopwatch.StartNew();
|
|||
|
|
string dateStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|||
|
|
var (success, message) = await CommonMethods.hbgMes.ProducResultParamAsync(CommonMethods.mesConfig.ProductResultParams, CommonMethods.mesConfig.siteCode, CommonMethods.mesConfig.lineCode,
|
|||
|
|
CommonMethods.mesConfig.equipNum, CommonMethods.mesConfig.MaterialCode, CommonMethods.mesConfig.mesUserName, m, MesUploadType.DD, dateStr);
|
|||
|
|
sw2.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"ProducResultParamAsync m.BarCode={m.BarCode} 耗时{sw2.ElapsedMilliseconds}ms");
|
|||
|
|
if (!success)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"条码: {m.BarCode}, 结果数据上传失败, {message}", "系统报错");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m.Flag1 = "1";
|
|||
|
|
var sw = Stopwatch.StartNew();
|
|||
|
|
int a = await CommonMethods.db.UpdateSingleAsync(m, it => new BGearEntity() { Flag1 = m.Flag1 }, it => it.BarCode == m.BarCode);
|
|||
|
|
sw.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"UpdateSingleAsync Flag1 耗时{sw.ElapsedMilliseconds}ms");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
swTotal.Stop();
|
|||
|
|
LogHelper.Instance.WriteLog($"UpProducResultParamAsync 总 耗时{swTotal.ElapsedMilliseconds}ms");
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"结果数据上传失败, 原因: {ex}", "系统报错");
|
|||
|
|
//throw new Exception(ex.ToString());
|
|||
|
|
}
|
|||
|
|
LogHelper.Instance.WriteError($"UpProducResultParam-end", "A出站");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 判断CCD结果
|
|||
|
|
private bool GetCcdResult(BGearEntity m)
|
|||
|
|
{
|
|||
|
|
if (m.CCDNegativeTerminalWeldingZone2DInspectionResult.Contains("NG") || m.CCDNegativeTerminalWeldingZone25DInspectionResult.Contains("NG")
|
|||
|
|
|| m.CCDCoverPlate2DInspectionResult.Contains("NG") || m.CCDCoverPlate25DInspectionResult.Contains("NG") || m.CCDTerminalPost2DInspectionResult.Contains("NG")
|
|||
|
|
|| m.CCDTerminalPost3DInspectionResult.Contains("NG") || m.CCDSealingNail2DInspectionResult.Contains("NG") || m.CCDSealingNail3DInspectionResult.Contains("NG")
|
|||
|
|
|| m.CCDTopFillet25DInspectionResult.Contains("NG") || m.CCDBottomFillet25DInspectionResult.Contains("NG") || m.CCDCylindricalSurface25DInspectionResult.Contains("NG")
|
|||
|
|
|| m.CCDCylindricalSurface3DInspectionResult.Contains("NG"))
|
|||
|
|
{ return false; }
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据组合
|
|||
|
|
private bool GetDataCombine(BGearEntity m, MesResType mesResType, string mesMesage, ref short res, ref string result, ref string remark, ref string flag)
|
|||
|
|
{
|
|||
|
|
#region 数据组合
|
|||
|
|
|
|||
|
|
if (String.IsNullOrEmpty(m.BarCode) || m.BarCode.Trim() == "ERROR" || !IsAlphaNumeric(m.BarCode))
|
|||
|
|
{
|
|||
|
|
res = 2;
|
|||
|
|
result = "NG";
|
|||
|
|
m.Info = "电芯码不良".Translated();
|
|||
|
|
flag = "2";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// 本地判断OK,MES判断OK
|
|||
|
|
if (result == "OK" && mesResType == MesResType.D)
|
|||
|
|
{
|
|||
|
|
result += ",MES OK";
|
|||
|
|
m.Info = "良品".Translated();
|
|||
|
|
res = 1;
|
|||
|
|
flag = "1";
|
|||
|
|
}
|
|||
|
|
// 本地判断OK,MES判断NG
|
|||
|
|
else if (result == "OK" && mesResType != MesResType.D)
|
|||
|
|
{
|
|||
|
|
switch (mesResType)
|
|||
|
|
{
|
|||
|
|
case MesResType.A: // 停线,设备报警停机
|
|||
|
|
result += ",MES NG";
|
|||
|
|
remark += $"A,{mesMesage}";
|
|||
|
|
res = 3;//10
|
|||
|
|
flag = "2";
|
|||
|
|
break;
|
|||
|
|
case MesResType.B: // MES不良
|
|||
|
|
result += ",MES NG";
|
|||
|
|
remark += $"B,{mesMesage}";
|
|||
|
|
res = 3;//9
|
|||
|
|
flag = "2";
|
|||
|
|
break;
|
|||
|
|
case MesResType.C: // 警示
|
|||
|
|
result += ",MES OK"; // MES认为是可以当成良品流下去的
|
|||
|
|
remark += $"Alarm:{mesMesage}";
|
|||
|
|
res = 1;
|
|||
|
|
flag = "1";
|
|||
|
|
break;
|
|||
|
|
case MesResType.D: // 条码上传OK
|
|||
|
|
result += ",MES OK";
|
|||
|
|
remark += $"D,{mesMesage}";
|
|||
|
|
res = 1;
|
|||
|
|
flag = "1";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
result += ",MES NG";
|
|||
|
|
remark += $"{mesMesage}";
|
|||
|
|
res = 3;//9
|
|||
|
|
flag = "2";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// 本地判断NG,MES判断OK
|
|||
|
|
else if (result == "NG" && mesResType == MesResType.D)
|
|||
|
|
{
|
|||
|
|
result += ",MES OK";
|
|||
|
|
remark += $"D,{mesMesage}";
|
|||
|
|
res = 1;
|
|||
|
|
flag = "1";
|
|||
|
|
}
|
|||
|
|
// 本地判断NG,MES判断NG
|
|||
|
|
else if (result == "NG" && mesResType != MesResType.D)
|
|||
|
|
{
|
|||
|
|
result += ",MES NG";
|
|||
|
|
remark += $"{mesResType.ToString()},{mesMesage}";
|
|||
|
|
res = 3;//9
|
|||
|
|
flag = "2";
|
|||
|
|
}
|
|||
|
|
// 其他情况
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result += ",MES NG";
|
|||
|
|
remark += mesMesage;
|
|||
|
|
res = 3;//9
|
|||
|
|
flag = "2";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 结构件料盘工位(数据处理)
|
|||
|
|
/// <summary>
|
|||
|
|
/// 结构件料盘工位
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="resByte"></param>
|
|||
|
|
/// <param name="plcModel"></param>
|
|||
|
|
///
|
|||
|
|
|
|||
|
|
private async Task MaterialStation(JYResult<byte[]> bArrays, object plcModel)
|
|||
|
|
{
|
|||
|
|
PlcGroup pf = plcModel as PlcGroup;
|
|||
|
|
var sw = new Stopwatch();
|
|||
|
|
if (bArrays.IsSuccess && bArrays.Content != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
sw.Restart();
|
|||
|
|
#region 初始化数据
|
|||
|
|
List<DGearEntity> list = new List<DGearEntity>();//实体
|
|||
|
|
List<string> listMaterialCode = GetList<string>(1, "");//料盘码
|
|||
|
|
List<short> listRes = GetList<short>(1, 1);//默认为1,良品
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 数据解析
|
|||
|
|
byte[] bytes = bArrays.Content.ByteReverse();
|
|||
|
|
for (int i = 0; i < listMaterialCode.Count; i++)
|
|||
|
|
{
|
|||
|
|
listMaterialCode[i] = StringLib.GetStringFromByteArrayByEncoding(bytes, i * 40, 39, System.Text.Encoding.ASCII).
|
|||
|
|
Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
for (int i = 0; i < listMaterialCode.Count; i++)
|
|||
|
|
{
|
|||
|
|
DGearEntity m = new DGearEntity();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
switch (pf.GroupName)
|
|||
|
|
{
|
|||
|
|
case "结构件料盘B":
|
|||
|
|
m.ChannelNo = 1;
|
|||
|
|
break;
|
|||
|
|
case "结构件料盘D":
|
|||
|
|
m.ChannelNo = 2;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
m.TestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|||
|
|
m.MaterialCode = listMaterialCode[i];
|
|||
|
|
m.MaterialCodes = CommonMethods.mesConfig.MaterialCode;
|
|||
|
|
m.EquipNum = CommonMethods.mesConfig.equipNum;
|
|||
|
|
m.Flag = 0;
|
|||
|
|
if (String.IsNullOrEmpty(m.MaterialCode) || m.MaterialCode.Trim() == "ERROR" || m.MaterialCode.Trim() == "NG")
|
|||
|
|
{
|
|||
|
|
m.MaterialCode = "NG";
|
|||
|
|
m.Result = "NG";
|
|||
|
|
m.Remark = "料盘码不良";
|
|||
|
|
listRes[i] = 2;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m.Result = "OK";
|
|||
|
|
m.Remark = "良品";
|
|||
|
|
#region MES对接
|
|||
|
|
if (CommonMethods.sysConfig.MesModeSwitching && CommonMethods.mesConfig.isConnected)
|
|||
|
|
{
|
|||
|
|
var (mesRes, Mesage, mesResType) = await CommonMethods.hbgMes.RawMaterialStationAsync(CommonMethods.mesConfig.MaterialInputInfo,
|
|||
|
|
CommonMethods.mesConfig.MaterialCode, CommonMethods.mesConfig.equipNum, m.MaterialCode);
|
|||
|
|
|
|||
|
|
if (mesRes) //调用接口成功
|
|||
|
|
{
|
|||
|
|
m.Flag = 1;
|
|||
|
|
//本地判断OK,MES判断OK
|
|||
|
|
if (m.Result == "OK" && mesResType == MesResType.D)
|
|||
|
|
{
|
|||
|
|
m.Result = "OK";
|
|||
|
|
m.Remark = m.Remark + Mesage;
|
|||
|
|
listRes[i] = 1;
|
|||
|
|
}
|
|||
|
|
//本地判断OK,MES判断NG
|
|||
|
|
else if (m.Result == "OK" && mesResType != MesResType.D)
|
|||
|
|
{
|
|||
|
|
switch (mesResType)
|
|||
|
|
{
|
|||
|
|
case MesResType.B:
|
|||
|
|
m.Result = "MES NG";
|
|||
|
|
m.Remark = $"{Mesage}";
|
|||
|
|
listRes[i] = 9;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
m.Result = "MES NG";
|
|||
|
|
m.Remark = $"{Mesage}";
|
|||
|
|
listRes[i] = 9;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//其他情况
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m.Result = " MES NG";
|
|||
|
|
m.Remark = Mesage;
|
|||
|
|
listRes[i] = 9;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m.Result = " MES NG";
|
|||
|
|
m.Remark = Mesage;
|
|||
|
|
listRes[i] = 9;
|
|||
|
|
if (Mesage.Contains("接口调用失败"))
|
|||
|
|
{
|
|||
|
|
listRes[i] = 10;
|
|||
|
|
CommonMethods.AddLog(false, $"原材料上传失败,请联系IT人员检查MES网络或服务器");
|
|||
|
|
LogHelper.Instance.WriteLog($"原材料上传失败,请联系IT人员检查MES网络或服务器", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
list.Add(m);
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"结构件料盘线程数据解析:{ex}", "系统报错");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
JYResult result1 = CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue(pf.VarList[2].VarAddress, listRes.ToArray(), PLC.DataType.ArrShort);//判断结果写入PLC
|
|||
|
|
|
|||
|
|
JYResult result3 = CommonMethods.plcDevices[pf.PlcNum - 1].WriteValue(pf.VarList[0].VarAddress, 0);//置位
|
|||
|
|
//数据存储 -异步处理
|
|||
|
|
|
|||
|
|
await SaveMaterialData(list);
|
|||
|
|
|
|||
|
|
sw.Stop();
|
|||
|
|
////输出上料数据处理耗时:
|
|||
|
|
CommonMethods.AddDataMonitorLog(0, $"结构件料盘线程共耗时:{sw.ElapsedMilliseconds}ms");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 结构件料盘保存
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="list"></param>
|
|||
|
|
private Task SaveMaterialData(List<DGearEntity> list)
|
|||
|
|
{
|
|||
|
|
//数据的保存
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (list != null && list.Count > 0)
|
|||
|
|
{
|
|||
|
|
string strRes = "";
|
|||
|
|
foreach (DGearEntity m in list)
|
|||
|
|
{
|
|||
|
|
if (m.MaterialCode != "NG")
|
|||
|
|
{
|
|||
|
|
//bool b1 = await CommonMethods.db.AddReturnBoolAsync<DGearEntity>(m);
|
|||
|
|
//strRes = b1 ? ",本存Yes" : ",本存No";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strRes = ",不存储";
|
|||
|
|
}
|
|||
|
|
m.Remark = m.Remark + strRes;
|
|||
|
|
}
|
|||
|
|
//数据显示
|
|||
|
|
CommonMethods.ShowMaterialDelegate.Invoke(list);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"结构件料盘数据List为空", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"结构件料盘保存处理异常:{ex}", "SysErrorLog");
|
|||
|
|
}
|
|||
|
|
return Task.CompletedTask;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 创建空的数组List
|
|||
|
|
public List<T> GetList<T>(int num, T data)
|
|||
|
|
{
|
|||
|
|
List<T> list = new List<T>();
|
|||
|
|
for (int i = 0; i < num; i++)
|
|||
|
|
{
|
|||
|
|
list.Add(data);
|
|||
|
|
}
|
|||
|
|
return list;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<MesResType> GetMesType(int Num)
|
|||
|
|
{
|
|||
|
|
List<MesResType> mesResTypes = new List<MesResType>();
|
|||
|
|
for (int i = 0; i < Num; i++)
|
|||
|
|
{
|
|||
|
|
mesResTypes.Add(MesResType.UnKnow);
|
|||
|
|
}
|
|||
|
|
return mesResTypes;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// PLC内批量写\0
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="Num"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public string GetString_0(int Num)
|
|||
|
|
{
|
|||
|
|
string ff = "";
|
|||
|
|
for (int i = 0; i < Num; i++)
|
|||
|
|
{
|
|||
|
|
ff = ff.Insert(ff.Length, "\0");
|
|||
|
|
}
|
|||
|
|
return ff;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string GetBarCodeNum(int Num)
|
|||
|
|
{
|
|||
|
|
string CodeNo = "";
|
|||
|
|
int CodeLenth = Num.ToString().Length;
|
|||
|
|
|
|||
|
|
switch (CodeLenth)
|
|||
|
|
{
|
|||
|
|
case 1:
|
|||
|
|
return CodeNo = $"00000{Num}";
|
|||
|
|
case 2:
|
|||
|
|
return CodeNo = $"0000{Num}";
|
|||
|
|
case 3:
|
|||
|
|
return CodeNo = $"000{Num}";
|
|||
|
|
case 4:
|
|||
|
|
return CodeNo = $"00{Num}";
|
|||
|
|
case 5:
|
|||
|
|
return CodeNo = $"0{Num}";
|
|||
|
|
default:
|
|||
|
|
return CodeNo = $"{Num}";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 检测数据是否只包含字母加数字
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="input"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool IsAlphaNumeric(string input)
|
|||
|
|
{
|
|||
|
|
// 使用正则表达式检查是否只包含字母和数字
|
|||
|
|
return Regex.IsMatch(input, "^[a-zA-Z0-9]+$");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region 方法
|
|||
|
|
/// <summary>
|
|||
|
|
/// 下料数据保存本地
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="strData"></param>
|
|||
|
|
private void BlankingDataSaveLocal(string strData)
|
|||
|
|
{
|
|||
|
|
#region
|
|||
|
|
string savePath = string.Format(@"{0}\{1}\{2}\{3}\", @"D:\LocalData", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
|
|||
|
|
bool acquiredLock = false;
|
|||
|
|
Monitor.TryEnter(FileLock, ref acquiredLock);
|
|||
|
|
|
|||
|
|
if (!Directory.Exists(savePath))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(savePath);
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (acquiredLock)
|
|||
|
|
{
|
|||
|
|
string strFileName = System.DateTime.Now.ToString("yyyyMMdd") + ".csv";//yyyyMMdd.csv
|
|||
|
|
|
|||
|
|
if (!File.Exists(savePath + strFileName)) //如果文件不存在,创建文件,并保存到本地
|
|||
|
|
{
|
|||
|
|
string strProlnfoFileHead = string.Empty;
|
|||
|
|
foreach (var item in CommonMethods.m_DBCtrl.HeaderTextOut)
|
|||
|
|
{
|
|||
|
|
strProlnfoFileHead += item + ",";
|
|||
|
|
}
|
|||
|
|
strProlnfoFileHead = strProlnfoFileHead.TrimEnd(',');
|
|||
|
|
|
|||
|
|
strProlnfoFileHead = strProlnfoFileHead.Substring(strProlnfoFileHead.IndexOf(',') + 1);
|
|||
|
|
|
|||
|
|
StreamWriter sw = new StreamWriter(savePath + strFileName, true, Encoding.GetEncoding("GB2312"));
|
|||
|
|
sw.WriteLine(strProlnfoFileHead);
|
|||
|
|
sw.WriteLine(strData);
|
|||
|
|
|
|||
|
|
sw.Flush();
|
|||
|
|
sw.Close();
|
|||
|
|
sw.Dispose();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
StreamWriter sw = new StreamWriter(savePath + strFileName, true, Encoding.GetEncoding("GB2312"));
|
|||
|
|
sw.WriteLine(strData);
|
|||
|
|
|
|||
|
|
sw.Flush();
|
|||
|
|
sw.Close();
|
|||
|
|
sw.Dispose();
|
|||
|
|
}
|
|||
|
|
Monitor.Exit(FileLock);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelper.Instance.WriteError($"下料数据保存异常:{ex}", "SysErrorLog");
|
|||
|
|
if (acquiredLock)
|
|||
|
|
{ Monitor.Exit(FileLock); }
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 批量保存本地数据
|
|||
|
|
/// </summary>
|
|||
|
|
private void BlankingDataSaveLocalBatch(List<string> lines)
|
|||
|
|
{
|
|||
|
|
if (lines == null || lines.Count == 0) return;
|
|||
|
|
|
|||
|
|
string savePath = string.Format(@"{0}\{1}\{2}\{3}\", @"D:\LocalData", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
|
|||
|
|
string strFileName = DateTime.Now.ToString("yyyyMMdd") + ".csv";
|
|||
|
|
|
|||
|
|
if (!Directory.Exists(savePath))
|
|||
|
|
Directory.CreateDirectory(savePath);
|
|||
|
|
|
|||
|
|
string fullPath = Path.Combine(savePath, strFileName);
|
|||
|
|
|
|||
|
|
lock (FileLock)
|
|||
|
|
{
|
|||
|
|
bool isNewFile = !File.Exists(fullPath);
|
|||
|
|
using (var sw = new StreamWriter(fullPath, true, Encoding.GetEncoding("GB2312")))
|
|||
|
|
{
|
|||
|
|
if (isNewFile)
|
|||
|
|
{
|
|||
|
|
// 写入表头
|
|||
|
|
var header = string.Join(",", CommonMethods.m_DBCtrl.HeaderTextOut);
|
|||
|
|
header = header.Substring(header.IndexOf(',') + 1);
|
|||
|
|
sw.WriteLine(header);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (var line in lines)
|
|||
|
|
{
|
|||
|
|
sw.WriteLine(line);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 电池结果辅助方法
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private string GetNGReasons(int value, string reasonCode)
|
|||
|
|
{
|
|||
|
|
// 只有当值为2时才返回原因代码,否则返回空字符串
|
|||
|
|
return value == 2 ? reasonCode : string.Empty;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 组合多个NG原因字段
|
|||
|
|
private string CombineNGReasons(params string[] reasons)
|
|||
|
|
{
|
|||
|
|
// 过滤空值并连接
|
|||
|
|
var validReasons = reasons
|
|||
|
|
.Where(r => !string.IsNullOrEmpty(r))
|
|||
|
|
.Distinct(); // 去重
|
|||
|
|
|
|||
|
|
return string.Join(",", validReasons);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|