800 lines
40 KiB
C#
800 lines
40 KiB
C#
|
||
using JinYuan.CommunicationLib.Enum;
|
||
using JinYuan.DataConvertLib;
|
||
using JinYuan.Helper;
|
||
using JinYuan.MES.Enums;
|
||
using JinYuan.MES.Models;
|
||
using JinYuan.Models;
|
||
using JinYuan.VirtualDataLibrary;
|
||
using PLCCommunication;
|
||
using SqlSugar;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Diagnostics;
|
||
using System.Diagnostics.Eventing.Reader;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
|
||
|
||
namespace JinYuan.ControlCenters
|
||
{
|
||
public partial class ControlCenter
|
||
{
|
||
|
||
#region 上料工位(数据处理)
|
||
/// <summary>
|
||
/// 上料工位
|
||
/// </summary>
|
||
int JXCount = 0;
|
||
|
||
Stopwatch sw2 = new Stopwatch();
|
||
//上料解析
|
||
private void FeedingStation(JYResult<byte[]> bArrays, object plcModel)
|
||
{
|
||
Group pf = plcModel as Group;
|
||
if(bArrays==null)
|
||
{
|
||
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
||
CommonMethods.AddLog(false, $"电芯进站PLC有触发信号,但无数据!");
|
||
LogHelper.Instance.WriteLog($"电芯进站PLC有触发信号,但无数据!", "Info");
|
||
}
|
||
if (bArrays.IsSuccess && bArrays.Content != null)
|
||
{
|
||
sw2.Restart();
|
||
//解析数据
|
||
List<AGearEntity> list = new List<AGearEntity>();//实体
|
||
List<string> listBarCode = GetList<string>(4, "");//电芯条码
|
||
//List<string> listNum = GetList<string>(1, "");//进站磁悬浮动子编号
|
||
List<short> listRes = GetList<short>(4, 0);//进站电芯反馈结果
|
||
|
||
byte[] bytes = bArrays.Content.ByteReverse();//高低位转换
|
||
|
||
// 从D2100开始
|
||
#region 数据解析
|
||
//电芯反馈结果
|
||
listRes[0] = ShortLib.GetShortFromByteArray(bArrays.Content, 0, DataFormat.CDAB);
|
||
listRes[1] = ShortLib.GetShortFromByteArray(bArrays.Content, 0 + 2, DataFormat.CDAB);
|
||
listRes[2] = ShortLib.GetShortFromByteArray(bArrays.Content, 0 + 4, DataFormat.CDAB);
|
||
listRes[3] = ShortLib.GetShortFromByteArray(bArrays.Content, 0 + 6, DataFormat.CDAB);
|
||
|
||
//电芯条码
|
||
//从bytes读取第二位参数到第三位参数的内容 0-19 第四位参数为格式 第五位为规则
|
||
listBarCode[0] = StringLib.GetStringFromByteArrayByEncoding(bytes, 200, 40, System.Text.Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
||
listBarCode[1] = StringLib.GetStringFromByteArrayByEncoding(bytes, 240, 40, System.Text.Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
||
listBarCode[2] = StringLib.GetStringFromByteArrayByEncoding(bytes, 280, 40, System.Text.Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
||
listBarCode[3] = StringLib.GetStringFromByteArrayByEncoding(bytes, 320, 40, System.Text.Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
||
//listBarCode[0] = "5590101D14E9400002";
|
||
//listBarCode[1] = "5590101D14E9400001";
|
||
//listBarCode[2] = "5590101D14E9400002";
|
||
//listBarCode[3] = "5590101D14E9400001";
|
||
|
||
List<string> MesMessage = new List<string>();
|
||
List<MesResType> mesResType = new List<MesResType>();
|
||
if (CommonMethods.mesConfig.isUpMes)
|
||
{
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
List<string> listBar = new List<string>();
|
||
//foreach (var e in listBarCode)
|
||
//{
|
||
// listBar.Add(e);
|
||
//}
|
||
listBar.Add(listBarCode[i]);
|
||
string url = CommonMethods.mesConfig.InPutStationMesUrl;
|
||
string siteCode = CommonMethods.mesConfig.siteCode;
|
||
string lineCode = CommonMethods.mesConfig.lineCode;
|
||
string equipNum = CommonMethods.mesConfig.equipNum;
|
||
string materialCode = CommonMethods.mesConfig.MaterialCode;
|
||
string userName = CommonMethods.mesConfig.mesUserName;
|
||
//int type = 1;
|
||
//string materialLotCodeLocator = "";
|
||
string MesMessage1 ="";
|
||
MesResType mesResType1 =MesResType.A;
|
||
|
||
bool Res = CommonMethods.hbgMes.SingleCellInStation(url, siteCode, lineCode, equipNum, materialCode, userName, listBar[0], ref MesMessage1, ref mesResType1);
|
||
if (Res)
|
||
{
|
||
listRes[0] = 1;
|
||
listRes[1] = 1;
|
||
listRes[2] = 1;
|
||
listRes[3] = 1;
|
||
}
|
||
else
|
||
{
|
||
for (int j = 0; j < 4; j++)
|
||
{
|
||
switch (mesResType1)
|
||
{
|
||
case MesResType.A:// 停线,设备报警停机
|
||
listRes[j] = 10;
|
||
break;
|
||
case MesResType.B:
|
||
listRes[j] = 9;
|
||
break;
|
||
case MesResType.C:
|
||
listRes[j] = 1;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
try
|
||
{
|
||
AGearEntity m = new AGearEntity();
|
||
//m.MaglevNum = listNum[0];
|
||
m.ID = i + 1;
|
||
m.CNum = "i";
|
||
m.TestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
m.BarCode = listBarCode[i];
|
||
m.Result = listRes[i];
|
||
m.Remark = "无";
|
||
list.Add(m);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError($"卷芯进站线程数据解析:{ex}", "SysErrorLog");
|
||
}
|
||
}
|
||
#endregion
|
||
{
|
||
//for (int i = 0; i < 2; i++)
|
||
//{
|
||
// AGearEntity m = new AGearEntity();
|
||
// try
|
||
// {
|
||
// m.ChannelNo = i + 1;
|
||
// m.TestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
// m.DiRFID = listDiRFID[i];
|
||
// m.GaoRFID = listGaoRFID[i];
|
||
// m.YaLiValue = Convert.ToDecimal(listYaLiValue[i].ToString("f3"));
|
||
// if (listBuPing[i] == 0)
|
||
// {
|
||
// m.DiRFID = "NG";
|
||
// m.GaoRFID = "NG";
|
||
// m.BarCode = "NG";
|
||
// m.Result = "NOT";
|
||
// m.Remark = "无部品状态";
|
||
// listRes[i] = 10;
|
||
// }
|
||
// else //有部品状态
|
||
// {
|
||
// if (String.IsNullOrEmpty(m.DiRFID) || m.DiRFID.Trim() == "ERROR") //地托杯没码
|
||
// {
|
||
// m.DiRFID = "NG";
|
||
// m.BarCode = "NG";
|
||
// m.Result = "NG";
|
||
// m.Remark = "低托杯码NG";
|
||
// listRes[i] = 3;
|
||
// }
|
||
// else
|
||
// {
|
||
// //从服务器数据库以托杯码获取卷芯码——————————————————
|
||
// var result3 = CommonMethods.dbServer.Query<DataTurnover>(it => it.containerCode == m.DiRFID);
|
||
// if (result3 != null)
|
||
// {
|
||
// m.BarCode = result3.identification.ToString();
|
||
// if (m.BarCode.Trim() == "NoCode" || m.BarCode.Trim() == "NG" || m.BarCode.Trim() == "ERROR" || m.BarCode.Trim() == "" || m.BarCode.Trim() == "0000000000000000")
|
||
// {
|
||
// m.Result = "NG";
|
||
// m.BarCode = "NG";
|
||
// m.Remark = "上工序卷芯码异常";
|
||
// listRes[i] = 2;
|
||
// }
|
||
// else
|
||
// {
|
||
// if (String.IsNullOrEmpty(m.GaoRFID) || m.GaoRFID.Trim() == "ERROR")
|
||
// {
|
||
// m.GaoRFID = "NG";
|
||
// m.Result = "NG";
|
||
// m.Remark = "高托杯码NG";
|
||
// listRes[i] = 3;
|
||
// }
|
||
// else
|
||
// {
|
||
// m.Result = "OK";
|
||
// m.Remark = "良品";
|
||
|
||
// string strErr = "";
|
||
// listRes[i] = GetResult(m, ref strErr);
|
||
// m.Result = listRes[i] == 1 ? "OK" : "NG";
|
||
// listRes[i] = 1;
|
||
// }
|
||
// }
|
||
// }
|
||
// else
|
||
// {
|
||
// m.BarCode = "NG";
|
||
// m.Result = "NG";
|
||
// m.Remark = "未查询到此托杯码";
|
||
// listRes[i] = 4;
|
||
// }
|
||
// }
|
||
// }
|
||
// list.Add(m);
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// LogHelper.Instance.WriteError($"卷芯进站线程数据解析:{ex}", "SysErrorLog");
|
||
// }
|
||
//}
|
||
}
|
||
//写入·结果反馈
|
||
JYResult result = CommonMethods.PlcLink.WriteValue("D2010", listRes.ToArray(), Data_Type.ArrShort);//判断结果写入PLC
|
||
if (result != null)
|
||
{
|
||
string strres = $"卷心工位发送给PLC: D2010={listRes[0]},D2011={listRes[1]},D2012={listRes[2]},D2013={listRes[3]},";
|
||
CommonMethods.AddDataMonitorLog(0, strres);
|
||
}
|
||
|
||
//读取结果显示
|
||
//数据存储 -异步处理
|
||
Task.Run(() =>{ SaveFeedingData(list); });
|
||
|
||
|
||
sw2.Stop();
|
||
////输出上料数据处理耗时:
|
||
CommonMethods.AddDataMonitorLog(0, $"卷芯进站共耗时:{sw2.Elapsed.TotalMilliseconds}ms");
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
#region 保存上料数据
|
||
/// <summary>
|
||
/// 保存上料数据到数据
|
||
/// </summary>
|
||
/// <param name="list"></param>
|
||
private void SaveFeedingData(List<AGearEntity> list)
|
||
{
|
||
//数据的保存
|
||
try
|
||
{
|
||
if (list != null && list.Count > 0)
|
||
{
|
||
//数据显示
|
||
List<AGearEntity> Blist = list;
|
||
int i = 0;
|
||
string strRes = "";
|
||
foreach (AGearEntity m in list)
|
||
{
|
||
if (true)
|
||
{
|
||
//int b1 = CommonMethods.dbServer.Delete<DataTurnover>(it => it.containerCode == m.DiRFID);
|
||
Thread.Sleep(10);
|
||
//int b2 = CommonMethods.dbServer.Delete<DataTurnover>(it => it.containerCode == m.GaoRFID);
|
||
|
||
//int b1 = CommonMethods.dbServer.Delete<DataTurnover>(it => it.containerCode == m.BarCode);
|
||
|
||
bool b = CommonMethods.db.AddReturnBool<AGearEntity>(m);
|
||
|
||
//strRes = b1 > 0 ? ",远删Yes" : ",远删No";
|
||
strRes += b;
|
||
|
||
DataTurnover server = new DataTurnover
|
||
{
|
||
equipNum = CommonMethods.mesConfig.equipNum,
|
||
containerCode = m.BarCode,
|
||
identification = m.BarCode,
|
||
message = m.Result,
|
||
Time = DateTime.Now,
|
||
};
|
||
|
||
try
|
||
{
|
||
//bool res = CommonMethods.dbServer.AddReturnBool<DataTurnover>(server);
|
||
//strRes += res == true ? ",远存Yes" : ",远存No";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
JYResult result = CommonMethods.PlcLink.WriteValue("D80", 1, Data_Type.Short);//反馈PLC结果
|
||
CommonMethods.AddDataMonitorLog(1, $"服务器连接失败!解决办法:1、请检查MES网络,2、查看服务器是否正常!!");
|
||
LogHelper.Instance.WriteError($"服务器连接失败:{ex}", "系统报错");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
strRes = ",不存储";
|
||
}
|
||
//m.Remark = m.Remark + strRes;
|
||
Blist[i].Remark = m.Remark;
|
||
i++;
|
||
}
|
||
//数据显示
|
||
CommonMethods.ShowFeedingDelegate.Invoke(Blist);
|
||
}
|
||
else
|
||
{
|
||
LogHelper.Instance.WriteError($"电芯进站数据List为空", "SysErrorLog");
|
||
}
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError($"卷芯上料保存处理异常:{ex}", "SysErrorLog");
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region 下料工位(数据处理)
|
||
//int OutCount = 0;
|
||
//下料解析
|
||
private void BlankingStation(JYResult<byte[]> bArrays, object plcModel)
|
||
{
|
||
Group pf = plcModel as Group;
|
||
if (bArrays == null)
|
||
{
|
||
CommonMethods.PlcLink.WriteInt16(pf.VarList[0].VarAddress, 0);//置位0
|
||
CommonMethods.AddLog(false, $"电芯出站PLC有触发信号,但无数据!");
|
||
LogHelper.Instance.WriteLog($"电芯出站PLC有触发信号,但无数据!", "SysErrorLog");
|
||
}
|
||
if (bArrays.IsSuccess && bArrays.Content != null)
|
||
{
|
||
Random random = new Random();
|
||
//解析数据
|
||
sw2.Restart();
|
||
#region 数据变量定义
|
||
List<BGearEntity> list = new List<BGearEntity>();//实体
|
||
short[] MyRes = new short[2];//AB反馈结果
|
||
//List<string> ScanTime = GetList<string>(2,"");//AB芯包扫码时间
|
||
//List<string> listBatCode = GetList<string>(2,"");//AB芯包条码
|
||
//List<short> list_Data1 = GetList<short>(23, 0);//芯包信息1
|
||
//List<List<short>> List_list_Data1 = GetList<List<short>>(2, list_Data1);//AB芯包信息1列表
|
||
//List<short> list_CutNO = GetList<short>(2, 0);//电芯极耳切刀编号
|
||
//List<List<short>> List_list_CutNO = GetList<List<short>>(2, list_CutNO);//电芯极耳切刀编号列表
|
||
//List<string> list_Process = GetList<string>(5, "");//电芯工序信息
|
||
//List<List<string>> List_list_Process = GetList<List<string>>(2, list_Process);//AB电芯工序信息列表
|
||
//List<float> list_Data2 = GetList<float>(65, 0);//芯包信息2
|
||
//List<List<float>> List_list_Data2 = GetList<List<float>>(2, list_Data2);//AB芯包信息2列表
|
||
|
||
#endregion
|
||
//高低位转换
|
||
byte[] bytes = bArrays.Content.ByteReverse();
|
||
byte[] bytes1 = bArrays.Content;
|
||
//反馈结果
|
||
#region 电芯解析
|
||
//D3100起
|
||
//电芯解析
|
||
#region 上传MES
|
||
|
||
for (int i = 0; i < 2; i++)
|
||
{
|
||
try
|
||
{
|
||
BGearEntity m = new BGearEntity();
|
||
if (i == 0)
|
||
{
|
||
//序号
|
||
for(int j = 0; j < 2; j++)
|
||
{
|
||
m.MyNo[j] = j + 1;
|
||
}
|
||
//A芯包信息1 D3240~D3262
|
||
for (int j = 0; j < 23; j++)
|
||
{
|
||
m.list_Data1[i,j] = ShortLib.GetShortFromByteArray(bArrays.Content, 280 + j * 2, DataFormat.CDAB);
|
||
}
|
||
//A电芯极耳切刀编号 D3263~D3265
|
||
for (int j = 0; j < 2; j++)
|
||
{
|
||
m.list_CutNO[i, j] = ShortLib.GetShortFromByteArray(bArrays.Content, 326 + j * 4, DataFormat.CDAB);
|
||
}
|
||
//A电芯工序信息 D3267~D3273
|
||
for (int j = 0; j < 4; j++)
|
||
{
|
||
m.list_Process[i, j] = StringLib.GetStringFromByteArrayByEncoding(bytes, 334 + 4 * j, 4, System.Text.Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
||
}
|
||
//电芯A异常反馈信息
|
||
m.list_Process[i, 3] = "";
|
||
|
||
//A芯包信息2 D3278~D3406
|
||
for (int j = 0; j < 64; j++)
|
||
{
|
||
m.list_Data2[i,j] = FloatLib.GetFloatFromByteArray(bArrays.Content, 356 + j * 4, DataFormat.CDAB);
|
||
}
|
||
//A芯包背面极耳撕裂裂纹检测结果(mm)
|
||
m.list_Data2[i, 64] = FloatLib.GetFloatFromByteArray(bArrays.Content, 350, DataFormat.CDAB);
|
||
}
|
||
else
|
||
{
|
||
//B芯包信息1 D3407~D3429
|
||
for (int j = 0; j < 23; j++)
|
||
{
|
||
m.list_Data1[i, j] = ShortLib.GetShortFromByteArray(bArrays.Content, 614 + j * 2, DataFormat.CDAB);
|
||
}
|
||
//B电芯极耳切刀编号 D3431~D3433
|
||
for (int j = 0; j < 2; j++)
|
||
{
|
||
m.list_CutNO[i, j] = ShortLib.GetShortFromByteArray(bArrays.Content, 662 + j * 4, DataFormat.CDAB);
|
||
}
|
||
//B电芯工序信息 D3435~D3443
|
||
for (int j = 0; j < 5; j++)
|
||
{
|
||
m.list_Process[i, j] = StringLib.GetStringFromByteArrayByEncoding(bytes, 670 + 4 * j, 4, System.Text.Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
||
}
|
||
//B芯包信息2 D3445~D3573
|
||
for (int j = 0; j < 65; j++)
|
||
{
|
||
m.list_Data2[i, j] = FloatLib.GetFloatFromByteArray(bArrays.Content, 690 + j * 4, DataFormat.CDAB);
|
||
}
|
||
}
|
||
//芯包扫码时间
|
||
m.ScanTime[i] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
//芯包条码 D3200~D3239
|
||
m.listBatCode[i] = StringLib.GetStringFromByteArrayByEncoding(bytes, 200 + 40 * i, 40, System.Text.Encoding.ASCII).Replace('\0', ' ').Replace('\r', ' ').Replace(" ", "").Trim();
|
||
|
||
m.ChannelNo = m.MyNo[i];
|
||
//m.TestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
m.Result = 1; //反馈结果,需要上位机->PLC,D3100和D3101
|
||
m.CSBYHASCANNINGTIME = m.ScanTime[i];
|
||
m.CSBYHCODEA = m.listBatCode[i];
|
||
m.CSBYHWEIGHTNOA1 = m.list_Data1[i, 0];
|
||
m.CSBYHWEIGHTRESULTA1 = m.list_Data1[i, 1];
|
||
m.RingA = m.list_Data1[i, 2];
|
||
m.CSBYHTHICKNESSTESTSTATIONNOA = m.list_Data1[i, 3];
|
||
m.CSBYHTHICKNESSTESTJUDGERESULTA = m.list_Data1[i, 4];
|
||
m.CSBYHPOLARITYRESULTA = m.list_Data1[i, 5];
|
||
m.CSBYHTOOLNOA = m.list_Data1[i, 6];
|
||
m.CSBYHCUWELDINGSTATIONNOA = m.list_Data1[i, 7];
|
||
m.CSBYHCUWELDHEADCOUNTA = m.list_Data1[i, 8];
|
||
m.CSBYHCUWELDBASECOUNTA = m.list_Data1[i, 9];
|
||
m.CSBYHALWELDINGSTATIONNOA = m.list_Data1[i, 10];
|
||
m.CSBYHALWELDHEADCOUNTA = m.list_Data1[i, 11];
|
||
m.CSBYHALWELDBASECOUNTA = m.list_Data1[i, 12];
|
||
m.CSBYHCUTABCUTTERCOUNTA = m.list_Data1[i, 13];
|
||
m.CSBYHALTABCUTTERCOUNTA = m.list_Data1[i, 14];
|
||
m.CSBYHCUTADHESIONJUDGERESULTA = m.list_Data1[i, 15];
|
||
m.CSBYHCUTBURRJUDGERESULTA = m.list_Data1[i, 16];
|
||
m.CSBYHSOLDERJUDGERESULTA = m.list_Data1[i, 17];
|
||
m.CSBYHFRONTEARCRACKLEJUDGERESULTA = m.list_Data1[i, 18];
|
||
m.CSBYHBACKEARCRACKLEJUDGERESULTA = m.list_Data1[i, 19];
|
||
m.CSBYHFRONTEARFLODINGRESULTA = m.list_Data1[i, 20];
|
||
m.CSBYHBACKEARFLODINGRESULTA = m.list_Data1[i, 21];
|
||
m.CSBYHOUTSTATIONJUDGMENTRESULT = m.list_Data1[i, 22];
|
||
m.CSBYHCUTABCUTTERNOA = m.list_CutNO[i, 0];
|
||
m.CSBYHALTABCUTTERNOA = m.list_CutNO[i, 1];
|
||
m.CSBYHPROCESSNAME = m.list_Process[i, 0];
|
||
m.CSBYHSCHEDULE = m.list_Process[i, 1];
|
||
m.CSBYHINSTATIONTIME = m.list_Process[i, 2];
|
||
m.CSBYHOUTSTATIONTIME = m.list_Process[i, 3];
|
||
|
||
m.CSBYHWEIGHTA1MAXSETTING = m.list_Data2[i, 0];
|
||
m.CSBYHWEIGHTA1MINSETTING = m.list_Data2[i, 1];
|
||
m.CSBYHWEIGHTA1 = m.list_Data2[i, 2];
|
||
m.CSBYHTHICKNESSTESTPRESSUREMAXSETTINGA = m.list_Data2[i, 3];
|
||
m.CSBYHTHICKNESSTESTPRESSUREMINSETTINGA = m.list_Data2[i, 4];
|
||
m.CSBYHTHICKNESSTESTPRESSUREA = m.list_Data2[i, 5];
|
||
m.CSBYHTHICKNESSTESTPRESSURESIZEA = m.list_Data2[i, 6];
|
||
m.CSBYHTHICKNESSTESTPRESSUREMAXSIZEA = m.list_Data2[i, 7];
|
||
m.CSBYHTHICKNESSTESTPRESSUREMINSIZEA = m.list_Data2[i, 8];
|
||
m.CSBYHCUWELDINGPRESSUREMAXSETTING = m.list_Data2[i, 9];
|
||
m.CSBYHCUWELDINGPRESSUREMINSETTING = m.list_Data2[i, 10];
|
||
m.CSBYHCUWELDINGPOWERMAXSETTING = m.list_Data2[i, 11];
|
||
m.CSBYHCUWELDINGPOWERMINSETTING = m.list_Data2[i, 12];
|
||
m.CSBYHCUWELDINGENERGYMAXSETTING = m.list_Data2[i, 13];
|
||
m.CSBYHCUWELDINGENERGYMINSETTING = m.list_Data2[i, 14];
|
||
m.CSBYHCUWELDINGAMPLITUDEMAXSETTING = m.list_Data2[i, 15];
|
||
m.CSBYHCUWELDINGAMPLITUDEMINSETTING = m.list_Data2[i, 16];
|
||
m.CSBYHCUPRESSUREA1 = m.list_Data2[i, 17];
|
||
m.CSBYHCUPOWERA1 = m.list_Data2[i, 18];
|
||
m.CSBYHCUENERGYA1 = m.list_Data2[i, 19];
|
||
m.CSBYHCUAMPLITUDEA1 = m.list_Data2[i, 20];
|
||
m.CSBYHCUTIMEA1 = m.list_Data2[i, 21];
|
||
m.CSBYHCUPRESSUREA2 = m.list_Data2[i, 22];
|
||
m.CSBYHCUPOWERA2 = m.list_Data2[i, 23];
|
||
m.CSBYHCUENERGYA2 = m.list_Data2[i, 24];
|
||
m.CSBYHCUAMPLITUDEA2 = m.list_Data2[i, 25];
|
||
m.CSBYHCUTIMEA2 = m.list_Data2[i, 26];
|
||
m.CSBYHCUPRESSUREA3 = m.list_Data2[i, 27];
|
||
m.CSBYHCUPOWERA3 = m.list_Data2[i, 28];
|
||
m.CSBYHCUENERGYA3 = m.list_Data2[i, 29];
|
||
m.CSBYHCUAMPLITUDEA3 = m.list_Data2[i, 30];
|
||
m.CSBYHCUTIMEA3 = m.list_Data2[i, 31];
|
||
m.CSBYHALWELDINGPRESSUREMAXSETTING = m.list_Data2[i, 32];
|
||
m.CSBYHALWELDINGPRESSUREMINSETTING = m.list_Data2[i, 33];
|
||
m.CSBYHALWELDINGPOWERMAXSETTING = m.list_Data2[i, 34];
|
||
m.CSBYHALWELDINGPOWERMINSETTING = m.list_Data2[i, 35];
|
||
m.CSBYHALWELDINGENERGYMAXSETTING = m.list_Data2[i, 36];
|
||
m.CSBYHALWELDINGENERGYMINSETTING = m.list_Data2[i, 37];
|
||
m.CSBYHALWELDINGAMPLITUDEMAXSETTING = m.list_Data2[i, 38];
|
||
m.CSBYHALWELDINGAMPLITUDEMINSETTING = m.list_Data2[i, 39];
|
||
m.CSBYHALPRESSUREA1 = m.list_Data2[i, 40];
|
||
m.CSBYHALPOWERA1 = m.list_Data2[i, 41];
|
||
m.CSBYHALENERGYA1 = m.list_Data2[i, 42];
|
||
m.CSBYHALAMPLITUDEA1 = m.list_Data2[i, 43];
|
||
m.CSBYHALTIMEA1 = m.list_Data2[i, 44];
|
||
m.CSBYHALPRESSUREA2 = m.list_Data2[i, 45];
|
||
m.CSBYHALPOWERA2 = m.list_Data2[i, 46];
|
||
m.CSBYHALENERGYA2 = m.list_Data2[i, 47];
|
||
m.CSBYHALAMPLITUDEA2 = m.list_Data2[i, 48];
|
||
m.CSBYHALTIMEA2 = m.list_Data2[i, 49];
|
||
m.CSBYHALPRESSUREA3 = m.list_Data2[i, 50];
|
||
m.CSBYHALPOWERA3 = m.list_Data2[i, 51];
|
||
m.CSBYHALENERGYA3 = m.list_Data2[i, 52];
|
||
m.CSBYHALAMPLITUDEA3 = m.list_Data2[i, 53];
|
||
m.CSBYHALTIMEA3 = m.list_Data2[i, 54];
|
||
m.CSBYHCUTABLENGTHA = m.list_Data2[i, 55];
|
||
m.CSBYHCUTABWIDTHA = m.list_Data2[i, 56];
|
||
m.CSBYHALTABLENGTHA = m.list_Data2[i, 57];
|
||
m.CSBYHALTABWIDTHA = m.list_Data2[i, 58];
|
||
m.CSBYHCUTADHESIONRESULTA = m.list_Data2[i, 59];
|
||
m.CSBYHCUTBURRRESULTA = m.list_Data2[i, 60];
|
||
m.CSBYHTOPTOSOLDERDISTANCEA = m.list_Data2[i, 61];
|
||
m.CSBYHSOLDERTOEARDISTANCEA = m.list_Data2[i, 62];
|
||
m.CSBYHFRONTEARCRACKLERESULTA = m.list_Data2[i, 63];
|
||
|
||
m.CSBYHBACKEARCRACKLERESULTA = m.list_Data2[i, 64];
|
||
|
||
list.Add(m);
|
||
|
||
string ur2 = CommonMethods.mesConfig.ResultProcessParamMesUrl;
|
||
string siteCode1 = CommonMethods.mesConfig.siteCode;
|
||
string lineCode1 = CommonMethods.mesConfig.lineCode;
|
||
string equipNum1 = CommonMethods.mesConfig.equipNum;
|
||
string materialCode1 = CommonMethods.mesConfig.MaterialCode;
|
||
string userName1 = CommonMethods.mesConfig.mesUserName;
|
||
MesUploadType unloadType = MesUploadType.DD;
|
||
string Mesage = "";
|
||
bool Res1 = CommonMethods.hbgMes.ProducResultParam(ur2, siteCode1, lineCode1, equipNum1, materialCode1, userName1, m, unloadType, ref Mesage);
|
||
if (!Res1)
|
||
{
|
||
m.Flag = 0;
|
||
}
|
||
if (CommonMethods.mesConfig.isUpMes)
|
||
{
|
||
string url = CommonMethods.mesConfig.OutStationMesUrl;
|
||
string siteCode = CommonMethods.mesConfig.siteCode;
|
||
string lineCode = CommonMethods.mesConfig.lineCode;
|
||
string equipNum = CommonMethods.mesConfig.equipNum;
|
||
string materialCode = CommonMethods.mesConfig.MaterialCode;
|
||
string userName = CommonMethods.mesConfig.mesUserName;
|
||
int type = 1;
|
||
//int type = 1;
|
||
//string materialLotCodeLocator = "";
|
||
List<string> MesMessage = GetList<string>(2, "");
|
||
List<MesResType> mesResType = GetMesType(2);
|
||
|
||
bool Res = CommonMethods.hbgMes.OutboundInformations(url, siteCode, lineCode, equipNum, materialCode, userName, list, ref MesMessage, ref mesResType);
|
||
//bool Res = CommonMethods.hbgMes.SingleCellOutStation(url, siteCode, lineCode, equipNum, materialCode, userName, m,)
|
||
if (Res)
|
||
{
|
||
m.listRes[0] = 1;
|
||
m.listRes[1] = 1;
|
||
MyRes[0] = m.listRes[0];
|
||
MyRes[1] = m.listRes[0];
|
||
}
|
||
else
|
||
{
|
||
switch (mesResType[i])
|
||
{
|
||
case MesResType.A:// 停线,设备报警停机
|
||
m.listRes[i] = 10;
|
||
MyRes[i] = m.listRes[i];
|
||
break;
|
||
case MesResType.B:
|
||
m.listRes[i] = 9;
|
||
MyRes[i] = m.listRes[i];
|
||
break;
|
||
case MesResType.C:
|
||
m.listRes[i] = 1;
|
||
MyRes[i] = m.listRes[i];
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
JYResult Result1 = CommonMethods.PlcLink.WriteValue("D80", 2, Data_Type.Short);//反馈PLC结果
|
||
JYResult Result2 = CommonMethods.PlcLink.WriteValue("D81", 2, Data_Type.Short);//反馈PLC结果
|
||
JYResult Result3 = CommonMethods.PlcLink.WriteValue("D82", 2, Data_Type.Short);//反馈PLC结果
|
||
JYResult Result4 = CommonMethods.PlcLink.WriteValue("D83", 2, Data_Type.Short);//反馈PLC结果
|
||
JYResult Result5 = CommonMethods.PlcLink.WriteValue("D84", 2, Data_Type.Short);//反馈PLC结果
|
||
JYResult Result6 = CommonMethods.PlcLink.WriteValue("D85", 2, Data_Type.Short);//反馈PLC结果
|
||
JYResult Result7 = CommonMethods.PlcLink.WriteValue("D86", 2, Data_Type.Short);//反馈PLC结果
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError($"卷芯进站线程数据解析:{ex}", "SysErrorLog");
|
||
}
|
||
|
||
|
||
}
|
||
|
||
#endregion
|
||
JYResult result1 = null;
|
||
JYResult result2 = null;
|
||
if (pf.IsFeedbackPlc)
|
||
{
|
||
result1 = CommonMethods.PlcLink.WriteValue(pf.VarList[2].VarAddress, MyRes[0], Data_Type.Short);//判断结果写入PLC
|
||
result2 = CommonMethods.PlcLink.WriteValue(pf.VarList[3].VarAddress, MyRes[1], Data_Type.Short);//判断结果写入PLC
|
||
}
|
||
JYResult result3 = CommonMethods.PlcLink.WriteValue(pf.VarList[0].VarAddress, 0);//置位0
|
||
CommonMethods.AddDataMonitorLog(0, $"发送信息给PLC:{result1.IsSuccess},{MyRes[0]},{MyRes[1]}");
|
||
LogHelper.Instance.WriteLog($"发送信息给PLC:{result1.IsSuccess},{MyRes[0]},{MyRes[1]}");
|
||
|
||
//数据存储 - 异步处理
|
||
Task.Run(() =>
|
||
{
|
||
SaveBlankingData(list);
|
||
});
|
||
|
||
sw2.Stop();
|
||
////输出下料数据处理耗时:
|
||
CommonMethods.AddDataMonitorLog(0, $"卷芯进站共耗时:{sw2.Elapsed.TotalMilliseconds}ms");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 电池结果判断
|
||
/// </summary>
|
||
/// <param name="HJ_Result"></param>
|
||
/// <param name="strErr"></param>
|
||
/// <returns></returns>
|
||
private ushort GetResult(AGearEntity m, ref string strErr)
|
||
{
|
||
//strErr = "";
|
||
//bool b = m.YaLiValue <= 2 ? true : false;//压力值结果NG
|
||
//if (b)
|
||
//{
|
||
// strErr = "良品";
|
||
// return 1;
|
||
//}
|
||
//if (!b)
|
||
//{
|
||
// strErr = "压力值NG";
|
||
// return 5;
|
||
//}
|
||
|
||
return 1;
|
||
}
|
||
|
||
#region 保存下料数据
|
||
/// <summary>
|
||
/// 保存下料数据到数据
|
||
/// </summary>
|
||
/// <param name="list"></param>
|
||
private void SaveBlankingData(List<BGearEntity> list)
|
||
{
|
||
//数据的保存
|
||
try
|
||
{
|
||
if (list != null && list.Count > 0)
|
||
{
|
||
//数据显示
|
||
List<BGearEntity> Blist = list;
|
||
int i = 0;
|
||
string strRes = "";
|
||
foreach (BGearEntity m in list)
|
||
{
|
||
if (true)
|
||
{
|
||
bool b = CommonMethods.db.AddReturnBool<BGearEntity>(m);
|
||
//strRes = b ? ",本存Yes" : ",本存No";
|
||
|
||
#region 存储到服务器
|
||
DataTurnover server = new DataTurnover
|
||
{
|
||
equipNum = CommonMethods.mesConfig.equipNum,
|
||
containerCode = m.listBatCode[0],
|
||
identification = m.listBatCode[1],
|
||
message = m.Result,
|
||
Time = DateTime.Now,
|
||
};
|
||
|
||
try
|
||
{
|
||
//int b1 = CommonMethods.dbServer.Delete<DataTurnover>(it => it.containerCode == m.RFID);
|
||
//bool res = CommonMethods.dbServer.AddReturnBool<DataTurnover>(server);
|
||
//strRes += res == true ? ",远存Yes" : ",远存No";
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
JYResult result = CommonMethods.PlcLink.WriteValue("D80", 1, Data_Type.Short);//反馈PLC结果
|
||
//CommonMethods.AddDataMonitorLog(1, $"服务器连接失败!解决办法:1、请检查MES网络,2、查看服务器是否正常!");
|
||
//LogHelper.Instance.WriteError($"服务器连接失败:{ex}", "系统报错");
|
||
}
|
||
|
||
#endregion
|
||
|
||
}
|
||
else
|
||
{
|
||
strRes = ",不存储";
|
||
}
|
||
m.Remark = m.Remark + strRes;
|
||
Blist[i].Remark = m.Remark;
|
||
i++;
|
||
}
|
||
|
||
//数据显示
|
||
CommonMethods.ShowBlankingDelegate.Invoke(Blist);
|
||
}
|
||
else
|
||
{
|
||
LogHelper.Instance.WriteError($"电芯出站数据List为空", "SysErrorLog");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Instance.WriteError($"电芯出站数据保存异常:{ex}", "SysErrorLog");
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#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
|
||
}
|
||
}
|
||
#endregion
|