From f3652923f4819571405141376bb67596c03a2e3f Mon Sep 17 00:00:00 2001 From: gongxh Date: Fri, 13 May 2022 09:08:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CleanMachineHMI/DataBase/clearMac.db | Bin 380928 -> 380928 bytes CleanMachineHMI/Utils/ByteTransformBase.cs | 536 ++++++++++++++++++++ CleanMachineHMI/Utils/DataFormat.cs | 28 + CleanMachineHMI/Utils/PlcOperationHelper.cs | 35 +- CleanMachineHMI/frmMainNew.cs | 210 ++++---- 5 files changed, 701 insertions(+), 108 deletions(-) create mode 100644 CleanMachineHMI/Utils/ByteTransformBase.cs create mode 100644 CleanMachineHMI/Utils/DataFormat.cs diff --git a/CleanMachineHMI/DataBase/clearMac.db b/CleanMachineHMI/DataBase/clearMac.db index a6fc0251f159d2a72c54f45620e7918802f25cf7..5d32175c4049dd2866845e9041e2359cf088aa50 100644 GIT binary patch delta 696 zcmZozAl|S*e1bIN(up$8j7v8r-1cEy(QM<}ZsW@c#7x_5e3?&7VwPv@n9lxy*_4Yp zh3OSj8RH+uj?EJloEW(a8#Tlk%*`1&IE1J3KVue+f7-t5+3s1-*G_ub(BR?g3F1zh zi6+QoWMXV&WNBn#Vq{=sq-$WRYiOikXli9-X=Q4JMX0<{U7W$z7H&!E)86)%GkdYv zgCP#J$`EKFx>bgzScD22)lmKOV*hMRd(Z@dmKXv3V*n&kEwQjNF~lNN-lz)qkNQ() zl`vpHJ=@XxY)c~~xR5Obnr&!gWMPTLAOlRZ4Gha0Rp4gN2Aa(bG<&+E8?&e}kO4Fd z=s*h#Ac^Wwb1R?#rqK3#kC~Nu*g2gU6c}bQPv`i+ET_USlj9CYBKr&WBDP;_wQQoS z3s`koI+#B*hcNADQedoR_|Ncv@q8-j@g9 z12waeAff}e-s1x!3 0) + + int SysRunTime = (int)PlcOperationHelper.Instance.ReadPlcItem("SysRuningTime", PlcItemTypeDesc.D); + int Minutes = SysRunTime / 60; + BeginInvoke(new Action(() => { - int sysRuningTimeLen = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'SysRuningTimeLen'")[0]["PARAMETER_VALUE"]); - int scrapRate = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'ScrapRate'")[0]["PARAMETER_VALUE"]); - int maintainItemTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainItemTime'")[0]["PARAMETER_VALUE"]); - int maintainAlarmTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainAlarmTime'")[0]["PARAMETER_VALUE"]); - int maintainQuitTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainQuitTime'")[0]["PARAMETER_VALUE"]); - int maintainFlag = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainFlag'")[0]["PARAMETER_VALUE"]); - string maintainRelieveCode = dtParam.Select("PARAMETER_CODE = 'MaintainRelieveCode'")[0]["PARAMETER_VALUE"].ToString(); - if (maintainFlag == 0) - { - bool isRun = (bool)PlcOperationHelper.Instance.ReadPlcItem("CleanMacRunStatusNew", PlcItemTypeDesc.M); - if (isRun) - { + kryptonLabel1.Text = Minutes + " Minutes"; + })); - if (timerRunNUm == 60) - { - sysRuningTimeLen++; - if (sysRuningTimeLen < maintainItemTime) - { - //pictureBox1.Visible = false; - BeginInvoke(new Action(() => { pictureBox1.Visible = false; })); - } - else if (sysRuningTimeLen >= maintainItemTime && sysRuningTimeLen < maintainAlarmTime) - { - //pictureBox1.Visible = true; - BeginInvoke(new Action(() => { pictureBox1.Visible = true; })); - } - else if (sysRuningTimeLen >= maintainAlarmTime && sysRuningTimeLen < maintainQuitTime) - { - //BeginInvoke(new Action(() => - //{ - // pictureBox1.Visible = true; - // if (!sysAlarmFrmShowFlag) - // { - // sysAlarmFrmShowFlag = true; - // frmSysExitAlarm frm = new frmSysExitAlarm(); - // //frm.showMsg = "机器即将于" + (maintainQuitTime - sysRuningTimeLen) + "分钟后退出。"; - // frm.showMsg = $"The machine will exit in {(maintainQuitTime - sysRuningTimeLen)} minutes."; - // frm.TopLevel = true; - // frm.ShowDialog(); - // } - //})); - } - else if (sysRuningTimeLen >= maintainQuitTime) - { - //BeginInvoke(new Action(() => - //{ - // pictureBox1.Visible = true; - // string sql = "SELECT 1 FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0"; - // DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0]; - // if (dt != null && dt.Rows.Count > 0) - // { - // if (!sysAlarmFrmShowFlag) - // { - // sysAlarmFrmShowFlag = true; - // frmSysExitAlarm frm = new frmSysExitAlarm(); - // frm.showMsg = $"The machine maintenance time has exceeded: [{(maintainQuitTime - sysRuningTimeLen)}] minutes, please complete the current operation tray as soon as possible, and carry out equipment maintenance !!!!!!"; - // frm.TopLevel = true; - // frm.ShowDialog(); - // } - // } - // else - // { - // string sqlUpdateParam = $@"update SYS_PARAMETER set PARAMETER_VALUE = '1' WHERE PARAMETER_CODE = 'MaintainFlag'"; - // LeadDbHelperSQLite.ExecuteSql(sqlUpdateParam); - // PlcOperationHelper.Instance.WritePlcItem("StopSys", "True", PlcItemTypeDesc.M); - // PlcOperationHelper.Instance.WritePlcItem("StopSys", "False", PlcItemTypeDesc.M); - // PlcOperationHelper.Instance.WritePlcItem("ResetSys", "True", PlcItemTypeDesc.M); - // PlcOperationHelper.Instance.WritePlcItem("ResetSys", "False", PlcItemTypeDesc.M); - // Environment.Exit(0); - // } - //})); - } - string sqlUpdateRunTimeLen = $@"UPDATE SYS_PARAMETER set PARAMETER_VALUE = '{sysRuningTimeLen}' WHERE PARAMETER_CODE = 'SysRuningTimeLen'"; - LeadDbHelperSQLite.ExecuteSql(sqlUpdateRunTimeLen); - BeginInvoke(new Action(() => - { - kryptonLabel1.Text = sysRuningTimeLen + " Minutes"; - })); - timerRunNUm = 1; - } - else - { - timerRunNUm++; - BeginInvoke(new Action(() => - { - kryptonLabel1.Text = sysRuningTimeLen + " Minutes"; - })); - } - } + + //string sqlParam = $@"SELECT * FROM SYS_PARAMETER"; + //DataTable dtParam = LeadDbHelperSQLite.Query(sqlParam).Tables[0]; + //if (dtParam != null && dtParam.Rows.Count > 0) + //{ + // int sysRuningTimeLen = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'SysRuningTimeLen'")[0]["PARAMETER_VALUE"]); + // int scrapRate = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'ScrapRate'")[0]["PARAMETER_VALUE"]); + // int maintainItemTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainItemTime'")[0]["PARAMETER_VALUE"]); + // int maintainAlarmTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainAlarmTime'")[0]["PARAMETER_VALUE"]); + // int maintainQuitTime = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainQuitTime'")[0]["PARAMETER_VALUE"]); + // int maintainFlag = Convert.ToInt32(dtParam.Select("PARAMETER_CODE = 'MaintainFlag'")[0]["PARAMETER_VALUE"]); + // string maintainRelieveCode = dtParam.Select("PARAMETER_CODE = 'MaintainRelieveCode'")[0]["PARAMETER_VALUE"].ToString(); + // if (maintainFlag == 0) + // { + // bool isRun = (bool)PlcOperationHelper.Instance.ReadPlcItem("CleanMacRunStatusNew", PlcItemTypeDesc.M); + + // if (isRun) + // { + + // if (timerRunNUm == 60) + // { + // sysRuningTimeLen++; + // if (sysRuningTimeLen < maintainItemTime) + // { + // //pictureBox1.Visible = false; + // BeginInvoke(new Action(() => { pictureBox1.Visible = false; })); + // } + // else if (sysRuningTimeLen >= maintainItemTime && sysRuningTimeLen < maintainAlarmTime) + // { + // //pictureBox1.Visible = true; + // BeginInvoke(new Action(() => { pictureBox1.Visible = true; })); + // } + // else if (sysRuningTimeLen >= maintainAlarmTime && sysRuningTimeLen < maintainQuitTime) + // { + // //BeginInvoke(new Action(() => + // //{ + // // pictureBox1.Visible = true; + // // if (!sysAlarmFrmShowFlag) + // // { + // // sysAlarmFrmShowFlag = true; + // // frmSysExitAlarm frm = new frmSysExitAlarm(); + // // //frm.showMsg = "机器即将于" + (maintainQuitTime - sysRuningTimeLen) + "分钟后退出。"; + // // frm.showMsg = $"The machine will exit in {(maintainQuitTime - sysRuningTimeLen)} minutes."; + // // frm.TopLevel = true; + // // frm.ShowDialog(); + // // } + // //})); + // } + // else if (sysRuningTimeLen >= maintainQuitTime) + // { + // //BeginInvoke(new Action(() => + // //{ + // // pictureBox1.Visible = true; + // // string sql = "SELECT 1 FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0"; + // // DataTable dt = LeadDbHelperSQLite.Query(sql).Tables[0]; + // // if (dt != null && dt.Rows.Count > 0) + // // { + // // if (!sysAlarmFrmShowFlag) + // // { + // // sysAlarmFrmShowFlag = true; + // // frmSysExitAlarm frm = new frmSysExitAlarm(); + // // frm.showMsg = $"The machine maintenance time has exceeded: [{(maintainQuitTime - sysRuningTimeLen)}] minutes, please complete the current operation tray as soon as possible, and carry out equipment maintenance !!!!!!"; + // // frm.TopLevel = true; + // // frm.ShowDialog(); + // // } + // // } + // // else + // // { + // // string sqlUpdateParam = $@"update SYS_PARAMETER set PARAMETER_VALUE = '1' WHERE PARAMETER_CODE = 'MaintainFlag'"; + // // LeadDbHelperSQLite.ExecuteSql(sqlUpdateParam); + // // PlcOperationHelper.Instance.WritePlcItem("StopSys", "True", PlcItemTypeDesc.M); + // // PlcOperationHelper.Instance.WritePlcItem("StopSys", "False", PlcItemTypeDesc.M); + // // PlcOperationHelper.Instance.WritePlcItem("ResetSys", "True", PlcItemTypeDesc.M); + // // PlcOperationHelper.Instance.WritePlcItem("ResetSys", "False", PlcItemTypeDesc.M); + // // Environment.Exit(0); + // // } + // //})); + // } + // string sqlUpdateRunTimeLen = $@"UPDATE SYS_PARAMETER set PARAMETER_VALUE = '{sysRuningTimeLen}' WHERE PARAMETER_CODE = 'SysRuningTimeLen'"; + // LeadDbHelperSQLite.ExecuteSql(sqlUpdateRunTimeLen); + // BeginInvoke(new Action(() => + // { + // kryptonLabel1.Text = sysRuningTimeLen + " Minutes"; + // })); + // timerRunNUm = 1; + // } + // else + // { + // timerRunNUm++; + // BeginInvoke(new Action(() => + // { + // kryptonLabel1.Text = sysRuningTimeLen + " Minutes"; + // })); + // } + // } - } - else - { - BeginInvoke(new Action(() => - { - pictureBox1.Visible = true; - })); - } - } + // } + // else + // { + // BeginInvoke(new Action(() => + // { + // pictureBox1.Visible = true; + // })); + // } + //} #region 定期清理历史业务数据 -- 数据保存2个月