添加编译指令
This commit is contained in:
@@ -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)
|
private void kryptonButton7_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (isManualStatus())
|
if (isManualStatus())
|
||||||
|
|||||||
@@ -135,8 +135,10 @@ namespace CleanMachineHMI
|
|||||||
}
|
}
|
||||||
public void RefreshPlcItem_M()
|
public void RefreshPlcItem_M()
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
bool[] readBytArr_M = master.ReadCoils(slaveAddress, 2248, 50);
|
bool[] readBytArr_M = master.ReadCoils(slaveAddress, 2248, 50);
|
||||||
bool[] readBytArr_M1 = master.ReadCoils(slaveAddress, 2048, 50);
|
bool[] readBytArr_M1 = master.ReadCoils(slaveAddress, 2048, 50);
|
||||||
if (readBytArr_M.Length > 0 && readBytArr_M1.Length > 0)
|
if (readBytArr_M.Length > 0 && readBytArr_M1.Length > 0)
|
||||||
@@ -170,16 +172,20 @@ namespace CleanMachineHMI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"读取M 类型PLC变量时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
LogHelper.WriteLog($"读取M 类型PLC变量时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
public void RefreshPlcItem_D()
|
public void RefreshPlcItem_D()
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
ushort[] tmpReadAlarmBytArr_D = master.ReadHoldingRegisters(slaveAddress, 4106, 50);
|
ushort[] tmpReadAlarmBytArr_D = master.ReadHoldingRegisters(slaveAddress, 4106, 50);
|
||||||
ushort[] readBytArr_D = master.ReadHoldingRegisters(slaveAddress, 4505, 50);
|
ushort[] readBytArr_D = master.ReadHoldingRegisters(slaveAddress, 4505, 50);
|
||||||
if (readBytArr_D.Length > 0 && tmpReadAlarmBytArr_D.Length > 0)
|
if (readBytArr_D.Length > 0 && tmpReadAlarmBytArr_D.Length > 0)
|
||||||
@@ -231,18 +237,22 @@ namespace CleanMachineHMI
|
|||||||
}
|
}
|
||||||
HandleWaringLog(tmpReadAlarmBytArr_D);
|
HandleWaringLog(tmpReadAlarmBytArr_D);
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"读取D 类型PLC变量时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
LogHelper.WriteLog($"读取D 类型PLC变量时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//报警信息记录
|
//报警信息记录
|
||||||
private void HandleWaringLog(ushort[] tmpReadAlarmBytArr_D)
|
private void HandleWaringLog(ushort[] tmpReadAlarmBytArr_D)
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
int index = 10;
|
int index = 10;
|
||||||
string priStr = "D";
|
string priStr = "D";
|
||||||
string priWarnCode = "bit";
|
string priWarnCode = "bit";
|
||||||
@@ -565,17 +575,21 @@ namespace CleanMachineHMI
|
|||||||
//frmMainNew.Show_ptb_Alarm(false);
|
//frmMainNew.Show_ptb_Alarm(false);
|
||||||
GlobalHelper.ShowMainFrmAlarmMsg(false, EventArgs.Empty);
|
GlobalHelper.ShowMainFrmAlarmMsg(false, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"处理设备报警信息时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
LogHelper.WriteLog($"处理设备报警信息时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshPlcItem_X()
|
public void RefreshPlcItem_X()
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
bool[] readBytArr_X = master.ReadInputs(slaveAddress, 1024, 50);
|
bool[] readBytArr_X = master.ReadInputs(slaveAddress, 1024, 50);
|
||||||
if (readBytArr_X.Length > 0)
|
if (readBytArr_X.Length > 0)
|
||||||
//if(true)
|
//if(true)
|
||||||
@@ -600,17 +614,21 @@ namespace CleanMachineHMI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"读取X 类型PLC变量时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
LogHelper.WriteLog($"读取X 类型PLC变量时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshPlcItem_Y()
|
public void RefreshPlcItem_Y()
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
bool[] readBytArr_Y = master.ReadCoils(slaveAddress, 1280, 50);
|
bool[] readBytArr_Y = master.ReadCoils(slaveAddress, 1280, 50);
|
||||||
if (readBytArr_Y.Length > 0)
|
if (readBytArr_Y.Length > 0)
|
||||||
//if(true)
|
//if(true)
|
||||||
@@ -635,17 +653,21 @@ namespace CleanMachineHMI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"读取Y 类型PLC变量时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
LogHelper.WriteLog($"读取Y 类型PLC变量时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ReadPlcItem(string plcItemCode, PlcItemTypeDesc itemType)
|
public object ReadPlcItem(string plcItemCode, PlcItemTypeDesc itemType)
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
object retObj;
|
object retObj;
|
||||||
switch (itemType)
|
switch (itemType)
|
||||||
{
|
{
|
||||||
@@ -714,6 +736,7 @@ namespace CleanMachineHMI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return retObj;
|
return retObj;
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -721,12 +744,15 @@ namespace CleanMachineHMI
|
|||||||
LogHelper.WriteLog($"读取【{itemType.ToString()}】类型PLC变量【{plcItemCode}】时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
LogHelper.WriteLog($"读取【{itemType.ToString()}】类型PLC变量【{plcItemCode}】时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool WritePlcItem(string plcItemCode, string writeValue, PlcItemTypeDesc itemType)
|
public bool WritePlcItem(string plcItemCode, string writeValue, PlcItemTypeDesc itemType)
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
switch (itemType)
|
switch (itemType)
|
||||||
{
|
{
|
||||||
case PlcItemTypeDesc.M:
|
case PlcItemTypeDesc.M:
|
||||||
@@ -758,12 +784,14 @@ namespace CleanMachineHMI
|
|||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"写入【{itemType.ToString()}】类型PLC变量【{plcItemCode}】的值【{writeValue}】时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
LogHelper.WriteLog($"写入【{itemType}】类型PLC变量【{plcItemCode}】的值【{writeValue}】时发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
private int wcsToPlcHeartDataNew = 0;
|
private int wcsToPlcHeartDataNew = 0;
|
||||||
private DateTime HeartbeatTime = new DateTime();
|
private DateTime HeartbeatTime = new DateTime();
|
||||||
@@ -774,8 +802,10 @@ namespace CleanMachineHMI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void HeartbeatDetection()
|
public void HeartbeatDetection()
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
int wcsToPlcHeartData = Convert.ToInt32(ReadPlcItem("PlcHeartbeatWriteData", PlcItemTypeDesc.D) == null ? 0 : ReadPlcItem("PlcHeartbeatWriteData", PlcItemTypeDesc.D));
|
int wcsToPlcHeartData = Convert.ToInt32(ReadPlcItem("PlcHeartbeatWriteData", PlcItemTypeDesc.D) == null ? 0 : ReadPlcItem("PlcHeartbeatWriteData", PlcItemTypeDesc.D));
|
||||||
int plcToWcsHeartData = Convert.ToInt32(ReadPlcItem("PlcHeartbeatReadData", PlcItemTypeDesc.D) == null ? 0 : ReadPlcItem("PlcHeartbeatReadData", PlcItemTypeDesc.D));
|
int plcToWcsHeartData = Convert.ToInt32(ReadPlcItem("PlcHeartbeatReadData", PlcItemTypeDesc.D) == null ? 0 : ReadPlcItem("PlcHeartbeatReadData", PlcItemTypeDesc.D));
|
||||||
if (wcsToPlcHeartData == 0 && plcToWcsHeartData == 0)
|
if (wcsToPlcHeartData == 0 && plcToWcsHeartData == 0)
|
||||||
@@ -829,8 +859,6 @@ namespace CleanMachineHMI
|
|||||||
WritePlcItem("PlcHeartbeatWriteData", wcsToPlcHeartDataNew.ToString(), PlcItemTypeDesc.D);
|
WritePlcItem("PlcHeartbeatWriteData", wcsToPlcHeartDataNew.ToString(), PlcItemTypeDesc.D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if USE_LOCAL_TCP_DEBUG
|
#if USE_LOCAL_TCP_DEBUG
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -848,11 +876,14 @@ namespace CleanMachineHMI
|
|||||||
ReConnNum++;
|
ReConnNum++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -484,8 +484,10 @@ namespace CleanMachineHMI
|
|||||||
long lastTick = DateTime.Now.Ticks;
|
long lastTick = DateTime.Now.Ticks;
|
||||||
while (GlobalHelper.SysThIsRunFlag)
|
while (GlobalHelper.SysThIsRunFlag)
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
#region 定时器运行函数
|
#region 定时器运行函数
|
||||||
//当前托报废率超过10%,则提示
|
//当前托报废率超过10%,则提示
|
||||||
string sql_CurrPalletmsg = $@"SELECT * FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0";
|
string sql_CurrPalletmsg = $@"SELECT * FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0";
|
||||||
@@ -642,11 +644,14 @@ namespace CleanMachineHMI
|
|||||||
|
|
||||||
PlcOperationHelper.Instance.HeartbeatDetection();
|
PlcOperationHelper.Instance.HeartbeatDetection();
|
||||||
#endregion
|
#endregion
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"定时器运行函数发生异常:【{ex.Message}】", LogTypeEum.Err);
|
LogHelper.WriteLog($"定时器运行函数发生异常:【{ex.Message}】", LogTypeEum.Err);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ namespace LeadDataBaseUtility
|
|||||||
public static int ExecuteSql(string sql)
|
public static int ExecuteSql(string sql)
|
||||||
{
|
{
|
||||||
int affectedRows = 0;
|
int affectedRows = 0;
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
|
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
@@ -41,12 +42,14 @@ namespace LeadDataBaseUtility
|
|||||||
}
|
}
|
||||||
conn.Close();
|
conn.Close();
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{sql}】。", LogTypeEum.DbErr);
|
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{sql}】。", LogTypeEum.DbErr);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return affectedRows;
|
return affectedRows;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -59,17 +62,21 @@ namespace LeadDataBaseUtility
|
|||||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||||
{
|
{
|
||||||
DataSet ds = new DataSet();
|
DataSet ds = new DataSet();
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
connection.Open();
|
connection.Open();
|
||||||
SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
|
SQLiteDataAdapter command = new SQLiteDataAdapter(SQLString, connection);
|
||||||
command.Fill(ds, "ds");
|
command.Fill(ds, "ds");
|
||||||
connection.Close();
|
connection.Close();
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{SQLString}】。", LogTypeEum.DbErr);
|
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{SQLString}】。", LogTypeEum.DbErr);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,8 +91,10 @@ namespace LeadDataBaseUtility
|
|||||||
{
|
{
|
||||||
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
|
using (SQLiteCommand cmd = new SQLiteCommand(SQLString, connection))
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
connection.Open();
|
connection.Open();
|
||||||
object obj = cmd.ExecuteScalar();
|
object obj = cmd.ExecuteScalar();
|
||||||
if ((Equals(obj, null)) || (Equals(obj, System.DBNull.Value)))
|
if ((Equals(obj, null)) || (Equals(obj, System.DBNull.Value)))
|
||||||
@@ -98,6 +107,7 @@ namespace LeadDataBaseUtility
|
|||||||
connection.Close();
|
connection.Close();
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (System.Data.SQLite.SQLiteException e)
|
catch (System.Data.SQLite.SQLiteException e)
|
||||||
{
|
{
|
||||||
@@ -105,6 +115,7 @@ namespace LeadDataBaseUtility
|
|||||||
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{SQLString}】。", LogTypeEum.DbErr);
|
LogHelper.WriteLog($"数据库运行异常:【{e.Message}】。SQL语句:【{SQLString}】。", LogTypeEum.DbErr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ namespace NX_LogUtility
|
|||||||
}
|
}
|
||||||
public static class LogHelper
|
public static class LogHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
private readonly static System.Collections.Concurrent.BlockingCollection<string> messages = new System.Collections.Concurrent.BlockingCollection<string>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 记录日志为文本文档形式
|
#region 记录日志为文本文档形式
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录日志类
|
/// 记录日志类
|
||||||
@@ -75,9 +83,10 @@ namespace NX_LogUtility
|
|||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
lock (lockobj)
|
lock (lockobj)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(strDir))//如果日志文件存放的文件夹不存在,就新建一个文件夹。
|
if (!Directory.Exists(strDir))//如果日志文件存放的文件夹不存在,就新建一个文件夹。
|
||||||
@@ -104,18 +113,24 @@ namespace NX_LogUtility
|
|||||||
sw.Close();
|
sw.Close();
|
||||||
fs.Close();
|
fs.Close();
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
if (sw != null)
|
if (sw != null)
|
||||||
sw.Close();
|
sw.Close();
|
||||||
if (fs != null)
|
if (fs != null)
|
||||||
fs.Close();
|
fs.Close();
|
||||||
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user