Exemplo n.º 1
0
 private void button_connect_Click(object sender, EventArgs e)
 {
     Rc rc2;
         LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
         NativeMethods.LJV7IF_StopHighSpeedDataCommunication(Define.DEVICE_ID);
         NativeMethods.LJV7IF_HighSpeedDataCommunicationFinalize(Define.DEVICE_ID);
         ThreadSafeBuffer.Clear(Define.DEVICE_ID);
         LJV7IF_HIGH_SPEED_PRE_START_REQ req = new LJV7IF_HIGH_SPEED_PRE_START_REQ();
         try
         {
             _ethernetConfig.abyIpAddress = new byte[] {
                 Convert.ToByte(textbox_ipaddress1.Text),
                 Convert.ToByte(textbox_ipaddress2.Text),
                 Convert.ToByte(textbox_ipaddress3.Text),
                 Convert.ToByte(textbox_ipaddress4.Text)
             };
             rc2 = (Rc)NativeMethods.LJV7IF_HighSpeedDataEthernetCommunicationInitalize(Define.DEVICE_ID, ref _ethernetConfig,
                 Convert.ToUInt16(textbox_hsport.Text), _callback, Convert.ToUInt32(textbox_frequency.Text), (uint)Define.DEVICE_ID);
             if (rc2 != Rc.Ok)
             {
                 textBox_status.AppendText("High Speed Data Communication Initialize Failed...\n");
                 return;
             }
             req.bySendPos = Convert.ToByte(textbox_stprofile.Text);
         }
         catch (FormatException ex)
         {
             textBox_status.Text = ex.ToString()+"\n";
             WriteLog(ex.ToString() + Environment.NewLine + "   at " + convertTimeZone(TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString()) + "\n");
             textBox_status.AppendText("Exception Occured. Please refer log file." + "\n");
             return;
         }
         catch (OverflowException ex)
         {
             textBox_status.Text = ex.ToString() + "\n";
             WriteLog(ex.ToString() + Environment.NewLine + "   at " + convertTimeZone(TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString()) + "\n");
             textBox_status.AppendText("Exception Occured. Please refer log file." + "\n");
             return;
         }
         rc2 = (Rc)NativeMethods.LJV7IF_PreStartHighSpeedDataCommunication(Define.DEVICE_ID, ref req, ref profileInfo);
         if (rc2 != Rc.Ok)
         {
             return;
         }
         rc2 = (Rc)NativeMethods.LJV7IF_StartHighSpeedDataCommunication(Define.DEVICE_ID);
         if (rc2 != Rc.Ok)
         {
             return;
         }
         highSpeedTimer.Start();
 }
 internal static extern int LJV7IF_PreStartHighSpeedDataCommunication(
 int lDeviceId, ref LJV7IF_HIGH_SPEED_PRE_START_REQ pReq,
 ref LJV7IF_PROFILE_INFO pProfileInfo);
Exemplo n.º 3
0
        private void button_connect_Click(object sender, EventArgs e)
        {
            if (textbox_filename.Text.Trim().Equals(string.Empty))
                {
                    textBox_status.AppendText("Choose File to add Sensor Data...\n");
                    return;
                }
                Rc rc2;
                NativeMethods.LJV7IF_StopHighSpeedDataCommunication(Define.DEVICE_ID);
                NativeMethods.LJV7IF_HighSpeedDataCommunicationFinalize(Define.DEVICE_ID);
                ThreadSafeBuffer.Clear(Define.DEVICE_ID);
                LJV7IF_HIGH_SPEED_PRE_START_REQ req = new LJV7IF_HIGH_SPEED_PRE_START_REQ();
                try
                {
                    _ethernetConfig.abyIpAddress = new byte[] {
                        Convert.ToByte(textbox_ipaddress1.Text),
                        Convert.ToByte(textbox_ipaddress2.Text),
                        Convert.ToByte(textbox_ipaddress3.Text),
                        Convert.ToByte(textbox_ipaddress4.Text)
                    };
                    rc2 = (Rc)NativeMethods.LJV7IF_HighSpeedDataEthernetCommunicationInitalize(Define.DEVICE_ID, ref _ethernetConfig,
                        Convert.ToUInt16(textbox_hsport.Text), _callback, Convert.ToUInt32(textbox_frequency.Text), (uint)Define.DEVICE_ID);
                    if (rc2 != Rc.Ok)
                        textBox_status.AppendText("High Speed Data Communication Initialize Failed...\n");
                        return;
                    req.bySendPos = Convert.ToByte(textbox_stprofile.Text);
                }
                catch (FormatException ex)
                {
                    textBox_status.Text = ex.ToString()+"\n";
                    return;
                }
                catch (OverflowException ex)
                {
                    textBox_status.Text = ex.ToString() + "\n";
                    return;
                }
                LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
                rc2 = (Rc)NativeMethods.LJV7IF_PreStartHighSpeedDataCommunication(Define.DEVICE_ID, ref req, ref profileInfo);
                if (rc2 != Rc.Ok) return;

                rc2 = (Rc)NativeMethods.LJV7IF_StartHighSpeedDataCommunication(Define.DEVICE_ID);
                if (rc2 != Rc.Ok) return;
                highSpeedTimer.Start();
        }