public void AlarmCheck() { string strValue = ""; int iWordNo = 0; int iBitNo = 0; int iIndex = 0; WorldGeneralLib.PLC.PLCResponse response = 0; response = PLC.GetWordS(strPlcName, strWordStartAddress, strWordEndAddress, ref strValue); if (response == WorldGeneralLib.PLC.PLCResponse.SUCCESS) { //01 C 00000 01 foreach (KeyValuePair <string, AlarmItem> keyValuePair in alarmItemDis) { int iKeyLength = keyValuePair.Value.strMachine.Length; iWordNo = int.Parse(keyValuePair.Key.Substring(iKeyLength + 3, 5)); iBitNo = int.Parse(keyValuePair.Key.Substring(iKeyLength + 8, 2)); //iWordNo = int.Parse(keyValuePair.Key.Substring(3, 5)); //iBitNo = int.Parse(keyValuePair.Key.Substring(8, 2)); iIndex = (iWordNo - iStartAddr) * 16 + iBitNo; if (strValue[iIndex] == '1') { keyValuePair.Value.bCurrentStatus = true; } else { keyValuePair.Value.bCurrentStatus = false; } } foreach (KeyValuePair <string, AlarmItem> keyValuePair in alarmItemDis) { if (keyValuePair.Value.bCurrentStatus != keyValuePair.Value.bPreStatus) { if (keyValuePair.Value.bCurrentStatus) { if (AlarmManageMent.alarmForm != null) { AlarmManageMent.alarmForm.InsertAlarmPLC(keyValuePair.Value.strMachine, keyValuePair.Value.strAlarmMes); //AlarmManageMent.alarmForm.InsertAlarmPLC(keyValuePair.Key, keyValuePair.Value.strAlarmMes); } } else { if (AlarmManageMent.alarmForm != null) { AlarmManageMent.alarmForm.RemoveAlarmPLC(keyValuePair.Value.strMachine); } } } } foreach (KeyValuePair <string, AlarmItem> keyValuePair in alarmItemDis) { keyValuePair.Value.bPreStatus = keyValuePair.Value.bCurrentStatus; } } }
public void UpdateGroupStatus() { string strValue = ""; int iWordNo = 0; int iBitNo = 0; int iIndex = 0; WorldGeneralLib.PLC.PLCResponse response = 0; response = PLC.GetWordS(strPlcName, strWordStartAddress, strWordEndAddress, ref strValue); if (response == WorldGeneralLib.PLC.PLCResponse.SUCCESS) { //01 C 00000 01 HiPerfTimer timeTemp = new HiPerfTimer(); timeTemp.Start(); foreach (KeyValuePair <string, BitButton> keyValuePair in bitCtrlItemDis) { iWordNo = int.Parse(keyValuePair.Key.Substring(3, 5)); iBitNo = int.Parse(keyValuePair.Key.Substring(8, 2)); iIndex = (iWordNo - iStartAddr) * 16 + iBitNo; keyValuePair.Value.m_plcRes = response; if (strValue[iIndex] == '1') { keyValuePair.Value.SetDriverStatus(true); } else { keyValuePair.Value.SetDriverStatus(false); } } foreach (KeyValuePair <string, BitButton> keyValuePair in bitCtrlItemDis) { keyValuePair.Value.FreshDriverStatus(); } double Time = timeTemp.Duration; } else { foreach (KeyValuePair <string, BitButton> keyValuePair in bitCtrlItemDis) { keyValuePair.Value.m_plcRes = response; } foreach (KeyValuePair <string, BitButton> keyValuePair in bitCtrlItemDis) { keyValuePair.Value.FreshDriverStatus(); } } }
public void UpdateGroupStatus() { string strValue = ""; int iWordNo = 0; int iIndex = 0; WorldGeneralLib.PLC.PLCResponse response = 0; response = PLC.GetWordSS(strPlcName, strWordStartAddress, strWordEndAddress, ref strValue); if (response == WorldGeneralLib.PLC.PLCResponse.SUCCESS) { //01 C 00000 01 HiPerfTimer timeTemp = new HiPerfTimer(); timeTemp.Start(); foreach (KeyValuePair <string, DWordTextBox> keyValuePair in wordCtrlItemDis) { iWordNo = int.Parse(keyValuePair.Key.Substring(3, 5)); iIndex = (iWordNo - iStartAddr) * 4; keyValuePair.Value.m_plcRes = response; keyValuePair.Value.SetDriverStatus(strValue.Substring(iIndex, 8)); } foreach (KeyValuePair <string, DWordTextBox> keyValuePair in wordCtrlItemDis) { keyValuePair.Value.FreshDriverStatus(); } double Time = timeTemp.Duration; } else { foreach (KeyValuePair <string, DWordTextBox> keyValuePair in wordCtrlItemDis) { keyValuePair.Value.m_plcRes = response; } foreach (KeyValuePair <string, DWordTextBox> keyValuePair in wordCtrlItemDis) { keyValuePair.Value.FreshDriverStatus(); } } }