Exemplo n.º 1
0
        private int InitComm()
        {
            int    nRet = 0;
            string strPort;

            if (0 == m_nCommType)
            {
                strPort = "COM" + m_nPort.ToString();
                nRet    = CP5200.CP5200_RS232_InitEx(Marshal.StringToHGlobalAnsi(strPort), m_nBaudrate, m_nTimeout);
            }
            else
            {
                m_dwIPAddr = GetIP(IPAddr.Text);
                if (0 != m_dwIPAddr)
                {
                    m_dwIDCode = GetIP(IDCode.Text);
                    if (0 != m_dwIDCode)
                    {
                        CP5200.CP5200_Net_Init(m_dwIPAddr, m_nIPPort, m_dwIDCode, m_nTimeout);
                        nRet = 1;
                    }
                }
            }

            return(nRet);
        }
Exemplo n.º 2
0
 private void InitComm()
 {
     if (0 == m_nCommType)
     {
         int    nPort     = Convert.ToByte(m_cmbPort.SelectedIndex + 1);
         String strPort   = "COM" + nPort.ToString();
         int    nBaudrate = Convert.ToInt32(m_lBaudtbl[m_cmbBaudrate.SelectedIndex]);
         CP5200.CP5200_RS232_InitEx(Marshal.StringToHGlobalAnsi(strPort), nBaudrate, m_nTimeout);
     }
     else
     {
         uint dwIPAddr = GetIP(m_txtIPAddr.Text);
         uint dwIDCode = GetIP(m_txtIDCode.Text);
         int  nIPPort  = Convert.ToInt32(m_txtIPPort.Text);
         if (dwIPAddr != 0 && dwIDCode != 0)
         {
             CP5200.CP5200_Net_Init(dwIPAddr, nIPPort, dwIDCode, m_nTimeout);
         }
     }
 }