old mode 100755
new mode 100644
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 网关接收事件(参数1:主题 参数2:推送消息) |
| | | /// </summary> |
| | | private Action<string, string> GatewayReceiveEvent = null; |
| | | /// <summary> |
| | | /// 接收网关的id |
| | | /// </summary> |
| | | private string GatewayReceiveId = null; |
| | | /// <summary> |
| | | /// 设备推送事件集合
|
| | | /// </summary>
|
| | | private Dictionary<string, Action<CommonDevice>> dicDeviceEvent = new Dictionary<string, Action<CommonDevice>>();
|
| | |
| | | /// <param name="msgData">接收的数据</param>
|
| | | public void GatewayOverallMsgReceive(string gatewayId, string topic, string reportTopic, string msgData)
|
| | | {
|
| | | //如果它在登陆界面,则不做任何处理 |
| | | if (Common.Config.Instance.HomeId == string.Empty) |
| | | { |
| | | return; |
| | | } |
| | | if (topic == "AppNoLogin")
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | |
| | | {
|
| | | if (HdlGatewayLogic.Current.IsGatewayExist(gatewayId) == false)
|
| | | {
|
| | | //不是自己绑定的网关,则不处理
|
| | | //不是自己绑定的网关,则不处理,但是下面这个东西有点特殊 |
| | | if (gatewayId == this.GatewayReceiveId) |
| | | { |
| | | this.GatewayReceiveEvent?.Invoke(topic, msgData); |
| | | } |
| | | return;
|
| | | }
|
| | | //设备属性上报
|
| | |
| | | {
|
| | | this.SceneExecPush(null);
|
| | | }
|
| | | //网关接收事件 |
| | | else if (gatewayId == this.GatewayReceiveId) |
| | | { |
| | | this.GatewayReceiveEvent?.Invoke(topic, msgData); |
| | | } |
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | var tempList = Common.LocalDevice.Current.GetDevicesByMac(report.DeviceAddr, false); |
| | | var res = Common.LocalDevice.Current.GetMyDeviceEnumInfo(tempList); |
| | | if (res.ConcreteType == Common.DeviceConcreteType.Airer) |
| | | { |
| | | //晾衣架特殊处理,本地只存了端点1,其余2~5端点都不存 |
| | | deviceEpoint = 1; |
| | | } |
| | | //处理网关上报的数据,然后变更本地缓存
|
| | | var locadevice = Common.LocalDevice.Current.GetDevice(deviceAddr, deviceEpoint);
|
| | | if (locadevice != null)
|
| | |
| | | locadevice.LastDateTime = DateTime.Now;
|
| | |
|
| | | #region ■ 开关功能
|
| | | //晾衣架回路2,3,4,5都是CluterID是6 ,但是功能不是开关 |
| | | if (locadevice.Type == DeviceType.Airer) |
| | | { |
| | | if (report.DeviceStatusReport.CluterID == 6) |
| | | { |
| | | foreach (var attData in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport; |
| | | if (attData.AttributeId == 0) |
| | | { |
| | | //注意晾衣架回路上报都端点都是被替换为回路1,所以这里用上报都回路 |
| | | switch (report.DeviceEpoint) |
| | | { |
| | | //照明 |
| | | case 2: |
| | | ((Airer)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | break; |
| | | //风干 |
| | | case 3: |
| | | ((Airer)locadevice).WindOnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | break; |
| | | //烘干 |
| | | case 4: |
| | | ((Airer)locadevice).DryOnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | break; |
| | | //消毒 |
| | | case 5: |
| | | ((Airer)locadevice).DisinfectOnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //晾衣架(风干/烘干/消毒)设置的默认时间 |
| | | // 注意,第一阶段时间设备不支持而暂停,没有处理剩余多少时间触发,直接上报回复一个属性ID的情况 |
| | | //if (attData.AttributeId == 16385) |
| | | //{ |
| | | // //注意晾衣架回路上报都端点都是被替换为回路1,所以这里用上报都回路 |
| | | // switch (report.DeviceEpoint) |
| | | // { |
| | | // //风干 |
| | | // case 3: |
| | | // ((Airer)locadevice).WindTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | // break; |
| | | // //烘干 |
| | | // case 4: |
| | | // ((Airer)locadevice).DryTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | // break; |
| | | // //消毒 |
| | | // case 5: |
| | | // ((Airer)locadevice).DisinfectTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | // break; |
| | | // } |
| | | //} |
| | | //晾衣架(风干/烘干/消毒)设置的剩余多少时间触发 |
| | | // 注意,第一阶段时间设备不支持而暂停,没有处理剩余多少时间触发,直接上报回复一个属性ID的情况 |
| | | //if (attData.AttributeId == 16386) |
| | | //{ |
| | | // //注意晾衣架回路上报都端点都是被替换为回路1,所以这里用上报都回路 |
| | | // switch (report.DeviceEpoint) |
| | | // { |
| | | // //风干 |
| | | // case 3: |
| | | // ((Airer)locadevice).WindRemainTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | // break; |
| | | // //烘干 |
| | | // case 4: |
| | | // ((Airer)locadevice).DryRemainTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | // break; |
| | | // //消毒 |
| | | // case 5: |
| | | // ((Airer)locadevice).DisinfectRemainTime = report.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | // break; |
| | | // } |
| | | //} |
| | | |
| | | //已经接收到状态 |
| | | locadevice.HadReadDeviceStatu = true; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //开关功能
|
| | | if (report.DeviceStatusReport.CluterID == 6)
|
| | | {
|
| | |
| | | ((LightBase)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | } |
| | | }
|
| | | }
|
| | | #endregion
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 添加网关接收事件(action只能存在一个,与AddAttributeEvent不共存,AddAttributeEvent优先) |
| | | /// </summary> |
| | | /// <param name="i_gatewayId">网关id</param> |
| | | /// <param name="action">只能存在一个action (参数1:主题 参数2:推送消息)</param> |
| | | public void AddGatewayReceiveEvent(string i_gatewayId, Action<string, string> action) |
| | | { |
| | | //添加事件 |
| | | this.GatewayReceiveEvent = action; |
| | | this.GatewayReceiveId = i_gatewayId; |
| | | } |
| | | |
| | | #endregion
|
| | |
|
| | | #region ■ 移除设备监听_______________________
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 移除网关接收事件(只能存在一个事件) |
| | | /// </summary> |
| | | public void RemoveGatewayReceiveEvent() |
| | | { |
| | | this.GatewayReceiveEvent = null; |
| | | this.GatewayReceiveId = null; |
| | | } |
| | | |
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|