页面布局修改
This commit is contained in:
1 parent
d20b935213
commit
752e1f37b6
9 files changed
+1636
-1044
No files matched your search
+283
-240
@@ -44,17 +44,22 @@ namespace WindowsFormsApp1
|
||||
private ApiClient statusApiClient = new ApiClient(); // 专用于状态上报的API客户端
|
||||
private object curingLock = new object();
|
||||
private int OldPlcTrigger = 0;
|
||||
|
||||
// 在MainForm类的成员变量部分添加
|
||||
private List<Label> eventNameLabels = new List<Label>();
|
||||
private List<Panel> eventPanels = new List<Panel>();
|
||||
private Queue<EventInfo> eventHistory = new Queue<EventInfo>();
|
||||
private const int MAX_EVENT_DISPLAY = 5;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
// 添加FormClosed事件处理程序
|
||||
this.FormClosed += MainForm_FormClosed;
|
||||
|
||||
InitializeEventDisplay();
|
||||
CheckForIllegalCrossThreadCalls = false;
|
||||
|
||||
// 初始化状态上报定时器
|
||||
statusReportTimer.Interval = 15000; // 15秒
|
||||
//statusReportTimer.Tick += StatusReportTimer_Tick;
|
||||
statusReportTimer.Tick += StatusReportTimer_Tick;
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
@@ -62,13 +67,15 @@ namespace WindowsFormsApp1
|
||||
LogExecute.logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||
LogExecute.PlclogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||
LogExecute.ApilogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||
LogExecute.OEElogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||
|
||||
|
||||
FormRecover();
|
||||
|
||||
linename.Text = Init.t_Line.linename;
|
||||
linecode.Text = Init.t_Line.lineremark1;
|
||||
linetype.Text = Init.t_Line.lineremark2;
|
||||
linemode.Text = Init.t_Line.lineremark3;
|
||||
linename.Text = $"{Init.t_Line.linename}";
|
||||
linecode.Text = $"Line: {Init.t_Line.lineremark1}";
|
||||
linetype.Text = $"Station: {Init.t_Line.lineremark2}";
|
||||
linemode.Text = $"MachineID: {Init.t_Line.lineremark3}";
|
||||
//lineremark1.Text = "";
|
||||
//lineremark2.Text = "";
|
||||
//lineremark3.Text = "";
|
||||
@@ -103,6 +110,15 @@ namespace WindowsFormsApp1
|
||||
|
||||
public void build(t_plc Plc, CancellationToken token)
|
||||
{
|
||||
// 获取当前线程名称
|
||||
string threadName = Thread.CurrentThread.Name ?? $"PLC_{Plc?.id}_Thread";
|
||||
|
||||
// 确保线程只操作自己的PLC
|
||||
if (!threadName.Contains($"PLC_{Plc.id}"))
|
||||
{
|
||||
LogExecute.logNet.WriteError($"线程 {threadName} 尝试操作非指定PLC {Plc.id},已跳过");
|
||||
return;
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
@@ -164,16 +180,17 @@ namespace WindowsFormsApp1
|
||||
|
||||
//if(Plc.id == 1)
|
||||
//{
|
||||
LOT号.Text = PlcData.Read_MaterialCode0;
|
||||
//PlcData.Read_MaterialCode0 = PlcData.Write_stSN;
|
||||
LOT号.Text = PlcData.Write_stSN;
|
||||
Tray盘二维码.Text = PlcData.Read_MaterialCode1;
|
||||
材料值.Text = PlcData.Read_MaterialCode2;
|
||||
Init.ImageLocation = PlcData.Read_Other4;
|
||||
Init.ImageName = PlcData.Read_Other3.ToString();
|
||||
//}
|
||||
|
||||
|
||||
|
||||
当前时间.Text = $"PLC状态:{plcstatus.GetName(typeof(plcstatus), PlcData.Read_Status)}";
|
||||
|
||||
|
||||
DateTime Plc_Time = DateTime.Now;
|
||||
|
||||
//PLC链接状态.Text = "PLC链接状态:OK";
|
||||
@@ -191,12 +208,13 @@ namespace WindowsFormsApp1
|
||||
otherdata otherdata = new otherdata();
|
||||
//Init.SN = PlcData.Read_MaterialCode0;
|
||||
#region 机台状态及报警
|
||||
|
||||
|
||||
//机台状态
|
||||
//机台状态.Text = "机台状态:" + Enum.GetName(typeof(plcstatus), Init.Plcstatus);
|
||||
Init.Plcstatus = PlcData.Read_Status;
|
||||
int oldstatus = Init.Plcstatus;
|
||||
//if (PlcData.Read_Status != 0)
|
||||
if(false)
|
||||
if (false)
|
||||
{
|
||||
//状态+报警
|
||||
if (oldstatus != PlcData.Read_Status)
|
||||
@@ -272,10 +290,11 @@ namespace WindowsFormsApp1
|
||||
{
|
||||
//机台状态.BackColor = SystemColors.Control;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 判断及查找流程
|
||||
|
||||
|
||||
if (PlcData.Read_Trigger == OldPlcTrigger)
|
||||
{
|
||||
continue;
|
||||
@@ -321,7 +340,7 @@ namespace WindowsFormsApp1
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 根据流程,判断是否需要扫码、气密、扭力等
|
||||
if (nowflow.scan)
|
||||
{
|
||||
@@ -332,6 +351,7 @@ namespace WindowsFormsApp1
|
||||
{
|
||||
string returnValue = scanForm.ReturnValue;
|
||||
otherdata.JS_SN = returnValue;
|
||||
PlcData.Write_stSN = returnValue;
|
||||
//Init.SN = returnValue;
|
||||
LOT号.Text = returnValue;
|
||||
Init.ScanString = returnValue;
|
||||
@@ -468,7 +488,7 @@ namespace WindowsFormsApp1
|
||||
//文件上传
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 判断物料调用次数 固化站
|
||||
|
||||
lock (curingLock)
|
||||
@@ -551,13 +571,12 @@ namespace WindowsFormsApp1
|
||||
otherdata.ImageAddress = Init.t_Keyvalues.First(x => x.key == "ImageFilePath").value;
|
||||
otherdata.VedioAddress = Init.t_Keyvalues.First(x => x.key == "VedioFilePath").value;
|
||||
|
||||
|
||||
#region 调用后端接口
|
||||
var result = apiClient.CallFunctionByName(nowinterface.code, PlcData, otherdata);
|
||||
if (result.IsShow)
|
||||
{
|
||||
MES_MsgfORM(nowinterface.code, result, result.Requesttime);
|
||||
}
|
||||
//if (result.IsShow)
|
||||
//{
|
||||
// MES_MsgfORM(nowinterface.code, result, result.Requesttime);
|
||||
//}
|
||||
|
||||
if (result.Success)
|
||||
{
|
||||
@@ -701,6 +720,9 @@ namespace WindowsFormsApp1
|
||||
|
||||
// 初始化PLC状态面板
|
||||
InitializePlcStatusPanel();
|
||||
// 启动状态上报定时器
|
||||
statusReportTimer.Start();
|
||||
|
||||
#endregion
|
||||
#region 初始化COM口服务
|
||||
try
|
||||
@@ -718,7 +740,6 @@ namespace WindowsFormsApp1
|
||||
底部注释1.Text = "扫码枪COM-Ready";
|
||||
底部注释1.Visible = true;
|
||||
// 订阅 DataReceived 事件
|
||||
胶水上下线.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -746,7 +767,6 @@ namespace WindowsFormsApp1
|
||||
底部注释2.Visible = true;
|
||||
}
|
||||
|
||||
胶水上下线.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -766,6 +786,7 @@ namespace WindowsFormsApp1
|
||||
{
|
||||
threadHelp.cancellationTokenSource1 = new CancellationTokenSource();
|
||||
threadHelp.Thread = new Thread(() => build(plc, threadHelp.cancellationTokenSource1.Token));
|
||||
threadHelp.Thread.Name = $"PLC_{plc.id}_Thread"; // 显式设置线程名称
|
||||
threadHelp.Thread.Start();
|
||||
threadHelp.isrunning1 = true;
|
||||
}
|
||||
@@ -801,58 +822,6 @@ namespace WindowsFormsApp1
|
||||
}
|
||||
}
|
||||
|
||||
// 添加FormClosed事件处理程序
|
||||
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
// 如果已经执行过清理,则直接返回
|
||||
//if (_isCleanupDone)
|
||||
// return;
|
||||
|
||||
//try
|
||||
//{
|
||||
// _isCleanupDone = true; // 标记清理操作已执行
|
||||
// // 给日志系统一点时间完成写入
|
||||
// System.Threading.Thread.Sleep(100);
|
||||
// // 停止所有线程
|
||||
// if (Init.threadHelps != null)
|
||||
// {
|
||||
// foreach (var thread in Init.threadHelps)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (thread.Thread != null && thread.Thread.IsAlive)
|
||||
// {
|
||||
// thread.cancellationTokenSource1?.Cancel();
|
||||
// }
|
||||
// }
|
||||
// catch { /* 忽略异常 */ }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 安全关闭串口
|
||||
// try
|
||||
// {
|
||||
// if (Init.ScanPort != null && Init.ScanPort.IsOpen)
|
||||
// {
|
||||
// Init.ScanPort.Close();
|
||||
// Init.ScanPort = null;
|
||||
// }
|
||||
// }
|
||||
// catch { /* 忽略异常 */ }
|
||||
|
||||
// try
|
||||
// {
|
||||
// if (Init.AirtightPort != null && Init.AirtightPort.IsOpen)
|
||||
// {
|
||||
// Init.AirtightPort.Close();
|
||||
// Init.AirtightPort = null;
|
||||
// }
|
||||
// }
|
||||
// catch { /* 忽略异常 */ }
|
||||
//}
|
||||
//catch { /* 忽略所有异常 */ }
|
||||
}
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
// 设置窗体正在关闭标志
|
||||
@@ -978,11 +947,11 @@ namespace WindowsFormsApp1
|
||||
materialScanForm.Show();
|
||||
}
|
||||
|
||||
private void 图片展示ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ImageDisplayForm displayForm = new ImageDisplayForm();
|
||||
displayForm.Show();
|
||||
}
|
||||
//private void 图片展示ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// ImageDisplayForm displayForm = new ImageDisplayForm();
|
||||
// displayForm.Show();
|
||||
//}
|
||||
|
||||
private void pLC通讯设置ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -1068,36 +1037,59 @@ namespace WindowsFormsApp1
|
||||
break;
|
||||
}
|
||||
|
||||
// 确定应该显示在哪个日志框中
|
||||
RichTextBox targetLogBox;
|
||||
|
||||
// 根据日志来源确定目标日志框
|
||||
if (sender == LogExecute.OEElogNet)
|
||||
{
|
||||
targetLogBox = richTextBox2; // PLC相关日志显示在第二个日志框
|
||||
}
|
||||
else
|
||||
{
|
||||
targetLogBox = richTextBox1; // 其他日志显示在第一个日志框
|
||||
}
|
||||
|
||||
logBuilder.Append(logPrefix).Append(time.ToString()).Append(" | ").Append(text).Append("\n");
|
||||
|
||||
// 检查日志行数,如果超过阈值则清理
|
||||
int lineCount = richTextBox1.GetLineFromCharIndex(richTextBox1.TextLength);
|
||||
int lineCount = targetLogBox.GetLineFromCharIndex(targetLogBox.TextLength);
|
||||
if (lineCount >= 200)
|
||||
{
|
||||
// 优化:只保留后 100 行,而不是全部清空再重新添加
|
||||
int startIndex = richTextBox1.GetFirstCharIndexFromLine(lineCount - 100);
|
||||
int startIndex = targetLogBox.GetFirstCharIndexFromLine(lineCount - 100);
|
||||
if (startIndex > 0)
|
||||
{
|
||||
richTextBox1.Select(0, startIndex);
|
||||
richTextBox1.SelectedText = "";
|
||||
targetLogBox.Select(0, startIndex);
|
||||
targetLogBox.SelectedText = "";
|
||||
}
|
||||
}
|
||||
|
||||
// 添加新日志
|
||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||
richTextBox1.SelectionLength = 0;
|
||||
richTextBox1.SelectionColor = logColor;
|
||||
richTextBox1.AppendText(logBuilder.ToString());
|
||||
targetLogBox.SelectionStart = richTextBox1.TextLength;
|
||||
targetLogBox.SelectionLength = 0;
|
||||
targetLogBox.SelectionColor = logColor;
|
||||
targetLogBox.AppendText(logBuilder.ToString());
|
||||
|
||||
// 重置颜色并滚动到底部
|
||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||
richTextBox1.SelectionLength = 0;
|
||||
richTextBox1.SelectionColor = richTextBox1.ForeColor;
|
||||
richTextBox1.ScrollToCaret();
|
||||
targetLogBox.SelectionStart = richTextBox1.TextLength;
|
||||
targetLogBox.SelectionLength = 0;
|
||||
targetLogBox.SelectionColor = richTextBox1.ForeColor;
|
||||
targetLogBox.ScrollToCaret();
|
||||
}));
|
||||
}
|
||||
catch { /* 忽略异常 */ }
|
||||
}
|
||||
|
||||
// 添加一个事件信息类
|
||||
private class EventInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public mesresult Result { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
当前时间.Text = "当前时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
|
||||
@@ -1107,20 +1099,6 @@ namespace WindowsFormsApp1
|
||||
开始处理.Text = "开始处理";
|
||||
开始处理.BackColor = Color.Green;
|
||||
|
||||
//MES链接状态.Text = "MES链接状态:None";
|
||||
//MES链接状态.BackColor = SystemColors.Control;
|
||||
|
||||
//MES通讯时间.Text = "MES通讯时间:None";
|
||||
//MES通讯时间.BackColor = SystemColors.Control;
|
||||
|
||||
|
||||
//胶水上下线.Enabled = false;
|
||||
|
||||
//MES提示信息.Visible = false;
|
||||
//LOT号.Visible = false;
|
||||
//Tray盘二维码.Visible = false;
|
||||
|
||||
|
||||
底部注释1.Visible = false;
|
||||
底部注释2.Visible = false;
|
||||
底部注释3.Visible = false;
|
||||
@@ -1237,112 +1215,159 @@ namespace WindowsFormsApp1
|
||||
catch { /* 忽略异常 */ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新事件显示区域
|
||||
/// </summary>
|
||||
// 添加初始化事件显示区域的方法
|
||||
private void InitializeEventDisplay()
|
||||
{
|
||||
// 清空现有列表
|
||||
eventNameLabels.Clear();
|
||||
eventPanels.Clear();
|
||||
|
||||
// 检查 eventTableLayout 是否已存在并且已配置
|
||||
if (eventTableLayout != null && eventTableLayout.RowCount >= MAX_EVENT_DISPLAY)
|
||||
{
|
||||
// 从 TableLayoutPanel 中获取已有的控件
|
||||
for (int i = 0; i < MAX_EVENT_DISPLAY; i++)
|
||||
{
|
||||
// 获取每行的标签和面板
|
||||
var nameLabel = eventTableLayout.GetControlFromPosition(0, i) as Label;
|
||||
var resultPanel = eventTableLayout.GetControlFromPosition(1, i) as Panel;
|
||||
|
||||
if (nameLabel != null && resultPanel != null)
|
||||
{
|
||||
// 将找到的控件添加到列表中
|
||||
eventNameLabels.Add(nameLabel);
|
||||
eventPanels.Add(resultPanel);
|
||||
|
||||
// 初始化标签和面板的状态
|
||||
nameLabel.Text = "";
|
||||
resultPanel.BackColor = SystemColors.Control;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有找到足够的控件,则创建新的
|
||||
if (eventNameLabels.Count < MAX_EVENT_DISPLAY)
|
||||
{
|
||||
LogExecute.logNet.WriteDebug($"事件显示区域控件不足,需要重新创建");
|
||||
|
||||
// 清空现有控件
|
||||
eventTableLayout.Controls.Clear();
|
||||
eventNameLabels.Clear();
|
||||
eventPanels.Clear();
|
||||
|
||||
// 重新创建控件
|
||||
for (int i = 0; i < MAX_EVENT_DISPLAY; i++)
|
||||
{
|
||||
// 创建事件名称标签
|
||||
Label nameLabel = new Label();
|
||||
nameLabel.Dock = DockStyle.Fill;
|
||||
nameLabel.TextAlign = ContentAlignment.MiddleLeft;
|
||||
nameLabel.Margin = new Padding(3);
|
||||
nameLabel.Text = "";
|
||||
|
||||
// 创建事件结果面板
|
||||
Panel resultPanel = new Panel();
|
||||
resultPanel.Dock = DockStyle.Fill;
|
||||
resultPanel.Margin = new Padding(3);
|
||||
resultPanel.BackColor = SystemColors.Control;
|
||||
|
||||
// 添加到TableLayoutPanel
|
||||
eventTableLayout.Controls.Add(nameLabel, 0, i);
|
||||
eventTableLayout.Controls.Add(resultPanel, 1, i);
|
||||
|
||||
// 保存引用以便后续更新
|
||||
eventNameLabels.Add(nameLabel);
|
||||
eventPanels.Add(resultPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// eventTableLayout 不存在或未正确配置,记录错误
|
||||
LogExecute.logNet.WriteError("事件显示区域未正确配置,无法初始化");
|
||||
}
|
||||
|
||||
// 初始化事件历史队列
|
||||
eventHistory = new Queue<EventInfo>();
|
||||
|
||||
}
|
||||
// 修改UpdateEventDisplay方法
|
||||
private void UpdateEventDisplay(string name, mesresult result, DateTime dateTime, string message)
|
||||
{
|
||||
UpdateEventSlot(事件1, 事件1结果, 事件1时间, name, result, dateTime, message);
|
||||
// 根据接口名称显示特定信息
|
||||
//UpdateSpecificEventInfo(name, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找可用的事件显示槽位
|
||||
/// </summary>
|
||||
private int FindAvailableEventSlot()
|
||||
{
|
||||
// 首先查找不可见的事件槽位
|
||||
if (!事件1.Visible) return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定事件槽位的显示内容
|
||||
/// </summary>
|
||||
private void UpdateEventSlot(Label eventLabel, Label resultLabel, Label timeLabel,
|
||||
string name, mesresult result, DateTime dateTime, string message)
|
||||
{
|
||||
// 设置事件名称
|
||||
eventLabel.Text = $"{name}";
|
||||
eventLabel.Visible = true;
|
||||
|
||||
// 设置事件结果
|
||||
resultLabel.Text = $"{(result == mesresult.PASS ? "PASS" : "FAIL")}";
|
||||
resultLabel.BackColor = result == mesresult.PASS ? Color.Green : Color.Red;
|
||||
resultLabel.Visible = true;
|
||||
|
||||
// 设置事件时间
|
||||
timeLabel.Text = $"{dateTime:MM-dd HH:mm:ss}";
|
||||
timeLabel.Visible = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据接口名称更新特定信息显示
|
||||
/// </summary>
|
||||
private void UpdateSpecificEventInfo(string name, string message)
|
||||
{
|
||||
// 根据不同的接口名称,显示特定的信息
|
||||
switch (name)
|
||||
// 创建新的事件信息
|
||||
EventInfo newEvent = new EventInfo
|
||||
{
|
||||
case "SN_Release":
|
||||
// 显示SN号
|
||||
if (!string.IsNullOrEmpty(Init.ScanString))
|
||||
{
|
||||
LOT号.Text = $"SN号:{Init.ScanString}";
|
||||
LOT号.Visible = true;
|
||||
}
|
||||
break;
|
||||
Name = name,
|
||||
Result = result,
|
||||
Time = dateTime,
|
||||
Message = message
|
||||
};
|
||||
|
||||
case "Tray_Release":
|
||||
// 显示Tray盘信息
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
Tray盘二维码.Text = $"Tray盘:{message}";
|
||||
Tray盘二维码.Visible = true;
|
||||
}
|
||||
break;
|
||||
// 添加到历史记录
|
||||
eventHistory.Enqueue(newEvent);
|
||||
|
||||
case "Status":
|
||||
// 机台状态信息已在其他地方更新
|
||||
break;
|
||||
// 如果超过最大显示数量,移除最早的记录
|
||||
while (eventHistory.Count > MAX_EVENT_DISPLAY)
|
||||
{
|
||||
eventHistory.Dequeue();
|
||||
}
|
||||
|
||||
case "Alarm":
|
||||
// 报警信息可以在底部注释中显示
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
底部注释3.Text = $"报警信息:{message}";
|
||||
底部注释3.Visible = true;
|
||||
}
|
||||
break;
|
||||
// 更新显示
|
||||
UpdateEventDisplayFromHistory();
|
||||
}
|
||||
|
||||
// 可以根据需要添加更多的接口类型处理
|
||||
default:
|
||||
// 对于其他类型的接口,可以在底部注释中显示额外信息
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
if (!底部注释4.Visible)
|
||||
{
|
||||
底部注释4.Text = $"{name}:{message}";
|
||||
底部注释4.Visible = true;
|
||||
}
|
||||
else if (!底部注释5.Visible)
|
||||
{
|
||||
底部注释5.Text = $"{name}:{message}";
|
||||
底部注释5.Visible = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// 添加从历史记录更新显示的方法
|
||||
private void UpdateEventDisplayFromHistory()
|
||||
{
|
||||
// 将历史记录转换为数组以便倒序访问
|
||||
EventInfo[] events = eventHistory.ToArray();
|
||||
|
||||
// 清空所有标签和面板
|
||||
for (int i = 0; i < MAX_EVENT_DISPLAY; i++)
|
||||
{
|
||||
eventNameLabels[i].Text = "";
|
||||
eventPanels[i].BackColor = SystemColors.Control;
|
||||
}
|
||||
|
||||
// 计算开始显示的索引,确保最新的事件显示在底部
|
||||
int startIndex = 0;
|
||||
int displayCount = Math.Min(events.Length, MAX_EVENT_DISPLAY);
|
||||
|
||||
// 填充显示区域,按照时间顺序从上到下排列
|
||||
for (int i = 0; i < displayCount; i++)
|
||||
{
|
||||
// 获取当前事件(从最早的开始)
|
||||
EventInfo currentEvent = events[i];
|
||||
|
||||
// 更新事件名称标签
|
||||
eventNameLabels[i].Text = $"{currentEvent.Name} | {currentEvent.Time.ToString("HH:mm:ss")} ";
|
||||
|
||||
// 更新事件结果面板颜色
|
||||
switch (currentEvent.Result)
|
||||
{
|
||||
case mesresult.PASS:
|
||||
eventPanels[i].BackColor = Color.Green;
|
||||
break;
|
||||
case mesresult.FAIL:
|
||||
eventPanels[i].BackColor = Color.Red;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 修改MES_MsgfORM方法
|
||||
public void MES_MsgfORM(string name, ApiFormResult result, DateTime dateTime)
|
||||
{
|
||||
if ("status,alarm".Contains(name.ToLower()))
|
||||
return;
|
||||
// 显示MES提示信息
|
||||
MES提示信息.Visible = true;
|
||||
MES提示信息.Text = $"{result.Msg}";
|
||||
MES提示信息.ForeColor = result.Mesresult == mesresult.PASS ? Color.Green : Color.Red;
|
||||
|
||||
事件结果.Visible = true;
|
||||
事件结果.Text = result.Mesresult == mesresult.PASS ? "PASS" : "FIELD";
|
||||
事件结果.ForeColor = result.Mesresult == mesresult.PASS ? Color.Green : Color.Red;
|
||||
|
||||
// 更新事件显示区域
|
||||
UpdateEventDisplay(name, result.Mesresult, dateTime, result.Msg);
|
||||
}
|
||||
@@ -1374,59 +1399,68 @@ namespace WindowsFormsApp1
|
||||
}
|
||||
var ReturnValue = dataBuilder.ToString();
|
||||
//LogExecute.logNet.WriteDebug($"通过气密仪获取到 {ReturnValue}");
|
||||
|
||||
int index1 = 1;
|
||||
int index2 = 1;
|
||||
string press = string.Empty;
|
||||
string leakage = string.Empty;
|
||||
//pressure选择为yes// export选择为yes(非常重要)
|
||||
var dataArray = ReturnValue.Trim('\r', '\n').Split('\t');
|
||||
float[] sealFloat = new float[2];
|
||||
|
||||
//充气压力
|
||||
if (dataArray[3] == "")
|
||||
if (ReturnValue.Length < 30)
|
||||
{
|
||||
sealFloat[0] = 0;
|
||||
//后一台气密
|
||||
//<01>:(OK): 0.032 ml/min
|
||||
Init.airtight.Leak_Value = ReturnValue.Substring(11, 5);
|
||||
Init.airtight.LastTime = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dataArray[3].Contains("-"))
|
||||
int index1 = 1;
|
||||
int index2 = 1;
|
||||
string press = string.Empty;
|
||||
string leakage = string.Empty;
|
||||
//pressure选择为yes// export选择为yes(非常重要)
|
||||
var dataArray = ReturnValue.Trim('\r', '\n').Split('\t');
|
||||
float[] sealFloat = new float[2];
|
||||
|
||||
//充气压力
|
||||
if (dataArray[3] == "")
|
||||
{
|
||||
press = dataArray[3].Remove(0, 1);
|
||||
index1 = -1;
|
||||
sealFloat[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
press = dataArray[3];
|
||||
index1 = 1;
|
||||
if (dataArray[3].Contains("-"))
|
||||
{
|
||||
press = dataArray[3].Remove(0, 1);
|
||||
index1 = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
press = dataArray[3];
|
||||
index1 = 1;
|
||||
}
|
||||
sealFloat[0] = float.Parse(press);
|
||||
}
|
||||
sealFloat[0] = float.Parse(press);
|
||||
}
|
||||
|
||||
//测试泄露结果
|
||||
if (dataArray[5] == "")
|
||||
sealFloat[1] = 0;
|
||||
else
|
||||
{
|
||||
if (dataArray[5].Contains("-"))
|
||||
{
|
||||
leakage = dataArray[5].Remove(0, 1);
|
||||
index2 = -1;
|
||||
}
|
||||
//测试泄露结果
|
||||
if (dataArray[5] == "")
|
||||
sealFloat[1] = 0;
|
||||
else
|
||||
{
|
||||
leakage = dataArray[5];
|
||||
index2 = 1;
|
||||
if (dataArray[5].Contains("-"))
|
||||
{
|
||||
leakage = dataArray[5].Remove(0, 1);
|
||||
index2 = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
leakage = dataArray[5];
|
||||
index2 = 1;
|
||||
}
|
||||
sealFloat[1] = float.Parse(leakage);
|
||||
}
|
||||
sealFloat[1] = float.Parse(leakage);
|
||||
}
|
||||
|
||||
int[] sealInt = new int[2];
|
||||
sealInt[0] = Convert.ToInt32(sealFloat[1] * 1000) * (index2);
|
||||
sealInt[1] = Convert.ToInt32(sealFloat[0] * 1000) * (index1);
|
||||
Init.airtight.Airtight_Value = sealInt[0].ToString();
|
||||
Init.airtight.Leak_Value = sealInt[1].ToString();
|
||||
Init.airtight.LastTime = DateTime.Now;
|
||||
int[] sealInt = new int[2];
|
||||
sealInt[0] = Convert.ToInt32(sealFloat[1] * 1000) * (index2);
|
||||
sealInt[1] = Convert.ToInt32(sealFloat[0] * 1000) * (index1);
|
||||
Init.airtight.Airtight_Value = sealInt[0].ToString();
|
||||
Init.airtight.Leak_Value = sealInt[1].ToString();
|
||||
Init.airtight.LastTime = DateTime.Now;
|
||||
}
|
||||
CsvLogger.Log($"{Init.airtight.Airtight_Value},{Init.airtight.Leak_Value}");
|
||||
LogExecute.SNlogNet.WriteDebug($"通过气密仪获取到 压力值:{Init.airtight.Airtight_Value},泄露值:{Init.airtight.Leak_Value}");
|
||||
}
|
||||
@@ -1449,7 +1483,7 @@ namespace WindowsFormsApp1
|
||||
otherdata statusOtherData = new otherdata();
|
||||
statusOtherData.Plc_Status = Init.Plcstatus;
|
||||
|
||||
var statusResult = statusApiClient.CallFunctionByName("Status", null, statusOtherData);
|
||||
var statusResult = statusApiClient.CallFunctionByName("Status", new plcdata(), statusOtherData);
|
||||
if (statusResult.Success)
|
||||
{
|
||||
MES_MsgfORM("Status", statusResult, statusResult.Requesttime);
|
||||
@@ -1457,13 +1491,11 @@ namespace WindowsFormsApp1
|
||||
// 更新最后上报时间
|
||||
Init.Plcstatus_LastTime = DateTime.Now;
|
||||
|
||||
LogExecute.logNet.WriteDebug($"定时上报机台状态成功: {Init.Plcstatus}");
|
||||
LogExecute.OEElogNet.WriteDebug($"定时上报机台状态成功: {plcstatus.GetName(typeof(plcstatus), Init.Plcstatus)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//MES链接状态.Text = "MES链接状态:NG";
|
||||
//MES链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"定时上报机台状态失败: MES通讯异常!");
|
||||
LogExecute.OEElogNet.WriteError($"定时上报机台状态失败: MES通讯异常!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1472,5 +1504,16 @@ namespace WindowsFormsApp1
|
||||
}
|
||||
}
|
||||
|
||||
private void 图片标注ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SimpleImageDisplayForm simpleImageDisplayForm = new SimpleImageDisplayForm();
|
||||
simpleImageDisplayForm.ShowDialog();
|
||||
}
|
||||
|
||||
private void 螺丝引导ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ImageDisplayForm imageDisplayForm = new ImageDisplayForm();
|
||||
imageDisplayForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user