/// <summary> /// CIM에서 설비로 발생하는 Event에 대한 처리 /// </summary> /// <param name="parameters">Parameter Array</param> /// <remarks> /// parameters[0] : cmdName /// parameters[1] : 1st parameter /// parameters[2] : 2nd parameter /// parameters[3] : 3rd parameter /// parameters[4] : 4th parameter /// parameters[5] : 5th Parameter /// (string strHOSTPPID, string strEQPPPID, string strTime, string strPPIDRev, string dstrPPIDType) /// </remarks> public void funProcessCIMEvent(object[] parameters) { string dstrWordAddress = "W1210"; string dstrWordData = ""; string dstrBitAddress = ""; StringBuilder dstrLog = new StringBuilder(); string dstrTemp = ""; try { InfoAct.clsEQPPPID CurrentEQPPPID = (InfoAct.clsEQPPPID)parameters[0]; dstrWordData += pEqpAct.funWordWriteString(1, CurrentEQPPPID.EQPPPID, EnuEQP.PLCRWType.Int_Data); dstrWordData += pEqpAct.funWordWriteString(10, "".PadRight(20), EnuEQP.PLCRWType.Hex_Data); dstrWordData += pEqpAct.funWordWriteString(1, "1", EnuEQP.PLCRWType.Int_Data); for (int dintLoop = 0; dintLoop < pInfo.Unit(0).SubUnit(0).PPIDBodyCount; dintLoop++) { if (pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop + 1).Length == 2) { if (CurrentEQPPPID.PPIDBody(dintLoop + 1) == null) { dstrTemp = "0"; } else { dstrTemp = FunStringH.funMakePLCData(FunStringH.funMakeRound(CurrentEQPPPID.PPIDBody(dintLoop + 1).Value, this.pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop + 1).Format)); } dstrWordData += pEqpAct.funWordWriteString(2, dstrTemp, EnuEQP.PLCRWType.Int_Data); } else { if (CurrentEQPPPID.PPIDBody(dintLoop + 1) == null) { dstrTemp = ""; } else { dstrTemp = CurrentEQPPPID.PPIDBody(dintLoop + 1).Value; } dstrWordData += pEqpAct.funWordWriteString(8, dstrTemp.PadRight(16), EnuEQP.PLCRWType.ASCII_Data); } } pEqpAct.funWordWrite(dstrWordAddress, dstrWordData, EnuEQP.PLCRWType.Hex_Data); //PPID 생성지시 dstrBitAddress = "B1032"; pEqpAct.funBitWrite(dstrBitAddress, "1"); if (pInfo.EQP("Main").DummyPLC) { pEqpAct.funWordWrite("W2540", dstrWordData, EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 pEqpAct.funBitWrite("B113A", "1"); } } catch (Exception ex) { pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString()); } }
/// <summary> /// CIM에서 설비로 발생하는 Event에 대한 처리 /// </summary> /// <param name="parameters">Parameter Array</param> /// <remarks> /// parameters[0] : cmdName /// parameters[1] : 1st parameter /// parameters[2] : 2nd parameter /// parameters[3] : 3rd parameter /// parameters[4] : 4th parameter /// parameters[5] : 5th Parameter /// (string strHOSTPPID, string strEQPPPID, string dstrPPIDBody, string dstrPPIDType) /// </remarks> public void funProcessCIMEvent(object[] parameters) { string strHOSTPPID = parameters[0].ToString(); string dstrEQPPPID = parameters[1].ToString(); string dstrPPIDBody = parameters[2].ToString(); string dstrPPIDType = parameters[3].ToString(); string dstrWordData = ""; string dstrValue = " "; string[] dstrData = null; string dstrHOSTPPID = FunStringH.funStringData("", 20); //HOST PPID는 항상 공백으로 써줌(필요없음) int dintPPIDType = 1; //EQP PPID(1) string strWordAddress = "W1210"; string dstrBitAddress = ""; string dstrTemp = ""; try { string[] arrCon = dstrPPIDBody.Split(';'); dstrWordData += pEqpAct.funWordWriteString(1, dstrEQPPPID, EnuEQP.PLCRWType.Int_Data); dstrWordData += pEqpAct.funWordWriteString(10, "".PadRight(20), EnuEQP.PLCRWType.Hex_Data); dstrWordData += pEqpAct.funWordWriteString(1, "1", EnuEQP.PLCRWType.Int_Data); for (int dintLoop = 0; dintLoop < arrCon.Length; dintLoop++) { if (pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop + 1).Length == 2) { dstrTemp = FunStringH.funMakePLCData(FunStringH.funMakeRound(arrCon[dintLoop], this.pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop + 1).Format)); dstrWordData += pEqpAct.funWordWriteString(2, dstrTemp, EnuEQP.PLCRWType.Int_Data); } else { dstrWordData += pEqpAct.funWordWriteString(8, arrCon[dintLoop].PadRight(16), EnuEQP.PLCRWType.ASCII_Data); } } pEqpAct.funWordWrite(strWordAddress, dstrWordData, EnuEQP.PLCRWType.Hex_Data); //EQP PPID Body 수정 dstrBitAddress = "B1034"; pEqpAct.funBitWrite(dstrBitAddress, "1"); if (pInfo.EQP("Main").DummyPLC) { pEqpAct.funWordWrite("W2540", dstrWordData, EnuEQP.PLCRWType.Hex_Data); pEqpAct.funBitWrite("B113B", "1"); } } catch (Exception ex) { pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString()); } }
/// <summary> /// 설비에서 CIM으로 발생하는 Event에 대한 처리 /// </summary> /// <param name="parameters">Parameter Array</param> /// <remarks> /// parameters[0] : strCompBit /// parameters[1] : dstrACTVal /// parameters[2] : dintActFrom /// parameters[3] : dstrACTFromSub /// parameters[4] : intBitVal /// parameters[5] : Special Parameter /// </remarks> public void funProcessEQPEvent(string[] parameters) { string dstrHGLSID = ""; string dstrWordAddress = "W1440"; string dstrBitAddress = ""; bool dbolItemCheck = false; string strAPCEQPPPID = ""; string dstrValue = ""; int APCItemIndex = 0; string JobRecipe = ""; string strWordWriteData = ""; try { #region 임시 dstrHGLSID = "TEST"; dstrWordAddress = "W1440"; dstrBitAddress = "B1018"; for (int dintLoop = 1; dintLoop <= pInfo.Unit(0).SubUnit(0).EQPPPID(strAPCEQPPPID).PPIDBodyCount; dintLoop++) { dbolItemCheck = false; for (int dintLoop2 = 0; dintLoop2 < pInfo.APC(dstrHGLSID).ParameterName.Length; dintLoop2++) { if (pInfo.APC(dstrHGLSID).ParameterName[dintLoop2] == pInfo.Unit(0).SubUnit(0).EQPPPID(strAPCEQPPPID).PPIDBody(dintLoop).Name) { APCItemIndex = dintLoop2; dbolItemCheck = true; break; } } if (dbolItemCheck) { dstrValue = Convert.ToInt32(FunStringH.funMakePLCData(pInfo.APC(dstrHGLSID).ParameterValue[APCItemIndex].ToString())).ToString(); } else { dstrValue = FunStringH.funMakePLCData(pInfo.Unit(0).SubUnit(0).EQPPPID(strAPCEQPPPID).PPIDBody(dintLoop).Value); } //if (pInfo.Unit(0).SubUnit(0).EQPPPID(strAPCEQPPPID).PPIDBody(dintLoop).Length > 1) //{ // pEqpAct.funDoubleWordWrite(dstrWordAddress, dstrValue, EnuEQP.PLCRWType.Int_Data); //} //else //{ // pEqpAct.funWordWrite(dstrWordAddress, dstrValue, EnuEQP.PLCRWType.Int_Data); //} //dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length); if (pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length == 2) { if (dstrValue.Contains("-")) { strWordWriteData = m_pEqpAct.funWordWriteString(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length, dstrValue.ToString(), EnuEQP.PLCRWType.Int_Data); //m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData, EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 } else { strWordWriteData = m_pEqpAct.funWordWriteString(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length, dstrValue.ToString(), EnuEQP.PLCRWType.Int_Data).Substring(4, 4) + m_pEqpAct.funWordWriteString(2, dstrValue.ToString(), EnuEQP.PLCRWType.Int_Data).Substring(0, 4); } m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData.Substring(4, 4), EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, 1); m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData.Substring(0, 4), EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 //m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData, EnuEQP.PLCRWType.Hex_Data); dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length - 1); } else { strWordWriteData = m_pEqpAct.funWordWriteString(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length, dstrValue, EnuEQP.PLCRWType.ASCII_Data); dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length); } } //pEqpAct.funBitWrite(dstrBitAddress, "1"); //pInfo.subSendSF_Set(InfoAct.clsInfo.SFName.S16F111APCStart, dstrHGLSID); #endregion //int dintTest = 124; //for (int dintLoop = 1; dintLoop <= pInfo.Unit(0).SubUnit(0).PPIDBodyCount; dintLoop++) //{ // if (pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length == 2) // { // dintTest -= 1; // if (dintTest < 0) // { // strWordWriteData = m_pEqpAct.funWordWriteString(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length, dintTest.ToString(), EnuEQP.PLCRWType.Int_Data); // //m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData, EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 // } // else // { // strWordWriteData = m_pEqpAct.funWordWriteString(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length, dintTest.ToString(), EnuEQP.PLCRWType.Int_Data).Substring(4, 4) + m_pEqpAct.funWordWriteString(2, dintTest.ToString(), EnuEQP.PLCRWType.Int_Data).Substring(0, 4); // } // m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData.Substring(4, 4), EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 // dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, 1); // m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData.Substring(0, 4), EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 // //m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData, EnuEQP.PLCRWType.Hex_Data); // dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length - 1); // } // else // { // strWordWriteData = m_pEqpAct.funWordWriteString(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length, dintTest.ToString(), EnuEQP.PLCRWType.ASCII_Data); // dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length); // } // //m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData.Substring(4, 4), EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 // //dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, 1); // //m_pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData.Substring(0, 4), EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 // //dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length - 1); //} } catch (Exception ex) { pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString()); } }
/// <summary> /// CIM에서 설비로 발생하는 Event에 대한 처리 /// </summary> /// <param name="parameters">Parameter Array</param> /// <remarks> /// parameters[0] : cmdName /// parameters[1] : 1st parameter /// parameters[2] : 2nd parameter /// parameters[3] : 3rd parameter /// parameters[4] : 4th parameter /// parameters[5] : 5th Parameter /// </remarks> public void funProcessCIMEvent(object[] parameters) { string dstrHGLSID = ""; string dstrWordAddress = ""; string dstrBitAddress = ""; bool dbolItemCheck = false; string strAPCEQPPPID = ""; string dstrValue = ""; int APCItemIndex = 0; string JobRecipe = ""; string strWordWriteData = ""; try { //dstrHGLSID = parameters[0].ToString(); dstrHGLSID = parameters[0].ToString(); //Test dstrWordAddress = "W1440"; dstrBitAddress = "B1018"; strAPCEQPPPID = pInfo.APC(dstrHGLSID).EQPPPID; //if (pInfo.All.GlassUpperJobFlag) //{ // JobRecipe = pInfo.Unit(0).SubUnit(0).MappingEQPPPID(strAPCEQPPPID).UP_EQPPPID; //} //else //{ // JobRecipe = pInfo.Unit(0).SubUnit(0).MappingEQPPPID(strAPCEQPPPID).LOW_EQPPPID; //} for (int dintLoop = 0; dintLoop < 574; dintLoop++) { pEqpAct.funWordWrite(dstrWordAddress, "0", EnuEQP.PLCRWType.Int_Data); dstrWordAddress = CommonAct.FunTypeConversion.funAddressAdd(dstrWordAddress, 1); } dstrWordAddress = "W1440"; for (int dintLoop = 1; dintLoop <= pInfo.Unit(0).SubUnit(0).EQPPPID(strAPCEQPPPID).PPIDBodyCount; dintLoop++) { dbolItemCheck = false; for (int dintLoop2 = 0; dintLoop2 < pInfo.APC(dstrHGLSID).ParameterName.Length; dintLoop2++) { if (pInfo.APC(dstrHGLSID).ParameterName[dintLoop2] == pInfo.Unit(0).SubUnit(0).EQPPPID(strAPCEQPPPID).PPIDBody(dintLoop).Name) { APCItemIndex = dintLoop2; dbolItemCheck = true; break; } } if (dbolItemCheck) { dstrValue = Convert.ToInt32(FunStringH.funMakePLCData(pInfo.APC(dstrHGLSID).ParameterValue[APCItemIndex].ToString())).ToString(); } else { dstrValue = FunStringH.funMakePLCData(pInfo.Unit(0).SubUnit(0).EQPPPID(strAPCEQPPPID).PPIDBody(dintLoop).Value); } //if (pInfo.Unit(0).SubUnit(0).EQPPPID(strAPCEQPPPID).PPIDBody(dintLoop).Length > 1) //{ // pEqpAct.funDoubleWordWrite(dstrWordAddress, dstrValue, EnuEQP.PLCRWType.Int_Data); //} //else //{ // pEqpAct.funWordWrite(dstrWordAddress, dstrValue, EnuEQP.PLCRWType.Int_Data); //} //dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length); if (pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length == 2) { if (dstrValue.Contains("-")) { strWordWriteData = pEqpAct.funWordWriteString(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length, dstrValue, EnuEQP.PLCRWType.Int_Data); } else { strWordWriteData = pEqpAct.funWordWriteString(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length, dstrValue, EnuEQP.PLCRWType.Int_Data).Substring(4, 4) + pEqpAct.funWordWriteString(2, dstrValue, EnuEQP.PLCRWType.Int_Data).Substring(0, 4); } pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData.Substring(4, 4), EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, 1); pEqpAct.funWordWrite(dstrWordAddress, strWordWriteData.Substring(0, 4), EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length - 1); } else { pEqpAct.funWordWrite(dstrWordAddress, dstrValue.PadRight(pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length), EnuEQP.PLCRWType.ASCII_Data); dstrWordAddress = FunTypeConversion.funAddressAdd(dstrWordAddress, pInfo.Unit(0).SubUnit(0).PPIDBody(dintLoop).Length); } } pEqpAct.funWordWrite("W167E", strAPCEQPPPID, EnuEQP.PLCRWType.Int_Data); pEqpAct.funBitWrite(dstrBitAddress, "1"); //pInfo.subSendSF_Set(InfoAct.clsInfo.SFName.S16F111APCStart, dstrHGLSID); } catch (Exception ex) { pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString()); } }
/// <summary> /// CIM에서 설비로 발생하는 Event에 대한 처리 /// </summary> /// <param name="parameters">Parameter Array</param> /// <remarks> /// parameters[0] : cmdName /// parameters[1] : 1st parameter /// parameters[2] : 2nd parameter /// parameters[3] : 3rd parameter /// parameters[4] : 4th parameter /// parameters[5] : 5th Parameter /// </remarks> public void funProcessCIMEvent(object[] parameters) { string dstrWordAddress = ""; string dstrWordData = ""; string dstrBitAddress = "B1020"; string[] dstrValue; string dstrECID = FunStringH.funMakeLengthStringFirst("0", 48); int dintECID = 0; int dintIndex = 0; string strConvertData = ""; try { if (pInfo.All.ECIDChange.Count > 0) { for (int dintLoop = 1; dintLoop <= pInfo.Unit(0).SubUnit(0).ECIDCount; dintLoop++) { dintIndex = pInfo.All.ECIDChange.IndexOfKey(dintLoop); //Key 값을 가지고 SortedList의 Index값을 가져온다. if (pInfo.All.ECIDChange.ContainsKey(dintLoop)) { dintECID = Convert.ToInt32(pInfo.All.ECIDChange.GetKey(dintIndex)); //Index값을 가지고 Key값을 알아온다, dstrValue = pInfo.All.ECIDChange.GetByIndex(dintIndex).ToString().Split(new char[] { ',' }); //Index값을 가지고 value값을 알아온다. //Word영역에 변경할 ECID를 Write한다. dstrWordData += pEqpAct.funWordWriteString(1, dintECID.ToString(), EnuEQP.PLCRWType.Int_Data); //dstrWordData += pEqpAct.funWordWriteString(2, dstrValue[0], EnuEQP.PLCRWType.Int_Data); if (!dstrValue[1].Contains("-")) { dstrWordData += pEqpAct.funWordWriteString(2, dstrValue[1], EnuEQP.PLCRWType.Int_Data); } else { strConvertData = pEqpAct.funWordWriteString(2, dstrValue[1], EnuEQP.PLCRWType.Int_Data); dstrWordData += strConvertData.Substring(4, 4) + strConvertData.Substring(0, 4); } if (!dstrValue[2].Contains("-")) { dstrWordData += pEqpAct.funWordWriteString(2, dstrValue[2], EnuEQP.PLCRWType.Int_Data); } else { strConvertData = pEqpAct.funWordWriteString(2, dstrValue[2], EnuEQP.PLCRWType.Int_Data); dstrWordData += strConvertData.Substring(4, 4) + strConvertData.Substring(0, 4); } if (!dstrValue[3].Contains("-")) { dstrWordData += pEqpAct.funWordWriteString(2, dstrValue[3], EnuEQP.PLCRWType.Int_Data); } else { strConvertData = pEqpAct.funWordWriteString(2, dstrValue[2], EnuEQP.PLCRWType.Int_Data); dstrWordData += strConvertData.Substring(4, 4) + strConvertData.Substring(0, 4); } //dstrWordData += pEqpAct.funWordWriteString(2, dstrValue[4], EnuEQP.PLCRWType.Int_Data); } else { clsECID CurrentECID = pInfo.Unit(0).SubUnit(0).ECID(dintLoop); dstrWordData += pEqpAct.funWordWriteString(1, CurrentECID.Index.ToString(), EnuEQP.PLCRWType.Int_Data); //dstrWordData += pEqpAct.funWordWriteString(2, FunStringH.funMakePLCData(FunStringH.funMakeRound(CurrentECID.ECSLL, CurrentECID.Format)), EnuEQP.PLCRWType.Int_Data); if (!CurrentECID.ECWLL.Contains("-")) { dstrWordData += pEqpAct.funWordWriteString(2, FunStringH.funMakePLCData(FunStringH.funMakeRound(CurrentECID.ECWLL, CurrentECID.Format)), EnuEQP.PLCRWType.Int_Data); } else { strConvertData = pEqpAct.funWordWriteString(2, FunStringH.funMakePLCData(FunStringH.funMakeRound(CurrentECID.ECWLL, CurrentECID.Format)), EnuEQP.PLCRWType.Int_Data); dstrWordData += strConvertData.Substring(4, 4) + strConvertData.Substring(0, 4); } if (!CurrentECID.ECDEF.Contains("-")) { dstrWordData += pEqpAct.funWordWriteString(2, FunStringH.funMakePLCData(FunStringH.funMakeRound(CurrentECID.ECDEF, CurrentECID.Format)), EnuEQP.PLCRWType.Int_Data); } else { strConvertData = pEqpAct.funWordWriteString(2, FunStringH.funMakePLCData(FunStringH.funMakeRound(CurrentECID.ECDEF, CurrentECID.Format)), EnuEQP.PLCRWType.Int_Data); dstrWordData += strConvertData.Substring(4, 4) + strConvertData.Substring(0, 4); } if (!CurrentECID.ECWUL.Contains("-")) { dstrWordData += pEqpAct.funWordWriteString(2, FunStringH.funMakePLCData(FunStringH.funMakeRound(CurrentECID.ECWUL, CurrentECID.Format)), EnuEQP.PLCRWType.Int_Data); } else { strConvertData = pEqpAct.funWordWriteString(2, FunStringH.funMakePLCData(FunStringH.funMakeRound(CurrentECID.ECWUL, CurrentECID.Format)), EnuEQP.PLCRWType.Int_Data); dstrWordData += strConvertData.Substring(4, 4) + strConvertData.Substring(0, 4); } } } //변경할 ECID 값을 써준다. dstrWordAddress = "W16C0"; pEqpAct.funWordWrite(dstrWordAddress, dstrWordData, EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 ////ECID 변경 지시를 내린다. pEqpAct.funBitWrite(dstrBitAddress, "1"); //if (pInfo.EQP("Main").DummyPLC) //{ //pEqpAct.funWordWrite("W2A00", dstrWordData, EnuEQP.PLCRWType.Hex_Data); //변경할 ECID 데이터 //pEqpAct.funBitWrite("B1121", "1"); //} } } catch (Exception ex) { pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString()); } }
public void Save() { bool dbolError = false; float fMIN = 0; float fECSLL = 0; float fECDEF = 0; float fECSUL = 0; float fMax = 0; int dintECID = 0; BindingSource pEOIDListSource = new BindingSource(); string arrECID = ""; string dstrSQL = ""; try { File.Copy(Application.StartupPath + @"\system\System.mdb", Application.StartupPath + @"\system\System.mdb.bak", true); try { //유효성검사 for (int dintLoop = 0; dintLoop < this.dataGridView1.RowCount; dintLoop++) { dintECID = Convert.ToInt32(this.dataGridView1.Rows[dintLoop].Cells[0].Value); fMIN = Convert.ToSingle(dataGridView1[2, dintLoop].Value.ToString()); fECSLL = Convert.ToSingle(dataGridView1[4, dintLoop].Value.ToString()); fECDEF = Convert.ToSingle(dataGridView1[5, dintLoop].Value.ToString()); fECSUL = Convert.ToSingle(dataGridView1[6, dintLoop].Value.ToString()); fMax = Convert.ToSingle(dataGridView1[8, dintLoop].Value.ToString()); if (fMIN > fECSLL || fECSLL > fECDEF || fECDEF > fECSUL || fECSUL > fMax) { dbolError = true; MessageBox.Show("올바르지 않는 Data가 있습니다!!"); break; } //if (dbolError == true) //{ // string dstrErrorMsg = this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).Name + " 의 값은 " + this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECSLL // + "~" + this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECSUL + " 이어야 합니다."; // MessageBox.Show(dstrErrorMsg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} } if (dbolError == false) { pInfo.All.ECIDChange.Clear(); pInfo.All.ECIDChangeFromHost = ""; pInfo.All.ECIDChangeHOSTReport.Clear(); //바뀐 EOV 값이 있는지 검사한다. for (int dintLoop = 0; dintLoop < this.dataGridView1.RowCount; dintLoop++) { dintECID = Convert.ToInt32(this.dataGridView1.Rows[dintLoop].Cells[0].Value); fMIN = Convert.ToSingle(dataGridView1[2, dintLoop].Value.ToString()); fECSLL = Convert.ToSingle(dataGridView1[4, dintLoop].Value.ToString()); fECDEF = Convert.ToSingle(dataGridView1[5, dintLoop].Value.ToString()); fECSUL = Convert.ToSingle(dataGridView1[6, dintLoop].Value.ToString()); fMax = Convert.ToSingle(dataGridView1[8, dintLoop].Value.ToString()); clsECID CurrentECID = pInfo.Unit(0).SubUnit(0).ECID(dintECID); if (Convert.ToSingle(CurrentECID.ECWLL) != fECSLL ||Convert.ToSingle( CurrentECID.ECDEF )!= fECDEF || Convert.ToSingle(CurrentECID.ECWUL) != fECSUL) { this.pInfo.All.ECIDChange.Add(dintECID, FunStringH.funMakePLCData(FunStringH.funMakeRound(fMIN.ToString(), CurrentECID.Format)) + "," + FunStringH.funMakePLCData(FunStringH.funMakeRound(fECSLL.ToString(), CurrentECID.Format)) + "," + FunStringH.funMakePLCData(FunStringH.funMakeRound(fECDEF.ToString(), CurrentECID.Format)) + "," + FunStringH.funMakePLCData(FunStringH.funMakeRound(fECSUL.ToString(), CurrentECID.Format)) + "," + FunStringH.funMakePLCData(FunStringH.funMakeRound(fMax.ToString(), CurrentECID.Format))); this.pInfo.All.ECIDChangeFromHost += dintECID + ";"; this.pInfo.All.ECIDChangeHOSTReport.Add(dintECID, fMIN + "," + fECSLL + "," + fECDEF + "," + fECSUL + "," + fMax); } } if (string.IsNullOrEmpty(pInfo.All.ECIDChangeFromHost)) { MessageBox.Show("변경된 ECID가 존재하지 않습니다."); pInfo.All.ECIDChange.Clear(); pInfo.All.ECIDChangeFromHost = ""; pInfo.All.ECIDChangeHOSTReport.Clear(); return; } else { pInfo.All.ECIDChangeBYWHO = "2"; //arrECID = arrECID.Substring(0, arrECID.Length - 1); pInfo.subPLCCommand_Set(clsInfo.PLCCommand.ECIDChange); MessageBox.Show("PLC에 ECID 변경 요청을 하였습니다."); } } //if (!DBAct.clsDBAct.funBeginTransaction()) //{ // MessageBox.Show("DB Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} ////DataAdapter 생성 //OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM tbECID order by ECID", DBAct.clsDBAct.funOleDbConnect()); //OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter); ////DataAdapter를 이용하여 DB로 업데이트를 한다. //dataAdapter.SelectCommand.Transaction = DBAct.clsDBAct.funOleDbTransaction(); //dataAdapter.Update((DataTable)pEOIDListSource.DataSource); //if (!DBAct.clsDBAct.funCommitTransaction()) //{ // MessageBox.Show("DB Commit Transaction NG!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); // DBAct.clsDBAct.funRollbackTransaction(); // return; //} //dstrSQL = "SELECT * FROM tbECID order by ECID"; //pInfo.Unit(0).SubUnit(0).RemoveECID(); //DataTable dt = DBAct.clsDBAct.funSelectQuery(dstrSQL); //pInfo.AddDataTable("ECID", dt); //pInfo.AddViewEvent(InfoAct.clsInfo.ViewEvent.ECIDUpdate); } catch (Exception ex) { pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString()); DBAct.clsDBAct.funRollbackTransaction(); DBAct.clsDBAct.funDisconnect(); // DB 연결을 끊는다. MessageBox.Show("DB Update Fail, Because DB Process Error!", "DB Update Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ////if (this.pEditMode) subSaveECList(); ////else subSaveECValue(); } catch (Exception ex) { pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString()); } }
/// <summary> /// Primary Message에 대해 처리한 후 Secondary Message를 Biuld하여 Driver에 전송한다. /// </summary> /// <param name="msgTran">Primary Message의 Transaction</param> public void funPrimaryReceive(Transaction msgTran) { string dstrModuleID = ""; int dintECIDCount = 0; int dintECID = 0; string dstrECName = ""; Boolean dbolFail = false; bool dbolECNameFail = false; bool dbolECIDFail = false; int dintFailCount = 0; //int dintECSLL = 0; //int dintECWLL = 0; //int dintECDEF = 0; //int dintECWUL = 0; //int dintECSUL = 0; float dintECSLL = 0; float dintECWLL = 0; float dintECDEF = 0; float dintECWUL = 0; float dintECSUL = 0; int dintEAC = 0; int dintEACName = 0; int dintEACECID = 0; int dintTEAC = 0; int dintEAC_SLL = 0; int dintEAC_WLL = 0; int dintEAC_DEF = 0; int dintEAC_WUL = 0; int dintEAC_SUL = 0; bool dbolErrorCheck = true; Boolean dbolLayerExist = false; Queue dqECID = new Queue(); try { dstrModuleID = msgTran.Primary().Item("MODULEID").Getvalue().ToString().Trim(); //for (int dintUnit = 0; dintUnit <= this.pInfo.UnitCount; dintUnit++) //{ if (dstrModuleID == pInfo.Unit(3).SubUnit(0).ModuleID) { dbolLayerExist = true; //break; } //} //ModuleID가 존재하지 않는 경우 if (dbolLayerExist == false) { msgTran.Secondary().Item("MODULEID").Putvalue(dstrModuleID); msgTran.Secondary().Item("MIACK").Putvalue(1); //1 : There is no such a MOUDLEID msgTran.Secondary().Item("ECCOUNT").Putvalue(0); funSendReply(msgTran); return; } msgTran.Secondary().Item("MODULEID").Putvalue(dstrModuleID); msgTran.Secondary().Item("MIACK").Putvalue(0); dintECIDCount = Convert.ToInt32(msgTran.Primary().Item("ECCOUNT").Getvalue()); msgTran.Secondary().Item("ECCOUNT").Putvalue(dintECIDCount); //받은 ECID중에 존재하지 않는것이 하나라도 있으면 NAK으로 보고하고 PLC에 모두 적용하지 않는다. for (int dintLoop = 1; dintLoop <= dintECIDCount; dintLoop++) { dintECID = Convert.ToInt32(msgTran.Primary().Item("ECID" + (dintLoop - 1)).Getvalue()); dstrECName = msgTran.Primary().Item("ECNAME" + (dintLoop - 1)).Getvalue().ToString().Trim(); //존재하지 않는 ECID가 왔을때 if (pInfo.Unit(0).SubUnit(0).ECID(dintECID) == null) { dbolECIDFail = true; } else { if (dstrECName != this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).Name) //존재하지 않는 ECID가 왔을때 { dbolECNameFail = true; } else if (this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).ModuleID.Contains(dstrModuleID) == false) { dbolFail = true; } else { string dstrFormat = this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).Format; dintECSLL = Convert.ToSingle(FunStringH.funMakeRound(msgTran.Primary().Item("ECSLL" + (dintLoop - 1)).Getvalue().ToString().Trim(), dstrFormat)); dintECWLL = Convert.ToSingle(FunStringH.funMakeRound(msgTran.Primary().Item("ECWLL" + (dintLoop - 1)).Getvalue().ToString().Trim(), dstrFormat)); dintECDEF = Convert.ToSingle(FunStringH.funMakeRound(msgTran.Primary().Item("ECDEF" + (dintLoop - 1)).Getvalue().ToString().Trim(), dstrFormat)); dintECWUL = Convert.ToSingle(FunStringH.funMakeRound(msgTran.Primary().Item("ECWUL" + (dintLoop - 1)).Getvalue().ToString().Trim(), dstrFormat)); dintECSUL = Convert.ToSingle(FunStringH.funMakeRound(msgTran.Primary().Item("ECSUL" + (dintLoop - 1)).Getvalue().ToString().Trim(), dstrFormat)); Single dSingleMin = Convert.ToSingle(this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).Min); Single dSingleMax = Convert.ToSingle(this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).Max); if (Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECSLL) != dintECSLL) { dbolFail = true; dintEAC_SLL = 2; } else if (Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECSUL) != dintECSUL) { dbolFail = true; dintEAC_SUL = 2; } else #region Min & Max 값 확인 if ((dintECDEF < dSingleMin) || (dintECDEF > dSingleMax)) { dbolFail = true; dintEAC_DEF = 2; } else if ((dintECSUL < dSingleMin) || (dintECSUL > dSingleMax)) { dbolFail = true; dintEAC_SUL = 2; } else if ((dintECSLL < dSingleMin) || (dintECSLL > dSingleMax)) { dbolFail = true; dintEAC_SLL = 2; } else if ((dintECWUL < dSingleMin) || (dintECWUL > dSingleMax)) { dbolFail = true; dintEAC_WUL = 2; } else if ((dintECWLL < dSingleMin) || (dintECWLL > dSingleMax)) { dbolFail = true; dintEAC_WLL = 2; } //if ((dintECWUL < dSingleMin) || (dintECWUL > dSingleMax)) //{ // dbolFail = true; // dintEAC_WUL = 2; //} //if ((dintECWLL < dSingleMin) || (dintECWLL > dSingleMax)) //{ // dbolFail = true; // dintEAC_WLL = 2; //} #endregion if (!dbolFail) { dbolErrorCheck = false; // 각 항목별 Data 확인 if (dintECSUL >= dintECWUL && dintECSUL >= dintECDEF && dintECSUL >= dintECWLL && dintECSUL >= dintECSLL) { if (dintECWUL >= dintECDEF && dintECWUL >= dintECWLL && dintECWLL >= dintECSLL) { if (dintECDEF >= dintECWLL && dintECDEF >= dintECSLL) { if (dintECWLL < dintECSLL) { dbolFail = true; dintEAC_WLL = 2; } else { dqECID.Enqueue(dintECID); //Update를 위해 Queue에 저장 } } else { if (!(dintECDEF > dintECWLL)) { dintEAC_DEF = 2; dintEAC_WLL = 2; } else { dintEAC_DEF = 2; dintEAC_SLL = 2; } dbolFail = true; //dintEAC_DEF = 2; } } else { if (!(dintECWUL > dintECDEF)) { dintEAC_WUL = 2; dintEAC_DEF = 2; } else if (!(dintECWUL > dintECWLL)) { dintEAC_WUL = 2; dintEAC_WLL = 2; } else { dintEAC_WUL = 2; dintEAC_SLL = 2; } dbolFail = true; //dintEAC_DEF = 2; } } else { if (!(dintECSUL > dintECWUL)) { dintEAC_SUL = 2; dintEAC_WUL = 2; } else if (!(dintECSUL > dintECDEF)) { dintEAC_SUL = 2; dintEAC_DEF = 2; } else if (!(dintECSUL > dintECWLL)) { dintEAC_SUL = 2; dintEAC_WLL = 2; } else { dintEAC_SUL = 2; dintEAC_SLL = 2; } dbolFail = true; //dintEAC_DEF = 2; } } } } if (dbolFail == true) //Validation 체크 에러 { dintFailCount = dintFailCount + 1; //각 항목별로 Fail이 났을때 1씩 증가 dintEAC = 2; if (dbolErrorCheck == false) { if (Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECSLL) != dintECSLL) { dintEAC_SLL = 2; } else if (Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECSUL) != dintECSUL) { dintEAC_SUL = 2; } else { //dintEAC_SLL = 0; //dintEAC_WLL = 0; //dintEAC_DEF = 0; //dintEAC_SUL = 0; //dintEAC_WUL = 0; //WLL 확인 if (!(Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECSLL) <= dintECWLL && dintECWLL <= Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECDEF))) { dintEAC_WLL = 2; dintEAC_SLL = 0; //dintEAC_WLL = 0; dintEAC_DEF = 0; dintEAC_SUL = 0; dintEAC_WUL = 0; } else { if (!(Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECWLL) <= dintECDEF && dintECDEF <= Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECWUL))) { dintEAC_DEF = 2; dintEAC_SLL = 0; dintEAC_WLL = 0; //dintEAC_DEF = 0; dintEAC_SUL = 0; dintEAC_WUL = 0; } else { if (!(Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECDEF) <= dintECWUL && dintECWUL <= Convert.ToSingle(pInfo.Unit(0).SubUnit(0).ECID(dintECID).ECSUL))) { dintEAC_WUL = 2; dintEAC_SLL = 0; dintEAC_WLL = 0; dintEAC_DEF = 0; dintEAC_SUL = 0; //dintEAC_WUL = 0; } else { int a = 0; } } } } } } else { dintEAC = 0; } if (dbolECIDFail == true) { dintEACECID = 2; } else { dintEACECID = 0; } if (dbolECNameFail == true) { dintEACName = 2; } else { dintEACName = 0; } if (dbolFail || dbolECIDFail || dbolECNameFail) { dintTEAC = 1; } else { dintTEAC = 0; } dbolFail = false; dbolECIDFail = false; dbolECNameFail = false; msgTran.Secondary().Item("TEAC" + (dintLoop - 1)).Putvalue(dintTEAC); msgTran.Secondary().Item("ECID" + (dintLoop - 1)).Putvalue(dintECID); msgTran.Secondary().Item("EAC1" + (dintLoop - 1)).Putvalue(dintEACECID); msgTran.Secondary().Item("ECNAME" + (dintLoop - 1)).Putvalue(dstrECName); msgTran.Secondary().Item("EAC2" + (dintLoop - 1)).Putvalue(dintEACName); msgTran.Secondary().Item("ECDEF" + (dintLoop - 1)).Putvalue(dintECDEF); msgTran.Secondary().Item("EAC3" + (dintLoop - 1)).Putvalue(dintEAC_DEF); msgTran.Secondary().Item("ECSLL" + (dintLoop - 1)).Putvalue(dintECSLL); msgTran.Secondary().Item("EAC4" + (dintLoop - 1)).Putvalue(dintEAC_SLL); msgTran.Secondary().Item("ECSUL" + (dintLoop - 1)).Putvalue(dintECSUL); msgTran.Secondary().Item("EAC5" + (dintLoop - 1)).Putvalue(dintEAC_SUL); msgTran.Secondary().Item("ECWLL" + (dintLoop - 1)).Putvalue(dintECWLL); msgTran.Secondary().Item("EAC6" + (dintLoop - 1)).Putvalue(dintEAC_WLL); msgTran.Secondary().Item("ECWUL" + (dintLoop - 1)).Putvalue(dintECWUL); msgTran.Secondary().Item("EAC7" + (dintLoop - 1)).Putvalue(dintEAC_WUL); dintEAC_SLL = 0; dintEAC_WLL = 0; dintEAC_DEF = 0; dintEAC_WUL = 0; dintEAC_SUL = 0; } //HOST로 S2F16 보고 funSendReply(msgTran); if (dintFailCount > 0) { //Error가 발생한것임. dqECID.Clear(); return; } ////NACK값이 하나라도 존재하면 PLC에 적용하지 않느다. ////2011.01.13 송은선 //if (dintEAC != 0 && dintTEAC != 0) //{ // dqECID.Clear(); // return; //} //카운트가 0이상이면 맞는게 있음 if (dqECID.Count > 0) { this.pInfo.All.ECIDChangeBYWHO = "1"; //BY HOST this.pInfo.All.ECIDChange.Clear(); //초기화 this.pInfo.All.ECIDChangeHOSTReport.Clear(); //초기화 this.pInfo.All.ECIDChangeFromHost = ""; string dstrECSLL = string.Empty; string dstrECWLL = string.Empty; string dstrECDEF = string.Empty; string dstrECWUL = string.Empty; string dstrECSUL = string.Empty; //PLC에 Write할 ECID를 저장한다. for (int dintLoop = 1; dintLoop <= dintECIDCount; dintLoop++) { dintECID = Convert.ToInt32(msgTran.Primary().Item("ECID" + (dintLoop - 1)).Getvalue()); if (dqECID.Contains(dintECID) == true) { string dstrFormat = this.pInfo.Unit(0).SubUnit(0).ECID(dintECID).Format; dstrECSLL = FunStringH.funMakePLCData(FunStringH.funMakeRound(msgTran.Primary().Item("ECSLL" + (dintLoop - 1)).Getvalue().ToString(), dstrFormat)); dstrECWLL = FunStringH.funMakePLCData(FunStringH.funMakeRound(msgTran.Primary().Item("ECWLL" + (dintLoop - 1)).Getvalue().ToString(), dstrFormat)); dstrECDEF = FunStringH.funMakePLCData(FunStringH.funMakeRound(msgTran.Primary().Item("ECDEF" + (dintLoop - 1)).Getvalue().ToString(), dstrFormat)); dstrECWUL = FunStringH.funMakePLCData(FunStringH.funMakeRound(msgTran.Primary().Item("ECWUL" + (dintLoop - 1)).Getvalue().ToString(), dstrFormat)); dstrECSUL = FunStringH.funMakePLCData(FunStringH.funMakeRound(msgTran.Primary().Item("ECSUL" + (dintLoop - 1)).Getvalue().ToString(), dstrFormat)); this.pInfo.All.ECIDChange.Add(dintECID, dstrECSLL + "," + dstrECWLL + "," + dstrECDEF + "," + dstrECWUL + "," + dstrECSUL); this.pInfo.All.ECIDChangeFromHost += dintECID + ";"; this.pInfo.All.ECIDChangeHOSTReport.Add(dintECID, dstrECSLL + "," + dstrECWLL + "," + dstrECDEF + "," + dstrECWUL + "," + dstrECSUL); } } //HOST에서 받은것외에 없는 항목은 CIM이 가지고 있는 Data를 써준다. //변경할 ECID만 써주는게 아니고 모든 ECID를 써주기 때문임 for (int dintLoop = 1; dintLoop <= this.pInfo.Unit(0).SubUnit(0).ECIDCount; dintLoop++) { if (this.pInfo.All.ECIDChange.ContainsKey(dintLoop) == true) { } else { InfoAct.clsECID pECID = pInfo.Unit(0).SubUnit(0).ECID(dintLoop); this.pInfo.All.ECIDChange.Add(dintLoop, FunStringH.funMakePLCData(FunStringH.funMakeRound(pECID.ECSLL, pECID.Format)) + "," + FunStringH.funMakePLCData(FunStringH.funMakeRound(pECID.ECWLL, pECID.Format)) + "," + FunStringH.funMakePLCData(FunStringH.funMakeRound(pECID.ECDEF, pECID.Format)) + "," + FunStringH.funMakePLCData(FunStringH.funMakeRound(pECID.ECWUL, pECID.Format)) + "," + FunStringH.funMakePLCData(FunStringH.funMakeRound(pECID.ECSUL, pECID.Format))); } } //PLC로 ECID 변경 Write this.pInfo.subPLCCommand_Set(InfoAct.clsInfo.PLCCommand.ECIDChange); } } catch (Exception error) { funSetLog(InfoAct.clsInfo.LogType.CIM, error.ToString()); return; } }