增加报警信息代码
This commit is contained in:
+35
-17
@@ -173,14 +173,15 @@ namespace JY.Inspection
|
||||
/// </summary>
|
||||
List<ChartDataType> NGList = new List<ChartDataType>();
|
||||
|
||||
//private readonly object lockObject = new object();
|
||||
/// <summary>
|
||||
/// 报警原始数据
|
||||
/// </summary>
|
||||
List<byte> listAlamByte = new List<byte>();
|
||||
//List<byte> listAlamByte = new List<byte>();
|
||||
//报警表单数据
|
||||
List<AlarmForm> listAlarmForm = null;
|
||||
//PLC报警状态值
|
||||
List<AlarmStatus> listAlarmStatus = null;
|
||||
//List<AlarmStatus> listAlarmStatus = null;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -278,6 +279,8 @@ namespace JY.Inspection
|
||||
this.ControlBox = true;
|
||||
// 或设置窗口可调整大小
|
||||
this.Resizable = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void InitDgvBColumns()
|
||||
@@ -560,6 +563,8 @@ namespace JY.Inspection
|
||||
CheckClassShift();
|
||||
InitOmronCom();
|
||||
|
||||
string strFileName = Environment.CurrentDirectory + "\\欧姆龙报警寄存器对应表.csv";
|
||||
listAlarmForm = CSVHelper<AlarmForm>.ReadCSV(strFileName,",");
|
||||
|
||||
CancellationToken token1 = mctsA1.Token;
|
||||
CancellationToken token2 = mctsA2.Token;
|
||||
@@ -739,7 +744,7 @@ namespace JY.Inspection
|
||||
IsStartNGFL = IniFileHelper.ReadIniData("MES配置", "StartNGFL") == "1" ? true : false;
|
||||
chkStartNGFL.Checked = IsStartNGFL;
|
||||
|
||||
listAlamByte = GetListByte(200);
|
||||
//listAlamByte = GetListByte(200);
|
||||
|
||||
|
||||
Global.systemConfig.isUpMes = IniFileHelper.ReadIniData("SYSTEM_CONFIGURE", "IsMesUP") == "1" ? true : false;
|
||||
@@ -3123,30 +3128,43 @@ namespace JY.Inspection
|
||||
if (!mt.IsCancellationRequested)
|
||||
{
|
||||
sw.Restart();
|
||||
byte[] res = new byte[2];
|
||||
for (int i = 0; i < 30; i++)
|
||||
//byte[] res = new byte[2];
|
||||
//for (int i = 0; i < 30; i++)
|
||||
//{
|
||||
// res = omronPLCCom.lstMcUI[0].Readbyte("W6100[" + i + "].Word区", 1);
|
||||
// if (res != null)
|
||||
// {
|
||||
// for (int j = i; j < res.Length + i; j++)
|
||||
// {
|
||||
// listAlamByte[i + j] = res[j - i];
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
byte[] res = null;
|
||||
List<byte> listAlamByte = new List<byte>();
|
||||
foreach (var address in ConstValue.AlarmAddressDic.Keys)
|
||||
{
|
||||
res = omronPLCCom.lstMcUI[0].Readbyte("W6100[" + i + "].Word区", 1);
|
||||
if (res != null)
|
||||
ushort byteLen = (ushort)(ConstValue.AlarmAddressDic[address] * 10);
|
||||
res = omronPLCCom.lstMcUI[0].ReadByteFins($"D{address}", byteLen);
|
||||
|
||||
if (res == null)
|
||||
{
|
||||
for (int j = i; j < res.Length + i; j++)
|
||||
{
|
||||
listAlamByte[i + j] = res[j - i];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
listAlamByte.AddRange(res);
|
||||
}
|
||||
|
||||
//AddLog(0, "读取报警耗时:" + sw.ElapsedMilliseconds + "ms");
|
||||
if (listAlamByte == null) { return; }
|
||||
string strFileName = Environment.CurrentDirectory + "\\欧姆龙报警寄存器对应表.csv";
|
||||
listAlarmForm = CSVHelper<AlarmForm>.ReadCSV(strFileName);
|
||||
|
||||
//string strFileName = Environment.CurrentDirectory + "\\欧姆龙报警寄存器对应表.csv";
|
||||
//listAlarmForm = CSVHelper<AlarmForm>.ReadCSV(strFileName);
|
||||
//如果未配置报警地址信息返回 TODO
|
||||
if (listAlarmForm == null) { return; }
|
||||
int startPlcAddr = 0;//TODO 读取起始地址
|
||||
//3.公用方法解析byte[]数据 => List<AlarmStatus>
|
||||
if (listAlamByte == null) { return; } //如果未配置报警地址信息返回
|
||||
|
||||
//TODO 切换三菱和欧姆龙
|
||||
listAlarmStatus = PLCAlarmParse.OmronEIPByte2Status(startPlcAddr, listAlamByte);
|
||||
List<AlarmStatus> listAlarmStatus = PLCAlarmParse.OmronEIPByte2Status(listAlamByte);
|
||||
//4.判定有不良后,关联AlarmStatus 和AlarmForm
|
||||
if (listAlarmStatus == null) { return; } //状态信息为空返回
|
||||
|
||||
|
||||
Reference in New Issue
Block a user