Exemple #1
0
        public popTest(PLCComm.PLCComm opc)
        {
            InitializeComponent();

            _opc = opc;
        }
Exemple #2
0
        protected override void Form_Init()
        {
            try
            {
                base.Form_Init();

                Text        = $"TorqueTool [{vari.StationID}] v.{Application.ProductVersion}";
                Title_Label = $"TorqueTool [{vari.StationID}]";


                //운영모드 확인
                if (vari.OpMode == vari.enOpMode.Monitoring)
                {                   //모니터링
                    if (!tabControl1.TabPages.Contains(tabMonitoring))
                    {
                        tabControl1.TabPages.Insert(0, tabMonitoring);
                    }
                }
                else
                {                   //조화 Only
                    tabControl1.TabPages.Remove(tabMonitoring);
                }

                //이미지
                if (System.IO.File.Exists(vari.TorqueImagePath))
                {
                    try
                    {
                        pnlImage.BackgroundImage = new Bitmap(vari.TorqueImagePath);
                    }
                    catch (Exception ex)
                    {
                        pnlImage.BackgroundImage = null;
                        ProcException(ex, "Image 로드 실패", true);
                    }
                }
                else
                {
                    pnlImage.BackgroundImage = null;
                }

                //db if
                if (vari.bIF_Chk)
                {
                    lblIF_Status.Text = "";
                    ifLog.WLog("FormInit I/F 활성 화 중..");
                }
                else
                {
                    lblIF_Status.Text = "중지 중...";
                    ifLog.WLog("FormInit I/F 중지 상태");
                }


                try
                {
                    //plc 연결 정보 초기화
                    if (opc != null)
                    {
                        opc.Dispose();
                    }

                    Application.DoEvents();

#if (TestPLC)
                    opc = new PLCComm.PLCComm(PLCComm.enPlcType.TEST, "127.0.0.1", 6001, "", "PLC_LOG");
                    //new PLCModule.clsPLCModule(PLCModule.enPlcType.TEST, "", 0, "", "PLC_LOG");

                    Text += " - PLC Test Mode";
#else
                    //opc = new PLCModule.clsPLCModule(PLCModule.enPlcType.AB, vari.plc.RSLINX_ID, vari.plc.RSLINX_ID, "Torque", "Torque", 1000, "Torque_PLC");
                    opc = new PLCComm.PLCComm(PLCComm.enPlcType.AB, "", vari.plc.RSLINX_ID, "Torque", "Torque", 1000, "Torque_PLC");
#endif
                    opc.OnChConnectionStatus += Opc_OnChConnectionStatus;
                    PLCComm.delChAddressValue dChAddress = new PLCComm.delChAddressValue(OnChAddress);

                    opc.Open();

                    opc.AddAddress(vari.plc.Add_Trigger, PLCComm.enPLCValueType.INT);
                    opc.AddAddress(vari.plc.Add_Ack, PLCComm.enPLCValueType.INT);
                    opc.AddAddress(vari.plc.Add_Confirm, PLCComm.enPLCValueType.INT);
                    opc.AddAddress(vari.plc.Add_Info, PLCComm.enPLCValueType.STRING);
                    opc.AddAddress(vari.plc.Add_Data, PLCComm.enPLCValueType.HEX);


                    opc.ChangeEvtAddress_Add(vari.plc.Add_Trigger, dChAddress);
                }
                catch (Exception ex)
                {
                    ProcException(ex, "PLC 연결 초기화 실패", true);
                }


                try
                {
                    //db상태 체크 타이머
                    if (tmrDB_Chk == null)
                    {
                        tmrDB_Chk = new System.Threading.Timer(new TimerCallback(Sql_Connection_Chk), null, 0, 10000);
                    }
                    else
                    {
                        Sql_Connection_Chk(null);
                    }

                    //
                    if (tmrIF_Chk == null)
                    {
                        tmrIF_Chk = new System.Threading.Timer(new TimerCallback(IF_Db), null, 0, iIF_Span * 1000);
                    }
                    else
                    {
                        IF_Db(null);
                    }

                    //코드 테이블의 info 정보 변경
                    dba.dev_Station_set(vari.StationID);

                    //코드 정보 로드
                    vari.DB_CodeDetail_Load();

                    Last_Work_Get();
                }
                catch (Exception ex)
                {
                    ProcException(ex, "DB 연결 초기화 실패", true);
                }

                //plc 체크 쓰래드
                if (tmrWork == null)
                {
                    tmrWork = new System.Threading.Timer(new TimerCallback(Work_Plc), null, 5000, 10000);
                }


                //조회 조건 초기화
                Search_Conditon_Reset();
            }
            catch (Exception ex)
            {
                ProcException(ex, "Form_Init");
            }
        }