wxr
2020-05-11 7f233a10afa6882b4d9531185af60e8843bc1af2
HDL_ON/DriverLayer/Control_Bus.cs
@@ -3,6 +3,8 @@
using HDL_ON.DAL;
using HDL_ON.DAL.Net;
using HDL_ON.Entity;
using Shared;
using Shared.Net;
namespace HDL_ON
{
@@ -32,6 +34,72 @@
            MainPage.Log(command.ToString() + "::" + CommonPage.EndPoint.ToString());
        }
        /// <summary>
        /// 000E 搜索回复
        /// </summary>
        /// <param name="usefullBytes"></param>
        static void ReceiveReadRemark(byte[] usefullBytes)
        {
            try
            {
                //账号没登录不回复
                if (MainPage.LoginUser == null || !MainPage.LoginUser.IsLogin)
                {
                    return;
                }
                //if (!isHttpListenerStart)
                //{
                //    //数据接收端口没打开,不回复
                //    return;
                //}
                var sendStr = MainPage.LoginUser.accountString;
                //如果IP地址获取成功 显示最后一位
                var mAddressBytes = new Shared.Net.NetWiFi().IpAddress.GetAddressBytes();
                if (mAddressBytes != null && mAddressBytes.Length == 4)
                {
                    sendStr = (mAddressBytes[3] & 0xFF).ToString() + ":" + sendStr;
                }
                if (usefullBytes.Length <= 2)
                {
                    byte[] sendBytes = new byte[20];
                    byte[] b1 = CommonPage.MyEncodingGB2312.GetBytes(sendStr);
                    Array.Copy(b1, 0, sendBytes, 0, 20 < b1.Length ? 20 : b1.Length);
                    Control.ControlBytesSend(Command.ReadRemarkACK, 0xFF, 0xFF, sendBytes, 1);
                }
                else
                {
                    for (int i = 2, len = usefullBytes.Length; i < len; i++)
                    {
                        if (i % 2 == 0)
                        {
                            if ((usefullBytes[i] & 0xFF) == 0xFC
                                    && (usefullBytes[i + 1] & 0xFF) == 0xFC
                            )
                            {
                                byte[] sendBytes = new byte[20];
                                byte[] b1 = CommonPage.MyEncodingGB2312.GetBytes(sendStr);
                                //Remote_GroupName = CommonPage.MyEncodingGB2312.GetString (b1);
                                Array.Copy(b1, 0, sendBytes, 0, 20 < b1.Length ? 20 : b1.Length);
                                Control.ControlBytesSend(Command.ReadRemarkACK, 0xFF, 0xFF, sendBytes, 1);
                                break;
                            }
                        }
                    }
                }
            }
            catch { }
        }
        /// <summary>
        /// 处理接收回来的数据
@@ -58,7 +126,13 @@
                    case Command.ReadLogicLoopColorACK:
                    case Command.ReadACModeACK:
                    case Command.SetACModeACK:
                    case Command.ReadFloorHeatACK:
                    case Command.SetFloorHeatACK:
                        receiveFlag += string.Format("{0}", usefulBytes[0]);
                        break;
                    case Command.ReadRemark:
                        //buspro 读备注回复
                        ReceiveReadRemark(usefulBytes);
                        break;
                    //case Command.YIPanelDeviceInofACK:
                    //    for (int i = 0; i < 4; i++)
@@ -445,6 +519,8 @@
                case Command.ReadLogicLoopColor:
                case Command.ReadACMode:
                case Command.SetACMode:
                case Command.ReadFloorHeat:
                case Command.SetFloorHeat:
                    this.sendFlag += string.Format("{0}", target.AddData[0]);
                    break;
                case Command.SetLogicLoopColor: