R2000-UHD demo
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
namespace R2000_UHD_Demo
{
public partial class Form1 : Form
{
public static string IpAddress { get; set; }
string Packet_Type = "B";
string path;
bool Scanstart = false;
// bool OneTurnFinish = false;
FileStream fs;
StreamWriter sw;
public Form1()
{
InitializeComponent();
IpAddress = textBox2.Text;
//
BT_ReleaseH.Enabled = false;
BT_StartScan.Enabled = false;
BT_STOPScan.Enabled = false;
BT_TCPConnect.Enabled = false;
BT_TCPClose.Enabled = false;
BT_ReleaseH.Enabled = false;
Scanstart = false;
comboBox2.SelectedIndex = 0;
//
int i;
for (i = 0; i < 25200; i )
{
R2000StreamTcpClient.R2000ScanPoints[i] = new R2000ScanPoint(0, 0, 0);
R2000StreamTcpClient.R2000SingleTurnPoints[i] = new R2000ScanPoint(0, 0, 0);
}
}
public string R2000IP()
{
return IpAddress;
}
private void button1_Click(object sender, EventArgs e) // Get Protocol Info
{
if (IpAddress != "")
{
//Get R2000 Feedback Data
Thread R2000Thread = new Thread(new ThreadStart(R2000StreamTcpClient.R2000RecDataStream));
R2000Thread.IsBackground = true;
R2000Thread.Start();
TBox_Status.Text = R2000Commands.Get_Protocol_Info(IpAddress) (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
}
else
{
TBox_Error.Text = "Please Enter IP" (Char)13 (Char)10;
}
if (R2000Commands.Int16_Sucess == 1)
{
ChBox_TimerS.Checked = true;
//-------------------------------
BT_TCPConnect.Enabled = false;
BT_RequestH.Enabled = true;
BT_ReleaseH.Enabled = false;
BT_StartScan.Enabled = false;
BT_TCPConnect.Enabled = false;
TBox_Error.Text = "Connection Testing Sucessful" (Char)13 (Char)10;
Bt_Reboot.Enabled = true;
}
else
{
TBox_Error.Text = "Wrong IP or Wrong Network Setting, Check again" (Char)13 (Char)10;
}
}
private void button2_Click(object sender, EventArgs e) // Request Handle TCP
{
// Button Request Handle
if (IpAddress != "")
{
TBox_Status.Text = R2000Commands.Request_Handle_TCP(IpAddress, Packet_Type, "watchdogtimeout=30000", "0") (Char)13 (Char)10 "\n\rError: " R2000Commands.Int16_ErrorCode " \n\rSuccess: " R2000Commands.Int16_Sucess;
if (R2000Commands.Int16_Sucess == 1)
{
label1.Text = R2000Commands.Port;
Lbl_HandleValue.Text = R2000Commands.Handle;
BT_ReleaseH.Enabled = true;
BT_StartScan.Enabled = false;
BT_TCPConnect.Enabled = true;
BT_RequestH.Enabled = false;
TBox_Error.Text = "Handle Request Successful" (Char)13 (Char)10 label1.Text (Char)13 (Char)10 Lbl_HandleValue.Text;
}
}
else
{
BT_ReleaseH.Enabled = false;
BT_StartScan.Enabled = false;
BT_TCPConnect.Enabled = false;
BT_RequestH.Enabled = true;
TBox_Error.Text = "IP Address = NULL";
}
}
private void button3_Click(object sender, EventArgs e) // Release Handle
{
TBox_Status.Text = R2000Commands.Release_Handle(IpAddress) (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
Scanstart = false;
if (R2000Commands.Int16_Sucess == 1)
{
label1.Text = "Port = ";
R2000Commands.Port = "";
Lbl_HandleValue.Text = "Handle = ";
R2000Commands.Handle = "";
TBox_Error.Text = "Handle is Released" (Char)13 (Char)10;
BT_TCPConnect.Enabled = false;
BT_RequestH.Enabled = true;
BT_StartScan.Enabled = false;
}
else
{
TBox_Error.Text = "Handle Release is not Suceessful";
BT_RequestH.Enabled = true;
BT_TCPConnect.Enabled = false;
BT_StartScan.Enabled = false;
}
}
private void button4_Click(object sender, EventArgs e) // Start Scan Output
{
//Scan Start
TBox_Status.Text = R2000Commands.Start_Scanoutput(IpAddress) (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
Scanstart = true;
BT_STOPScan.Enabled = true;
BT_StartScan.Enabled = false;
BT_RequestH.Enabled = false;
BT_ReleaseH.Enabled = true;
//DateTime StartTime = DateTime.Now();
int i;
for (i = 0; i < 25200; i )
{
R2000StreamTcpClient.R2000ScanPoints[i].Distance = 0;
R2000StreamTcpClient.R2000ScanPoints[i].EchoValue = 0;
}
TBox_Error.Text = "Scan is Starting at: " (Char)13 (Char)10 DateTime.Now.ToString();
print_R2000Header();
}
private void button5_Click(object sender, EventArgs e) // Stop Scan Output
{
TBox_Status.Text = R2000Commands.Stop_Scanoutput(IpAddress) (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
Scanstart = false;
BT_ReleaseH.Enabled = true;
BT_StartScan.Enabled = true;
BT_STOPScan.Enabled = false;
BT_TCPConnect.Enabled = true;
TBox_Error.Text = "Scan stopped";
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
IpAddress = textBox2.Text;
}
private void button6_Click(object sender, EventArgs e) // TCP Connect
{
// TCP Connect
if (R2000Commands.Port != "")
{
R2000StreamTcpClient.R2000UHDTCPconnect(IpAddress, R2000Commands.Port);
BT_TCPClose.Enabled = true;
BT_TCPConnect.Enabled = false;
BT_StartScan.Enabled = true;
TBox_Error.Text = "TCP is Connected to R2000" (Char)13 (Char)10 " " label1.Text;
}
else
{
BT_ReleaseH.Enabled = true;
BT_TCPConnect.Enabled = true;
BT_StartScan.Enabled = false;
TBox_Error.Text = "ERROR: PORT = NULL";
}
}
private void button7_Click(object sender, EventArgs e) // TCP Close
{
R2000StreamTcpClient.SocketCloseCommand = true;
//R2000StreamTcpClient.R2000UHDTCPclose();
//Scanstart = false;
BT_TCPConnect.Enabled = true;
BT_TCPClose.Enabled = false;
BT_ReleaseH.Enabled = true;
TBox_Error.Text = "TCP Connection is closed" (Char)13 (Char)10;
//关闭流
//sw.Close();
///fs.Close();
}
private void timer_Watchdog_Tick(object sender, EventArgs e)
{
//TBox_Status.Text = R2000Commands.Feed_Watchdog(IpAddress);
//TBox_Test.Text = R2000Commands.Feed_Watchdog(IpAddress);
TBox_Test.Text = R2000Commands.Feed_Watchdog(IpAddress);
}
// Head Info Display at Text Box
public void print_R2000Header()
{
string txt = "packet_type = ";
switch (R2000StreamTcpClient.packet_type)
{
case 65:
txt = txt "A" (Char)13 (Char)10;
break;
case 66:
txt = txt "B" (Char)13 (Char)10;
break;
case 67:
txt = txt "C" (Char)13 (Char)10;
break;
default:
txt = txt (Char)13 (Char)10;
break;
}
txt = txt "packet_size = " R2000StreamTcpClient.packet_size.ToString("D") (Char)13 (Char)10;
txt = txt "header_size = " R2000StreamTcpClient.header_size.ToString("D") (Char)13 (Char)10;
txt = txt "scan_number = " R2000StreamTcpClient.scan_number.ToString("D") (Char)13 (Char)10;
txt = txt "packet_number = " R2000StreamTcpClient.packet_number.ToString("D") (Char)13 (Char)10;
txt = txt "timestamp_raw = " R2000StreamTcpClient.timestamp_raw.ToString("D") (Char)13 (Char)10;
txt = txt "timestamp_sync = " R2000StreamTcpClient.timestamp_sync.ToString("D") (Char)13 (Char)10;
txt = txt "scan_frequency = " R2000StreamTcpClient.scan_frequency.ToString("D") (Char)13 (Char)10;
txt = txt "num_points_scan = " R2000StreamTcpClient.num_points_scan.ToString("D") (Char)13 (Char)10;
txt = txt "num_points_packet = " R2000StreamTcpClient.num_points_packet.ToString("D") (Char)13 (Char)10;
txt = txt "first_index = " R2000StreamTcpClient.first_index.ToString("D") (Char)13 (Char)10;
txt = txt "first_angle = " R2000StreamTcpClient.first_angle.ToString("D") (Char)13 (Char)10;
txt = txt "angular_increment = " R2000StreamTcpClient.angular_increment.ToString("D") (Char)13 (Char)10;
txt = txt (char)13 (Char)10 "TCP Connected = " R2000StreamTcpClient.IsConnectedTCP (Char)13 (Char)10;
txt = txt "TCP Connection: " R2000StreamTcpClient.ErrorMsg_TCP_Connections (Char)13 (Char)10;
this.TBox_Header.Text = txt;
}
public void print_R2000ScanData()
{
string txt = "";
string str = ""; // new
int i;
int InvData = -1; //new
int startvalue;
if (textBox3.Text == "")
//startvalue = R2000StreamTcpClient.num_points_scan;
startvalue = 0;
else
startvalue = Convert.ToInt32(textBox3.Text);
if (startvalue > 25164)
startvalue = 25164;
txt = "Scan data point " startvalue "-" (startvalue 35) ":" (Char)13 (Char)10;
txt = txt "Startpoint: Distance mm: Echo: Angle:" (Char)13 (Char)10;
//for (i = startvalue; i < (startvalue 36); i )
//for (i = 0; i < startvalue; i )
for (i = startvalue; i < (startvalue 36); i )
{
txt = txt i.ToString("00000") " ";
str = str i.ToString("00000") " ";
if (R2000StreamTcpClient.R2000ScanPoints[i].Distance == 0xFFFFFFFF)
{
txt = txt "-00001";
str = str InvData.ToString("00000");
}
else
{
txt = txt R2000StreamTcpClient.R2000ScanPoints[i].Distance.ToString("000000");
str = str R2000StreamTcpClient.R2000ScanPoints[i].Distance.ToString("000000");
}
txt = txt " | " R2000StreamTcpClient.R2000ScanPoints[i].EchoValue.ToString("00000")
" | " R2000StreamTcpClient.R2000ScanPoints[i].Angle.ToString("000.00000") (Char)13 (Char)10;
str = str " " R2000StreamTcpClient.R2000ScanPoints[i].Angle.ToString("000.00000")
" " R2000StreamTcpClient.R2000ScanPoints[i].EchoValue.ToString("00000") (Char)13 (Char)10;
}
this.textBox_ScanPoints.Text = txt;
this.Txb_NPS.Text = Convert.ToString(startvalue);
//...........................................................................
// if (R2000StreamTcpClient.IsConnectedTCP && button4.Enabled == false)
//{
// Write(str);
//}
}
public void write_close()
{
sw.Close();
fs.Close();
}
public void Write(string txt)
{
//开始写入
sw.Write(txt);
//清空缓冲区
sw.Flush();
//关闭流
//sw.Close();
//fs.Close();
}
private void timer1_Tick(object sender, EventArgs e)
{
//print_R2000Header();
//HeadInfoPrinting();
if (Chbox_AutoUpdate.Checked == true)
{
print_R2000ScanData();
HeadInfoPrinting();
}
else
{
HeadInfoPrinting();
}
}
private void checkBox_Type_A_CheckedChanged_1(object sender, EventArgs e)
{
if (checkBox_Type_A.Checked == true)
{
Packet_Type = "A";
checkBox_Type_B.Checked = false;
checkBox_Type_C.Checked = false;
checkBox_Type_A.Enabled = false;
checkBox_Type_B.Enabled = true;
checkBox_Type_C.Enabled = true;
}
}
private void checkBox_Type_B_CheckedChanged(object sender, EventArgs e)
{
if (checkBox_Type_B.Checked == true)
{
Packet_Type = "B";
checkBox_Type_A.Checked = false;
checkBox_Type_C.Checked = false;
checkBox_Type_A.Enabled = true;
checkBox_Type_B.Enabled = false;
checkBox_Type_C.Enabled = true;
}
}
private void checkBox_Type_C_CheckedChanged_1(object sender, EventArgs e)
{
if (checkBox_Type_C.Checked == true)
{
Packet_Type = "C";
checkBox_Type_A.Checked = false;
checkBox_Type_B.Checked = false;
checkBox_Type_A.Enabled = true;
checkBox_Type_B.Enabled = true;
checkBox_Type_C.Enabled = false;
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Exit Program? 退出程序?", "R2000_UHD_Demo", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.Close();
}
}
// Check for NUM only
private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
e.Handled = true;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) // Select Scan Rate
{
switch (CmBox_SamplePS.SelectedIndex)
{
case 0:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=50&samples_per_scan=360") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
case 1:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=50&samples_per_scan=720") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
case 2:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=50&samples_per_scan=1440") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
case 3:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=10&samples_per_scan=3600") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
case 4:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=50&samples_per_scan=3600") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
case 5:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=50&samples_per_scan=5040") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
case 6:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=35&samples_per_scan=7200") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
case 7:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=20&samples_per_scan=12600") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
case 8:
TBox_Status.Text = R2000Commands.Set_Parameter(IpAddress, "scan_frequency=10&samples_per_scan=25200") (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
break;
default:
break;
}
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBox2.SelectedIndex)
{
case 0:
this.Timer_Print.Interval = 500;
break;
case 1:
this.Timer_Print.Interval = 50;
break;
case 2:
this.Timer_Print.Interval = 100;
break;
case 3:
this.Timer_Print.Interval = 200;
break;
case 4:
this.Timer_Print.Interval = 500;
break;
default:
break;
}
}
private void showRefelctorToolStripMenuItem_Click(object sender, EventArgs e)
{
frmReflector frm = new frmReflector();
frm.Show();
}
private void HeadInfoPrinting()
{
double Angleres = 0;
double firstangle = 0.0;
double firstangleabsolute = 0.0;
Angleres = Convert.ToDouble(R2000StreamTcpClient.angular_increment);
firstangle = Convert.ToDouble(R2000StreamTcpClient.first_angle) / 10000;
if (R2000StreamTcpClient.num_points_scan != 0)
firstangleabsolute = (R2000StreamTcpClient.first_index * 360) / R2000StreamTcpClient.num_points_scan;
this.Txb_NPS.Text = R2000StreamTcpClient.num_points_scan.ToString("00") " 点";
this.TxB_TimeS.Text = R2000StreamTcpClient.timestamp_raw.ToString("D");
this.TxB_NPPackage.Text = R2000StreamTcpClient.num_points_packet.ToString("D");
this.TxB_ScanNr.Text = R2000StreamTcpClient.scan_number.ToString("00000");
this.TxB_PackNr.Text = R2000StreamTcpClient.packet_number.ToString("D");
this.TxB_ScanFreq.Text = (R2000StreamTcpClient.scan_frequency / 1000).ToString("D") " Hz";
this.TxB_AngleRes.Text = (Angleres / 10000).ToString("0.00000") " °";
this.TxB_FirstIndex.Text = R2000StreamTcpClient.first_index.ToString("0000");
this.TxB_FirstAngle.Text = firstangle.ToString("0.0") " °";
this.TxB_StatusFlag.Text = R2000StreamTcpClient.field_status.ToString("D");
this.TxB_AngleAbsolute.Text = firstangleabsolute.ToString("0.0") " °";
//labels display
this.Lbl_PackType.Text = R2000StreamTcpClient.packet_type.ToString("00");
this.Lbl_HeaderSize.Text = R2000StreamTcpClient.header_size.ToString("00");
this.Lbl_PackageSize.Text = R2000StreamTcpClient.packet_size.ToString("0000");
}
private void BT_Close_Click_1(object sender, EventArgs e)
{
/*
// Close TCP
R2000StreamTcpClient.SocketCloseCommand = true;
// release handle
TBox_Status.Text = R2000Commands.Release_Handle(IpAddress) (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
if (R2000Commands.Int16_Sucess == 1)
{
label1.Text = "Port = ";
R2000Commands.Port = "";
Lbl_HandleValue.Text = "Handle = ";
R2000Commands.Handle = "";
}
*/
BT_RequestH.Enabled = true;
BT_ReleaseH.Enabled = false;
BT_StartScan.Enabled = false;
BT_TCPConnect.Enabled = false;
Form1.ActiveForm.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
BT_RequestH.Enabled = true;
BT_ReleaseH.Enabled = false;
BT_StartScan.Enabled = false;
BT_TCPConnect.Enabled = false;
BT_STOPScan.Enabled = false;
BT_TCPClose.Enabled = false;
timer_Watchdog.Enabled = false;
Timer_Print.Enabled = false;
Bt_Reboot.Enabled = false;
}
private void BT_PrintScan_Click(object sender, EventArgs e)
{
print_R2000ScanData();
HeadInfoPrinting();
}
private void BT_PrintAll_Click(object sender, EventArgs e)
{
if (Scanstart == false)
{
TBox_Error.Text = "Please Start Scan First " DateTime.Now.ToString() (Char)13 (Char)10;
return;
}
string txt = "";
int i;
int startvalue = 0;
//-------------------------------
//初始化写文件
path = Application.StartupPath "\\" TBox_FileName.Text ".txt";
//fs = new FileStream(path, FileMode.Create);
fs = new FileStream(path, FileMode.Append);
sw = new StreamWriter(fs);
//--------------------------------
txt = txt "Print Start at: " DateTime.Now.ToString() (Char)13 (Char)10;
txt = "Scan data point " startvalue "-" (startvalue 35) ":" (Char)13 (Char)10;
txt = txt "Startpoint: Distance mm: Echo: Angle:" (Char)13 (Char)10;
TBox_Error.Text = "Preperation at: " DateTime.Now.ToString() (Char)13 (Char)10;
Write(txt);
for (i = 0; i < 25200; i )
{
//txt = txt i.ToString("00000") " ";
txt = i.ToString("00000") " ";
if (R2000StreamTcpClient.R2000ScanPoints[i].Distance == 0xFFFFFFFF)
{
txt = txt "-000001";
//txt = "-1";
}
else
{
//txt = txt R2000StreamTcpClient.R2000ScanPoints[i].Distance.ToString("000000");
txt = txt R2000StreamTcpClient.R2000ScanPoints[i].Distance.ToString("000000");
}
//Write(txt);
txt = txt " " R2000StreamTcpClient.R2000ScanPoints[i].EchoValue.ToString("00000")
" " R2000StreamTcpClient.R2000ScanPoints[i].Angle.ToString("000.00000") (Char)13 (Char)10;
Write(txt);
}
//txt = txt "Print Stop at : " DateTime.Now.ToString() (Char)13 (Char)10;
txt = "Print Stop at : " DateTime.Now.ToString() (Char)13 (Char)10;
TBox_Error.Text = TBox_Error.Text "Ready to Write to File at " DateTime.Now.ToString() (Char)13 (Char)10;
Write(txt);
TBox_Error.Text = TBox_Error.Text "Write to File Finish at " DateTime.Now.ToString() (Char)13 (Char)10;
write_close();
}
private void BT_GetParam_Click(object sender, EventArgs e)
{
if (IpAddress != "")
TBox_Status.Text = R2000Commands.Get_Parameter_Info(IpAddress) (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
}
private void scanSettingToolStripMenuItem_Click(object sender, EventArgs e)
{
frmSettingOverview frm = new frmSettingOverview();
frm.Show();
}
private void BT_SendSetting_Click(object sender, EventArgs e)
{
// using set_scanoutput_config command
String parameter = "";
if (IpAddress == null)
{
TBox_Error.Text = " No IP Address is valid";
return;
}
if (Lbl_HandleValue.Text == "Handle")
{
TBox_Error.Text = " No Handle Exist";
return;
}
parameter = "handle=" Lbl_HandleValue.Text "&packet_type=" Packet_Type;
TBox_Status.Text = R2000Commands.set_scanoutput_config(IpAddress, parameter) (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
TBox_Error.Text = "Packet Type Change Sucessfully ";
}
private void BT_GetScanConfig_Click(object sender, EventArgs e)
{
String parameter = "";
if (IpAddress == null)
{
TBox_Error.Text = " No IP Address is valid";
return;
}
if (Lbl_HandleValue.Text == "Handle")
{
TBox_Error.Text = " No Handle Exist";
return;
}
parameter = "handle=" Lbl_HandleValue.Text;
TBox_Status.Text = R2000Commands.get_scanoutput_config(IpAddress, parameter) (Char)13 (Char)10 "\nError: " R2000Commands.Int16_ErrorCode " \nSuccess: " R2000Commands.Int16_Sucess;
TBox_Error.Text = "Get Scan Output Configuration Sucessfully";
}
private void hMIWindowsToolStripMenuItem_Click(object sender, EventArgs e)
{
frmHMIDisplay frm = new frmHMIDisplay();
frm.Show();
}
private void restartToolStripMenuItem_Click(object sender, EventArgs e)
{
TBox_Status.Text = R2000Commands.reboot_device(IpAddress);
TBox_Error.Text = "R2000 Rebooting " (Char)13 (Char)10;
}
private void communicationProtocolToolStripMenuItem_Click(object sender, EventArgs e)
{
frmManualView frm = new frmManualView();
frm.Show();
}
private void ChBox_TimerS_CheckedChanged(object sender, EventArgs e)
{
if (ChBox_TimerS.Checked == true)
{
timer_Watchdog.Enabled = true;
Timer_Print.Enabled = true;
}
else
{
timer_Watchdog.Enabled = false;
Timer_Print.Enabled = false;
}
}
private void Bt_Reboot_Click(object sender, EventArgs e)
{
TBox_Status.Text = R2000Commands.reboot_device(IpAddress);
if (R2000Commands.Int16_Sucess == 1)
TBox_Error.Text = "R2000 Rebooting " (Char)13 (Char)10 "it will take 10 sec";
}
private void Chbox_AutoUpdate_CheckedChanged(object sender, EventArgs e)
{
if (Chbox_AutoUpdate.Checked == true)
{
Timer_Print.Enabled = true;
Timer_Print.Start();
}
else
{
Timer_Print.Enabled = false;
Timer_Print.Stop();
}
}
private void BT_UpdateValue_Click(object sender, EventArgs e)
{
// Print Out Current Value
// print_R2000Header();
if (Lbl_HandleValue.Text == "Handle")
{
TBox_Error.Text = "Please Get Handle" (Char)13 (Char)10;
return;
}
//---------------------------------------------------------
if (Chbox_AutoUpdate.Checked == true)
return;
if (BT_UpdateValue.Text == "Update Start")
{
if (Timer_Print.Enabled == false)
{
Timer_Print.Enabled = true;
Timer_Print.Start();
BT_UpdateValue.Text = "Update Stop";
TBox_Error.Text = "Head Information is Updated" (Char)13 (Char)10;
}
else
{
BT_UpdateValue.Text = "Update Stop";
//BT_UpdateValue.BackColor = System PeachPuff;
}
}
else
{
if (Timer_Print.Enabled == true)
{
//Timer_Print.Enabled = true;
//Timer_Print.Start();
BT_UpdateValue.Text = "Update Start";
Timer_Print.Enabled = false;
Timer_Print.Stop();
TBox_Error.Text = "Head Information Update Stopped" (Char)13 (Char)10;
}
}
HeadInfoPrinting();
}
private void BT_PrintSingleTurn_Click(object sender, EventArgs e)
{
string txt = "";
int i;
int startvalue;
double SingleTurnTime = 0.0;
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
if (textBox3.Text == "")
startvalue = 0;
else
startvalue = Convert.ToInt32(textBox3.Text);
if (startvalue > 25164)
startvalue = 25164;
txt = "Scan data point " startvalue "-" (startvalue 35) ":" (Char)13 (Char)10;
txt = txt "Startpoint: Distance mm: Echo: Angle:" (Char)13 (Char)10;
for (i = startvalue; i < (startvalue 36); i )
{
txt = txt i.ToString("000000") " ";
if (R2000StreamTcpClient.R2000SingleTurnPoints[i].Distance == 0xFFFFFFFF)
{
txt = txt "-1";
}
else
{
txt = txt R2000StreamTcpClient.R2000SingleTurnPoints[i].Distance.ToString("000000");
}
txt = txt " | " R2000StreamTcpClient.R2000SingleTurnPoints[i].EchoValue.ToString("00000")
" | " R2000StreamTcpClient.R2000SingleTurnPoints[i].Angle.ToString("000.00000") (Char)13 (Char)10;
}
this.textBox_ScanPoints.Text = txt;
this.Txb_NPS.Text = Convert.ToString(startvalue);
this.Lbl_TotalPacket.Text = R2000StreamTcpClient.SingleTurnPacketNr.ToString("D");
//this.Lbl_TotalTime.Text = R2000StreamTcpClient.SingleTurnTimeTotal.ToString("D");
///----------Calculation NTP Format Time, ps
//
SingleTurnTime = Convert.ToDouble(R2000StreamTcpClient.SingleTurnTimeTotal);
SingleTurnTime = (SingleTurnTime * 1000/ 4294967296);
this.Lbl_TotalTime.Text = SingleTurnTime.ToString("0.00000") "ms";
TBox_Error.Text = "Single Turn Printing Finish" (Char)13 (Char)10;
}
private void BT_GetSingleTurn_Click(object sender, EventArgs e)
{
if (Scanstart == false)
{
TBox_Error.Text = "Please Start Scanning" (Char)13 (Char)10;
return;
}
R2000StreamTcpClient.SingleScanFinish = false;
R2000StreamTcpClient.SingleTurnStart = false;
TBox_Error.Text = "Single Turn Measurment Done" (Char)13 (Char)10;
}
private void BT_STurnToFile_Click(object sender, EventArgs e)
{
string txt = "";
int i;
int startvalue = 0;
if (Scanstart == false)
{
TBox_Error.Text = "Please Start Scan First " DateTime.Now.ToString() (Char)13 (Char)10;
return;
}
//-------------------------------
//初始化写文件
path = Application.StartupPath "\\" TBox_SingleTurnFileName.Text ".txt";
//fs = new FileStream(path, FileMode.Create);
fs = new FileStream(path, FileMode.Append);
sw = new StreamWriter(fs);
//--------------------------------
txt = txt "Print Start at: " DateTime.Now.ToString() (Char)13 (Char)10;
txt = "Scan data point " startvalue "-" (startvalue 35) ":" (Char)13 (Char)10;
txt = txt "Startpoint: Distance mm: Echo: Angle:" (Char)13 (Char)10;
TBox_Error.Text = "Single Turn Save at: " (Char)13 (Char)10 DateTime.Now.ToString() (Char)13 (Char)10;
Write(txt);
for (i = 0; i < 25200; i )
{
//txt = txt i.ToString("00000") " ";
txt = i.ToString("00000") " ";
if (R2000StreamTcpClient.R2000SingleTurnPoints[i].Distance == 0xFFFFFFFF)
{
txt = txt "-000001";
//txt = "-1";
}
else
{
//txt = txt R2000StreamTcpClient.R2000ScanPoints[i].Distance.ToString("000000");
txt = txt R2000StreamTcpClient.R2000SingleTurnPoints[i].Distance.ToString("000000");
}
//Write(txt);
txt = txt " " R2000StreamTcpClient.R2000SingleTurnPoints[i].EchoValue.ToString("00000")
" " R2000StreamTcpClient.R2000SingleTurnPoints[i].Angle.ToString("000.00000") (Char)13 (Char)10;
Write(txt);
}
//txt = txt "Print Stop at : " DateTime.Now.ToString() (Char)13 (Char)10;
txt = "Print Stop at : " DateTime.Now.ToString() (Char)13 (Char)10;
TBox_Error.Text = TBox_Error.Text "Single Turn Ready to Write to File at " (Char)13 (Char)10 DateTime.Now.ToString() (Char)13 (Char)10;
Write(txt);
TBox_Error.Text = TBox_Error.Text "Write to File Finish at: " (Char)13 (Char)10 DateTime.Now.ToString() (Char)13 (Char)10;
write_close();
}
private void BT_R2000Info_Click(object sender, EventArgs e)
{
frmSettingOverview frm = new frmSettingOverview();
frm.Show();
}
private void BT_OpenHMIWindows_Click(object sender, EventArgs e)
{
frmHMIDisplay frm = new frmHMIDisplay();
frm.Show();
}
}
}
资源文件列表
R2000_C_Demo/app.config , 144
R2000_C_Demo/bin/Debug/R2000-UHD.application , 1961
R2000_C_Demo/bin/Debug/R2000-UHD.exe , 659968
R2000_C_Demo/bin/Debug/R2000-UHD.exe.config , 144
R2000_C_Demo/bin/Debug/R2000-UHD.exe.manifest , 5156
R2000_C_Demo/bin/Debug/R2000-UHD.pdb , 126464
R2000_C_Demo/bin/Debug/R2000-UHD.vshost.application , 1961
R2000_C_Demo/bin/Debug/R2000-UHD.vshost.exe , 22984
R2000_C_Demo/bin/Debug/R2000-UHD.vshost.exe.config , 144
R2000_C_Demo/bin/Debug/R2000-UHD.vshost.exe.manifest , 5156
R2000_C_Demo/bin/Debug/R2000Data_1.txt , 6028356
R2000_C_Demo/bin/Debug/R2000Data_10.txt , 6031884
R2000_C_Demo/bin/Debug/R2000Data_19.txt , 1512548
R2000_C_Demo/bin/Debug/R2000Data_2.txt , 8983884
R2000_C_Demo/bin/Debug/R2000D_1.txt , 1514242
R2000_C_Demo/bin/Debug/R2000S_1.txt , 3030318
R2000_C_Demo/bin/Debug/R2000_C_Demo.vshost.application , 1909
R2000_C_Demo/bin/Debug/R2000_C_Demo.vshost.exe.manifest , 3502
R2000_C_Demo/bin/Release/app.publish/Application Files/R2000-UHD_1_6_18_15/AxInterop.AcroPDFLib.dll.deploy , 9216
R2000_C_Demo/bin/Release/app.publish/Application Files/R2000-UHD_1_6_18_15/Interop.AcroPDFLib.dll.deploy , 12800
R2000_C_Demo/bin/Release/app.publish/Application Files/R2000-UHD_1_6_18_15/R2000-UHD.exe.config.deploy , 144
R2000_C_Demo/bin/Release/app.publish/Application Files/R2000-UHD_1_6_18_15/R2000-UHD.exe.deploy , 753152
R2000_C_Demo/bin/Release/app.publish/Application Files/R2000-UHD_1_6_18_15/R2000-UHD.exe.manifest , 6431
R2000_C_Demo/bin/Release/app.publish/Application Files/R2000-UHD_1_6_18_15/R2000_frei-128.ico.deploy , 51262
R2000_C_Demo/bin/Release/app.publish/Application Files/R2000-UHD_1_6_18_15/zh-Hans/Microsoft.VisualBasic.PowerPacks.Vs.resources.dll.deploy , 61008
R2000_C_Demo/bin/Release/app.publish/autorun.inf , 45
R2000_C_Demo/bin/Release/app.publish/R2000-UHD.application , 2001
R2000_C_Demo/bin/Release/app.publish/setup.exe , 471040
R2000_C_Demo/bin/Release/AxInterop.AcroPDFLib.dll , 9216
R2000_C_Demo/bin/Release/Interop.AcroPDFLib.dll , 12800
R2000_C_Demo/bin/Release/Manual/OMDxxM-R2000 Ethernet Communication.pdf , 4413390
R2000_C_Demo/bin/Release/R2000-UHD.application , 1963
R2000_C_Demo/bin/Release/R2000-UHD.exe , 753152
R2000_C_Demo/bin/Release/R2000-UHD.exe.config , 144
R2000_C_Demo/bin/Release/R2000-UHD.exe.manifest , 6431
R2000_C_Demo/bin/Release/R2000-UHD.pdb , 122368
R2000_C_Demo/bin/Release/R2000-UHD.vshost.application , 1963
R2000_C_Demo/bin/Release/R2000-UHD.vshost.exe , 22984
R2000_C_Demo/bin/Release/R2000-UHD.vshost.exe.config , 144
R2000_C_Demo/bin/Release/R2000-UHD.vshost.exe.manifest , 6431
R2000_C_Demo/bin/Release/R2000S_1.txt , 1514402
R2000_C_Demo/ClassDiagram1.cd , 1
R2000_C_Demo/Form1.cs , 37607
R2000_C_Demo/Form1.Designer.cs , 104790
R2000_C_Demo/Form1.resx , 87020
R2000_C_Demo/frmHMIDisplay.cs , 6822
R2000_C_Demo/frmHMIDisplay.Designer.cs , 17861
R2000_C_Demo/frmHMIDisplay.resx , 6223
R2000_C_Demo/frmManualView.cs , 947
R2000_C_Demo/frmManualView.Designer.cs , 4871
R2000_C_Demo/frmManualView.resx , 6272
R2000_C_Demo/frmReflector.cs , 12204
R2000_C_Demo/frmReflector.Designer.cs , 16204
R2000_C_Demo/frmReflector.resx , 83802
R2000_C_Demo/frmSettingOverview.cs , 678
R2000_C_Demo/frmSettingOverview.Designer.cs , 6574
R2000_C_Demo/frmSettingOverview.resx , 6024
R2000_C_Demo/Manual/OMDxxM-R2000 Ethernet Communication.pdf , 4413390
R2000_C_Demo/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache , 15003
R2000_C_Demo/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 7990
R2000_C_Demo/obj/x86/Debug/R2000-UHD.application , 1961
R2000_C_Demo/obj/x86/Debug/R2000-UHD.exe , 659968
R2000_C_Demo/obj/x86/Debug/R2000-UHD.exe.manifest , 5156
R2000_C_Demo/obj/x86/Debug/R2000-UHD.pdb , 126464
R2000_C_Demo/obj/x86/Debug/R2000UHD_Demo.csproj.FileListAbsolute.txt , 1754
R2000_C_Demo/obj/x86/Debug/R2000UHD_Demo.csproj.GenerateResource.Cache , 1519
R2000_C_Demo/obj/x86/Debug/R2000UHD_Demo.csprojResolveAssemblyReference.cache , 8291
R2000_C_Demo/obj/x86/Debug/R2000_C_Demo.csproj.FileListAbsolute.txt , 6244
R2000_C_Demo/obj/x86/Debug/R2000_C_Demo.csproj.GenerateResource.Cache , 1040
R2000_C_Demo/obj/x86/Debug/R2000_UHD_Demo.Form1.resources , 54093
R2000_C_Demo/obj/x86/Debug/R2000_UHD_Demo.frmHMIDisplay.resources , 180
R2000_C_Demo/obj/x86/Debug/R2000_UHD_Demo.frmManualView.resources , 180
R2000_C_Demo/obj/x86/Debug/R2000_UHD_Demo.frmReflector.resources , 51828
R2000_C_Demo/obj/x86/Debug/R2000_UHD_Demo.frmSettingOverview.resources , 180
R2000_C_Demo/obj/x86/Debug/R2000_UHD_Demo.Properties.Resources.resources , 400542
R2000_C_Demo/obj/x86/Debug/TempPE/Properties.Resources.Designer.cs.dll , 5632
R2000_C_Demo/obj/x86/Release/AxInterop.AcroPDFLib.dll , 9216
R2000_C_Demo/obj/x86/Release/DesignTimeResolveAssemblyReferences.cache , 12609
R2000_C_Demo/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache , 8630
R2000_C_Demo/obj/x86/Release/Interop.AcroPDFLib.dll , 12800
R2000_C_Demo/obj/x86/Release/R2000-UHD.application , 1963
R2000_C_Demo/obj/x86/Release/R2000-UHD.exe , 753152
R2000_C_Demo/obj/x86/Release/R2000-UHD.exe.manifest , 6431
R2000_C_Demo/obj/x86/Release/R2000-UHD.pdb , 122368
R2000_C_Demo/obj/x86/Release/R2000UHD_Demo.csproj.FileListAbsolute.txt , 2308
R2000_C_Demo/obj/x86/Release/R2000UHD_Demo.csproj.GenerateResource.Cache , 1796
R2000_C_Demo/obj/x86/Release/R2000UHD_Demo.csproj.ResolveComReference.cache , 771
R2000_C_Demo/obj/x86/Release/R2000UHD_Demo.csprojResolveAssemblyReference.cache , 8291
R2000_C_Demo/obj/x86/Release/R2000_UHD_Demo.Form1.resources , 54093
R2000_C_Demo/obj/x86/Release/R2000_UHD_Demo.frmHMIDisplay.resources , 180
R2000_C_Demo/obj/x86/Release/R2000_UHD_Demo.frmManualView.resources , 565
R2000_C_Demo/obj/x86/Release/R2000_UHD_Demo.frmReflector.resources , 51828
R2000_C_Demo/obj/x86/Release/R2000_UHD_Demo.frmSettingOverview.resources , 180
R2000_C_Demo/obj/x86/Release/R2000_UHD_Demo.Properties.Resources.resources , 494339
R2000_C_Demo/obj/x86/Release/TempPE/Properties.Resources.Designer.cs.dll , 6656
R2000_C_Demo/PDF/OMDxxM-R2000 Ethernet Communication.pdf , 4413390
R2000_C_Demo/PIC/App_Navigation.jpg , 19372
R2000_C_Demo/PIC/App_RoboterPicking.jpg , 16841
R2000_C_Demo/PIC/App_RoboterPickingjpg.jpg , 17034
R2000_C_Demo/PIC/PRT.jpg , 8680
R2000_C_Demo/PIC/R2000.jpg , 26670
R2000_C_Demo/PIC/R2000ICO.jpg , 27100
R2000_C_Demo/PIC/R2000_Back.jpg , 13476
R2000_C_Demo/PIC/R2000_HMI_Housing.jpg , 25069
R2000_C_Demo/PIC/R2000_Light.jpg , 7329
R2000_C_Demo/PIC/R2000_Pixcel_Arrangment.jpg , 98880
R2000_C_Demo/PIC/R2000_PolarCo_Screen.jpg , 100772
R2000_C_Demo/PIC/R2000_Polar_Housing.jpg , 24810
R2000_C_Demo/PIC/R2000_ScanSamples_Screen.jpg , 122785
R2000_C_Demo/PIC/R2000_Small.jpg , 9900
R2000_C_Demo/Program.cs , 510
R2000_C_Demo/Properties/AssemblyInfo.cs , 1571
R2000_C_Demo/Properties/Resources.Designer.cs , 7904
R2000_C_Demo/Properties/Resources.resx , 9249
R2000_C_Demo/Properties/Settings.Designer.cs , 1114
R2000_C_Demo/Properties/Settings.settings , 249
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_4/R2000-UHD.application , 1998
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_4/R2000-UHD.exe.config.deploy , 144
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_4/R2000-UHD.exe.deploy , 641024
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_4/R2000-UHD.exe.manifest , 4110
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_4/R2000_frei-128.ico.deploy , 51262
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_5/R2000-UHD.application , 1998
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_5/R2000-UHD.exe.config.deploy , 144
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_5/R2000-UHD.exe.deploy , 641536
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_5/R2000-UHD.exe.manifest , 4110
R2000_C_Demo/publish/Application Files/R2000-UHD_1_0_10_5/R2000_frei-128.ico.deploy , 51262
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_6/R2000-UHD.application , 1998
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_6/R2000-UHD.exe.config.deploy , 144
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_6/R2000-UHD.exe.deploy , 641536
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_6/R2000-UHD.exe.manifest , 4110
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_6/R2000_frei-128.ico.deploy , 51262
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_7/R2000-UHD.application , 1998
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_7/R2000-UHD.exe.config.deploy , 144
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_7/R2000-UHD.exe.deploy , 641536
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_7/R2000-UHD.exe.manifest , 4110
R2000_C_Demo/publish/Application Files/R2000-UHD_1_2_10_7/R2000_frei-128.ico.deploy , 51262
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_10_8/R2000-UHD.application , 1998
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_10_8/R2000-UHD.exe.config.deploy , 144
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_10_8/R2000-UHD.exe.deploy , 751616
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_10_8/R2000-UHD.exe.manifest , 5156
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_10_8/R2000_frei-128.ico.deploy , 51262
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_10_8/zh-Hans/Microsoft.VisualBasic.PowerPacks.Vs.resources.dll.deploy , 61008
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_10/AxInterop.AcroPDFLib.dll.deploy , 9216
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_10/Interop.AcroPDFLib.dll.deploy , 12800
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_10/R2000-UHD.application , 2001
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_10/R2000-UHD.exe.config.deploy , 144
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_10/R2000-UHD.exe.deploy , 753152
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_10/R2000-UHD.exe.manifest , 6431
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_10/R2000_frei-128.ico.deploy , 51262
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_10/zh-Hans/Microsoft.VisualBasic.PowerPacks.Vs.resources.dll.deploy , 61008
R2000_C_Demo/publish/Application Files/R2000-UHD_1_3_11_9/AxInterop.AcroPDFLib.dll.deploy , 9216
最多只能显示150条信息!
