From 4d94b1bed58899e130a06615d15d6f16ff37d5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Wed, 14 Sep 2022 10:14:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=9C=B0=E5=9D=80=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HKControl/Main.cs | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/HKControl/Main.cs b/HKControl/Main.cs index 9d4dc11..e2f6bc0 100644 --- a/HKControl/Main.cs +++ b/HKControl/Main.cs @@ -68,11 +68,20 @@ namespace HKControl { ThreadManage.GetInstance().StartLong(new Action(() => { - DataModels[item.DeviceNum].LeftWindowData.IsSwipe = SiemensDicitonary[item.DeviceNum].Read("M0.0"); - DataModels[item.DeviceNum].LeftWindowData.Complete = SiemensDicitonary[item.DeviceNum].Read("M0.0"); + var res = SiemensDicitonary[item.DeviceNum].Read("MB7"); - DataModels[item.DeviceNum].RightWindowData.IsSwipe = SiemensDicitonary[item.DeviceNum].Read("M0.0"); - DataModels[item.DeviceNum].RightWindowData.Complete = SiemensDicitonary[item.DeviceNum].Read("M0.0"); + DataModels[item.DeviceNum].LeftWindowData.IsSwipe = Get8bitValue(res, 1); + DataModels[item.DeviceNum].LeftWindowData.Complete = Get8bitValue(res, 2); + + DataModels[item.DeviceNum].RightWindowData.IsSwipe = Get8bitValue(res, 3); + DataModels[item.DeviceNum].RightWindowData.Complete = Get8bitValue(res, 4); + + + //DataModels[item.DeviceNum].LeftWindowData.IsSwipe = SiemensDicitonary[item.DeviceNum].Read("M7.0"); + //DataModels[item.DeviceNum].LeftWindowData.Complete = SiemensDicitonary[item.DeviceNum].Read("M7.1"); + + //DataModels[item.DeviceNum].RightWindowData.IsSwipe = SiemensDicitonary[item.DeviceNum].Read("M7.2"); + //DataModels[item.DeviceNum].RightWindowData.Complete = SiemensDicitonary[item.DeviceNum].Read("M7.3"); Thread.Sleep(100); }), $"{item.DeviceNum} 号设备监听"); @@ -94,18 +103,22 @@ namespace HKControl switch (carNum) { case 1: + SiemensDicitonary[1].Write("M6.0", true); + break; case 2: - SiemensDicitonary[1].Write("M0.0", true); + SiemensDicitonary[1].Write("M6.1", true); break; - case 3: + SiemensDicitonary[2].Write("M6.0", true); + break; case 4: - SiemensDicitonary[2].Write("M0.0", true); + SiemensDicitonary[2].Write("M6.1", true); break; - case 5: + SiemensDicitonary[3].Write("M6.0", true); + break; case 6: - SiemensDicitonary[3].Write("M0.0", true); + SiemensDicitonary[3].Write("M6.1", true); break; default: @@ -145,5 +158,17 @@ namespace HKControl Json.Save(); } } + + /// + /// 获取字节中指定位的值 + /// + /// 要获取的整数 + /// 偏移量 范围(1-8) + /// + public bool Get8bitValue(byte data, byte offset) + { + if (offset > 8 || offset < 1) return false; + return (data & 1 << offset - 1) == 0 ? false : true; + } } } \ No newline at end of file