调试
This commit is contained in:
@@ -22,18 +22,20 @@ namespace 头罩视野.Views
|
||||
/// <summary>
|
||||
/// VisiData.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
|
||||
|
||||
|
||||
public partial class VisiData : Page
|
||||
{
|
||||
private TcpClient _tcpClient => ModbusResourceManager.Instance.TcpClient;
|
||||
private IModbusMaster _modbusMaster => ModbusResourceManager.Instance.ModbusMaster;
|
||||
|
||||
DispatcherTimer _timer;
|
||||
DataChange c = new DataChange();
|
||||
Function ma;
|
||||
public VisiData()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeModbusTcp();
|
||||
_timer = InitDispatcherTimer();
|
||||
}
|
||||
//复位btn
|
||||
private void Button_Click_Reset(object sender, RoutedEventArgs e)
|
||||
@@ -50,18 +52,53 @@ namespace 头罩视野.Views
|
||||
{
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||
}
|
||||
|
||||
|
||||
//反转
|
||||
private void Button_Click_Res(object sender, RoutedEventArgs e)
|
||||
private bool _isPressing = false;
|
||||
private async void Button_Click_ResDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 10);
|
||||
((Button)sender).CaptureMouse();
|
||||
_isPressing = true;
|
||||
await Task.Run(() => {
|
||||
//重新占位写入
|
||||
_modbusMaster.WriteSingleCoilAsync(1, 10, true);
|
||||
Task.Delay(100);
|
||||
System.Diagnostics.Debug.WriteLine("stard1111");
|
||||
});
|
||||
}
|
||||
|
||||
private void Button_Click_ResUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
((Button)sender).ReleaseMouseCapture();
|
||||
_isPressing = false;
|
||||
System.Diagnostics.Debug.WriteLine("end1111");
|
||||
|
||||
}
|
||||
//正转
|
||||
private void Button_Click_For(object sender, RoutedEventArgs e)
|
||||
|
||||
private bool _isPressing1 = false;
|
||||
private async void Button_Click_ForDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 11);
|
||||
((Button)sender).CaptureMouse();
|
||||
_isPressing1 = true;
|
||||
|
||||
await Task.Run(() => {
|
||||
//重新占位写入
|
||||
_modbusMaster.WriteSingleCoilAsync(1, 11, true);
|
||||
System.Diagnostics.Debug.WriteLine("正传start");
|
||||
Task.Delay(100);
|
||||
});
|
||||
}
|
||||
|
||||
private void Button_Click_ForUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
((Button)sender).ReleaseMouseCapture();
|
||||
|
||||
_isPressing1 = false;
|
||||
System.Diagnostics.Debug.WriteLine("正传end");
|
||||
}
|
||||
|
||||
|
||||
//测试btn
|
||||
private void Button_Click_Test(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -73,7 +110,7 @@ namespace 头罩视野.Views
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 103);
|
||||
}
|
||||
//读取
|
||||
//读取数据
|
||||
//读取数据
|
||||
private DispatcherTimer InitDispatcherTimer()
|
||||
{
|
||||
var timer = new DispatcherTimer
|
||||
@@ -134,7 +171,7 @@ namespace 头罩视野.Views
|
||||
ShowError($"读取数据失败:{ex.Message}");
|
||||
}
|
||||
}
|
||||
// 地址, 根据格式显示字符长度 32:2 16:1 ,绑定页面的name 值,F2 保留两位小数,单位
|
||||
// 地址, 根据格式显示字符长度 32:2 16:1 ,绑定页面的name 值,F2 保留两位小数,单位
|
||||
private async Task ReadAndUpdateFloatAsync(int address, int length, System.Windows.Controls.TextBox control, string format, string unit)
|
||||
{
|
||||
try
|
||||
@@ -238,7 +275,6 @@ namespace 头罩视野.Views
|
||||
return;
|
||||
}
|
||||
|
||||
ma = new Function(_modbusMaster);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -248,8 +284,10 @@ namespace 头罩视野.Views
|
||||
}
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_timer.Start();
|
||||
|
||||
//InitializeModbusTcp();
|
||||
ma = new Function(_modbusMaster);
|
||||
c = new DataChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user