修改消息处理
This commit is contained in:
@@ -25,8 +25,11 @@ namespace CleanMachineHMI.FrmUserControl
|
||||
public frmMainDetail()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private List<CleanType> basCleanTypeMsgList = new List<CleanType>();
|
||||
/// <summary>
|
||||
@@ -171,12 +174,15 @@ namespace CleanMachineHMI.FrmUserControl
|
||||
}
|
||||
//加载当前工作信息
|
||||
LoadCurrentWorkingTray();
|
||||
|
||||
Thread th1 = new Thread(MainDtlRunTh)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th1.Start();
|
||||
|
||||
|
||||
|
||||
PlcOperationHelper.Instance.OnReadFinish += Instance_OnReadFinish;
|
||||
//Thread th1 = new Thread(MainDtlRunTh)
|
||||
//{
|
||||
// IsBackground = true
|
||||
//};
|
||||
//th1.Start();
|
||||
|
||||
foreach (Control item in panMenu.Controls)
|
||||
{
|
||||
@@ -303,6 +309,281 @@ namespace CleanMachineHMI.FrmUserControl
|
||||
LogHelper.WriteLog($"1111【{ex.Message}】", LogTypeEum.Err);
|
||||
}
|
||||
}
|
||||
|
||||
private void Instance_OnReadFinish()
|
||||
{
|
||||
|
||||
|
||||
if (Convert.ToBoolean(PlcOperationHelper.Instance.ReadPlcItem("CleanMacRunStatusNew", PlcItemTypeDesc.M)))
|
||||
{
|
||||
cbt_RunStatusTran.BackColor = Color.Lime;
|
||||
}
|
||||
else
|
||||
{
|
||||
cbt_RunStatusTran.BackColor = Color.Gray;
|
||||
}
|
||||
//毛刷1运行状态
|
||||
if (Convert.ToBoolean(PlcOperationHelper.Instance.ReadPlcItem("Hairbrush1Selection", PlcItemTypeDesc.M)))
|
||||
{
|
||||
|
||||
cbt_Brush1StatusTran.BackColor = Color.Lime;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cbt_Brush1StatusTran.BackColor = Color.Gray;
|
||||
|
||||
}
|
||||
|
||||
//毛刷2启用状态
|
||||
|
||||
if (Convert.ToBoolean(PlcOperationHelper.Instance.ReadPlcItem("Hairbrush2Selection", PlcItemTypeDesc.M)))
|
||||
{
|
||||
|
||||
cbt_Brush2StatusTran.BackColor = Color.Lime;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cbt_Brush2StatusTran.BackColor = Color.Gray;
|
||||
|
||||
}
|
||||
//毛刷3启用状态
|
||||
if (Convert.ToBoolean(PlcOperationHelper.Instance.ReadPlcItem("Hairbrush3Selection", PlcItemTypeDesc.M)))
|
||||
{
|
||||
|
||||
cbt_Brush3StatusTran.BackColor = Color.Lime;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
cbt_Brush3StatusTran.BackColor = Color.Gray;
|
||||
|
||||
}
|
||||
//喷头选择状态
|
||||
//if (Convert.ToBoolean(PlcOperationHelper.Instance.ReadPlcItem("NozzleSelection", PlcItemTypeDesc.M)))
|
||||
//{
|
||||
// Invoke(new Action(() =>
|
||||
// {
|
||||
// cbt_NozzleStatusTran.BackColor = Color.Lime;
|
||||
// }));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Invoke(new Action(() =>
|
||||
// {
|
||||
// cbt_NozzleStatusTran.BackColor = Color.Gray;
|
||||
// }));
|
||||
//}
|
||||
//静电棒选择
|
||||
|
||||
if (Convert.ToBoolean(PlcOperationHelper.Instance.ReadPlcItem("StaticbarsSel", PlcItemTypeDesc.M)))
|
||||
{
|
||||
|
||||
cbt_staticbar.BackColor = Color.Lime;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cbt_staticbar.BackColor = Color.Gray;
|
||||
|
||||
}
|
||||
|
||||
//计数模式选择
|
||||
//if (Convert.ToBoolean(PlcOperationHelper.Instance.ReadPlcItem("FullPalletMode", PlcItemTypeDesc.M)))
|
||||
//{
|
||||
// Invoke(new Action(() =>
|
||||
// {
|
||||
// cbt_fpalletmod.BackColor = Color.Lime;
|
||||
// }));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Invoke(new Action(() =>
|
||||
// {
|
||||
// cbt_fpalletmod.BackColor = Color.Gray;
|
||||
// }));
|
||||
//}
|
||||
|
||||
//显示托盘编号
|
||||
if (ktb_IR.Text.Trim().Length > 0)
|
||||
{
|
||||
string sqlWorkPalletSel = $@"SELECT * FROM CM_WORKING_PALLET WHERE WORKING_STATUS = 0 ORDER BY CREATE_TIME DESC";
|
||||
DataTable dtWorkPalletSel = LeadDbHelperSQLite.Query(sqlWorkPalletSel).Tables[0];
|
||||
if (dtWorkPalletSel.Rows.Count > 0)
|
||||
{
|
||||
|
||||
ktb_CurrPalletCode.Text = dtWorkPalletSel.Rows[0]["WORKING_PALLET_CODE"].ToString();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ktb_CurrPalletCode.Text = "";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
string ktb_IRTest = "";
|
||||
|
||||
string kcmb_SheetTypeText = "";
|
||||
string CurrPalletCodeText = "";
|
||||
|
||||
ktb_IRTest = this.ktb_IR.Text;
|
||||
kcmb_SheetTypeText = this.kcmb_SheetType.Text;
|
||||
|
||||
CurrPalletCodeText = ktb_CurrPalletCode.Text.Trim();
|
||||
|
||||
|
||||
|
||||
//防止中途关闭系统产生数据丢失,因此每周期都会更新数据
|
||||
string sql = $@"SELECT SUM(CURRENT_NUMBER) FROM CM_WORKING_PALLET_DTL WHERE CLEAN_MODE_CODE = 'SortedCleaned' AND IR_CODE = '{ktb_IRTest}' AND SHEET_TYPE_CODE = '{kcmb_SheetTypeText}'";
|
||||
object obj = LeadDbHelperSQLite.GetSingle(sql);
|
||||
if (obj == null)
|
||||
{
|
||||
ktb_CompleteNum.Text = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
ktb_CompleteNum.Text = obj.ToString();
|
||||
}
|
||||
string sql1 = $@"SELECT SUM(CURRENT_NUMBER) FROM CM_WORKING_PALLET_DTL WHERE CLEAN_MODE_CODE <> 'SortedCleaned' AND IR_CODE = '{ktb_IRTest}' AND SHEET_TYPE_CODE = '{kcmb_SheetTypeText}'";
|
||||
object obj1 = LeadDbHelperSQLite.GetSingle(sql1);
|
||||
if (obj1 == null)
|
||||
{
|
||||
|
||||
ktb_ScrapNum.Text = "0";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ktb_ScrapNum.Text = obj1.ToString();
|
||||
|
||||
}
|
||||
string sql11 = $@"SELECT SUM(CURRENT_NUMBER) FROM CM_WORKING_PALLET_DTL WHERE CLEAN_MODE_CODE = 'Scrap' AND IR_CODE = '{ktb_IRTest}' AND SHEET_TYPE_CODE = '{kcmb_SheetTypeText}' AND WORKING_PALLET_CODE = '{CurrPalletCodeText}'";
|
||||
object obj11 = LeadDbHelperSQLite.GetSingle(sql11);
|
||||
if (obj11 == null)
|
||||
{
|
||||
|
||||
ktb_Scrap.Text = "0";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ktb_Scrap.Text = obj11.ToString();
|
||||
|
||||
}
|
||||
|
||||
string sqlPalletCount = $@"SELECT CURRENT_NUMBER,WORKING_DTL_STATUS FROM CM_WORKING_PALLET_DTL WHERE CLEAN_MODE_CODE = 'SortedCleaned' AND IR_CODE = '{ktb_IRTest}' AND SHEET_TYPE_CODE = '{kcmb_SheetTypeText}'";
|
||||
DataTable dtPalletCount = LeadDbHelperSQLite.Query(sqlPalletCount).Tables[0];
|
||||
if (dtPalletCount != null && dtPalletCount.Rows.Count > 0)
|
||||
{
|
||||
int finishedPalletNum = 0;
|
||||
int currentPalletNum = 0;
|
||||
foreach (DataRow item in dtPalletCount.Rows)
|
||||
{
|
||||
if (item["WORKING_DTL_STATUS"].ToString() == "1")
|
||||
{
|
||||
finishedPalletNum += Convert.ToInt32(item["CURRENT_NUMBER"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentPalletNum += Convert.ToInt32(item["CURRENT_NUMBER"]);
|
||||
}
|
||||
}
|
||||
|
||||
ktb_CurrentPalletNum.Text = currentPalletNum.ToString();
|
||||
ktb_FinishedPalletNum.Text = finishedPalletNum.ToString();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ktb_CurrentPalletNum.Text = "0";
|
||||
ktb_FinishedPalletNum.Text = "0";
|
||||
|
||||
|
||||
}
|
||||
//读取PLC当前值-这个值带有初始值
|
||||
int currNum = Convert.ToInt32(PlcOperationHelper.Instance.ReadPlcItem("NozzleNum", PlcItemTypeDesc.D));
|
||||
|
||||
int fullPalletNum = Convert.ToInt32(PlcOperationHelper.Instance.ReadPlcItem("WorkedFullPalletNum", PlcItemTypeDesc.D));
|
||||
//
|
||||
|
||||
if (0 < (fullPalletNum - currNum) && (fullPalletNum - currNum) <= 10 && fullPalletNum != 0)
|
||||
{
|
||||
if ((fullPalletNum - currNum) != remainingQty)
|
||||
{
|
||||
frmMainNew.RefreshFrmHost($"The tray is about to fill up and the remaining quantity is [{fullPalletNum - currNum}]!!");
|
||||
LogHelper.WriteLog($"托盘即将满料,剩余数量为【{fullPalletNum - currNum}】!!", LogTypeEum.Run);
|
||||
remainingQty = fullPalletNum - currNum;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
remainingQty = fullPalletNum - currNum;
|
||||
frmMainNew.RefreshFrmHost(null);
|
||||
}
|
||||
//托盘在当前IR中的数量
|
||||
currNum -= this.lastPaltteRemain;
|
||||
if (currNum > 0)
|
||||
{
|
||||
//string sqlFinishIrSheetTypeDtl = $"select sum(CURRENT_NUMBER) from CM_WORKING_PALLET_DTL where CLEAN_MODE_CODE = 'SortedCleaned' and WORKING_DTL_STATUS = 1";
|
||||
//DataTable dtFinishIrSheetTypeDtl = LeadDbHelperSQLite.Query(sqlFinishIrSheetTypeDtl).Tables[0];
|
||||
|
||||
//int finishIrSheetTypeNum = 0;
|
||||
//if (dtFinishIrSheetTypeDtl != null && dtFinishIrSheetTypeDtl.Rows.Count > 0)
|
||||
//{
|
||||
// finishIrSheetTypeNum = Convert.ToInt32(dtFinishIrSheetTypeDtl.Rows[0][0] == DBNull.Value ? 0 : dtFinishIrSheetTypeDtl.Rows[0][0]);
|
||||
//}
|
||||
//if (autoCleanNum != (currNum - finishIrSheetTypeNum))
|
||||
//{
|
||||
//防止中途关闭系统后产生内存数据丢失
|
||||
string sql12 = $@"
|
||||
UPDATE CM_WORKING_PALLET_DTL
|
||||
SET CURRENT_NUMBER = '{currNum }',
|
||||
UPDATE_BY = '{Global.UserInfo.UserId}',
|
||||
UPDATE_TIME = datetime('now', 'localtime'),
|
||||
DATA_VERSION = DATA_VERSION + 1
|
||||
WHERE
|
||||
CLEAN_MODE_CODE = 'SortedCleaned'
|
||||
AND IR_CODE = '{ktb_IRTest}'
|
||||
AND SHEET_TYPE_CODE = '{kcmb_SheetTypeText}'
|
||||
AND WORKING_DTL_STATUS = 0
|
||||
AND WORKING_PALLET_CODE = '{CurrPalletCodeText}'
|
||||
";
|
||||
|
||||
int row = LeadDbHelperSQLite.ExecuteSql(sql12);
|
||||
//autoCleanNum = currNum - finishIrSheetTypeNum;
|
||||
if (row > 0)
|
||||
{
|
||||
//LogHelper.WriteLog($"用户:【{GlobalHelper.UserInfo.USER_NAME}】作业托盘:【{ktb_CurrPalletCode.Text}】作业IR:【{ktb_IR.Text}】作业板材:【{kcmb_SheetType.Text}】顺序清洗计数+1成功,数量为:【{currNum}】。", LogTypeEum.Run);
|
||||
}
|
||||
else
|
||||
{
|
||||
//LogHelper.WriteLog($"用户:【{GlobalHelper.UserInfo.USER_NAME}】作业托盘:【{ktb_CurrPalletCode.Text}】作业IR:【{ktb_IR.Text}】作业板材:【{kcmb_SheetType.Text}】顺序清洗计数+1失败。", LogTypeEum.Run);
|
||||
}
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
//autoCleanNum = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SyncFinishPalletData(object sender, EventArgs e)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
|
||||
@@ -65,6 +65,24 @@ namespace CleanMachineHMI
|
||||
_synchronization = SynchronizationContext.Current;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取完成的委托
|
||||
/// </summary>
|
||||
public delegate void ReadFinish();
|
||||
|
||||
public event ReadFinish OnReadFinish;
|
||||
|
||||
public void DoOnReadFinish(object data)
|
||||
{
|
||||
|
||||
OnReadFinish?.Invoke();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private SynchronizationContext _synchronization;
|
||||
@@ -98,7 +116,7 @@ namespace CleanMachineHMI
|
||||
|
||||
|
||||
|
||||
public List<PlcItem> PlcItemMdList { get; set; } = new List<PlcItem>();
|
||||
public List<PlcItem> PlcItemMdList { get; set; } = new List<PlcItem>();
|
||||
public List<PlcItem> PlcItemMd_D_List { get; set; } = new List<PlcItem>();
|
||||
|
||||
public List<PlcItem> PlcItemMd_M_List { get; set; } = new List<PlcItem>();
|
||||
@@ -108,15 +126,15 @@ namespace CleanMachineHMI
|
||||
public List<PlcItem> PlcItemMd_Y_List { get; set; } = new List<PlcItem>();
|
||||
|
||||
|
||||
//public void StartRead()
|
||||
//{
|
||||
// Thread th = new Thread(RefreshPlcItem)
|
||||
// {
|
||||
// IsBackground = true
|
||||
// };
|
||||
// th.Start();
|
||||
public void StartRead()
|
||||
{
|
||||
Thread th = new Thread(RefreshPlcItem)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
th.Start();
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -126,10 +144,18 @@ namespace CleanMachineHMI
|
||||
{
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
RefreshPlcItem_M();
|
||||
RefreshPlcItem_D();
|
||||
RefreshPlcItem_X();
|
||||
RefreshPlcItem_Y();
|
||||
var haschange=false;
|
||||
RefreshPlcItem_M(ref haschange);
|
||||
RefreshPlcItem_D(ref haschange);
|
||||
RefreshPlcItem_X(ref haschange);
|
||||
RefreshPlcItem_Y(ref haschange);
|
||||
if (haschange)
|
||||
{
|
||||
if (_synchronization != null)
|
||||
{
|
||||
_synchronization.Post(this.DoOnReadFinish, null);
|
||||
}
|
||||
}
|
||||
// thEvent.Set();
|
||||
// ShowWarningMsg();
|
||||
Thread.Sleep(100);
|
||||
@@ -246,8 +272,9 @@ namespace CleanMachineHMI
|
||||
isConn = false;
|
||||
}
|
||||
}
|
||||
public void RefreshPlcItem_M()
|
||||
public void RefreshPlcItem_M(ref bool haschange)
|
||||
{
|
||||
|
||||
#if RELEASE
|
||||
try
|
||||
{
|
||||
@@ -260,15 +287,17 @@ namespace CleanMachineHMI
|
||||
{
|
||||
foreach (PlcItem item in PlcItemMd_M_List)
|
||||
{
|
||||
string value = "";
|
||||
if (Convert.ToInt32(item.PlcItemPriAddress) >= 200)
|
||||
{
|
||||
|
||||
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
||||
{
|
||||
//string PlcItemId = item.PlcItemId.ToString();
|
||||
// string plcdatatype = item.PlcItemDataType.ToString();
|
||||
//string plcdatatype = item.PlcItemDataType.ToString();
|
||||
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
||||
item.PlcItemValue = readBytArr_M[plcItemDeviationAddress].ToString();
|
||||
Global.ShowSensorStatus(item, new EventArgs());
|
||||
value = readBytArr_M[plcItemDeviationAddress].ToString();
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -278,10 +307,20 @@ namespace CleanMachineHMI
|
||||
//string PlcItemId = item.PlcItemId.ToString();
|
||||
//string plcdatatype = item.PlcItemDataType.ToString();
|
||||
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
||||
item.PlcItemValue = readBytArr_M1[plcItemDeviationAddress].ToString();
|
||||
Global.ShowSensorStatus(item, new EventArgs());
|
||||
value = readBytArr_M1[plcItemDeviationAddress].ToString();
|
||||
|
||||
}
|
||||
}
|
||||
if (value != "")
|
||||
{
|
||||
if (item.PlcItemValue != value)
|
||||
{
|
||||
haschange = true;
|
||||
}
|
||||
item.PlcItemValue = value;
|
||||
Global.ShowSensorStatus(item, new EventArgs());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -293,7 +332,7 @@ namespace CleanMachineHMI
|
||||
}
|
||||
#endif
|
||||
}
|
||||
public void RefreshPlcItem_D()
|
||||
public void RefreshPlcItem_D(ref bool haschange)
|
||||
{
|
||||
#if RELEASE
|
||||
try
|
||||
@@ -307,6 +346,7 @@ namespace CleanMachineHMI
|
||||
{
|
||||
foreach (PlcItem item in PlcItemMd_D_List)
|
||||
{
|
||||
var value = "";
|
||||
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
||||
{
|
||||
|
||||
@@ -315,7 +355,8 @@ namespace CleanMachineHMI
|
||||
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
||||
if (Convert.ToInt32(item.PlcItemPriAddress) < 409)
|
||||
{
|
||||
item.PlcItemValue = tmpReadAlarmBytArr_D[plcItemDeviationAddress].ToString();
|
||||
|
||||
value = tmpReadAlarmBytArr_D[plcItemDeviationAddress].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -337,16 +378,30 @@ namespace CleanMachineHMI
|
||||
|
||||
#region 方法二 :Short数组转换为int数据 20201014 孙亚龙
|
||||
//相较而言 使用位移的算法效率更高一些。
|
||||
item.PlcItemValue = ((readBytArr_D[plcItemDeviationAddress + 1] << 16) + readBytArr_D[plcItemDeviationAddress]).ToString();
|
||||
value = ((readBytArr_D[plcItemDeviationAddress + 1] << 16) + readBytArr_D[plcItemDeviationAddress]).ToString();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
item.PlcItemValue = readBytArr_D[plcItemDeviationAddress].ToString();
|
||||
value = readBytArr_D[plcItemDeviationAddress].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (value != "")
|
||||
{
|
||||
if (item.PlcItemValue != value)
|
||||
{
|
||||
haschange = true;
|
||||
}
|
||||
item.PlcItemValue = value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
string priStr = "D";
|
||||
@@ -372,7 +427,7 @@ namespace CleanMachineHMI
|
||||
{
|
||||
Global.ShowMainFrmAlarmMsg(false, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// HandleWaringLog(tmpReadAlarmBytArr_D);
|
||||
}
|
||||
@@ -728,7 +783,7 @@ namespace CleanMachineHMI
|
||||
#endif
|
||||
}
|
||||
|
||||
public void RefreshPlcItem_X()
|
||||
public void RefreshPlcItem_X(ref bool haschange)
|
||||
{
|
||||
#if RELEASE
|
||||
try
|
||||
@@ -742,18 +797,33 @@ namespace CleanMachineHMI
|
||||
{
|
||||
foreach (PlcItem item in PlcItemMd_X_List)
|
||||
{
|
||||
string value = "";
|
||||
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
||||
{
|
||||
string PlcItemId = item.PlcItemId.ToString();
|
||||
string plcdatatype = item.PlcItemDataType.ToString();
|
||||
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
||||
item.PlcItemValue = readBytArr_X[plcItemDeviationAddress].ToString();
|
||||
value = readBytArr_X[plcItemDeviationAddress].ToString();
|
||||
if (value != null)
|
||||
{
|
||||
if (item.PlcItemValue != value)
|
||||
{
|
||||
haschange = true;
|
||||
item.PlcItemValue = value;
|
||||
Global.ShowX_Y_Status(item, new EventArgs());
|
||||
Global.ShowSensorStatus(item, new EventArgs());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Random r = new Random();
|
||||
//item.PlcItemValue = r.Next(0, 2) == 0 ? "False" : "True";
|
||||
|
||||
Global.ShowX_Y_Status(item, new EventArgs());
|
||||
Global.ShowSensorStatus(item, new EventArgs());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -767,7 +837,7 @@ namespace CleanMachineHMI
|
||||
#endif
|
||||
}
|
||||
|
||||
public void RefreshPlcItem_Y()
|
||||
public void RefreshPlcItem_Y(ref bool haschange)
|
||||
{
|
||||
#if RELEASE
|
||||
try
|
||||
@@ -781,17 +851,31 @@ namespace CleanMachineHMI
|
||||
{
|
||||
foreach (PlcItem item in PlcItemMd_Y_List)
|
||||
{
|
||||
string value = "";
|
||||
if (!string.IsNullOrEmpty(item.PlcItemDeviationAddress))
|
||||
{
|
||||
string PlcItemId = item.PlcItemId.ToString();
|
||||
string plcdatatype = item.PlcItemDataType.ToString();
|
||||
int plcItemDeviationAddress = Convert.ToInt32(item.PlcItemDeviationAddress);
|
||||
item.PlcItemValue = readBytArr_Y[plcItemDeviationAddress].ToString();
|
||||
value = readBytArr_Y[plcItemDeviationAddress].ToString();
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
if (item.PlcItemValue != value)
|
||||
{
|
||||
haschange=true;
|
||||
item.PlcItemValue = value;
|
||||
Global.ShowX_Y_Status(item, new EventArgs());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Random r = new Random();
|
||||
//item.PlcItemValue = r.Next(0, 2) == 0 ? "False" : "True";
|
||||
|
||||
Global.ShowX_Y_Status(item, new EventArgs());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
1280
CleanMachineHMI/frmIoMonitorNew.Designer.cs
generated
1280
CleanMachineHMI/frmIoMonitorNew.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -126,4 +126,7 @@
|
||||
<metadata name="kryptonPanel4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="kryptonPanel4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -222,7 +222,7 @@ namespace CleanMachineHMI
|
||||
isPlcConnStatus = true;
|
||||
|
||||
Global.SysThIsRunFlag = true;
|
||||
// PlcOperationHelper.Instance.StartRead();
|
||||
PlcOperationHelper.Instance.StartRead();
|
||||
|
||||
|
||||
Thread th = new Thread(RefreshPlcItem)
|
||||
@@ -379,7 +379,7 @@ namespace CleanMachineHMI
|
||||
DataTable dt1 = LeadDbHelperSQLite.Query(sql1).Tables[0];
|
||||
if (dt1 != null && dt1.Rows.Count > 0)
|
||||
{
|
||||
|
||||
|
||||
foreach (DataRow item in dt1.Rows)
|
||||
{
|
||||
Global.CmWarningLogMd_List.Add(new WarningLog
|
||||
@@ -469,10 +469,11 @@ namespace CleanMachineHMI
|
||||
{
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_M();
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_D();
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_X();
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_Y();
|
||||
bool hashchange = false;
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_M(ref hashchange);
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_D(ref hashchange);
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_X(ref hashchange);
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_Y(ref hashchange);
|
||||
ShowWarningMsg();
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@@ -486,7 +487,8 @@ namespace CleanMachineHMI
|
||||
{
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_M();
|
||||
var hashchange = false;
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_M(ref hashchange);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
@@ -494,7 +496,8 @@ namespace CleanMachineHMI
|
||||
{
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_D();
|
||||
var hashchange = false;
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_D(ref hashchange);
|
||||
ShowWarningMsg();
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@@ -503,7 +506,8 @@ namespace CleanMachineHMI
|
||||
{
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_X();
|
||||
var hashchange = false;
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_X(ref hashchange);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
@@ -511,7 +515,8 @@ namespace CleanMachineHMI
|
||||
{
|
||||
while (Global.SysThIsRunFlag)
|
||||
{
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_Y();
|
||||
var hashchange = false;
|
||||
PlcOperationHelper.Instance.RefreshPlcItem_Y(ref hashchange);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user