Beispiel #1
0
        /// <summary>
        /// High-speed data communication "Start" button pressed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _btnStartHighSpeed_Click(object sender, EventArgs e)
        {
            // Stop/exit high-speed data communication.
            NativeMethods.LJV7IF_StopHighSpeedDataCommunication(DEVICE_ID);
            NativeMethods.LJV7IF_HighSpeedDataCommunicationFinalize(DEVICE_ID);

            // Initialize data.
            ThreadSafeBuffer.Clear();
            Rc rc = Rc.Ok;

            // Initialize the high-speed communication path.
            // High-speed communication start prep
            LJV7IF_HIGH_SPEED_PRE_START_REQ req = new LJV7IF_HIGH_SPEED_PRE_START_REQ();

            try
            {
                uint frequency = Convert.ToUInt32(_txtCallbackFrequency.Text);
                uint threadId  = (uint)DEVICE_ID;

                if (_rdUsb.Checked)
                {
                    // Initialize USB high-speed data communication
                    rc = (Rc)NativeMethods.LJV7IF_HighSpeedDataUsbCommunicationInitalize(DEVICE_ID, _callback, frequency, threadId);
                }
                else
                {
                    // Create Ethernet communication settings.
                    ushort highSpeedPort = 0;
                    _ethernetConfig.abyIpAddress = new byte[] {
                        Convert.ToByte(_txtIpFirstSegment.Text),
                        Convert.ToByte(_txtIpSecondSegment.Text),
                        Convert.ToByte(_txtIpThirdSegment.Text),
                        Convert.ToByte(_txtIpFourthSegment.Text)
                    };
                    _ethernetConfig.wPortNo = Convert.ToUInt16(_txtCommandPort.Text);
                    highSpeedPort           = Convert.ToUInt16(_txtHighSpeedPort.Text);

                    // Initialize Ethernet high-speed data communication
                    rc = (Rc)NativeMethods.LJV7IF_HighSpeedDataEthernetCommunicationInitalize(DEVICE_ID, ref _ethernetConfig,
                                                                                              highSpeedPort, _callback, frequency, threadId);
                }
                if (!CheckReturnCode(rc))
                {
                    return;
                }
                req.bySendPos = Convert.ToByte(_txtStartProfileNo.Text);
            }
            catch (FormatException ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }
            catch (OverflowException ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }

            // High-speed data communication start prep
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();

            rc = (Rc)NativeMethods.LJV7IF_PreStartHighSpeedDataCommunication(DEVICE_ID, ref req, ref profileInfo);
            if (!CheckReturnCode(rc))
            {
                return;
            }

            // Start high-speed data communication.
            rc = (Rc)NativeMethods.LJV7IF_StartHighSpeedDataCommunication(DEVICE_ID);
            if (!CheckReturnCode(rc))
            {
                return;
            }

            _lblReceiveProfileCount.Text = "0";
            _timerHighSpeed.Start();
        }
Beispiel #2
0
 internal static extern int LJV7IF_PreStartHighSpeedDataCommunication(
     int lDeviceId, ref LJV7IF_HIGH_SPEED_PRE_START_REQ pReq,
     ref LJV7IF_PROFILE_INFO pProfileInfo);