示例#1
0
        public bool doInitialize(byte[] IpAddr, ushort PortNo)
        {
            LJV7IF_ETHERNET_CONFIG tmpEthernet = new LJV7IF_ETHERNET_CONFIG();

            if (_ethernetConfig.abyIpAddress != null)
            {
                MessageBox.Show("儀器已連線");
                return(false);
            }

            Rc rc = Rc.Ok;

            // Initialize the DLL.
            rc = (Rc)NativeMethods.LJV7IF_Initialize();
            if (!CheckReturnCode(rc))
            {
                return(false);
            }

            // Open communication path.
            // Create Ethernet communication settings.
            try
            {
                tmpEthernet.abyIpAddress = IpAddr;
                tmpEthernet.wPortNo      = PortNo;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }

            rc = (Rc)NativeMethods.LJV7IF_EthernetOpen(DEVICE_ID, ref tmpEthernet);
            if (!CheckReturnCode(rc))
            {
                return(false);
            }
            status          = ObjectLJV7.STATUS.CONNECTED;
            _ethernetConfig = tmpEthernet;
            return(true);
        }
 internal static extern int LJV7IF_HighSpeedDataEthernetCommunicationInitalize(
     int lDeviceId, ref LJV7IF_ETHERNET_CONFIG pEthernetConfig, ushort wHighSpeedPortNo,
     HightSpeedDataCallBack pCallBack, uint dwProfileCnt, uint dwThreadId);
 internal static extern int LJV7IF_EthernetOpen(int lDeviceId, ref LJV7IF_ETHERNET_CONFIG ethernetConfig);