页面布局修改
This commit is contained in:
1 parent
d20b935213
commit
752e1f37b6
9 files changed
+1625
-1033
No files matched your search
@@ -187,6 +187,9 @@
|
|||||||
<Compile Include="form\ScanForm_SSQ.Designer.cs">
|
<Compile Include="form\ScanForm_SSQ.Designer.cs">
|
||||||
<DependentUpon>ScanForm_SSQ.cs</DependentUpon>
|
<DependentUpon>ScanForm_SSQ.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="form\SimpleImageDisplayForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="form\Torqueaddress_Manage.cs">
|
<Compile Include="form\Torqueaddress_Manage.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -334,6 +337,9 @@
|
|||||||
<EmbeddedResource Include="form\ScanForm_SSQ.resx">
|
<EmbeddedResource Include="form\ScanForm_SSQ.resx">
|
||||||
<DependentUpon>ScanForm_SSQ.cs</DependentUpon>
|
<DependentUpon>ScanForm_SSQ.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="form\SimpleImageDisplayForm.resx">
|
||||||
|
<DependentUpon>SimpleImageDisplayForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="form\Torqueaddress_Manage.resx">
|
<EmbeddedResource Include="form\Torqueaddress_Manage.resx">
|
||||||
<DependentUpon>Torqueaddress_Manage.cs</DependentUpon>
|
<DependentUpon>Torqueaddress_Manage.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|||||||
Generated
+596
-434
File diff suppressed because it is too large.
Load diff
+276
-233
@@ -44,17 +44,22 @@ namespace WindowsFormsApp1
|
|||||||
private ApiClient statusApiClient = new ApiClient(); // 专用于状态上报的API客户端
|
private ApiClient statusApiClient = new ApiClient(); // 专用于状态上报的API客户端
|
||||||
private object curingLock = new object();
|
private object curingLock = new object();
|
||||||
private int OldPlcTrigger = 0;
|
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()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
// 添加FormClosed事件处理程序
|
InitializeEventDisplay();
|
||||||
this.FormClosed += MainForm_FormClosed;
|
|
||||||
|
|
||||||
CheckForIllegalCrossThreadCalls = false;
|
CheckForIllegalCrossThreadCalls = false;
|
||||||
|
|
||||||
// 初始化状态上报定时器
|
// 初始化状态上报定时器
|
||||||
statusReportTimer.Interval = 15000; // 15秒
|
statusReportTimer.Interval = 15000; // 15秒
|
||||||
//statusReportTimer.Tick += StatusReportTimer_Tick;
|
statusReportTimer.Tick += StatusReportTimer_Tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Form1_Load(object sender, EventArgs e)
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
@@ -62,13 +67,15 @@ namespace WindowsFormsApp1
|
|||||||
LogExecute.logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
LogExecute.logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||||
LogExecute.PlclogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
LogExecute.PlclogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||||
LogExecute.ApilogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
LogExecute.ApilogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||||
|
LogExecute.OEElogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||||
|
|
||||||
|
|
||||||
FormRecover();
|
FormRecover();
|
||||||
|
|
||||||
linename.Text = Init.t_Line.linename;
|
linename.Text = $"{Init.t_Line.linename}";
|
||||||
linecode.Text = Init.t_Line.lineremark1;
|
linecode.Text = $"Line: {Init.t_Line.lineremark1}";
|
||||||
linetype.Text = Init.t_Line.lineremark2;
|
linetype.Text = $"Station: {Init.t_Line.lineremark2}";
|
||||||
linemode.Text = Init.t_Line.lineremark3;
|
linemode.Text = $"MachineID: {Init.t_Line.lineremark3}";
|
||||||
//lineremark1.Text = "";
|
//lineremark1.Text = "";
|
||||||
//lineremark2.Text = "";
|
//lineremark2.Text = "";
|
||||||
//lineremark3.Text = "";
|
//lineremark3.Text = "";
|
||||||
@@ -103,6 +110,15 @@ namespace WindowsFormsApp1
|
|||||||
|
|
||||||
public void build(t_plc Plc, CancellationToken token)
|
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)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -164,7 +180,8 @@ namespace WindowsFormsApp1
|
|||||||
|
|
||||||
//if(Plc.id == 1)
|
//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;
|
Tray盘二维码.Text = PlcData.Read_MaterialCode1;
|
||||||
材料值.Text = PlcData.Read_MaterialCode2;
|
材料值.Text = PlcData.Read_MaterialCode2;
|
||||||
Init.ImageLocation = PlcData.Read_Other4;
|
Init.ImageLocation = PlcData.Read_Other4;
|
||||||
@@ -194,9 +211,10 @@ namespace WindowsFormsApp1
|
|||||||
|
|
||||||
//机台状态
|
//机台状态
|
||||||
//机台状态.Text = "机台状态:" + Enum.GetName(typeof(plcstatus), Init.Plcstatus);
|
//机台状态.Text = "机台状态:" + Enum.GetName(typeof(plcstatus), Init.Plcstatus);
|
||||||
|
Init.Plcstatus = PlcData.Read_Status;
|
||||||
int oldstatus = Init.Plcstatus;
|
int oldstatus = Init.Plcstatus;
|
||||||
//if (PlcData.Read_Status != 0)
|
//if (PlcData.Read_Status != 0)
|
||||||
if(false)
|
if (false)
|
||||||
{
|
{
|
||||||
//状态+报警
|
//状态+报警
|
||||||
if (oldstatus != PlcData.Read_Status)
|
if (oldstatus != PlcData.Read_Status)
|
||||||
@@ -274,6 +292,7 @@ namespace WindowsFormsApp1
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 判断及查找流程
|
#region 判断及查找流程
|
||||||
|
|
||||||
if (PlcData.Read_Trigger == OldPlcTrigger)
|
if (PlcData.Read_Trigger == OldPlcTrigger)
|
||||||
@@ -332,6 +351,7 @@ namespace WindowsFormsApp1
|
|||||||
{
|
{
|
||||||
string returnValue = scanForm.ReturnValue;
|
string returnValue = scanForm.ReturnValue;
|
||||||
otherdata.JS_SN = returnValue;
|
otherdata.JS_SN = returnValue;
|
||||||
|
PlcData.Write_stSN = returnValue;
|
||||||
//Init.SN = returnValue;
|
//Init.SN = returnValue;
|
||||||
LOT号.Text = returnValue;
|
LOT号.Text = returnValue;
|
||||||
Init.ScanString = returnValue;
|
Init.ScanString = returnValue;
|
||||||
@@ -551,13 +571,12 @@ namespace WindowsFormsApp1
|
|||||||
otherdata.ImageAddress = Init.t_Keyvalues.First(x => x.key == "ImageFilePath").value;
|
otherdata.ImageAddress = Init.t_Keyvalues.First(x => x.key == "ImageFilePath").value;
|
||||||
otherdata.VedioAddress = Init.t_Keyvalues.First(x => x.key == "VedioFilePath").value;
|
otherdata.VedioAddress = Init.t_Keyvalues.First(x => x.key == "VedioFilePath").value;
|
||||||
|
|
||||||
|
|
||||||
#region 调用后端接口
|
#region 调用后端接口
|
||||||
var result = apiClient.CallFunctionByName(nowinterface.code, PlcData, otherdata);
|
var result = apiClient.CallFunctionByName(nowinterface.code, PlcData, otherdata);
|
||||||
if (result.IsShow)
|
//if (result.IsShow)
|
||||||
{
|
//{
|
||||||
MES_MsgfORM(nowinterface.code, result, result.Requesttime);
|
// MES_MsgfORM(nowinterface.code, result, result.Requesttime);
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
@@ -701,6 +720,9 @@ namespace WindowsFormsApp1
|
|||||||
|
|
||||||
// 初始化PLC状态面板
|
// 初始化PLC状态面板
|
||||||
InitializePlcStatusPanel();
|
InitializePlcStatusPanel();
|
||||||
|
// 启动状态上报定时器
|
||||||
|
statusReportTimer.Start();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region 初始化COM口服务
|
#region 初始化COM口服务
|
||||||
try
|
try
|
||||||
@@ -718,7 +740,6 @@ namespace WindowsFormsApp1
|
|||||||
底部注释1.Text = "扫码枪COM-Ready";
|
底部注释1.Text = "扫码枪COM-Ready";
|
||||||
底部注释1.Visible = true;
|
底部注释1.Visible = true;
|
||||||
// 订阅 DataReceived 事件
|
// 订阅 DataReceived 事件
|
||||||
胶水上下线.Enabled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -746,7 +767,6 @@ namespace WindowsFormsApp1
|
|||||||
底部注释2.Visible = true;
|
底部注释2.Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
胶水上下线.Enabled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -766,6 +786,7 @@ namespace WindowsFormsApp1
|
|||||||
{
|
{
|
||||||
threadHelp.cancellationTokenSource1 = new CancellationTokenSource();
|
threadHelp.cancellationTokenSource1 = new CancellationTokenSource();
|
||||||
threadHelp.Thread = new Thread(() => build(plc, threadHelp.cancellationTokenSource1.Token));
|
threadHelp.Thread = new Thread(() => build(plc, threadHelp.cancellationTokenSource1.Token));
|
||||||
|
threadHelp.Thread.Name = $"PLC_{plc.id}_Thread"; // 显式设置线程名称
|
||||||
threadHelp.Thread.Start();
|
threadHelp.Thread.Start();
|
||||||
threadHelp.isrunning1 = true;
|
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)
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
// 设置窗体正在关闭标志
|
// 设置窗体正在关闭标志
|
||||||
@@ -978,11 +947,11 @@ namespace WindowsFormsApp1
|
|||||||
materialScanForm.Show();
|
materialScanForm.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void 图片展示ToolStripMenuItem_Click(object sender, EventArgs e)
|
//private void 图片展示ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
//{
|
||||||
ImageDisplayForm displayForm = new ImageDisplayForm();
|
// ImageDisplayForm displayForm = new ImageDisplayForm();
|
||||||
displayForm.Show();
|
// displayForm.Show();
|
||||||
}
|
//}
|
||||||
|
|
||||||
private void pLC通讯设置ToolStripMenuItem_Click(object sender, EventArgs e)
|
private void pLC通讯设置ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@@ -1068,36 +1037,59 @@ namespace WindowsFormsApp1
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确定应该显示在哪个日志框中
|
||||||
|
RichTextBox targetLogBox;
|
||||||
|
|
||||||
|
// 根据日志来源确定目标日志框
|
||||||
|
if (sender == LogExecute.OEElogNet)
|
||||||
|
{
|
||||||
|
targetLogBox = richTextBox2; // PLC相关日志显示在第二个日志框
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetLogBox = richTextBox1; // 其他日志显示在第一个日志框
|
||||||
|
}
|
||||||
|
|
||||||
logBuilder.Append(logPrefix).Append(time.ToString()).Append(" | ").Append(text).Append("\n");
|
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)
|
if (lineCount >= 200)
|
||||||
{
|
{
|
||||||
// 优化:只保留后 100 行,而不是全部清空再重新添加
|
// 优化:只保留后 100 行,而不是全部清空再重新添加
|
||||||
int startIndex = richTextBox1.GetFirstCharIndexFromLine(lineCount - 100);
|
int startIndex = targetLogBox.GetFirstCharIndexFromLine(lineCount - 100);
|
||||||
if (startIndex > 0)
|
if (startIndex > 0)
|
||||||
{
|
{
|
||||||
richTextBox1.Select(0, startIndex);
|
targetLogBox.Select(0, startIndex);
|
||||||
richTextBox1.SelectedText = "";
|
targetLogBox.SelectedText = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加新日志
|
// 添加新日志
|
||||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
targetLogBox.SelectionStart = richTextBox1.TextLength;
|
||||||
richTextBox1.SelectionLength = 0;
|
targetLogBox.SelectionLength = 0;
|
||||||
richTextBox1.SelectionColor = logColor;
|
targetLogBox.SelectionColor = logColor;
|
||||||
richTextBox1.AppendText(logBuilder.ToString());
|
targetLogBox.AppendText(logBuilder.ToString());
|
||||||
|
|
||||||
// 重置颜色并滚动到底部
|
// 重置颜色并滚动到底部
|
||||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
targetLogBox.SelectionStart = richTextBox1.TextLength;
|
||||||
richTextBox1.SelectionLength = 0;
|
targetLogBox.SelectionLength = 0;
|
||||||
richTextBox1.SelectionColor = richTextBox1.ForeColor;
|
targetLogBox.SelectionColor = richTextBox1.ForeColor;
|
||||||
richTextBox1.ScrollToCaret();
|
targetLogBox.ScrollToCaret();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
catch { /* 忽略异常 */ }
|
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)
|
private void timer1_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
当前时间.Text = "当前时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
|
当前时间.Text = "当前时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
|
||||||
@@ -1107,20 +1099,6 @@ namespace WindowsFormsApp1
|
|||||||
开始处理.Text = "开始处理";
|
开始处理.Text = "开始处理";
|
||||||
开始处理.BackColor = Color.Green;
|
开始处理.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;
|
底部注释1.Visible = false;
|
||||||
底部注释2.Visible = false;
|
底部注释2.Visible = false;
|
||||||
底部注释3.Visible = false;
|
底部注释3.Visible = false;
|
||||||
@@ -1237,112 +1215,159 @@ namespace WindowsFormsApp1
|
|||||||
catch { /* 忽略异常 */ }
|
catch { /* 忽略异常 */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// 添加初始化事件显示区域的方法
|
||||||
/// 更新事件显示区域
|
private void InitializeEventDisplay()
|
||||||
/// </summary>
|
{
|
||||||
|
// 清空现有列表
|
||||||
|
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)
|
private void UpdateEventDisplay(string name, mesresult result, DateTime dateTime, string message)
|
||||||
{
|
{
|
||||||
UpdateEventSlot(事件1, 事件1结果, 事件1时间, name, result, dateTime, message);
|
// 创建新的事件信息
|
||||||
// 根据接口名称显示特定信息
|
EventInfo newEvent = new EventInfo
|
||||||
//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)
|
|
||||||
{
|
{
|
||||||
case "SN_Release":
|
Name = name,
|
||||||
// 显示SN号
|
Result = result,
|
||||||
if (!string.IsNullOrEmpty(Init.ScanString))
|
Time = dateTime,
|
||||||
{
|
Message = message
|
||||||
LOT号.Text = $"SN号:{Init.ScanString}";
|
};
|
||||||
LOT号.Visible = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Tray_Release":
|
// 添加到历史记录
|
||||||
// 显示Tray盘信息
|
eventHistory.Enqueue(newEvent);
|
||||||
if (!string.IsNullOrEmpty(message))
|
|
||||||
{
|
|
||||||
Tray盘二维码.Text = $"Tray盘:{message}";
|
|
||||||
Tray盘二维码.Visible = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Status":
|
// 如果超过最大显示数量,移除最早的记录
|
||||||
// 机台状态信息已在其他地方更新
|
while (eventHistory.Count > MAX_EVENT_DISPLAY)
|
||||||
break;
|
{
|
||||||
|
eventHistory.Dequeue();
|
||||||
|
}
|
||||||
|
|
||||||
case "Alarm":
|
// 更新显示
|
||||||
// 报警信息可以在底部注释中显示
|
UpdateEventDisplayFromHistory();
|
||||||
if (!string.IsNullOrEmpty(message))
|
}
|
||||||
{
|
|
||||||
底部注释3.Text = $"报警信息:{message}";
|
|
||||||
底部注释3.Visible = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 可以根据需要添加更多的接口类型处理
|
// 添加从历史记录更新显示的方法
|
||||||
default:
|
private void UpdateEventDisplayFromHistory()
|
||||||
// 对于其他类型的接口,可以在底部注释中显示额外信息
|
{
|
||||||
if (!string.IsNullOrEmpty(message))
|
// 将历史记录转换为数组以便倒序访问
|
||||||
{
|
EventInfo[] events = eventHistory.ToArray();
|
||||||
if (!底部注释4.Visible)
|
|
||||||
{
|
// 清空所有标签和面板
|
||||||
底部注释4.Text = $"{name}:{message}";
|
for (int i = 0; i < MAX_EVENT_DISPLAY; i++)
|
||||||
底部注释4.Visible = true;
|
{
|
||||||
}
|
eventNameLabels[i].Text = "";
|
||||||
else if (!底部注释5.Visible)
|
eventPanels[i].BackColor = SystemColors.Control;
|
||||||
{
|
}
|
||||||
底部注释5.Text = $"{name}:{message}";
|
|
||||||
底部注释5.Visible = true;
|
// 计算开始显示的索引,确保最新的事件显示在底部
|
||||||
}
|
int startIndex = 0;
|
||||||
}
|
int displayCount = Math.Min(events.Length, MAX_EVENT_DISPLAY);
|
||||||
break;
|
|
||||||
|
// 填充显示区域,按照时间顺序从上到下排列
|
||||||
|
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)
|
public void MES_MsgfORM(string name, ApiFormResult result, DateTime dateTime)
|
||||||
{
|
{
|
||||||
|
if ("status,alarm".Contains(name.ToLower()))
|
||||||
|
return;
|
||||||
// 显示MES提示信息
|
// 显示MES提示信息
|
||||||
MES提示信息.Visible = true;
|
MES提示信息.Visible = true;
|
||||||
MES提示信息.Text = $"{result.Msg}";
|
MES提示信息.Text = $"{result.Msg}";
|
||||||
MES提示信息.ForeColor = result.Mesresult == mesresult.PASS ? Color.Green : Color.Red;
|
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);
|
UpdateEventDisplay(name, result.Mesresult, dateTime, result.Msg);
|
||||||
}
|
}
|
||||||
@@ -1374,59 +1399,68 @@ namespace WindowsFormsApp1
|
|||||||
}
|
}
|
||||||
var ReturnValue = dataBuilder.ToString();
|
var ReturnValue = dataBuilder.ToString();
|
||||||
//LogExecute.logNet.WriteDebug($"通过气密仪获取到 {ReturnValue}");
|
//LogExecute.logNet.WriteDebug($"通过气密仪获取到 {ReturnValue}");
|
||||||
|
if (ReturnValue.Length < 30)
|
||||||
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] == "")
|
|
||||||
{
|
{
|
||||||
sealFloat[0] = 0;
|
//后一台气密
|
||||||
|
//<01>:(OK): 0.032 ml/min
|
||||||
|
Init.airtight.Leak_Value = ReturnValue.Substring(11, 5);
|
||||||
|
Init.airtight.LastTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
else
|
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);
|
sealFloat[0] = 0;
|
||||||
index1 = -1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
press = dataArray[3];
|
if (dataArray[3].Contains("-"))
|
||||||
index1 = 1;
|
{
|
||||||
|
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] == "")
|
if (dataArray[5] == "")
|
||||||
sealFloat[1] = 0;
|
sealFloat[1] = 0;
|
||||||
else
|
|
||||||
{
|
|
||||||
if (dataArray[5].Contains("-"))
|
|
||||||
{
|
|
||||||
leakage = dataArray[5].Remove(0, 1);
|
|
||||||
index2 = -1;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
leakage = dataArray[5];
|
if (dataArray[5].Contains("-"))
|
||||||
index2 = 1;
|
{
|
||||||
|
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];
|
int[] sealInt = new int[2];
|
||||||
sealInt[0] = Convert.ToInt32(sealFloat[1] * 1000) * (index2);
|
sealInt[0] = Convert.ToInt32(sealFloat[1] * 1000) * (index2);
|
||||||
sealInt[1] = Convert.ToInt32(sealFloat[0] * 1000) * (index1);
|
sealInt[1] = Convert.ToInt32(sealFloat[0] * 1000) * (index1);
|
||||||
Init.airtight.Airtight_Value = sealInt[0].ToString();
|
Init.airtight.Airtight_Value = sealInt[0].ToString();
|
||||||
Init.airtight.Leak_Value = sealInt[1].ToString();
|
Init.airtight.Leak_Value = sealInt[1].ToString();
|
||||||
Init.airtight.LastTime = DateTime.Now;
|
Init.airtight.LastTime = DateTime.Now;
|
||||||
|
}
|
||||||
CsvLogger.Log($"{Init.airtight.Airtight_Value},{Init.airtight.Leak_Value}");
|
CsvLogger.Log($"{Init.airtight.Airtight_Value},{Init.airtight.Leak_Value}");
|
||||||
LogExecute.SNlogNet.WriteDebug($"通过气密仪获取到 压力值:{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();
|
otherdata statusOtherData = new otherdata();
|
||||||
statusOtherData.Plc_Status = Init.Plcstatus;
|
statusOtherData.Plc_Status = Init.Plcstatus;
|
||||||
|
|
||||||
var statusResult = statusApiClient.CallFunctionByName("Status", null, statusOtherData);
|
var statusResult = statusApiClient.CallFunctionByName("Status", new plcdata(), statusOtherData);
|
||||||
if (statusResult.Success)
|
if (statusResult.Success)
|
||||||
{
|
{
|
||||||
MES_MsgfORM("Status", statusResult, statusResult.Requesttime);
|
MES_MsgfORM("Status", statusResult, statusResult.Requesttime);
|
||||||
@@ -1457,13 +1491,11 @@ namespace WindowsFormsApp1
|
|||||||
// 更新最后上报时间
|
// 更新最后上报时间
|
||||||
Init.Plcstatus_LastTime = DateTime.Now;
|
Init.Plcstatus_LastTime = DateTime.Now;
|
||||||
|
|
||||||
LogExecute.logNet.WriteDebug($"定时上报机台状态成功: {Init.Plcstatus}");
|
LogExecute.OEElogNet.WriteDebug($"定时上报机台状态成功: {plcstatus.GetName(typeof(plcstatus), Init.Plcstatus)}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//MES链接状态.Text = "MES链接状态:NG";
|
LogExecute.OEElogNet.WriteError($"定时上报机台状态失败: MES通讯异常!");
|
||||||
//MES链接状态.BackColor = Color.Red;
|
|
||||||
LogExecute.logNet.WriteError($"定时上报机台状态失败: MES通讯异常!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,28 @@ namespace WindowsFormsApp1
|
|||||||
public MaterialScanForm()
|
public MaterialScanForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Init.ScanPort.DataReceived += SerialPort_DataReceived_CL;
|
// 检查串口是否可用
|
||||||
|
if (Init.ScanPort != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 如果串口未打开,尝试打开
|
||||||
|
if (!Init.ScanPort.IsOpen)
|
||||||
|
{
|
||||||
|
Init.ScanPort.Open();
|
||||||
|
}
|
||||||
|
// 订阅事件
|
||||||
|
Init.ScanPort.DataReceived += SerialPort_DataReceived_CL;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"扫码枪串口初始化失败: {ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("扫码枪串口未配置,请检查系统设置", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
_dbHelper = new SQLiteHelper<t_materialscan>();
|
_dbHelper = new SQLiteHelper<t_materialscan>();
|
||||||
_apiClient = new ApiClient();
|
_apiClient = new ApiClient();
|
||||||
LoadMaterials();
|
LoadMaterials();
|
||||||
@@ -42,9 +63,17 @@ namespace WindowsFormsApp1
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!Init.ScanPort.IsOpen)
|
if (Init.ScanPort != null && !Init.ScanPort.IsOpen)
|
||||||
{
|
{
|
||||||
Init.ScanPort?.Open();
|
try
|
||||||
|
{
|
||||||
|
Init.ScanPort.Open();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"无法打开扫码枪串口: {ex.Message}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 读取串口接收到的数据
|
// 读取串口接收到的数据
|
||||||
var dataBuilder = new StringBuilder();
|
var dataBuilder = new StringBuilder();
|
||||||
|
|||||||
@@ -10,28 +10,29 @@ namespace WindowsFormsApp1
|
|||||||
{
|
{
|
||||||
public partial class ImageDisplayForm : Form
|
public partial class ImageDisplayForm : Form
|
||||||
{
|
{
|
||||||
|
#region 控件字段
|
||||||
protected PictureBox pictureBox;
|
protected PictureBox pictureBox;
|
||||||
protected Button btnLoadImage;
|
#endregion
|
||||||
protected TextBox txtX;
|
|
||||||
protected TextBox txtY;
|
|
||||||
protected TextBox txtName;
|
|
||||||
protected TextBox txtPosition;
|
|
||||||
protected Button btnSave;
|
|
||||||
protected Panel panel;
|
|
||||||
protected Label lblX;
|
|
||||||
protected Label lblY;
|
|
||||||
protected Label lblName;
|
|
||||||
protected Label lblPosition;
|
|
||||||
|
|
||||||
|
#region 私有字段
|
||||||
|
private IContainer components = null;
|
||||||
private Bitmap originalImage;
|
private Bitmap originalImage;
|
||||||
private Bitmap markedImage;
|
private Bitmap markedImage;
|
||||||
private Timer blinkTimer;
|
private Timer blinkTimer;
|
||||||
private bool isBlinking = false;
|
private Timer autoUpdateTimer;
|
||||||
private IContainer components = null;
|
|
||||||
private string currentName = "";
|
private string currentName = "";
|
||||||
private string currentPosition = "";
|
private string currentPosition = "";
|
||||||
private Timer autoUpdateTimer;
|
private bool isBlinking = false;
|
||||||
|
|
||||||
|
// 圆形标记相关参数
|
||||||
|
private float currentRadius = 20f;
|
||||||
|
private const float MIN_RADIUS = 20f;
|
||||||
|
private const float MAX_RADIUS = 50f;
|
||||||
|
private bool isExpanding = true;
|
||||||
|
private const float RADIUS_CHANGE_SPEED = 2f;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 构造函数和初始化
|
||||||
public ImageDisplayForm()
|
public ImageDisplayForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -39,18 +40,22 @@ namespace WindowsFormsApp1
|
|||||||
|
|
||||||
// 初始化自动更新定时器
|
// 初始化自动更新定时器
|
||||||
autoUpdateTimer = new Timer();
|
autoUpdateTimer = new Timer();
|
||||||
autoUpdateTimer.Interval = 10000;
|
autoUpdateTimer.Interval = 1000;
|
||||||
autoUpdateTimer.Tick += new EventHandler(AutoUpdateTimer_Tick);
|
autoUpdateTimer.Tick += new EventHandler(AutoUpdateTimer_Tick);
|
||||||
autoUpdateTimer.Start();
|
autoUpdateTimer.Start();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 公共方法
|
||||||
// 设置当前名称的方法,可以从外部调用
|
// 设置当前名称的方法,可以从外部调用
|
||||||
public void SetCurrentName(string name)
|
public void SetCurrentName(string name)
|
||||||
{
|
{
|
||||||
currentName = name;
|
currentName = name;
|
||||||
LoadImageByName(name);
|
LoadImageByName(name);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 图像加载和处理
|
||||||
// 根据名称加载图片
|
// 根据名称加载图片
|
||||||
private void LoadImageByName(string name)
|
private void LoadImageByName(string name)
|
||||||
{
|
{
|
||||||
@@ -93,7 +98,6 @@ namespace WindowsFormsApp1
|
|||||||
originalImage = new Bitmap(imagePath);
|
originalImage = new Bitmap(imagePath);
|
||||||
markedImage = new Bitmap(originalImage);
|
markedImage = new Bitmap(originalImage);
|
||||||
pictureBox.Image = markedImage;
|
pictureBox.Image = markedImage;
|
||||||
txtName.Text = name;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -106,80 +110,12 @@ namespace WindowsFormsApp1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动更新定时器事件
|
// 在图像上绘制标记
|
||||||
private void AutoUpdateTimer_Tick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
// 这里应该从某处获取当前位置变量
|
|
||||||
string newPosition = Init.ImageLocation.ToString();
|
|
||||||
|
|
||||||
if (newPosition != currentPosition || (string.IsNullOrEmpty(currentPosition) && !string.IsNullOrEmpty(newPosition)))
|
|
||||||
{
|
|
||||||
currentPosition = newPosition;
|
|
||||||
txtPosition.Text = currentPosition;
|
|
||||||
|
|
||||||
// 如果名称和位置都有值,则查询坐标并标注
|
|
||||||
if (!string.IsNullOrEmpty(currentName) && !string.IsNullOrEmpty(currentPosition))
|
|
||||||
{
|
|
||||||
QueryAndMarkPosition(currentName, currentPosition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前位置的方法(需要根据实际情况实现)
|
|
||||||
private string GetCurrentPosition()
|
|
||||||
{
|
|
||||||
// 生成1-10的随机数
|
|
||||||
Random random = new Random();
|
|
||||||
int position = random.Next(1, 11); // 1到10之间的随机数
|
|
||||||
return position.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据名称和位置查询坐标并标注
|
|
||||||
private void QueryAndMarkPosition(string name, string position)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
|
|
||||||
var positions = sQLiteHelper_position.Query(x => x.name == name
|
|
||||||
&& x.position == position).Data;
|
|
||||||
|
|
||||||
if (positions != null && positions.Count > 0)
|
|
||||||
{
|
|
||||||
var pos = positions[0];
|
|
||||||
// 更新坐标文本框
|
|
||||||
txtX.Text = pos.x.ToString();
|
|
||||||
txtY.Text = pos.y.ToString();
|
|
||||||
|
|
||||||
// 标记位置
|
|
||||||
if (originalImage != null)
|
|
||||||
{
|
|
||||||
isBlinking = true; // 设置为 true 后不再切换
|
|
||||||
currentRadius = MIN_RADIUS; // 重置半径
|
|
||||||
blinkTimer.Start();
|
|
||||||
DrawMark(pos.x, pos.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"查询坐标失败:{ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float breathScale = 1.0f; // 添加这个字段到类的顶部
|
|
||||||
private const float MIN_SCALE = 0.6f;
|
|
||||||
private const float MAX_SCALE = 1.4f;
|
|
||||||
private bool scaleIncreasing = true;
|
|
||||||
|
|
||||||
// 修改半径相关的常量
|
|
||||||
private float currentRadius = 20f; // 增大初始半径
|
|
||||||
private const float MIN_RADIUS = 20f; // 最小半径
|
|
||||||
private const float MAX_RADIUS = 50f; // 增大最大半径
|
|
||||||
private bool isExpanding = true;
|
|
||||||
private const float RADIUS_CHANGE_SPEED = 2f;
|
|
||||||
|
|
||||||
private void DrawMark(int x, int y)
|
private void DrawMark(int x, int y)
|
||||||
{
|
{
|
||||||
|
if (originalImage == null)
|
||||||
|
return;
|
||||||
|
|
||||||
markedImage = new Bitmap(originalImage);
|
markedImage = new Bitmap(originalImage);
|
||||||
using (Graphics g = Graphics.FromImage(markedImage))
|
using (Graphics g = Graphics.FromImage(markedImage))
|
||||||
{
|
{
|
||||||
@@ -189,7 +125,7 @@ namespace WindowsFormsApp1
|
|||||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
||||||
|
|
||||||
// 只绘制白色圆
|
// 只绘制白色圆
|
||||||
using (Brush whiteBrush = new SolidBrush(Color.Yellow))
|
using (Brush whiteBrush = new SolidBrush(Color.White))
|
||||||
{
|
{
|
||||||
g.FillEllipse(whiteBrush,
|
g.FillEllipse(whiteBrush,
|
||||||
x - currentRadius,
|
x - currentRadius,
|
||||||
@@ -221,139 +157,86 @@ namespace WindowsFormsApp1
|
|||||||
}
|
}
|
||||||
pictureBox.Image = markedImage;
|
pictureBox.Image = markedImage;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private void BlinkTimer_Tick(object sender, EventArgs e)
|
#region 数据查询和更新
|
||||||
|
// 自动更新定时器事件
|
||||||
|
private void AutoUpdateTimer_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// 移除 isBlinking 切换,保持为 true
|
// 获取当前位置变量
|
||||||
if (!int.TryParse(txtX.Text, out int x) || !int.TryParse(txtY.Text, out int y))
|
//string newPosition = GetCurrentPosition();
|
||||||
return;
|
string newPosition = Init.ImageLocation.ToString();
|
||||||
DrawMark(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PictureBox_Click(object sender, EventArgs e)
|
if (newPosition != currentPosition || (string.IsNullOrEmpty(currentPosition) && !string.IsNullOrEmpty(newPosition)))
|
||||||
{
|
|
||||||
if (originalImage == null || !(e is MouseEventArgs me))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 获取图片在 PictureBox 中的实际显示尺寸和位置
|
|
||||||
float ratioX = (float)originalImage.Width / pictureBox.ClientSize.Width;
|
|
||||||
float ratioY = (float)originalImage.Height / pictureBox.ClientSize.Height;
|
|
||||||
float ratio = Math.Max(ratioX, ratioY);
|
|
||||||
|
|
||||||
float imageWidth = originalImage.Width / ratio;
|
|
||||||
float imageHeight = originalImage.Height / ratio;
|
|
||||||
|
|
||||||
// 计算图片在 PictureBox 中的显示位置
|
|
||||||
float imageX = (pictureBox.ClientSize.Width - imageWidth) / 2;
|
|
||||||
float imageY = (pictureBox.ClientSize.Height - imageHeight) / 2;
|
|
||||||
|
|
||||||
// 将点击坐标转换为图片实际坐标
|
|
||||||
int x = (int)((me.X - imageX) * ratio);
|
|
||||||
int y = (int)((me.Y - imageY) * ratio);
|
|
||||||
|
|
||||||
// 确保坐标在图片范围内
|
|
||||||
if (x >= 0 && x < originalImage.Width && y >= 0 && y < originalImage.Height)
|
|
||||||
{
|
{
|
||||||
txtX.Text = x.ToString();
|
currentPosition = newPosition;
|
||||||
txtY.Text = y.ToString();
|
|
||||||
BtnMark_Click(sender, e); // 自动标记位置
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BtnLoadImage_Click(object sender, EventArgs e)
|
// 如果名称和位置都有值,则查询坐标并标注
|
||||||
{
|
if (!string.IsNullOrEmpty(currentName) && !string.IsNullOrEmpty(currentPosition))
|
||||||
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
|
||||||
{
|
|
||||||
openFileDialog.Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp|所有文件|*.*";
|
|
||||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
// 停止闪烁定时器并重置状态
|
QueryAndMarkPosition(currentName, currentPosition);
|
||||||
blinkTimer?.Stop();
|
|
||||||
isBlinking = false;
|
|
||||||
|
|
||||||
originalImage = new Bitmap(openFileDialog.FileName);
|
|
||||||
markedImage = new Bitmap(originalImage);
|
|
||||||
pictureBox.Image = markedImage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnMark_Click(object sender, EventArgs e)
|
// 获取当前位置的方法(需要根据实际情况实现)
|
||||||
|
private string GetCurrentPosition()
|
||||||
{
|
{
|
||||||
if (markedImage == null || !int.TryParse(txtX.Text, out int x) || !int.TryParse(txtY.Text, out int y))
|
// 生成1-10的随机数
|
||||||
{
|
Random random = new Random();
|
||||||
MessageBox.Show("请先加载图片并输入有效的坐标值");
|
int position = random.Next(1, 11); // 1到10之间的随机数
|
||||||
return;
|
return position.ToString();
|
||||||
}
|
|
||||||
|
|
||||||
DrawMark(x, y);
|
|
||||||
isBlinking = true;
|
|
||||||
blinkTimer.Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnSave_Click(object sender, EventArgs e)
|
// 根据名称和位置查询坐标并标注
|
||||||
|
private void QueryAndMarkPosition(string name, string position)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(txtName.Text) ||
|
|
||||||
string.IsNullOrWhiteSpace(txtPosition.Text) ||
|
|
||||||
string.IsNullOrWhiteSpace(txtX.Text) ||
|
|
||||||
string.IsNullOrWhiteSpace(txtY.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("请填写完整信息");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加坐标值验证
|
|
||||||
if (!int.TryParse(txtX.Text, out int x) || !int.TryParse(txtY.Text, out int y))
|
|
||||||
{
|
|
||||||
MessageBox.Show("坐标值必须是有效的数字");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查图片是否已加载
|
|
||||||
if (originalImage == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("请先加载图片");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查坐标是否在图片范围内
|
|
||||||
if (x <= 0 || y <= 0 || x >= originalImage.Width || y >= originalImage.Height)
|
|
||||||
{
|
|
||||||
MessageBox.Show($"坐标值超出范围!\n有效范围:X(1-{originalImage.Width}) Y(1-{originalImage.Height})");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
|
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
|
||||||
t_imageposition position = new t_imageposition
|
var positions = sQLiteHelper_position.Query(x => x.name == name
|
||||||
{
|
&& x.position == position).Data;
|
||||||
name = txtName.Text,
|
|
||||||
position = txtPosition.Text,
|
|
||||||
x = int.Parse(txtX.Text),
|
|
||||||
y = int.Parse(txtY.Text),
|
|
||||||
createtime = DateTime.Now
|
|
||||||
};
|
|
||||||
|
|
||||||
var result = sQLiteHelper_position.Insert(position);
|
if (positions != null && positions.Count > 0)
|
||||||
if (result.Success)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show("保存成功!");
|
var pos = positions[0];
|
||||||
// 清空输入框
|
|
||||||
//txtName.Text = "";
|
// 标记位置
|
||||||
txtPosition.Text = "";
|
if (originalImage != null)
|
||||||
}
|
{
|
||||||
else
|
isBlinking = true; // 设置为 true 后不再切换
|
||||||
{
|
currentRadius = MIN_RADIUS; // 重置半径
|
||||||
MessageBox.Show($"保存失败");
|
blinkTimer.Start();
|
||||||
|
DrawMark(pos.x, pos.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show($"保存失败:{ex.Message}");
|
Console.WriteLine($"查询坐标失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 事件处理
|
||||||
|
// 闪烁定时器事件
|
||||||
|
private void BlinkTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
|
||||||
|
var positions = sQLiteHelper_position.Query(x => x.name == currentName
|
||||||
|
&& x.position == currentPosition).Data;
|
||||||
|
|
||||||
|
if (positions != null && positions.Count > 0)
|
||||||
|
{
|
||||||
|
var pos = positions[0];
|
||||||
|
DrawMark(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移除了 BtnLoadImage_Click 事件处理程序
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 资源释放
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
@@ -368,163 +251,33 @@ namespace WindowsFormsApp1
|
|||||||
}
|
}
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
this.panel = new System.Windows.Forms.Panel();
|
|
||||||
this.btnLoadImage = new System.Windows.Forms.Button();
|
|
||||||
this.txtX = new System.Windows.Forms.TextBox();
|
|
||||||
this.txtY = new System.Windows.Forms.TextBox();
|
|
||||||
this.txtName = new System.Windows.Forms.TextBox();
|
|
||||||
this.txtPosition = new System.Windows.Forms.TextBox();
|
|
||||||
this.btnSave = new System.Windows.Forms.Button();
|
|
||||||
this.lblX = new System.Windows.Forms.Label();
|
|
||||||
this.lblY = new System.Windows.Forms.Label();
|
|
||||||
this.lblName = new System.Windows.Forms.Label();
|
|
||||||
this.lblPosition = new System.Windows.Forms.Label();
|
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
this.blinkTimer = new System.Windows.Forms.Timer(this.components);
|
this.blinkTimer = new System.Windows.Forms.Timer(this.components);
|
||||||
this.panel.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// panel
|
|
||||||
//
|
|
||||||
this.panel.Controls.Add(this.btnLoadImage);
|
|
||||||
this.panel.Controls.Add(this.txtX);
|
|
||||||
this.panel.Controls.Add(this.txtY);
|
|
||||||
this.panel.Controls.Add(this.txtName);
|
|
||||||
this.panel.Controls.Add(this.txtPosition);
|
|
||||||
this.panel.Controls.Add(this.btnSave);
|
|
||||||
this.panel.Controls.Add(this.lblX);
|
|
||||||
this.panel.Controls.Add(this.lblY);
|
|
||||||
this.panel.Controls.Add(this.lblName);
|
|
||||||
this.panel.Controls.Add(this.lblPosition);
|
|
||||||
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
|
|
||||||
this.panel.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.panel.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
|
||||||
this.panel.Name = "panel";
|
|
||||||
this.panel.Size = new System.Drawing.Size(1600, 125);
|
|
||||||
this.panel.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// btnLoadImage
|
|
||||||
//
|
|
||||||
this.btnLoadImage.Location = new System.Drawing.Point(20, 21);
|
|
||||||
this.btnLoadImage.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
|
||||||
this.btnLoadImage.Name = "btnLoadImage";
|
|
||||||
this.btnLoadImage.Size = new System.Drawing.Size(200, 62);
|
|
||||||
this.btnLoadImage.TabIndex = 0;
|
|
||||||
this.btnLoadImage.Text = "加载图片";
|
|
||||||
this.btnLoadImage.UseVisualStyleBackColor = true;
|
|
||||||
this.btnLoadImage.Click += new System.EventHandler(this.BtnLoadImage_Click);
|
|
||||||
//
|
|
||||||
// txtX
|
|
||||||
//
|
|
||||||
this.txtX.Location = new System.Drawing.Point(240, 21);
|
|
||||||
this.txtX.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
|
||||||
this.txtX.Name = "txtX";
|
|
||||||
this.txtX.Size = new System.Drawing.Size(116, 31);
|
|
||||||
this.txtX.TabIndex = 1;
|
|
||||||
this.txtX.Text = "0";
|
|
||||||
//
|
|
||||||
// txtY
|
|
||||||
//
|
|
||||||
this.txtY.Location = new System.Drawing.Point(380, 21);
|
|
||||||
this.txtY.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
|
||||||
this.txtY.Name = "txtY";
|
|
||||||
this.txtY.Size = new System.Drawing.Size(116, 31);
|
|
||||||
this.txtY.TabIndex = 2;
|
|
||||||
this.txtY.Text = "0";
|
|
||||||
//
|
|
||||||
// txtName
|
|
||||||
//
|
|
||||||
this.txtName.Location = new System.Drawing.Point(740, 21);
|
|
||||||
this.txtName.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
|
||||||
this.txtName.Name = "txtName";
|
|
||||||
this.txtName.Size = new System.Drawing.Size(196, 31);
|
|
||||||
this.txtName.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// txtPosition
|
|
||||||
//
|
|
||||||
this.txtPosition.Location = new System.Drawing.Point(960, 21);
|
|
||||||
this.txtPosition.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
|
||||||
this.txtPosition.Name = "txtPosition";
|
|
||||||
this.txtPosition.Size = new System.Drawing.Size(196, 31);
|
|
||||||
this.txtPosition.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// btnSave
|
|
||||||
//
|
|
||||||
this.btnSave.Location = new System.Drawing.Point(1180, 21);
|
|
||||||
this.btnSave.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
|
||||||
this.btnSave.Name = "btnSave";
|
|
||||||
this.btnSave.Size = new System.Drawing.Size(200, 62);
|
|
||||||
this.btnSave.TabIndex = 6;
|
|
||||||
this.btnSave.Text = "保存";
|
|
||||||
this.btnSave.UseVisualStyleBackColor = true;
|
|
||||||
this.btnSave.Click += new System.EventHandler(this.BtnSave_Click);
|
|
||||||
//
|
|
||||||
// lblX
|
|
||||||
//
|
|
||||||
this.lblX.AutoSize = true;
|
|
||||||
this.lblX.ForeColor = System.Drawing.Color.Gray;
|
|
||||||
this.lblX.Location = new System.Drawing.Point(240, 83);
|
|
||||||
this.lblX.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
|
||||||
this.lblX.Name = "lblX";
|
|
||||||
this.lblX.Size = new System.Drawing.Size(68, 25);
|
|
||||||
this.lblX.TabIndex = 7;
|
|
||||||
this.lblX.Text = "X坐标";
|
|
||||||
//
|
|
||||||
// lblY
|
|
||||||
//
|
|
||||||
this.lblY.AutoSize = true;
|
|
||||||
this.lblY.ForeColor = System.Drawing.Color.Gray;
|
|
||||||
this.lblY.Location = new System.Drawing.Point(380, 83);
|
|
||||||
this.lblY.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
|
||||||
this.lblY.Name = "lblY";
|
|
||||||
this.lblY.Size = new System.Drawing.Size(69, 25);
|
|
||||||
this.lblY.TabIndex = 8;
|
|
||||||
this.lblY.Text = "Y坐标";
|
|
||||||
//
|
|
||||||
// lblName
|
|
||||||
//
|
|
||||||
this.lblName.AutoSize = true;
|
|
||||||
this.lblName.ForeColor = System.Drawing.Color.Gray;
|
|
||||||
this.lblName.Location = new System.Drawing.Point(740, 83);
|
|
||||||
this.lblName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
|
||||||
this.lblName.Name = "lblName";
|
|
||||||
this.lblName.Size = new System.Drawing.Size(117, 25);
|
|
||||||
this.lblName.TabIndex = 9;
|
|
||||||
this.lblName.Text = "请输入名称";
|
|
||||||
//
|
|
||||||
// lblPosition
|
|
||||||
//
|
|
||||||
this.lblPosition.AutoSize = true;
|
|
||||||
this.lblPosition.ForeColor = System.Drawing.Color.Gray;
|
|
||||||
this.lblPosition.Location = new System.Drawing.Point(960, 83);
|
|
||||||
this.lblPosition.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
|
||||||
this.lblPosition.Name = "lblPosition";
|
|
||||||
this.lblPosition.Size = new System.Drawing.Size(117, 25);
|
|
||||||
this.lblPosition.TabIndex = 10;
|
|
||||||
this.lblPosition.Text = "请输入位置";
|
|
||||||
//
|
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
this.pictureBox.BackColor = System.Drawing.Color.LightGray;
|
this.pictureBox.BackColor = System.Drawing.Color.LightGray;
|
||||||
this.pictureBox.Cursor = System.Windows.Forms.Cursors.Cross;
|
this.pictureBox.Cursor = System.Windows.Forms.Cursors.Cross;
|
||||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.pictureBox.Location = new System.Drawing.Point(0, 125);
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.pictureBox.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
this.pictureBox.Margin = new System.Windows.Forms.Padding(6);
|
||||||
this.pictureBox.Name = "pictureBox";
|
this.pictureBox.Name = "pictureBox";
|
||||||
this.pictureBox.Size = new System.Drawing.Size(1600, 1125);
|
this.pictureBox.Size = new System.Drawing.Size(1600, 1250);
|
||||||
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
this.pictureBox.Click += new System.EventHandler(this.PictureBox_Click);
|
|
||||||
//
|
//
|
||||||
// blinkTimer
|
// blinkTimer
|
||||||
|
//
|
||||||
this.blinkTimer.Interval = 50; // 修改为50毫秒
|
this.blinkTimer.Interval = 50; // 修改为50毫秒
|
||||||
this.blinkTimer.Tick += new System.EventHandler(this.BlinkTimer_Tick);
|
this.blinkTimer.Tick += new System.EventHandler(this.BlinkTimer_Tick);
|
||||||
//
|
//
|
||||||
@@ -534,16 +287,12 @@ namespace WindowsFormsApp1
|
|||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1600, 1250);
|
this.ClientSize = new System.Drawing.Size(1600, 1250);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.panel);
|
this.Margin = new System.Windows.Forms.Padding(6);
|
||||||
this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
|
||||||
this.Name = "ImageDisplayForm";
|
this.Name = "ImageDisplayForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "图片展示";
|
this.Text = "螺丝引导";
|
||||||
this.panel.ResumeLayout(false);
|
|
||||||
this.panel.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -0,0 +1,475 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using WindowsFormsApp1.mod;
|
||||||
|
using WindowsFormsApp1.db;
|
||||||
|
|
||||||
|
namespace WindowsFormsApp1
|
||||||
|
{
|
||||||
|
public partial class SimpleImageDisplayForm : Form
|
||||||
|
{
|
||||||
|
#region 控件字段
|
||||||
|
protected PictureBox pictureBox;
|
||||||
|
protected Button btnLoadImage;
|
||||||
|
protected TextBox txtX;
|
||||||
|
protected TextBox txtY;
|
||||||
|
protected TextBox txtName;
|
||||||
|
protected TextBox txtPosition;
|
||||||
|
protected Button btnSave;
|
||||||
|
protected Panel panel;
|
||||||
|
protected Label lblX;
|
||||||
|
protected Label lblY;
|
||||||
|
protected Label lblName;
|
||||||
|
protected Label lblPosition;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 私有字段
|
||||||
|
private IContainer components = null;
|
||||||
|
private Bitmap originalImage;
|
||||||
|
private Bitmap markedImage;
|
||||||
|
private Timer blinkTimer;
|
||||||
|
private bool isBlinking = false;
|
||||||
|
|
||||||
|
// 圆形标记相关参数
|
||||||
|
private float currentRadius = 20f;
|
||||||
|
private const float MIN_RADIUS = 20f;
|
||||||
|
private const float MAX_RADIUS = 50f;
|
||||||
|
private bool isExpanding = true;
|
||||||
|
private const float RADIUS_CHANGE_SPEED = 2f;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 构造函数和初始化
|
||||||
|
public SimpleImageDisplayForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 图像加载和处理
|
||||||
|
// 在图像上绘制标记
|
||||||
|
private void DrawMark(int x, int y)
|
||||||
|
{
|
||||||
|
if (originalImage == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
markedImage = new Bitmap(originalImage);
|
||||||
|
using (Graphics g = Graphics.FromImage(markedImage))
|
||||||
|
{
|
||||||
|
if (isBlinking)
|
||||||
|
{
|
||||||
|
// 设置高质量绘图模式
|
||||||
|
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
||||||
|
|
||||||
|
// 只绘制白色圆
|
||||||
|
using (Brush whiteBrush = new SolidBrush(Color.White))
|
||||||
|
{
|
||||||
|
g.FillEllipse(whiteBrush,
|
||||||
|
x - currentRadius,
|
||||||
|
y - currentRadius,
|
||||||
|
currentRadius * 2,
|
||||||
|
currentRadius * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新半径
|
||||||
|
if (isExpanding)
|
||||||
|
{
|
||||||
|
currentRadius += RADIUS_CHANGE_SPEED;
|
||||||
|
if (currentRadius >= MAX_RADIUS)
|
||||||
|
{
|
||||||
|
currentRadius = MAX_RADIUS;
|
||||||
|
isExpanding = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentRadius -= RADIUS_CHANGE_SPEED;
|
||||||
|
if (currentRadius <= MIN_RADIUS)
|
||||||
|
{
|
||||||
|
currentRadius = MIN_RADIUS;
|
||||||
|
isExpanding = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pictureBox.Image = markedImage;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 事件处理
|
||||||
|
// 闪烁定时器事件
|
||||||
|
private void BlinkTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(txtX.Text, out int x) || !int.TryParse(txtY.Text, out int y))
|
||||||
|
return;
|
||||||
|
DrawMark(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 图片点击事件
|
||||||
|
private void PictureBox_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (originalImage == null || !(e is MouseEventArgs me))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 获取图片在 PictureBox 中的实际显示尺寸和位置
|
||||||
|
float ratioX = (float)originalImage.Width / pictureBox.ClientSize.Width;
|
||||||
|
float ratioY = (float)originalImage.Height / pictureBox.ClientSize.Height;
|
||||||
|
float ratio = Math.Max(ratioX, ratioY);
|
||||||
|
|
||||||
|
float imageWidth = originalImage.Width / ratio;
|
||||||
|
float imageHeight = originalImage.Height / ratio;
|
||||||
|
|
||||||
|
// 计算图片在 PictureBox 中的显示位置
|
||||||
|
float imageX = (pictureBox.ClientSize.Width - imageWidth) / 2;
|
||||||
|
float imageY = (pictureBox.ClientSize.Height - imageHeight) / 2;
|
||||||
|
|
||||||
|
// 将点击坐标转换为图片实际坐标
|
||||||
|
int x = (int)((me.X - imageX) * ratio);
|
||||||
|
int y = (int)((me.Y - imageY) * ratio);
|
||||||
|
|
||||||
|
// 确保坐标在图片范围内
|
||||||
|
if (x >= 0 && x < originalImage.Width && y >= 0 && y < originalImage.Height)
|
||||||
|
{
|
||||||
|
txtX.Text = x.ToString();
|
||||||
|
txtY.Text = y.ToString();
|
||||||
|
MarkPosition(); // 自动标记位置
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 标记位置
|
||||||
|
private void MarkPosition()
|
||||||
|
{
|
||||||
|
if (markedImage == null || !int.TryParse(txtX.Text, out int x) || !int.TryParse(txtY.Text, out int y))
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先加载图片并输入有效的坐标值");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMark(x, y);
|
||||||
|
isBlinking = true;
|
||||||
|
blinkTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载图片按钮事件
|
||||||
|
private void BtnLoadImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||||||
|
{
|
||||||
|
openFileDialog.Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp|所有文件|*.*";
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
// 停止闪烁定时器并重置状态
|
||||||
|
blinkTimer?.Stop();
|
||||||
|
isBlinking = false;
|
||||||
|
|
||||||
|
originalImage = new Bitmap(openFileDialog.FileName);
|
||||||
|
markedImage = new Bitmap(originalImage);
|
||||||
|
pictureBox.Image = markedImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存按钮事件
|
||||||
|
private void BtnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(txtName.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(txtPosition.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(txtX.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(txtY.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("请填写完整信息");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加坐标值验证
|
||||||
|
if (!int.TryParse(txtX.Text, out int x) || !int.TryParse(txtY.Text, out int y))
|
||||||
|
{
|
||||||
|
MessageBox.Show("坐标值必须是有效的数字");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查图片是否已加载
|
||||||
|
if (originalImage == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先加载图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查坐标是否在图片范围内
|
||||||
|
if (x < 0 || y < 0 || x >= originalImage.Width || y >= originalImage.Height)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"坐标值超出范围!\n有效范围:X(0-{originalImage.Width-1}) Y(0-{originalImage.Height-1})");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 保存数据到数据库
|
||||||
|
SQLiteHelper<t_imageposition> sQLiteHelper_position = new db.SQLiteHelper<t_imageposition>();
|
||||||
|
|
||||||
|
// 检查是否存在相同名称和位置的记录
|
||||||
|
var existingPositions = sQLiteHelper_position.Query(a =>
|
||||||
|
a.name == txtName.Text &&
|
||||||
|
a.position == txtPosition.Text).Data;
|
||||||
|
|
||||||
|
t_imageposition position = new t_imageposition
|
||||||
|
{
|
||||||
|
name = txtName.Text,
|
||||||
|
position = txtPosition.Text,
|
||||||
|
x = int.Parse(txtX.Text),
|
||||||
|
y = int.Parse(txtY.Text),
|
||||||
|
createtime = DateTime.Now
|
||||||
|
};
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
if (existingPositions != null && existingPositions.Count > 0)
|
||||||
|
{
|
||||||
|
// 更新现有记录
|
||||||
|
position.id = existingPositions[0].id;
|
||||||
|
var result = sQLiteHelper_position.Update(position);
|
||||||
|
success = result.Success;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 插入新记录
|
||||||
|
var result = sQLiteHelper_position.Insert(position);
|
||||||
|
success = result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存图片到images文件夹
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
SaveImageToFolder(txtName.Text);
|
||||||
|
// 只清空position的值
|
||||||
|
txtPosition.Text = "";
|
||||||
|
MessageBox.Show("保存成功!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("保存失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"保存失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存图片到images文件夹
|
||||||
|
private void SaveImageToFolder(string name)
|
||||||
|
{
|
||||||
|
string imagesFolder = Path.Combine(Application.StartupPath, "images");
|
||||||
|
|
||||||
|
// 确保目录存在
|
||||||
|
if (!Directory.Exists(imagesFolder))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(imagesFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
string imagePath = Path.Combine(imagesFolder, $"{name}.png");
|
||||||
|
|
||||||
|
// 检查文件是否已存在,如果存在则不覆盖
|
||||||
|
if (!File.Exists(imagePath))
|
||||||
|
{
|
||||||
|
originalImage.Save(imagePath, System.Drawing.Imaging.ImageFormat.Png);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 资源释放
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
blinkTimer?.Stop();
|
||||||
|
blinkTimer?.Dispose();
|
||||||
|
originalImage?.Dispose();
|
||||||
|
markedImage?.Dispose();
|
||||||
|
components?.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.panel = new System.Windows.Forms.Panel();
|
||||||
|
this.btnLoadImage = new System.Windows.Forms.Button();
|
||||||
|
this.txtX = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtY = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtName = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtPosition = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnSave = new System.Windows.Forms.Button();
|
||||||
|
this.lblX = new System.Windows.Forms.Label();
|
||||||
|
this.lblY = new System.Windows.Forms.Label();
|
||||||
|
this.lblName = new System.Windows.Forms.Label();
|
||||||
|
this.lblPosition = new System.Windows.Forms.Label();
|
||||||
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.blinkTimer = new System.Windows.Forms.Timer(this.components);
|
||||||
|
this.panel.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
this.panel.Controls.Add(this.btnLoadImage);
|
||||||
|
this.panel.Controls.Add(this.txtX);
|
||||||
|
this.panel.Controls.Add(this.txtY);
|
||||||
|
this.panel.Controls.Add(this.txtName);
|
||||||
|
this.panel.Controls.Add(this.txtPosition);
|
||||||
|
this.panel.Controls.Add(this.btnSave);
|
||||||
|
this.panel.Controls.Add(this.lblX);
|
||||||
|
this.panel.Controls.Add(this.lblY);
|
||||||
|
this.panel.Controls.Add(this.lblName);
|
||||||
|
this.panel.Controls.Add(this.lblPosition);
|
||||||
|
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panel.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.panel.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.panel.Name = "panel";
|
||||||
|
this.panel.Size = new System.Drawing.Size(1600, 120);
|
||||||
|
this.panel.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// btnLoadImage
|
||||||
|
//
|
||||||
|
this.btnLoadImage.Location = new System.Drawing.Point(20, 20);
|
||||||
|
this.btnLoadImage.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.btnLoadImage.Name = "btnLoadImage";
|
||||||
|
this.btnLoadImage.Size = new System.Drawing.Size(200, 60);
|
||||||
|
this.btnLoadImage.TabIndex = 0;
|
||||||
|
this.btnLoadImage.Text = "加载图片";
|
||||||
|
this.btnLoadImage.UseVisualStyleBackColor = true;
|
||||||
|
this.btnLoadImage.Click += new System.EventHandler(this.BtnLoadImage_Click);
|
||||||
|
//
|
||||||
|
// txtX
|
||||||
|
//
|
||||||
|
this.txtX.Location = new System.Drawing.Point(240, 20);
|
||||||
|
this.txtX.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.txtX.Name = "txtX";
|
||||||
|
this.txtX.Size = new System.Drawing.Size(116, 35);
|
||||||
|
this.txtX.TabIndex = 1;
|
||||||
|
this.txtX.Text = "0";
|
||||||
|
//
|
||||||
|
// txtY
|
||||||
|
//
|
||||||
|
this.txtY.Location = new System.Drawing.Point(380, 20);
|
||||||
|
this.txtY.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.txtY.Name = "txtY";
|
||||||
|
this.txtY.Size = new System.Drawing.Size(116, 35);
|
||||||
|
this.txtY.TabIndex = 2;
|
||||||
|
this.txtY.Text = "0";
|
||||||
|
//
|
||||||
|
// txtName
|
||||||
|
//
|
||||||
|
this.txtName.Location = new System.Drawing.Point(519, 20);
|
||||||
|
this.txtName.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.txtName.Name = "txtName";
|
||||||
|
this.txtName.Size = new System.Drawing.Size(196, 35);
|
||||||
|
this.txtName.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// txtPosition
|
||||||
|
//
|
||||||
|
this.txtPosition.Location = new System.Drawing.Point(744, 20);
|
||||||
|
this.txtPosition.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.txtPosition.Name = "txtPosition";
|
||||||
|
this.txtPosition.Size = new System.Drawing.Size(196, 35);
|
||||||
|
this.txtPosition.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
this.btnSave.Location = new System.Drawing.Point(964, 14);
|
||||||
|
this.btnSave.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.btnSave.Name = "btnSave";
|
||||||
|
this.btnSave.Size = new System.Drawing.Size(200, 60);
|
||||||
|
this.btnSave.TabIndex = 6;
|
||||||
|
this.btnSave.Text = "保存";
|
||||||
|
this.btnSave.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSave.Click += new System.EventHandler(this.BtnSave_Click);
|
||||||
|
//
|
||||||
|
// lblX
|
||||||
|
//
|
||||||
|
this.lblX.AutoSize = true;
|
||||||
|
this.lblX.ForeColor = System.Drawing.Color.Gray;
|
||||||
|
this.lblX.Location = new System.Drawing.Point(240, 80);
|
||||||
|
this.lblX.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||||
|
this.lblX.Name = "lblX";
|
||||||
|
this.lblX.Size = new System.Drawing.Size(70, 24);
|
||||||
|
this.lblX.TabIndex = 7;
|
||||||
|
this.lblX.Text = "X坐标";
|
||||||
|
//
|
||||||
|
// lblY
|
||||||
|
//
|
||||||
|
this.lblY.AutoSize = true;
|
||||||
|
this.lblY.ForeColor = System.Drawing.Color.Gray;
|
||||||
|
this.lblY.Location = new System.Drawing.Point(380, 80);
|
||||||
|
this.lblY.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||||
|
this.lblY.Name = "lblY";
|
||||||
|
this.lblY.Size = new System.Drawing.Size(70, 24);
|
||||||
|
this.lblY.TabIndex = 8;
|
||||||
|
this.lblY.Text = "Y坐标";
|
||||||
|
//
|
||||||
|
// lblName
|
||||||
|
//
|
||||||
|
this.lblName.AutoSize = true;
|
||||||
|
this.lblName.ForeColor = System.Drawing.Color.Gray;
|
||||||
|
this.lblName.Location = new System.Drawing.Point(515, 80);
|
||||||
|
this.lblName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||||
|
this.lblName.Name = "lblName";
|
||||||
|
this.lblName.Size = new System.Drawing.Size(130, 24);
|
||||||
|
this.lblName.TabIndex = 9;
|
||||||
|
this.lblName.Text = "请输入名称";
|
||||||
|
//
|
||||||
|
// lblPosition
|
||||||
|
//
|
||||||
|
this.lblPosition.AutoSize = true;
|
||||||
|
this.lblPosition.ForeColor = System.Drawing.Color.Gray;
|
||||||
|
this.lblPosition.Location = new System.Drawing.Point(740, 80);
|
||||||
|
this.lblPosition.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||||
|
this.lblPosition.Name = "lblPosition";
|
||||||
|
this.lblPosition.Size = new System.Drawing.Size(130, 24);
|
||||||
|
this.lblPosition.TabIndex = 10;
|
||||||
|
this.lblPosition.Text = "请输入位置";
|
||||||
|
//
|
||||||
|
// pictureBox
|
||||||
|
//
|
||||||
|
this.pictureBox.BackColor = System.Drawing.Color.LightGray;
|
||||||
|
this.pictureBox.Cursor = System.Windows.Forms.Cursors.Cross;
|
||||||
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBox.Location = new System.Drawing.Point(0, 120);
|
||||||
|
this.pictureBox.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.pictureBox.Name = "pictureBox";
|
||||||
|
this.pictureBox.Size = new System.Drawing.Size(1600, 1080);
|
||||||
|
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||||
|
this.pictureBox.TabIndex = 1;
|
||||||
|
this.pictureBox.TabStop = false;
|
||||||
|
this.pictureBox.Click += new System.EventHandler(this.PictureBox_Click);
|
||||||
|
//
|
||||||
|
// blinkTimer
|
||||||
|
//
|
||||||
|
this.blinkTimer.Interval = 50;
|
||||||
|
this.blinkTimer.Tick += new System.EventHandler(this.BlinkTimer_Tick);
|
||||||
|
//
|
||||||
|
// SimpleImageDisplayForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1600, 1200);
|
||||||
|
this.Controls.Add(this.pictureBox);
|
||||||
|
this.Controls.Add(this.panel);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(6);
|
||||||
|
this.Name = "SimpleImageDisplayForm";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "图片标注";
|
||||||
|
this.panel.ResumeLayout(false);
|
||||||
|
this.panel.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="blinkTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
@@ -58,7 +58,7 @@ namespace WindowsFormsApp1.server
|
|||||||
|
|
||||||
// 初始化 CsvLogger
|
// 初始化 CsvLogger
|
||||||
// 初始化日志路径
|
// 初始化日志路径
|
||||||
_logBasePath = Path.Combine(@"D:\", "Logs", $"logs.csv");
|
_logBasePath = Path.Combine(@"C:\", "Logs", $"logs.csv");
|
||||||
|
|
||||||
// 初始化CSV日志记录器
|
// 初始化CSV日志记录器
|
||||||
CsvLogger.Initialize(_logBasePath);
|
CsvLogger.Initialize(_logBasePath);
|
||||||
@@ -94,8 +94,8 @@ namespace WindowsFormsApp1.server
|
|||||||
headers.Add("保压时间");
|
headers.Add("保压时间");
|
||||||
break;
|
break;
|
||||||
case "sealant":
|
case "sealant":
|
||||||
headers.Add("重量");
|
headers.Add("胶宽");
|
||||||
headers.Add("宽度");
|
headers.Add("CCD结果");
|
||||||
break;
|
break;
|
||||||
case "curing":
|
case "curing":
|
||||||
headers.Add("固化温度");
|
headers.Add("固化温度");
|
||||||
@@ -125,6 +125,7 @@ namespace WindowsFormsApp1.server
|
|||||||
var httpContent = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
|
var httpContent = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
#region test
|
#region test
|
||||||
|
|
||||||
// 回写对应PLC
|
// 回写对应PLC
|
||||||
if (statusCode > 0)
|
if (statusCode > 0)
|
||||||
PlcData.Write_Status = (short)statusCode;
|
PlcData.Write_Status = (short)statusCode;
|
||||||
@@ -132,11 +133,12 @@ namespace WindowsFormsApp1.server
|
|||||||
PlcData.Write_stSN = "testsn";
|
PlcData.Write_stSN = "testsn";
|
||||||
LogExecute.logNet.WriteDebug($"{eventName} 测ui接口请求成功\n请求:{jsonPayload}\n");
|
LogExecute.logNet.WriteDebug($"{eventName} 测ui接口请求成功\n请求:{jsonPayload}\n");
|
||||||
return ApiFormResult.Sucess(mesresult.PASS, true, "PASS", PlcData, DateTime.Now);
|
return ApiFormResult.Sucess(mesresult.PASS, true, "PASS", PlcData, DateTime.Now);
|
||||||
|
|
||||||
#endregion test
|
#endregion test
|
||||||
|
|
||||||
/*
|
|
||||||
#region 正式调用接口
|
#region 正式调用接口
|
||||||
try
|
|
||||||
|
/*try
|
||||||
{
|
{
|
||||||
#region MES交互
|
#region MES交互
|
||||||
|
|
||||||
@@ -224,8 +226,9 @@ namespace WindowsFormsApp1.server
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ApiFormResult.Sucess(mesresult.PASS, false, "", PlcData, DateTime.Now);
|
return ApiFormResult.Sucess(mesresult.PASS, false, "", PlcData, DateTime.Now);
|
||||||
#endregion 正式调用接口
|
|
||||||
*/
|
*/
|
||||||
|
#endregion 正式调用接口
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiFormResult SN_CheckIN(string url, plcdata PlcData, otherdata OtherData)
|
public ApiFormResult SN_CheckIN(string url, plcdata PlcData, otherdata OtherData)
|
||||||
@@ -235,7 +238,7 @@ namespace WindowsFormsApp1.server
|
|||||||
var stationid = Init.t_Line.lineremark2.ToLower();
|
var stationid = Init.t_Line.lineremark2.ToLower();
|
||||||
if ("loadaging,exchange2,exchange1".Contains(stationid))
|
if ("loadaging,exchange2,exchange1".Contains(stationid))
|
||||||
{
|
{
|
||||||
sn = PlcData.Read_MaterialCode0;
|
sn = PlcData.Write_stSN ?? OtherData.JS_SN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -321,7 +324,7 @@ namespace WindowsFormsApp1.server
|
|||||||
OPID = _opID,
|
OPID = _opID,
|
||||||
Token = _token,
|
Token = _token,
|
||||||
FixSN = _fixsn,
|
FixSN = _fixsn,
|
||||||
SN = OtherData.JS_SN ?? "",//扫码
|
SN = OtherData.JS_SN ?? PlcData.Write_stSN,//扫码
|
||||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -366,7 +369,7 @@ namespace WindowsFormsApp1.server
|
|||||||
Qty = "1"
|
Qty = "1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SN = PlcData.Read_MaterialCode0,
|
SN = PlcData.Write_stSN,
|
||||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -392,7 +395,7 @@ namespace WindowsFormsApp1.server
|
|||||||
OPID = _opID,
|
OPID = _opID,
|
||||||
Token = _token,
|
Token = _token,
|
||||||
FixSN = _fixsn,
|
FixSN = _fixsn,
|
||||||
SN = Init.ScanString,
|
SN = PlcData.Write_stSN,
|
||||||
//CarrierID = PlcData.Read_MaterialCode1,
|
//CarrierID = PlcData.Read_MaterialCode1,
|
||||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||||
};
|
};
|
||||||
@@ -460,7 +463,7 @@ namespace WindowsFormsApp1.server
|
|||||||
StationID = _stationID,
|
StationID = _stationID,
|
||||||
MachineID = _machineID,
|
MachineID = _machineID,
|
||||||
OPID = _opID,
|
OPID = _opID,
|
||||||
SN = OtherData.JS_SN ?? PlcData.Read_MaterialCode0 ?? "test",
|
SN = OtherData.JS_SN ?? PlcData.Write_stSN ?? "test",
|
||||||
CarrierID = PlcData.Read_MaterialCode1,
|
CarrierID = PlcData.Read_MaterialCode1,
|
||||||
DC_INFO = new List<DCInfoItem>(),
|
DC_INFO = new List<DCInfoItem>(),
|
||||||
CompList = new List<CompListItem>(),
|
CompList = new List<CompListItem>(),
|
||||||
@@ -554,7 +557,7 @@ namespace WindowsFormsApp1.server
|
|||||||
List<string> fileList = new List<string>();
|
List<string> fileList = new List<string>();
|
||||||
|
|
||||||
//从数据库读 未上传的 todo
|
//从数据库读 未上传的 todo
|
||||||
string snNumber = PlcData.Read_MaterialCode0;
|
string snNumber = PlcData.Write_stSN;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(snNumber))
|
if (string.IsNullOrEmpty(snNumber))
|
||||||
{
|
{
|
||||||
@@ -598,7 +601,7 @@ namespace WindowsFormsApp1.server
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
extensionstr = Path.GetExtension(file);
|
extensionstr = Path.GetExtension(file);
|
||||||
fileName = $"{month}{day}_{_stationID}_{result}_{PlcData.Read_MaterialCode0}_{monthDay}_{time}_{_machineID}_01_Original{num}{extensionstr}";
|
fileName = $"{month}{day}_{_stationID}_{result}_{PlcData.Write_stSN}_{monthDay}_{time}_{_machineID}_01_Original{num}{extensionstr}";
|
||||||
filePath = Path.Combine(sourceFolder, fileName1);
|
filePath = Path.Combine(sourceFolder, fileName1);
|
||||||
//string targetPath = Path.Combine(targetFolder, fileName);
|
//string targetPath = Path.Combine(targetFolder, fileName);
|
||||||
//File.Copy(file, targetPath, true);
|
//File.Copy(file, targetPath, true);
|
||||||
@@ -631,7 +634,7 @@ namespace WindowsFormsApp1.server
|
|||||||
{
|
{
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
SN = PlcData.Read_MaterialCode0,
|
SN = PlcData.Write_stSN,
|
||||||
FileInfo = fileList.Select(x => new
|
FileInfo = fileList.Select(x => new
|
||||||
{
|
{
|
||||||
FileName = x,
|
FileName = x,
|
||||||
@@ -736,7 +739,7 @@ namespace WindowsFormsApp1.server
|
|||||||
Line = _line, // 特殊值,不使用_line
|
Line = _line, // 特殊值,不使用_line
|
||||||
Station = _stationID,
|
Station = _stationID,
|
||||||
MachineID = _machineID,
|
MachineID = _machineID,
|
||||||
SN = PlcData.Read_MaterialCode0
|
SN = PlcData.Write_stSN
|
||||||
};
|
};
|
||||||
|
|
||||||
return CallApi(url, request, "CodeSoftPrint", PlcData, PLC_Status.CodeSoftPrint);
|
return CallApi(url, request, "CodeSoftPrint", PlcData, PLC_Status.CodeSoftPrint);
|
||||||
@@ -762,7 +765,7 @@ namespace WindowsFormsApp1.server
|
|||||||
{
|
{
|
||||||
new SNInfoItem()
|
new SNInfoItem()
|
||||||
{
|
{
|
||||||
SN = PlcData.Read_MaterialCode0,
|
SN = PlcData.Write_stSN,
|
||||||
Result = result,
|
Result = result,
|
||||||
DC_INFO = new List<DCInfoItem>(),
|
DC_INFO = new List<DCInfoItem>(),
|
||||||
CompList = new List<CompListItem>()
|
CompList = new List<CompListItem>()
|
||||||
@@ -796,21 +799,21 @@ namespace WindowsFormsApp1.server
|
|||||||
Value = Init.airtight.Leak_Value ?? "0",
|
Value = Init.airtight.Leak_Value ?? "0",
|
||||||
Result = result
|
Result = result
|
||||||
});
|
});
|
||||||
CsvLogger.Log($"{PlcData.Read_MaterialCode0},{Init.airtight.Airtight_Value},{Init.airtight.Leak_Value}");
|
CsvLogger.Log($"{PlcData.Write_stSN},{Init.airtight.Airtight_Value},{Init.airtight.Leak_Value}");
|
||||||
}
|
}
|
||||||
//扭力,角度
|
//扭力,角度
|
||||||
if ("ScrewE,Assy2,Assy3,ScrewS,ScrewM,ScrewTC".Contains(stationid))
|
if ("ScrewE,Assy2,Assy3,ScrewS,ScrewM,ScrewTC".Contains(stationid))
|
||||||
{
|
{
|
||||||
var count = OtherData.FinalAngleValue.Count(x => x > 0);
|
var count = OtherData.FinalAngleValue.Count(x => x > 0);
|
||||||
for(int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if ("Assy2,Assy3".Contains(stationid))
|
if ("Assy2,Assy3".Contains(stationid))
|
||||||
{
|
{
|
||||||
CsvLogger.Log($"{PlcData.Read_MaterialCode0},{OtherData.FinalAngleValue[i]},{OtherData.FinalTorqueValue[i]},{logresult}");
|
CsvLogger.Log($"{PlcData.Write_stSN},{OtherData.FinalAngleValue[i]},{OtherData.FinalTorqueValue[i]},{logresult}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CsvLogger.Log($"{PlcData.Read_MaterialCode0},{OtherData.FinalAngleValue[i]},{OtherData.FinalTorqueValue[i]}");
|
CsvLogger.Log($"{PlcData.Write_stSN},{OtherData.FinalAngleValue[i]},{OtherData.FinalTorqueValue[i]}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,7 +853,7 @@ namespace WindowsFormsApp1.server
|
|||||||
sninfo.DC_INFO.Add(dcInfo);
|
sninfo.DC_INFO.Add(dcInfo);
|
||||||
if (!"Assy2,Assy3,Sealant".Contains(stationid))
|
if (!"Assy2,Assy3,Sealant".Contains(stationid))
|
||||||
{
|
{
|
||||||
CsvLogger.Log($"{PlcData.Read_MaterialCode0},{logresult}");
|
CsvLogger.Log($"{PlcData.Write_stSN},{logresult}");
|
||||||
}
|
}
|
||||||
//LogExecute.SNlogNet.WriteDebug($"追溯码:{PlcData.Read_MaterialCode0},检测结果:{logresult}");
|
//LogExecute.SNlogNet.WriteDebug($"追溯码:{PlcData.Read_MaterialCode0},检测结果:{logresult}");
|
||||||
}
|
}
|
||||||
@@ -865,7 +868,7 @@ namespace WindowsFormsApp1.server
|
|||||||
dcInfo.Result = result;
|
dcInfo.Result = result;
|
||||||
sninfo.DC_INFO.Add(dcInfo);
|
sninfo.DC_INFO.Add(dcInfo);
|
||||||
|
|
||||||
str += $"{PlcData.Read_MaterialCode0},{dcInfo.Value}";
|
str += $"{PlcData.Write_stSN},{dcInfo.Value}";
|
||||||
|
|
||||||
dcInfo = new DCInfoItem();
|
dcInfo = new DCInfoItem();
|
||||||
dcInfo.Item = $"Hold_Time";
|
dcInfo.Item = $"Hold_Time";
|
||||||
@@ -880,7 +883,7 @@ namespace WindowsFormsApp1.server
|
|||||||
if ("Curing".Contains(stationid))
|
if ("Curing".Contains(stationid))
|
||||||
{
|
{
|
||||||
SQLiteHelper<t_materialcall> materialHelper = new db.SQLiteHelper<t_materialcall>();
|
SQLiteHelper<t_materialcall> materialHelper = new db.SQLiteHelper<t_materialcall>();
|
||||||
var material = materialHelper.QuerySingle(x => x.materialid == PlcData.Read_MaterialCode0);
|
var material = materialHelper.QuerySingle(x => x.materialid == PlcData.Write_stSN);
|
||||||
if (material.Success)
|
if (material.Success)
|
||||||
{
|
{
|
||||||
// 计算加热时间
|
// 计算加热时间
|
||||||
@@ -900,7 +903,7 @@ namespace WindowsFormsApp1.server
|
|||||||
Down = "75",
|
Down = "75",
|
||||||
Result = result
|
Result = result
|
||||||
});
|
});
|
||||||
CsvLogger.Log($"{PlcData.Read_MaterialCode0},{PlcData.Read_UploadData0.ToString()},{jrTime}");
|
CsvLogger.Log($"{PlcData.Write_stSN},{PlcData.Read_UploadData0.ToString()},{jrTime}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -915,7 +918,7 @@ namespace WindowsFormsApp1.server
|
|||||||
dcInfo.Value = PlcData.Read_UploadData0.ToString();
|
dcInfo.Value = PlcData.Read_UploadData0.ToString();
|
||||||
dcInfo.Result = result;
|
dcInfo.Result = result;
|
||||||
//LogExecute.SNlogNet.WriteDebug($"{PlcData.Read_MaterialCode0},{dcInfo.Item},{dcInfo.Value}");
|
//LogExecute.SNlogNet.WriteDebug($"{PlcData.Read_MaterialCode0},{dcInfo.Item},{dcInfo.Value}");
|
||||||
CsvLogger.Log($"{PlcData.Read_MaterialCode0},{dcInfo.Value}");
|
CsvLogger.Log($"{PlcData.Write_stSN},{dcInfo.Value}");
|
||||||
|
|
||||||
sninfo.DC_INFO.Add(dcInfo);
|
sninfo.DC_INFO.Add(dcInfo);
|
||||||
}
|
}
|
||||||
@@ -933,7 +936,7 @@ namespace WindowsFormsApp1.server
|
|||||||
dcInfo.Item = $"{stationid}_Width";
|
dcInfo.Item = $"{stationid}_Width";
|
||||||
dcInfo.Value = PlcData.Read_UploadData1.ToString();
|
dcInfo.Value = PlcData.Read_UploadData1.ToString();
|
||||||
dcInfo.Result = result;
|
dcInfo.Result = result;
|
||||||
CsvLogger.Log($"{PlcData.Read_MaterialCode0},{PlcData.Read_UploadData0.ToString()},{PlcData.Read_UploadData1.ToString()},{logresult}");
|
CsvLogger.Log($"{PlcData.Write_stSN},{PlcData.Read_UploadData0.ToString()},{PlcData.Read_UploadData1.ToString()},{logresult}");
|
||||||
|
|
||||||
sninfo.DC_INFO.Add(dcInfo);
|
sninfo.DC_INFO.Add(dcInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace WindowsFormsApp1.server
|
|||||||
public static ILogNet PlclogNet = new LogNetDateTime("C:\\Log\\PlcLogs", GenerateMode.ByEveryDay);
|
public static ILogNet PlclogNet = new LogNetDateTime("C:\\Log\\PlcLogs", GenerateMode.ByEveryDay);
|
||||||
public static ILogNet ApilogNet = new LogNetDateTime("C:\\Log\\Apilogs", GenerateMode.ByEveryHour);
|
public static ILogNet ApilogNet = new LogNetDateTime("C:\\Log\\Apilogs", GenerateMode.ByEveryHour);
|
||||||
public static ILogNet SNlogNet = new LogNetDateTime("C:\\Log\\SNlogs", GenerateMode.ByEveryDay);
|
public static ILogNet SNlogNet = new LogNetDateTime("C:\\Log\\SNlogs", GenerateMode.ByEveryDay);
|
||||||
|
public static ILogNet OEElogNet = new LogNetDateTime("C:\\Log\\Apilogs", GenerateMode.ByEveryDay);
|
||||||
|
|
||||||
public static HslCommunication.BasicFramework.SoftNumericalOrder softNumericalOrder = new HslCommunication.BasicFramework.SoftNumericalOrder("", "yyyyMMdd", 4, @"\numericalOrder.txt");
|
public static HslCommunication.BasicFramework.SoftNumericalOrder softNumericalOrder = new HslCommunication.BasicFramework.SoftNumericalOrder("", "yyyyMMdd", 4, @"\numericalOrder.txt");
|
||||||
|
|
||||||
public LogExecute()
|
public LogExecute()
|
||||||
|
|||||||
Reference in new issue
Block a user