Exemple #1
0
        /// <summary>
        /// 종료 버튼 클릭 이벤트 처리 메소드
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnStop_Click(object sender, RoutedEventArgs e)
        {
            if (comm != null)
            {
                comm.Close();
                comm = null;
            }
        }
Exemple #2
0
        /// <summary>
        /// D-Out 버튼 클릭 이벤트 처리 메소드
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDoutOpen_Click(object sender, RoutedEventArgs e)
        {
            if (DOutComm != null && DOutComm.isOpen())
            {
                if (DOutComm != null)
                {
                    DOutComm.Close();
                    DOutComm = null;
                }
                btnDoutOpen.Content = "Open";
            }
            else
            {
                Port dOutport = cbComPort2.SelectedItem as Port;
                DOutComm = new CommRS485(dOutport.PortName, OnOutDataReceived, 115200);

                if (DOutComm.Open())
                {
                    btnDoutOpen.Content = "Close";
                }
                else
                {
                    if (DOutComm != null)
                    {
                        DOutComm.Close();
                        DOutComm            = null;
                        btnDoutOpen.Content = "Open";
                    }
                    MessageBox.Show("ERROR 2 : D-Out 통신연결 실패. 포트를 확인하세요.");
                }
            }
        }
Exemple #3
0
        private void btnDinOpen_Click(object sender, RoutedEventArgs e)
        {
            if (comm != null && comm.isOpen())
            {
                if (comm != null)
                {
                    comm.Close();
                    comm = null;
                }

                btnDinOpen.Content = "Open";
            }
            else
            {
                Port dInport = cbComPort.SelectedItem as Port;
                comm = new CommRS485(dInport.PortName, OnDataReceived);

                if (comm.Open())
                {
                    //통신이 연결되면 명령어 전송 스레드를 시작한다.
                    Thread sendCmdThread = new Thread(new ThreadStart(SendCommandLoop));
                    sendCmdThread.Start();

                    btnDinOpen.Content = "Close";
                }
                else
                {
                    if (comm != null)
                    {
                        comm.Close();
                        comm = null;
                    }
                    btnDinOpen.Content = "Open";

                    MessageBox.Show("ERROR 1 : D-In 통신연결 실패. 포트를 확인하세요.");
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 시작 버튼 클릭 이벤트 처리 메소드
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            Port port = cbComPort.SelectedItem as Port;

            comm = new CommRS485(port.PortName, OnDataReceived);

            if (comm.Open())
            {
                //통신이 연결되면 명령어 전송 스레드를 시작한다.
                Thread sendCmdThread = new Thread(new ThreadStart(SendCommandLoop));
                sendCmdThread.Start();
            }
            else
            {
                if (comm != null)
                {
                    comm.Close();
                    comm = null;
                }

                MessageBox.Show("ERROR 1 - 통신연결 실패");
            }
        }