Beispiel #1
0
        public popTest(PLCModule.clsPLCModule opc)
        {
            InitializeComponent();

            _opc = opc;
        }
Beispiel #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);
                }


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

                    Application.DoEvents();

#if (TestPLC)
                    opc = new PLCModule.clsPLCModule(PLCModule.enPlcType.TEST, "", 0, "", "PLC_LOG");
#else
                    opc = new PLCModule.clsPLCModule(PLCModule.enPlcType.AB, vari.plc.RSLINX_ID, vari.plc.RSLINX_ID, "Torque", "Torque", 1000, "Torque_PLC");
#endif


                    opc.AddAddress(new string[] { vari.plc.Add_Trigger, vari.plc.Add_Ack, vari.plc.Add_Data });
                    opc.OnChConnectionStatus += Opc_OnChConnectionStatus;

                    opc.Open();
                }
                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);
                    }

                    //코드 정보 로드
                    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, 1000);
                }


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