结构整理,修改文件编码格式适配VS gb2312
This commit is contained in:
@@ -106,7 +106,9 @@ namespace WPFSerialAssistant
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoSendData()
|
||||
|
||||
|
||||
private void AutoSendData()
|
||||
{
|
||||
bool ret = SendData();
|
||||
|
||||
|
||||
@@ -435,11 +435,6 @@
|
||||
Header="功能按键">
|
||||
<StackPanel>
|
||||
|
||||
<TextBox
|
||||
x:Name="textVersion"
|
||||
Margin="5"
|
||||
Padding="10" />
|
||||
|
||||
<Button
|
||||
x:Name="getVersionButton"
|
||||
Margin="5"
|
||||
|
||||
@@ -25,55 +25,137 @@ namespace WPFSerialAssistant
|
||||
InitializeComponent();
|
||||
InitCore();
|
||||
}
|
||||
// 单次锁存
|
||||
// 单次锁存 可以通过单次锁存,读取当前的位置值
|
||||
private void SingleLatch_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//1 清空缓存
|
||||
string cmd = "01 06";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//2 设置单次模式
|
||||
cmd = "01 01 01";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//3 开始锁存
|
||||
cmd = "01 02";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//4 读取锁存值
|
||||
cmd = "01 09";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
}
|
||||
//定时锁存
|
||||
//定时锁存 每10ms(1000*10us),即100HZ,锁存一次位置的值,发一个脉冲
|
||||
private void TimingLatches_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//1 清空缓存
|
||||
string cmd = "01 06";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//2 设置定时模式
|
||||
cmd = "01 01 02 03 e8";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//3 开始锁存
|
||||
cmd = "01 02";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//4 停止锁存
|
||||
cmd = "01 03";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//5 读取锁存值
|
||||
cmd = "01 09";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//6 清空数据与flash
|
||||
cmd = "01 04";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
}
|
||||
//分频锁存
|
||||
//分频锁存 以X轴为基准,每20个脉冲锁存一次,并发送一次脉冲
|
||||
private void FreDivsionRadioButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//1 清空缓存
|
||||
string cmd = "01 06";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//2 设置定时模式
|
||||
cmd = "01 01 03 00 00 14 01";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//3 开始锁存
|
||||
cmd = "01 02";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//4 停止锁存
|
||||
cmd = "01 03";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//5 读取锁存值
|
||||
cmd = "01 09";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
|
||||
//6 清空数据与flash
|
||||
cmd = "01 04";
|
||||
SerialPortWrite(cmd);
|
||||
Utilities.sleep(5);
|
||||
}
|
||||
//获取固件版本
|
||||
private void GetVersionButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string cmd = "01 08";
|
||||
SerialPortWrite(cmd);
|
||||
}
|
||||
//设置归零
|
||||
//设置归零,表示XYZ轴的清零,把当前的位置读数重置为0.
|
||||
private void SetZeroButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string cmd = "01 06";
|
||||
SerialPortWrite(cmd);
|
||||
}
|
||||
//开始锁存
|
||||
private void StartRecordButtion_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string cmd = "01 02";
|
||||
SerialPortWrite(cmd);
|
||||
}
|
||||
//停止锁存
|
||||
private void StopRecordButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string cmd = "01 03";
|
||||
SerialPortWrite(cmd);
|
||||
}
|
||||
//获取锁存值
|
||||
private void GetRecordButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string cmd = "01 09";
|
||||
SerialPortWrite(cmd);
|
||||
}
|
||||
//清除Flash区
|
||||
private void ClearFlashButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string cmd = "01 04";
|
||||
SerialPortWrite(cmd);
|
||||
}
|
||||
//获得锁存点数量
|
||||
private void GetPointsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string cmd = "01 05";
|
||||
SerialPortWrite(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
//using System.Windows;
|
||||
//using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WPFSerialAssistant
|
||||
{
|
||||
public static class Utilities
|
||||
public static class Utilities
|
||||
{
|
||||
public static double m_Resolution = 0.0001; //分辨率设置 0.1um
|
||||
public static string BytesToText(List<byte> bytesBuffer, ReceiveMode mode, Encoding encoding)
|
||||
@@ -117,5 +118,28 @@ namespace WPFSerialAssistant
|
||||
return result.Trim();
|
||||
}
|
||||
|
||||
}
|
||||
public static void sleep(int milliSecond)
|
||||
{
|
||||
int start = Environment.TickCount;
|
||||
while (Math.Abs(Environment.TickCount - start) < milliSecond)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Delay(int delayTime)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
int s;
|
||||
do
|
||||
{
|
||||
TimeSpan spand = DateTime.Now - now;
|
||||
s = spand.Seconds;
|
||||
Application.DoEvents();
|
||||
}
|
||||
while (s < delayTime);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
Reference in New Issue
Block a user