更改部分界面,更新ApiFormResult部分字段
This commit is contained in:
1 parent
c322de2dd7
commit
16586d67aa
12 files changed
+936
-263
No files matched your search
+213
-42
@@ -35,19 +35,16 @@ namespace WindowsFormsApp1
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
label1.Visible = false;
|
||||
label2.Visible = false;
|
||||
label3.Visible = false;
|
||||
label4.Visible = false;
|
||||
label5.Visible = false;
|
||||
label6.Visible = false;
|
||||
label7.Visible = false;
|
||||
label8.Visible = false;
|
||||
|
||||
LogExecute.logNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||
LogExecute.PlclogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||
LogExecute.ApilogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
|
||||
|
||||
Formrecover();
|
||||
|
||||
线别.Text = "线别:" + Init.t_Line.linename;
|
||||
段别.Text = "段别:" + Init.t_Line.linemode;
|
||||
机台编号.Text = "机台编号:" + Init.t_Line.linecode;
|
||||
操作人员ID.Text = "操作人员ID:" + Init.t_User.username;
|
||||
}
|
||||
public void build(t_plc Plc, CancellationToken token)
|
||||
{
|
||||
@@ -71,8 +68,9 @@ namespace WindowsFormsApp1
|
||||
var openresult = siemensHelp.OpenConn();
|
||||
if (!openresult.Success)
|
||||
{
|
||||
label8.Text = $"PLC:{Plc.id}:{Plc.plcip}建立S7连接失败";
|
||||
//LogExecute.logNet.WriteError($"{Plc.plcip}建立S7连接失败");
|
||||
PLC链接状态.Text = "PLC链接状态:NG";
|
||||
PLC链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"{Plc.plcip}建立S7连接失败");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -82,7 +80,8 @@ namespace WindowsFormsApp1
|
||||
var resdresult = siemensHelp.ReadAddress(plcaddress, PlcData);
|
||||
if (!resdresult.Success)
|
||||
{
|
||||
label8.Text = $"PLC:{Plc.id}:{Plc.plcip}读取全部地址处理错误";
|
||||
PLC链接状态.Text = "PLC链接状态:NG";
|
||||
PLC链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"{Plc.plcip}读取全部地址处理错误:处理停止");
|
||||
continue;
|
||||
}
|
||||
@@ -92,16 +91,18 @@ namespace WindowsFormsApp1
|
||||
var haertresult = siemensHelp.WriteAddress(plcaddress, PlcData);
|
||||
if (!haertresult.Success)
|
||||
{
|
||||
label8.Text = $"PLC:{Plc.id}:{Plc.plcip}写入心跳错误";
|
||||
PLC链接状态.Text = "PLC链接状态:NG";
|
||||
PLC链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"{Plc.plcip}写入心跳错误:处理停止");
|
||||
continue;
|
||||
}
|
||||
|
||||
Plc.dateTime = DateTime.Now;
|
||||
DateTime Plc_Time = DateTime.Now;
|
||||
|
||||
PLC链接状态.Text = "PLC链接状态:OK";
|
||||
PLC链接状态.BackColor = SystemColors.Control;
|
||||
PLC通讯时间.Text = "PLC通讯时间:" + Plc_Time.ToString("MM-dd HH:mm:ss");
|
||||
|
||||
label8.Text = Plc.dateTime.ToString();
|
||||
|
||||
if (PlcData.Read_Trigger == 0 && PlcData.Write_Status == 0)
|
||||
{
|
||||
continue;
|
||||
@@ -116,49 +117,110 @@ namespace WindowsFormsApp1
|
||||
var writeresult = siemensHelp.WriteAddress(plcaddress, PlcData);
|
||||
if (!writeresult.Success)
|
||||
{
|
||||
label8.Text = $"PLC:{Plc.id}:{Plc.plcip}写入地址处理错误";
|
||||
PLC链接状态.Text = "PLC链接状态:NG";
|
||||
PLC链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"{Plc.plcip}写入地址处理错误:处理停止");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ApiClient apiClient = new ApiClient();
|
||||
otherdata otherdata = new otherdata();
|
||||
otherdata.JS_SN = "12345";
|
||||
|
||||
|
||||
|
||||
|
||||
//状态+报警
|
||||
if (Init.Plcstatus != PlcData.Read_Status || (Plc_Time - Init.Plcstatus_LastTime).TotalSeconds > 15)
|
||||
{
|
||||
//反馈状态
|
||||
var statusresult = apiClient.CallFunctionByName("Status", PlcData, otherdata);
|
||||
if (statusresult.Success)
|
||||
{
|
||||
MES链接状态.Text = "MES链接状态:OK";
|
||||
MES链接状态.BackColor = SystemColors.Control;
|
||||
MES通讯时间.Text = "MES通讯时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
|
||||
MES_MsgfORM("Status", statusresult.Mesresult, statusresult.Requesttime);
|
||||
}
|
||||
else
|
||||
{
|
||||
MES链接状态.Text = "MES链接状态:NG";
|
||||
MES链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"MES通讯异常!");
|
||||
}
|
||||
}
|
||||
if (Init.Plcstatus == (short)plcstatus.运行 && PlcData.Read_Status == (short)plcstatus.停机)
|
||||
{
|
||||
机台状态.BackColor = Color.Red;
|
||||
//反馈报警
|
||||
var statusresult = apiClient.CallFunctionByName("Alarm", PlcData, otherdata);
|
||||
if (statusresult.Success)
|
||||
{
|
||||
MES链接状态.Text = "MES链接状态:OK";
|
||||
MES链接状态.BackColor = SystemColors.Control;
|
||||
MES通讯时间.Text = "MES通讯时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
|
||||
MES_MsgfORM("Alarm", statusresult.Mesresult, statusresult.Requesttime);
|
||||
}
|
||||
else
|
||||
{
|
||||
MES链接状态.Text = "MES链接状态:NG";
|
||||
MES链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"MES通讯异常!");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
机台状态.BackColor = SystemColors.Control;
|
||||
}
|
||||
|
||||
Init.Plcstatus = PlcData.Read_Status;
|
||||
Init.Plcstatus_LastTime = DateTime.Now;
|
||||
机台状态.Text = Enum.GetName(typeof(plcstatus), Init.Plcstatus);
|
||||
|
||||
|
||||
|
||||
|
||||
var nowflow = Init.t_Flows.FirstOrDefault(a => a.hopestatus == PlcData.Read_Trigger);
|
||||
if (nowflow == null)
|
||||
{
|
||||
label8.Text = $"PLC:{Plc.id}:未找到当前触发字{PlcData.Read_Trigger},对应的流程";
|
||||
LogExecute.logNet.WriteError($"未找到当前触发字{PlcData.Read_Trigger},对应的流程!");
|
||||
continue;
|
||||
}
|
||||
var nowinterface = Init.t_Interfaces.FirstOrDefault(a => a.id == nowflow.hopeinterfaceid);
|
||||
if (nowinterface == null)
|
||||
{
|
||||
label8.Text = $"PLC:{Plc.id}:未找到当前期望接口ID {nowflow.hopeinterfaceid},对应的接口";
|
||||
LogExecute.logNet.WriteError($"未找到当前期望接口ID {nowflow.hopeinterfaceid},对应的接口!");
|
||||
continue;
|
||||
}
|
||||
|
||||
otherdata otherdata = new otherdata();
|
||||
otherdata.JS_SN = "12345";
|
||||
|
||||
|
||||
|
||||
|
||||
ApiClient apiClient = new ApiClient();
|
||||
|
||||
var result = apiClient.CallFunctionByName(nowinterface.code,PlcData, otherdata);
|
||||
if (result.Success)
|
||||
{
|
||||
var writeresult = siemensHelp.WriteAddress(Init.t_Plcaddresses.FindAll(a => a.plcid == Plc.id),PlcData);
|
||||
if (!writeresult.Success)
|
||||
{
|
||||
label8.Text = $"PLC:{Plc.id}:{Plc.plcip}写入地址处理错误";
|
||||
PLC链接状态.Text = "PLC链接状态:NG";
|
||||
PLC链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"{Plc.plcip}写入地址处理错误:处理停止");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
MES链接状态.Text = "MES链接状态:OK";
|
||||
MES链接状态.BackColor = SystemColors.Control;
|
||||
MES通讯时间.Text = "MES通讯时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label8.Text = $"MES通讯异常!";
|
||||
MES链接状态.Text = "MES链接状态:NG";
|
||||
MES链接状态.BackColor = Color.Red;
|
||||
LogExecute.logNet.WriteError($"MES通讯异常!");
|
||||
}
|
||||
}
|
||||
@@ -253,20 +315,6 @@ namespace WindowsFormsApp1
|
||||
|
||||
开始处理.Text = "停止处理";
|
||||
开始处理.BackColor = Color.Red;
|
||||
label1.Text = "MES站名:" + Init.t_Line.linename;
|
||||
label2.Text = "MES站名:" + Init.t_Line.linecode;
|
||||
label3.Text = "类型:" + Init.t_Line.linetype;
|
||||
label4.Text = "模组:" + Init.t_Line.linemode;
|
||||
|
||||
|
||||
label1.Visible = true;
|
||||
label2.Visible = true;
|
||||
label3.Visible = true;
|
||||
label4.Visible = true;
|
||||
label5.Visible = false;
|
||||
label6.Visible = false;
|
||||
label7.Visible = false;
|
||||
label8.Visible = true;
|
||||
LogExecute.logNet.WriteInfo($"用户{Init.t_User.username},开始处理!");
|
||||
}
|
||||
else
|
||||
@@ -290,10 +338,9 @@ namespace WindowsFormsApp1
|
||||
Thread.Sleep(500);
|
||||
开始处理.Text = "开始处理";
|
||||
开始处理.BackColor = Color.Green;
|
||||
label1.Visible = false;
|
||||
label2.Visible = false;
|
||||
label3.Visible = false;
|
||||
label4.Visible = false;
|
||||
|
||||
Formrecover();
|
||||
|
||||
LogExecute.logNet.WriteInfo($"用户{Init.t_User.username},停止处理!");
|
||||
}
|
||||
}
|
||||
@@ -387,6 +434,130 @@ namespace WindowsFormsApp1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
当前时间.Text = "当前时间:" + DateTime.Now.ToString("MM-dd HH:mm:ss");
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void Formrecover()
|
||||
{
|
||||
MES链接状态.Text = "MES链接状态:None";
|
||||
MES链接状态.BackColor = SystemColors.Control;
|
||||
|
||||
MES通讯时间.Text = "MES通讯时间:None";
|
||||
MES通讯时间.BackColor = SystemColors.Control;
|
||||
|
||||
PLC链接状态.Text = "PLC链接状态:None";
|
||||
PLC链接状态.BackColor = SystemColors.Control;
|
||||
|
||||
PLC通讯时间.Text = "PLC通讯时间:None";
|
||||
PLC通讯时间.BackColor = SystemColors.Control;
|
||||
|
||||
机台状态.Text = "机台状态:None";
|
||||
机台状态.BackColor = SystemColors.Control;
|
||||
|
||||
|
||||
请扫描LOT号.Enabled = false;
|
||||
LOT号.Visible = false;
|
||||
Tray盘二维码.Visible = false;
|
||||
|
||||
事件1.Visible = false;
|
||||
事件1结果.Visible = false;
|
||||
事件1时间.Visible = false;
|
||||
|
||||
事件2.Visible = false;
|
||||
事件2结果.Visible = false;
|
||||
事件2时间.Visible = false;
|
||||
|
||||
事件3.Visible = false;
|
||||
事件3结果.Visible = false;
|
||||
事件3时间.Visible = false;
|
||||
|
||||
事件4.Visible = false;
|
||||
事件4结果.Visible = false;
|
||||
事件4时间.Visible = false;
|
||||
|
||||
底部注释1.Visible = false;
|
||||
底部注释2.Visible = false;
|
||||
底部注释3.Visible = false;
|
||||
底部注释4.Visible = false;
|
||||
底部注释5.Visible = false;
|
||||
|
||||
}
|
||||
|
||||
public void MES_MsgfORM(string name,mesresult result,DateTime dateTime)
|
||||
{
|
||||
if (事件1.Text.Contains("事件"))
|
||||
{
|
||||
事件1.Visible = true;
|
||||
事件1结果.Visible = true;
|
||||
事件1时间.Visible = true;
|
||||
事件1.Text = name;
|
||||
事件1时间.Text = dateTime.ToString("MM-dd HH:mm:ss");
|
||||
事件1结果.Text = result.ToString();
|
||||
}
|
||||
else if (事件2.Text.Contains("事件"))
|
||||
{
|
||||
事件2.Visible = true;
|
||||
事件2结果.Visible = true;
|
||||
事件2时间.Visible = true;
|
||||
事件2.Text = name;
|
||||
事件2时间.Text = dateTime.ToString("MM-dd HH:mm:ss");
|
||||
事件2结果.Text = result.ToString();
|
||||
}
|
||||
else if (事件3.Text.Contains("事件"))
|
||||
{
|
||||
事件3.Visible = true;
|
||||
事件3结果.Visible = true;
|
||||
事件3时间.Visible = true;
|
||||
事件3.Text = name;
|
||||
事件3时间.Text = dateTime.ToString("MM-dd HH:mm:ss");
|
||||
事件3结果.Text = result.ToString();
|
||||
}
|
||||
else if (事件4.Text.Contains("事件"))
|
||||
{
|
||||
事件4.Visible = true;
|
||||
事件4结果.Visible = true;
|
||||
事件4时间.Visible = true;
|
||||
事件4.Text = name;
|
||||
事件4时间.Text = dateTime.ToString("MM-dd HH:mm:ss");
|
||||
事件4结果.Text = result.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
事件1.Visible = true;
|
||||
事件1结果.Visible = true;
|
||||
事件1时间.Visible = true;
|
||||
事件1.Text = name;
|
||||
事件1时间.Text = dateTime.ToString("MM-dd HH:mm:ss");
|
||||
事件1结果.Text = result.ToString();
|
||||
|
||||
事件2.Visible = false;
|
||||
事件2结果.Visible = false;
|
||||
事件2时间.Visible = false;
|
||||
事件2.Text = "事件2";
|
||||
事件2时间.Text = "事件2时间";
|
||||
事件2结果.Text = "OK";
|
||||
|
||||
事件3.Visible = false;
|
||||
事件3结果.Visible = false;
|
||||
事件3时间.Visible = false;
|
||||
事件3.Text = "事件3";
|
||||
事件3时间.Text = "事件3时间";
|
||||
事件3结果.Text = "OK";
|
||||
|
||||
事件4.Visible = false;
|
||||
事件4结果.Visible = false;
|
||||
事件4时间.Visible = false;
|
||||
事件4.Text = "事件4";
|
||||
事件4时间.Text = "事件4时间";
|
||||
事件4结果.Text = "OK";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user