Beispiel #1
0
        private void readSetting()
        {
            string ip = iniR.Read("SensorControllerEthernet", "IP");

            string[] ips = ip.Split('.');
            _txtIpFirstSegment.Text  = ips[0];
            _txtIpSecondSegment.Text = ips[1];
            _txtIpThirdSegment.Text  = ips[2];
            _txtIpFourthSegment.Text = ips[3];

            _txtCommandPort.Text   = iniR.Read("SensorControllerEthernet", "Port");
            _txtHighSpeedPort.Text = iniR.Read("SensorControllerEthernet", "HighSpeedPort");
        }
Beispiel #2
0
        private bool OpenEthernetConnection()
        {
            Rc rc = Rc.Ok;

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

            // Open the communication path
            // Generate the settings for Ethernet communication.
            string ip = iniH.Read("SensorControllerEthernet", "IP");

            string[] ips  = ip.Split('.');
            string   port = iniH.Read("SensorControllerEthernet", "Port");

            try
            {
                _ethernetConfig.abyIpAddress = new byte[] {
                    Convert.ToByte(ips[0]),
                    Convert.ToByte(ips[1]),
                    Convert.ToByte(ips[2]),
                    Convert.ToByte(ips[3])
                };
                _ethernetConfig.wPortNo = Convert.ToUInt16(port);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
                //toolStripStatusLabel2.Text = "未连接";
                AddLog("以太网通信连接失败!");
                return(false);
            }

            rc = (Rc)NativeMethods.LJV7IF_EthernetOpen(Define.DEVICE_ID, ref _ethernetConfig);

            if (!CheckReturnCode(rc))
            {
                AddLog("以太网通信连接失败!");
                return(false);
            }
            AddLog("以太网通信开启!");
            //toolStripStatusLabel2.Text = "已连接";
            return(true);
        }