Exemplo n.º 1
0
        private void subSaveECValue()
        {
            string ChangeECID = "";
            string ChangeECV = "";
            bool dbolErrorCheck = false;
            try
            {
                for (int dintLoop = 0; dintLoop < dataGridView1.Rows.Count; dintLoop++)
                {

                }

                if (dbolErrorCheck)
                {
                    
                }

                for (int dintLoop = 0; dintLoop < dataGridView1.Rows.Count; dintLoop++)
                {
                    int dintECID = Convert.ToInt32(dataGridView1[0, dintLoop].Value);

                    clsECID ECID = pInfo.Unit(0).SubUnit(0).ECID(dintECID);
                    if (ECID.ECDEF != dataGridView1[3, dintLoop].Value.ToString())
                    {
                        ChangeECID += dintECID + "=";
                        ChangeECV += dataGridView1[3, dintLoop].Value.ToString() + "=";
                        ECID.ECDEF = dataGridView1[3, dintLoop].Value.ToString();
                    }
                }

                pInfo.subPLCCommand_Set(clsInfo.PLCCommand.ECIDChange);

                //if (string.IsNullOrEmpty(ChangeECID) == false)
                //{
                //    funECID_DBDelete();
                //    funECID_DBInsert();
                //    //pInfo.subSendSF_Set(clsInfo.SFName.S6F11_ECReport, ChangeECID, ChangeECV);

                //}

            }
            catch (Exception ex)
            {
                pInfo.subLog_Set(InfoAct.clsInfo.LogType.CIM, ex.ToString());
                MessageBox.Show("EC Value Update Fail!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 2
0
        public bool funECID_DBInsert()
        {
            bool dbolDBUpdateFlag = false;
            string dstrSQL = "";
            try
            {

                foreach (int ECID in pInfo.Unit(0).SubUnit(0).ECID())
                {
                    clsECID CurrentECID = pInfo.Unit(0).SubUnit(0).ECID(ECID);

                    dstrSQL = string.Format(@"INSERT INTO tbECID VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}');",
                        ECID, CurrentECID.Name, CurrentECID.Min, CurrentECID.ECSLL, CurrentECID.ECWLL, CurrentECID.ECDEF, CurrentECID.ECWUL, CurrentECID.ECSUL, CurrentECID.Max, CurrentECID.DESC, CurrentECID.Use.ToString(), CurrentECID.ModuleID);
                    dbolDBUpdateFlag = DBAct.clsDBAct.funExecuteQuery(dstrSQL);
                }

            }
            catch (Exception)
            {
            }
            return dbolDBUpdateFlag;
        }
Exemplo n.º 3
0
        /// <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());
            }
        }
Exemplo n.º 4
0
        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());
            }
        }