Exemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------
        private void Button_Connect_Click(object sender, RoutedEventArgs e)
        {
            string strIp   = Text_IP.Text.ToString();
            string strPort = Text_PORT.Text.ToString();
            int    nPort   = 0;

            if (m_bConnect)
            {
                return;
            }

            //AcsApi = new Api();
            if (AcsApi == null)
            {
                AcsApi = new Api();
                mc_Acs = new ACSControl(AcsApi);
            }

            m_bConnect = false;

            if (mc_Acs != null)
            {
                mc_Acs.fn_CloseACS();                 //Close
            }
            if (m_nComType == 0)
            {
                if (strIp == null || strIp == "")
                {
                    return;
                }
                if (strPort == null || strPort == "")
                {
                    return;
                }
                nPort      = Convert.ToInt32(strPort);
                m_bConnect = mc_Acs.fn_OnConnectTCP(strIp, nPort);
            }
            else if (m_nComType == 1)
            {
                m_bConnect = mc_Acs.fn_OnConnectSimulator();
            }
            else
            {
                m_bConnect = false;
            }

            //
            if (!m_bConnect)
            {
                MessageBox.Show("ACS MOTOR에 연결 할 수 없습니다.!!!!", "[ERROR]");
            }
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------------

        /**
         * @brief     ACS Connection
         * @return
         * @param
         * @remark
         * -
         * @author    정지완(JUNGJIWAN)
         * @date      2019/12/16  9:55
         */
        public bool fn_ACSConnect(int type = 0)
        {
            //Local Var
            m_bConnect      = false;
            m_bConnectAsSim = false;

            string sIp  = "10.0.0.100";
            int    port = (int)EthernetCommOption.ACSC_SOCKET_STREAM_PORT;

            if (type == ACS_CON_NOR)
            {
                m_bConnect = ACS_MOTR.fn_OnConnectEthernet(sIp, port);
            }
            else
            {
                m_bConnect = ACS_MOTR.fn_OnConnectSimulator();
                if (m_bConnect)
                {
                    m_bConnectAsSim = true;
                }
            }

            if (m_bConnect)
            {
                if (m_bConnectAsSim)
                {
                    fn_WriteLog("[ACS] MOTOR Open as Simulator");
                }
                else
                {
                    fn_WriteLog("[ACS] MOTOR Open");
                }
            }
            else
            {
                fn_WriteLog(ACS_MOTR._sErrMsg);
            }

            return(m_bConnect);
        }