页面逻辑添加
This commit is contained in:
@@ -90,7 +90,7 @@ namespace 片剂四用仪.Views
|
|||||||
var tb = FindName(m.TextBoxName) as TextBox;
|
var tb = FindName(m.TextBoxName) as TextBox;
|
||||||
if (tb == null) continue;
|
if (tb == null) continue;
|
||||||
|
|
||||||
tb.LostFocus += async (s, e) =>
|
tb.GotFocus += async (s, e) =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -103,14 +103,17 @@ namespace 片剂四用仪.Views
|
|||||||
{
|
{
|
||||||
if (double.TryParse(tb.Text, out double val))
|
if (double.TryParse(tb.Text, out double val))
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(val);
|
// 弹窗修改值
|
||||||
ushort[] regs = new ushort[2];
|
|
||||||
regs[0] = (ushort)(BitConverter.ToUInt16(bytes, 2));
|
|
||||||
regs[1] = (ushort)(BitConverter.ToUInt16(bytes, 0));
|
|
||||||
|
|
||||||
if (UIInputDialog.ShowInputDoubleDialog(ref val, UIStyle.Inherited, 3, desc: "请输入值", showMask: false))
|
if (UIInputDialog.ShowInputDoubleDialog(ref val, UIStyle.Inherited, 3, desc: "请输入值", showMask: false))
|
||||||
{
|
{
|
||||||
|
// 更新界面
|
||||||
|
tb.Text = val.ToString("F3");
|
||||||
|
|
||||||
|
// 写入PLC(浮点数双寄存器)
|
||||||
|
byte[] bytes = BitConverter.GetBytes(val);
|
||||||
|
ushort[] regs = new ushort[2];
|
||||||
|
regs[0] = (ushort)BitConverter.ToUInt16(bytes, 2);
|
||||||
|
regs[1] = (ushort)BitConverter.ToUInt16(bytes, 0);
|
||||||
await _plc.WriteRegisterAsync((ushort)m.Address, (ushort)val);
|
await _plc.WriteRegisterAsync((ushort)m.Address, (ushort)val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user