添加新控制点

This commit is contained in:
gongxh
2022-05-13 09:08:42 +08:00
parent 08c7d6baef
commit f3652923f4
5 changed files with 701 additions and 108 deletions

View File

@@ -569,113 +569,123 @@ namespace CleanMachineHMI
}
}
string sqlParam = $@"SELECT * FROM SYS_PARAMETER";
DataTable dtParam = LeadDbHelperSQLite.Query(sqlParam).Tables[0];
if (dtParam != null && dtParam.Rows.Count > 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个月