protected override int InnerExecute() { string recipeId = "A10"; //10 string recipeVersionNo = ""; int CCODE = CCODE_CRE; // 1 string account = "ABCDEFGHIJK"; //5 //List<string> Param_Data = new List<string>(); List <int> Param_Data_List = new List <int>(); if (this.IsManualExecute) { recipeId = this.ProgramDataList[0].Value.ToString(); CCODE = int.Parse(ProgramDataList[1].Value.ToString()); account = this.ProgramDataList[2].Value.ToString(); Log(string.Format("{0}\t{1}", _component.ControlName, string.Format("PGM DATA SEND MANUAL"))); } else { string value = VI_RECIPE_CHANGE_REPORT.Value; string[] temp = value.Split('|'); int ParmCount = 0; if (temp != null && temp.Length == 3) { switch (temp[1].Trim())//C,M,D { case "1": CCODE = CCODE_CRE; break; case "2": CCODE = CCODE_MOD; break; case "3": CCODE = CCODE_DEL; break; } string[] data2 = temp[2].Split(','); recipeId = data2[0].Trim(); recipeVersionNo = data2[2].Trim(); ParmCount = int.Parse(data2[3]); List <CRecipeDataProperties> tempParameterList = _main.GetRecipeParameterData(); if (ParmCount != data2.Length - 4) { return(-1); } if (ParmCount != 0) { for (int i = 4; i < data2.Length; i++) { //Param_Data.Add(data2[i]); foreach (CRecipeDataProperties item in tempParameterList) { if (item.ParameterNo == (i - 3).ToString()) { item.ParameterValue = (data2[i]); break; } } } } if (ParmCount < tempParameterList.Count) { for (int i = ParmCount + 1; i <= tempParameterList.Count; i++) { //Param_Data.Add(data2[i]); foreach (CRecipeDataProperties item in tempParameterList) { if (item.ParameterNo == i.ToString()) { item.ParameterValue = ""; break; } } } } //else if(ParmCount ==0) //{ // for (int i = 0; i < 50; i++) // { // Param_Data.Add("0"); // } //} //if (Param_Data.Count < 50) //{ // while (Param_Data.Count < 50) // { // Param_Data.Add("0"); // } //} //OW_RECIPE_CHANGE_REPORT_ITEMS.Length Param_Data_List = CRecipeDataProperties.ConvertPLCDataList(tempParameterList); } else { throw new ArgumentException(); } account = _main.SystemConfig.UserAccount; } //List<string> dataList = new List<string>(); //dataList.Add("RECIPE_REQUEST"); //dataList.Add(recipeId); //_main.SendData(dataList); //while (true) //{ // if (_component.vi_recipe_request_reply) // { // _component.vi_recipe_request_reply = false; // break; // } // Thread.Sleep(50); //} _main.MelsecNetMultiWordWriteByString(OW_RECIPE_CHANGE_REPORT_RECIPE_ID, recipeId, 10, ' '); _main.MelsecNetWordWrite(OW_RECIPE_CHANGE_REPORT_RECIPE_CCODE, CCODE); _main.MelsecNetMultiWordWriteByString(OW_RECIPE_CHANGE_REPORT_USER_ACCOUNT, account, 5, ' '); CRecipeItems recipeItems = new CRecipeItems(); //string[] temp_Parm = VI_RECIPE_REQUEST_REPLY.Value.Split('|'); //if (temp_Parm != null && temp_Parm.Length == 3) //{ // string[] Parm_Value = temp_Parm[2].Split(','); // if (Parm_Value != null && Parm_Value.Length > 0) // { // //recipeItems.FL_GROUP_NUM = Parm_Value[0]; // //recipeItems.FR_GROUP_NUM = Parm_Value[1]; // //recipeItems.RL_GROUP_NUM = Parm_Value[2]; // //recipeItems.RR_GROUP_NUM = Parm_Value[3]; // //recipeItems.SUBSITE_NUM = Parm_Value[4]; // Param_Data = Parm_Value; // } //} //List<int> items = recipeItems.GetIntList(Param_Data); //134개 _main.MelsecNetMultiWordWrite(OW_RECIPE_CHANGE_REPORT_ITEMS, Param_Data_List); Log(string.Format("{0}\t{1}", _component.ControlName, string.Format("PGM DATA SEND - RECIPEID={0} CCODE={1} ACCOUNT={2}", recipeId, CCODE, account))); Log(string.Format("{0}\t{1}", _component.ControlName, "PGM DATA DISPLAY")); CTimeout timeout = CTimeoutManager.GetTimeout(_controlName, T1); timeout.TargetOffValueCheck = true; timeout.Begin(OB_RECIPE_CHANGE_REPORT, _main.CONTROLATTRIBUTES.GetProperty(IB_RECIPE_CHANGE_REPORT.ControlName, IB_RECIPE_CHANGE_REPORT.AttributeName) as ITimeoutResource); _main.MelsecNetBitOnOff(OB_RECIPE_CHANGE_REPORT, true); Thread.Sleep(1000); IB_RECIPE_CHANGE_REPORT.Value = true.ToString(); string tempMsg = ""; bool error = false; if (CTimeout.WaitSync(timeout, 10)) { return(0); } else { error = true; _main.MelsecNetBitOnOff(OB_RECIPE_CHANGE_REPORT, false); tempMsg = string.Format("RECIPE CHANGE TIMEOUT No response [timeout T1={0} sec]", T1 / 1000); Log(string.Format("{0}\t{1}", _component.ControlName, "PGM DATA " + tempMsg)); //tempMsg = string.Format("[{0}] Recipe Change Authorization Failure! No response [timeout T1={1} sec]", account.Trim(), T1 / 1000); } if (!error) { return(0); } Log(string.Format("{0}\t{1}", _component.ControlName, "PGM DATA DISPLAY")); #region 메시지 창 표시 string receivedTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); string msgId = "0"; string message = string.Format("[{0}] {1}", this.Name, tempMsg); string panelNo = "1"; CSubject subject = CUIManager.Inst.GetData("CIMMessage"); subject.SetValue("List", new List <string>() { "MESSAGE_SET", msgId, receivedTime, message, panelNo }); subject.Notify(); #endregion return(0); }
protected override int InnerExecute() { List <int> Param_Data_List = new List <int>(); string recipeTemp = ""; if (IsManualExecute) { recipeTemp = this.ProgramDataList[0].Value.ToString(); } else { recipeTemp = _main.MelsecNetMultiWordReadToString(IW_RECIPE_REQUEST_RECIPE_ID); } Log(string.Format("{0}\t{1}", _component.ControlName, string.Format("PGM DATA RECV - RECIPEID={0}", recipeTemp))); string tempMsg = ""; tempMsg = string.Format("NO REGISTERED RECIPEID={0}", recipeTemp.Trim()); Log(string.Format("{0}\t{1}", _component.ControlName, "PGM DATA " + tempMsg)); List <string> dataList = new List <string>(); dataList.Add("RECIPE_REQUEST"); dataList.Add(recipeTemp); _main.SendData(dataList); while (true) { if (_component.vi_recipe_request_reply) { _component.vi_recipe_request_reply = false; break; } Thread.Sleep(50); } bool error = true; //CRecipeItems recipeItems = new CRecipeItems(); string[] temp_Parm = VI_RECIPE_REQUEST_REPLY.Value.Split('|'); //string[] Param_Data = null; List <CRecipeDataProperties> tempParameterList = _main.GetRecipeParameterData(); if (temp_Parm != null && temp_Parm.Length == 3) { int ParmCount = int.Parse(temp_Parm[1]); string[] Parm_Value = temp_Parm[2].Split(','); if (ParmCount != Parm_Value.Length) { return(-1); } if (ParmCount != 0) { for (int i = 0; i < Parm_Value.Length; i++) { foreach (CRecipeDataProperties item in tempParameterList) { if (item.ParameterNo == (i + 1).ToString()) { item.ParameterValue = (Parm_Value[i]); break; } } } } if (ParmCount < tempParameterList.Count) { for (int i = ParmCount + 1; i <= tempParameterList.Count; i++) { //Param_Data.Add(data2[i]); foreach (CRecipeDataProperties item in tempParameterList) { if (item.ParameterNo == i.ToString()) { item.ParameterValue = ""; break; } } } } //if (Parm_Value != null && Parm_Value.Length > 0) //{ // //recipeItems.FL_GROUP_NUM = Parm_Value[0]; // //recipeItems.FR_GROUP_NUM = Parm_Value[1]; // //recipeItems.RL_GROUP_NUM = Parm_Value[2]; // //recipeItems.RR_GROUP_NUM = Parm_Value[3]; // //recipeItems.SUBSITE_NUM = Parm_Value[4]; // Param_Data = Parm_Value; //} Param_Data_List = CRecipeDataProperties.ConvertPLCDataList(tempParameterList); } //List<int> items = recipeItems.GetIntList(Param_Data); _main.MelsecNetMultiWordWrite(OW_RECIPE_REQUEST_RECIPE_PARAMS, Param_Data_List); Thread.Sleep(1000); _main.MelsecNetBitOnOff(OB_RECIPE_REQUEST, false); Log(string.Format("{0}\t{1}", _component.ControlName, string.Format("PGM DATA SEND - {0}", Param_Data_List.ToString()))); if (!error) { return(0); } Log(string.Format("{0}\t{1}", _component.ControlName, "PGM DATA DISPLAY")); #region 메시지 창 표시 string receivedTime = DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); string msgId = "0"; string message = string.Format("[{0}] {1}", this.Name, tempMsg); string panelNo = "1"; CSubject subject = CUIManager.Inst.GetData("CIMMessage"); subject.SetValue("List", new List <string>() { "MESSAGE_SET", msgId, receivedTime, message, panelNo }); subject.Notify(); #endregion return(0); }