添加编译指令
This commit is contained in:
@@ -1319,7 +1319,7 @@ namespace CleanMachineHMI.FrmUserControl
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
cbt_Brush3StatusTran.BackColor = Color.Gray;
|
||||
@@ -2832,7 +2832,12 @@ namespace CleanMachineHMI.FrmUserControl
|
||||
|
||||
}
|
||||
|
||||
//自动模式下,打印结束操控 M231 交替 别名: PrintFinish
|
||||
/// <summary>
|
||||
/// 自动模式下,打印结束操控 M231 交替 别名: PrintFinish
|
||||
/// 打印不成功时候按这个重新向PLC发这个指令
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void kryptonButton7_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (isManualStatus())
|
||||
@@ -3133,7 +3138,7 @@ namespace CleanMachineHMI.FrmUserControl
|
||||
{
|
||||
if (isManualStatus())
|
||||
{
|
||||
|
||||
|
||||
KryptonMessageBox.Show("The manual operation interface has been opened and is currently in manual mode.");
|
||||
return;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -372,7 +372,7 @@ namespace CleanMachineHMI
|
||||
PlcItem md = PlcItemMdList.Find(x => x.PlcItemCode == item["PLC_ITEM_CODE"].ToString());
|
||||
if (md != null)
|
||||
{
|
||||
md.PlcItemId =item["PLC_ITEM_ID"].ToString();
|
||||
md.PlcItemId = item["PLC_ITEM_ID"].ToString();
|
||||
md.PlcItemCode = item["PLC_ITEM_CODE"].ToString();
|
||||
md.PlcItemName = item["PLC_ITEM_NAME"].ToString();
|
||||
md.PlcItemType = Convert.ToInt32(item["PLC_ITEM_TYPE"].ToString());
|
||||
@@ -484,169 +484,174 @@ namespace CleanMachineHMI
|
||||
long lastTick = DateTime.Now.Ticks;
|
||||
while (GlobalHelper.SysThIsRunFlag)
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#region 定时器运行函数
|
||||
//当前托报废率超过10%,则提示
|
||||
string sql_CurrPalletmsg = $@"SELECT * FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0";
|
||||
DataTable dt_CurrPalletmsg = LeadDbHelperSQLite.Query(sql_CurrPalletmsg).Tables[0];
|
||||
if (dt_CurrPalletmsg != null && dt_CurrPalletmsg.Rows.Count > 0)
|
||||
#endif
|
||||
#region 定时器运行函数
|
||||
//当前托报废率超过10%,则提示
|
||||
string sql_CurrPalletmsg = $@"SELECT * FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0";
|
||||
DataTable dt_CurrPalletmsg = LeadDbHelperSQLite.Query(sql_CurrPalletmsg).Tables[0];
|
||||
if (dt_CurrPalletmsg != null && dt_CurrPalletmsg.Rows.Count > 0)
|
||||
{
|
||||
string palletCodeMsg = dt_CurrPalletmsg.Rows[0]["WORKING_PALLET_CODE"].ToString();
|
||||
string sqlCurrPalletScrapNumMsg = $@"SELECT CURRENT_NUMBER FROM VW_WORKING_PALLET_MSG WHERE WORKING_PALLET_CODE = '{palletCodeMsg}' AND CONTAMINATION_DTL_CODE = 'MoistureOrWet'";
|
||||
string sqlCurrPalletCountNumMsg = $@"SELECT SUM(CURRENT_NUMBER) FROM VW_WORKING_PALLET_MSG WHERE WORKING_PALLET_CODE = '{palletCodeMsg}'";
|
||||
DataTable dt_CurrPalletScrapNumMsg = LeadDbHelperSQLite.Query(sqlCurrPalletScrapNumMsg).Tables[0];
|
||||
DataTable dt_CurrPalletCountNumMsg = LeadDbHelperSQLite.Query(sqlCurrPalletCountNumMsg).Tables[0];
|
||||
if (dt_CurrPalletScrapNumMsg != null && dt_CurrPalletScrapNumMsg.Rows.Count > 0 && dt_CurrPalletCountNumMsg != null && dt_CurrPalletCountNumMsg.Rows.Count > 0)
|
||||
{
|
||||
string palletCodeMsg = dt_CurrPalletmsg.Rows[0]["WORKING_PALLET_CODE"].ToString();
|
||||
string sqlCurrPalletScrapNumMsg = $@"SELECT CURRENT_NUMBER FROM VW_WORKING_PALLET_MSG WHERE WORKING_PALLET_CODE = '{palletCodeMsg}' AND CONTAMINATION_DTL_CODE = 'MoistureOrWet'";
|
||||
string sqlCurrPalletCountNumMsg = $@"SELECT SUM(CURRENT_NUMBER) FROM VW_WORKING_PALLET_MSG WHERE WORKING_PALLET_CODE = '{palletCodeMsg}'";
|
||||
DataTable dt_CurrPalletScrapNumMsg = LeadDbHelperSQLite.Query(sqlCurrPalletScrapNumMsg).Tables[0];
|
||||
DataTable dt_CurrPalletCountNumMsg = LeadDbHelperSQLite.Query(sqlCurrPalletCountNumMsg).Tables[0];
|
||||
if (dt_CurrPalletScrapNumMsg != null && dt_CurrPalletScrapNumMsg.Rows.Count > 0 && dt_CurrPalletCountNumMsg != null && dt_CurrPalletCountNumMsg.Rows.Count > 0)
|
||||
int ScrapNumMsg = Convert.ToInt32(dt_CurrPalletScrapNumMsg.Rows[0][0]);
|
||||
int CountNumMsg = Convert.ToInt32(dt_CurrPalletCountNumMsg.Rows[0][0]);
|
||||
if (CountNumMsg == 0 || ScrapNumMsg == 0)
|
||||
{
|
||||
int ScrapNumMsg = Convert.ToInt32(dt_CurrPalletScrapNumMsg.Rows[0][0]);
|
||||
int CountNumMsg = Convert.ToInt32(dt_CurrPalletCountNumMsg.Rows[0][0]);
|
||||
if (CountNumMsg == 0 || ScrapNumMsg == 0)
|
||||
BeginInvoke(new Action(() => { label1.Visible = false; }));
|
||||
}
|
||||
else
|
||||
{
|
||||
int scrapRate = Convert.ToInt32(Math.Round(decimal.Parse(((decimal)ScrapNumMsg / (decimal)CountNumMsg).ToString("0.000")), 2) * 100);
|
||||
if (scrapRate >= 10)
|
||||
{
|
||||
BeginInvoke(new Action(() => { label1.Visible = false; }));
|
||||
}
|
||||
else
|
||||
{
|
||||
int scrapRate = Convert.ToInt32(Math.Round(decimal.Parse(((decimal)ScrapNumMsg / (decimal)CountNumMsg).ToString("0.000")), 2) * 100);
|
||||
if (scrapRate >= 10)
|
||||
{
|
||||
BeginInvoke(new Action(() => { label1.Visible = false; }));
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginInvoke(new Action(() => { label1.Visible = false; }));
|
||||
}
|
||||
BeginInvoke(new Action(() => { label1.Visible = false; }));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginInvoke(new Action(() => { label1.Visible = false; }));
|
||||
}
|
||||
}
|
||||
|
||||
string sqlParam = $@"SELECT * FROM SYS_PARAMETER";
|
||||
DataTable dtParam = LeadDbHelperSQLite.Query(sqlParam).Tables[0];
|
||||
if (dtParam != null && dtParam.Rows.Count > 0)
|
||||
else
|
||||
{
|
||||
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)
|
||||
BeginInvoke(new Action(() => { label1.Visible = false; }));
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
bool isRun = (bool)PlcOperationHelper.Instance.ReadPlcItem("CleanMacRunStatusNew", PlcItemTypeDesc.M);
|
||||
|
||||
if (isRun)
|
||||
if (timerRunNUm == 60)
|
||||
{
|
||||
|
||||
if (timerRunNUm == 60)
|
||||
sysRuningTimeLen++;
|
||||
if (sysRuningTimeLen < maintainItemTime)
|
||||
{
|
||||
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 = 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)
|
||||
{
|
||||
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.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 if (sysRuningTimeLen >= maintainQuitTime)
|
||||
{
|
||||
BeginInvoke(new Action(() =>
|
||||
}
|
||||
else
|
||||
{
|
||||
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";
|
||||
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);
|
||||
}
|
||||
}));
|
||||
timerRunNUm = 1;
|
||||
}
|
||||
else
|
||||
string sqlUpdateRunTimeLen = $@"UPDATE SYS_PARAMETER set PARAMETER_VALUE = '{sysRuningTimeLen}' WHERE PARAMETER_CODE = 'SysRuningTimeLen'";
|
||||
LeadDbHelperSQLite.ExecuteSql(sqlUpdateRunTimeLen);
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
timerRunNUm++;
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
kryptonLabel1.Text = sysRuningTimeLen + " Minutes";
|
||||
}));
|
||||
}
|
||||
kryptonLabel1.Text = sysRuningTimeLen + " Minutes";
|
||||
}));
|
||||
timerRunNUm = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginInvoke(new Action(() =>
|
||||
else
|
||||
{
|
||||
pictureBox1.Visible = true;
|
||||
}));
|
||||
timerRunNUm++;
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
kryptonLabel1.Text = sysRuningTimeLen + " Minutes";
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
pictureBox1.Visible = true;
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
#region 定期清理历史业务数据 -- 数据保存2个月
|
||||
string sqlZbkWorkingPallet = $@"DELETE FROM ZBK_WORKING_PALLET WHERE julianday('now') - julianday(UPDATE_TIME) > 30";
|
||||
string sqlZbkWorkingPalletDtl = $@"DELETE FROM ZBK_WORKING_PALLET_DTL WHERE julianday('now') - julianday(UPDATE_TIME) > 30";
|
||||
LeadDbHelperSQLite.ExecuteSql(sqlZbkWorkingPallet);
|
||||
LeadDbHelperSQLite.ExecuteSql(sqlZbkWorkingPalletDtl);
|
||||
#endregion
|
||||
|
||||
PlcOperationHelper.Instance.HeartbeatDetection();
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
#region 定期清理历史业务数据 -- 数据保存2个月
|
||||
string sqlZbkWorkingPallet = $@"DELETE FROM ZBK_WORKING_PALLET WHERE julianday('now') - julianday(UPDATE_TIME) > 30";
|
||||
string sqlZbkWorkingPalletDtl = $@"DELETE FROM ZBK_WORKING_PALLET_DTL WHERE julianday('now') - julianday(UPDATE_TIME) > 30";
|
||||
LeadDbHelperSQLite.ExecuteSql(sqlZbkWorkingPallet);
|
||||
LeadDbHelperSQLite.ExecuteSql(sqlZbkWorkingPalletDtl);
|
||||
#endregion
|
||||
|
||||
PlcOperationHelper.Instance.HeartbeatDetection();
|
||||
#endregion
|
||||
#if !DEBUG
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog($"定时器运行函数发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||
}
|
||||
#endif
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
@@ -770,8 +775,8 @@ namespace CleanMachineHMI
|
||||
|
||||
if (isPlcConnStatus)
|
||||
{
|
||||
// 断开PLC连接
|
||||
PlcOperationHelper.Instance.ClosePlcConn();
|
||||
// 断开PLC连接
|
||||
PlcOperationHelper.Instance.ClosePlcConn();
|
||||
isPlcConnStatus = false;
|
||||
}
|
||||
if (GlobalHelper.PopupWarningMsgForm != null)
|
||||
|
||||
Reference in New Issue
Block a user