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