增加通过读取EXCEL的方式读取报警信息

master
lhiven 1 year ago
parent a490e368d1
commit 910e251bfc

@ -0,0 +1,97 @@
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Entitys
{
public static class AlarmCollection
{
private static Dictionary<int,AlarmEntity> alarmDic = new Dictionary<int,AlarmEntity>();
static AlarmCollection()
{
}
public static void Load()
{
alarmDic.Clear();
XSSFWorkbook book;
FileStream fs = File.Open("Dorxx 报警文本(中英韩).xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
book = new XSSFWorkbook(fs);
fs.Close();
if(book!=null)
{
ISheet sheet = book.GetSheetAt(0);
if(sheet!=null)
{
int rowNum = sheet.LastRowNum;
if(rowNum>2)
{
for(int i=1;i<rowNum; i++)
{
AlarmEntity entity = new AlarmEntity();
IRow row = sheet.GetRow(i);
ICell cell = row.GetCell(0);
entity.AlartID = int.Parse(cell.NumericCellValue.ToString().Trim());
cell = row.GetCell(2);
if (cell != null)
entity.CN = cell.StringCellValue;
cell = row.GetCell(3);
if (cell != null)
entity.EN = cell.StringCellValue;
cell = row.GetCell(4);
if (cell != null)
entity.KO = cell.StringCellValue;
if(!alarmDic.ContainsKey(entity.AlartID))
{
alarmDic.Add(entity.AlartID, entity);
}
}
}
}
}
}
public static AlarmEntity Get(int _alarmID)
{
if(alarmDic.Count>0 && alarmDic.ContainsKey(_alarmID))
return alarmDic[_alarmID];
return null;
}
public static string GetAlarm(int _alarmID)
{
AlarmEntity alarm = Get(_alarmID);
if(alarm!=null)
{
return alarm.CN + "\r\n\r\n" + alarm.EN + "\r\n\r\n" + alarm.KO;
}
return "";
}
}
public class AlarmEntity
{
/// <summary>
/// 报警编号
/// </summary>
public int AlartID { get; set; }
/// <summary>
/// 中文
/// </summary>
public string CN { get; set; }
/// <summary>
/// 英文
/// </summary>
public string EN { get; set; }
/// <summary>
/// 韩文
/// </summary>
public string KO { get; set; }
}
}

@ -429,5 +429,10 @@ namespace Rs.MotionPlat
GlobalTray.GetTray(ETrayType.Empty2).Status = EStockTrayStatus.Empty.ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
MsgBox.ShowDialog(111, "取料失败!! \r\n周转吸嘴取治具{}号穴位的物料时失败 \r\nPickup fail !!\r\nNozzle of tester from site{} socket\r\nPickup fail !!\r\nSite{} socket 으로부터 Unit을 pickup할때 pickup fail이 발생하였습니다.", ETipButton.Yes);
}
}
}

@ -161,6 +161,7 @@
this.hWindow_Final2 = new ChoiceTech.Halcon.Control.HWindow_Final();
this.groupBox35 = new System.Windows.Forms.GroupBox();
this.hWindow_Final4 = new ChoiceTech.Halcon.Control.HWindow_Final();
this.button1 = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.panel3.SuspendLayout();
@ -997,6 +998,7 @@
//
// gboxNozzle2
//
this.gboxNozzle2.Controls.Add(this.button1);
this.gboxNozzle2.Controls.Add(this.himgNozzle2);
this.gboxNozzle2.Dock = System.Windows.Forms.DockStyle.Fill;
this.gboxNozzle2.ForeColor = System.Drawing.Color.White;
@ -2153,6 +2155,16 @@
this.hWindow_Final4.Size = new System.Drawing.Size(85, 141);
this.hWindow_Final4.TabIndex = 13;
//
// button1
//
this.button1.Location = new System.Drawing.Point(20, 113);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 13;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -2366,5 +2378,6 @@
private ChoiceTech.Halcon.Control.HWindow_Final hWindow_Final2;
private System.Windows.Forms.GroupBox groupBox35;
private ChoiceTech.Halcon.Control.HWindow_Final hWindow_Final4;
private System.Windows.Forms.Button button1;
}
}

@ -42,6 +42,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\HWindow_Tool.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\log4net.dll</HintPath>
@ -54,6 +58,22 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NPOI, Version=2.5.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\NPOI.dll</HintPath>
</Reference>
<Reference Include="NPOI.OOXML, Version=2.5.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\NPOI.OOXML.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXml4Net, Version=2.5.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\NPOI.OpenXml4Net.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXmlFormats, Version=2.5.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\NPOI.OpenXmlFormats.dll</HintPath>
</Reference>
<Reference Include="Rs.Camera, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\Rs.Camera.dll</HintPath>
@ -135,6 +155,7 @@
<Compile Include="Commom\SourceHelper.cs" />
<Compile Include="Commom\TestCenterMessageBox.cs" />
<Compile Include="Commom\VirtualBarCode.cs" />
<Compile Include="Entitys\AlarmEntity.cs" />
<Compile Include="Entitys\TransitNozzleManager.cs" />
<Compile Include="Commom\TrayPointManager.cs" />
<Compile Include="Commom\TurnoverSlotOffset.cs" />

Loading…
Cancel
Save