/// <summary> /// High-speed data communication "Start" button clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks>Perform the preparations for starting high-speed data communication, and then start high-speed data communication.</remarks> private void btnBeginHighSpeedCommunicationEx_Click(object sender, EventArgs e) { // Stop and finalize high-speed data communication. NativeMethods.LJV7IF_StopHighSpeedDataCommunication(Define.DEVICE_ID); NativeMethods.LJV7IF_HighSpeedDataCommunicationFinalize(Define.DEVICE_ID); // Initialize the data. ThreadSafeBuffer.Clear(Define.DEVICE_ID); Rc rc = Rc.Ok; // Initialize the high-speed communication path // High-speed communication start preparations LJV7IF_HIGH_SPEED_PRE_START_REQ req = new LJV7IF_HIGH_SPEED_PRE_START_REQ(); try { uint frequency = Convert.ToUInt32(_txtCallbackFrequency.Text); uint threadId = (uint)Define.DEVICE_ID; if (_rdUsb.Checked) { // Initialize USB high-speed data communication rc = (Rc)NativeMethods.LJV7IF_HighSpeedDataUsbCommunicationInitalize(Define.DEVICE_ID, _callback, frequency, threadId); } else { // Generate the settings for Ethernet communication. 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(Define.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 preparations LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO(); rc = (Rc)NativeMethods.LJV7IF_PreStartHighSpeedDataCommunication(Define.DEVICE_ID, ref req, ref profileInfo); if (!CheckReturnCode(rc)) return; // Start high-speed data communication. rc = (Rc)NativeMethods.LJV7IF_StartHighSpeedDataCommunication(Define.DEVICE_ID); if (!CheckReturnCode(rc)) return; _lblReceiveProfileCount.Text = "0"; _timerHighSpeed.Start(); }
internal static extern int LJV7IF_PreStartHighSpeedDataCommunication( int lDeviceId, ref LJV7IF_HIGH_SPEED_PRE_START_REQ pReq, ref LJV7IF_PROFILE_INFO pProfileInfo);