| | |
| | | /// <param name="gatewayId">网关ID</param>
|
| | | /// <param name="topic">整个主题</param>
|
| | | /// <param name="reportTopic">上报数据的主题</param>
|
| | | /// <param name="receiveData">接收的数据</param>
|
| | | public void GatewayOverallMsgReceive(string gatewayId, string topic, string reportTopic, JObject receiveData)
|
| | | /// <param name="msgData">接收的数据</param>
|
| | | public void GatewayOverallMsgReceive(string gatewayId, string topic, string reportTopic, string msgData)
|
| | | {
|
| | | if (topic == "AppNoLogin")
|
| | | {
|
| | |
| | | });
|
| | | return;
|
| | | }
|
| | | else if (topic == "BeingSqueezedOffline")
|
| | | else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze")
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | |
| | | });
|
| | | return;
|
| | | }
|
| | | else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Home.Id + "_" + Common.Config.Instance.Guid + "/PrimaryUserDelYou")
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //分享住宅已更改,请联系管理员!
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uShardResidenceHadDeletePleaseTakeToAdmin);
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
| | | contr.Show();
|
| | |
|
| | | UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
|
| | | });
|
| | | return;
|
| | | }
|
| | | else if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Update")
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //您的权限已经变更,请重新登陆
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uYouAccessHadChangedPleaseTakeToAdmin);
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
| | | contr.Show();
|
| | |
|
| | | UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
|
| | | });
|
| | | return;
|
| | | }
|
| | | else if (UserCenterResourse.UserInfo.AuthorityNo == 3)
|
| | | {
|
| | | if (topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/Deleted"
|
| | | || topic == "ZigbeeGateWayToClient/" + Common.Config.Instance.Guid + "/Push/DeletedShareData")
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //分享数据已经变更,请重新登陆
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uShardDataIsChangedPleaseLoginAgain);
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
| | | contr.Show();
|
| | |
|
| | | UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
|
| | | });
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | try
|
| | | {
|
| | | if (HdlGatewayLogic.Current.IsGatewayExist(gatewayId) == false)
|
| | |
| | | //不是自己绑定的网关,则不处理
|
| | | return;
|
| | | }
|
| | |
|
| | | //设备属性上报
|
| | | if (reportTopic == "DeviceStatusReport")
|
| | | {
|
| | | //设备属性上报
|
| | | this.DeviceAttributeReportPush(receiveData);
|
| | | this.DeviceAttributeReportPush(JObject.Parse(msgData));
|
| | | }
|
| | | //传感器上报
|
| | | else if (reportTopic == "IASInfoReport")
|
| | | {
|
| | | this.SensorDeviceReportPush(receiveData);
|
| | | this.SensorDeviceReportPush(JObject.Parse(msgData));
|
| | | }
|
| | | //门锁上报
|
| | | else if (topic == gatewayId + "/Alarms/SendAlarmInform")
|
| | | {
|
| | | this.DoorLockDeviceReportPush(receiveData);
|
| | | this.DoorLockDeviceReportPush(JObject.Parse(msgData));
|
| | | }
|
| | | //通过外部方式布防撤防成功时报告
|
| | | else if (topic == gatewayId + "/Security/EnOrWithdrawSucceedReport")
|
| | | {
|
| | | this.SecurityEnOrWithdrawSucceedReport(receiveData);
|
| | | this.SecurityEnOrWithdrawSucceedReport(JObject.Parse(msgData));
|
| | | }
|
| | | //设备在线状态更新反馈
|
| | | else if (reportTopic == "OnlineStatusChange_Respon")
|
| | | {
|
| | | this.DeviceOnlineChangePush(receiveData);
|
| | | this.DeviceOnlineChangePush(JObject.Parse(msgData));
|
| | | }
|
| | | //设备控制状态反馈
|
| | | else if (reportTopic == "DeviceDefaultAck")
|
| | | {
|
| | | this.DeviceControlResponePush(JObject.Parse(msgData));
|
| | | }
|
| | | //撤防
|
| | | else if (topic == gatewayId + "/Security/WithdrawMode_Respon")
|
| | | {
|
| | | this.RemoveSafetyGarrisonPush(receiveData);
|
| | | this.RemoveSafetyGarrisonPush(JObject.Parse(msgData));
|
| | | }
|
| | | //布防
|
| | | else if (topic == gatewayId + "/Security/EnableMode_Respon")
|
| | | {
|
| | | this.SetSafetyGarrisonPush(receiveData);
|
| | | this.SetSafetyGarrisonPush(JObject.Parse(msgData));
|
| | | }
|
| | | //逻辑触发上报
|
| | | else if (topic == gatewayId + "/Logic/Execute_Respon")
|
| | | {
|
| | | this.LogicExecutePush(receiveData);
|
| | | this.LogicExecutePush(JObject.Parse(msgData));
|
| | | }
|
| | | //场景触发上报
|
| | | else if (topic == gatewayId + "/Scene/Exec_Respon")
|
| | | {
|
| | | this.SceneExecPush(receiveData);
|
| | | this.SceneExecPush(null);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | |
| | | /// <param name="receiveData"></param>
|
| | | private void DeviceAttributeReportPush(JObject receiveData)
|
| | | {
|
| | | if (this.dicDeviceEvent.Count == 0)
|
| | | {
|
| | | //没有添加监听
|
| | | return;
|
| | | }
|
| | | var deviceAddr = receiveData.Value<string>("DeviceAddr");
|
| | | var deviceEpoint = receiveData.Value<int>("Epoint");
|
| | |
|
| | | var tempDevice = new CommonDevice { DeviceAddr = deviceAddr, DeviceEpoint = deviceEpoint };
|
| | | tempDevice.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceStatusReportData>(receiveData["Data"].ToString());
|
| | | var report = new CommonDevice { DeviceAddr = deviceAddr, DeviceEpoint = deviceEpoint };
|
| | | report.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceStatusReportData>(receiveData["Data"].ToString());
|
| | | if (report.DeviceStatusReport.AttriBute.Count == 0)
|
| | | {
|
| | | //网关有些奇葩,没有属性它也会发过来
|
| | | return;
|
| | | }
|
| | |
|
| | | this.DeviceReportPush(tempDevice, ReceiveComandDiv.A设备属性上报);
|
| | | //处理网关上报的数据,然后变更本地缓存
|
| | | var locadevice = Common.LocalDevice.Current.GetDevice(deviceAddr, deviceEpoint);
|
| | | if (locadevice != null)
|
| | | {
|
| | | //有反馈,这个设备肯定是在线的
|
| | | locadevice.IsOnline = 1;
|
| | | locadevice.LastDateTime = DateTime.Now;
|
| | |
|
| | | #region ■ 开关功能
|
| | | //开关功能
|
| | | if (report.DeviceStatusReport.CluterID == 6)
|
| | | {
|
| | | if (locadevice is LightBase)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | ((LightBase)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 窗帘数据
|
| | | //窗帘数据
|
| | | else if (report.DeviceStatusReport.CluterID == 258)
|
| | | {
|
| | | //窗帘类型
|
| | | if (report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | ((Rollershade)locadevice).WcdType = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | //这个东西要保存
|
| | | locadevice.ReSave();
|
| | | }
|
| | | //窗帘百分比
|
| | | else if (report.DeviceStatusReport.AttriBute[0].AttributeId == 8)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | ((Rollershade)locadevice).WcdCurrentPositionLiftPercentage = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 空调和新风数据
|
| | | //空调数据
|
| | | else if (report.DeviceStatusReport.CluterID == 513)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | foreach (var attData in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | var curTemp = attData.AttriButeData / 100;
|
| | | if (attData.AttributeId == 0)
|
| | | {
|
| | | //此属性表明室内当前的温度 * 100,实际温度为“LocalTemperature / 100”,单位:℃
|
| | | ((AC)locadevice).currentLocalTemperature = curTemp;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | else if (attData.AttributeId == 17)
|
| | | {
|
| | | //此属性表明室内当前的温度 * 100,实际温度为“LocalTemperature / 100”,单位:℃
|
| | | ((AC)locadevice).currentCoolingSetpoint = curTemp;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | else if (attData.AttributeId == 18)
|
| | | {
|
| | | //此属性表明此设备当前的制热温度,实际温度为“HeatingSetpoint / 100”,单位:℃。
|
| | | ((AC)locadevice).currentHeatingSetpoint = curTemp;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | else if (attData.AttributeId == 28)
|
| | | {
|
| | | //此属性描述恒温设备正处于哪种模式
|
| | | ((AC)locadevice).currentSystemMode = attData.AttriButeData;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | else if (attData.AttributeId == 4096)
|
| | | {
|
| | | //此属性表明此设备当前的自动温度,实际温度为“AutoSetpoint / 100”,单位:℃。
|
| | | ((AC)locadevice).currentAutoSetpoint = curTemp;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | else if (attData.AttributeId == 4097)
|
| | | {
|
| | | //过虑网清洗标志:42
|
| | | ((AC)locadevice).CleanStatu = attData.AttriButeData == 42;
|
| | | }
|
| | | else if (attData.AttributeId == 4099)
|
| | | {
|
| | | //转换为二进制
|
| | | var value = Convert.ToString(attData.AttriButeData, 2).PadLeft(16, '0');
|
| | | //这五个设置是放在后面的
|
| | | value = value.Substring(value.Length - 5, 5);
|
| | | for (int i = 0; i < value.Length; i++)
|
| | | {
|
| | | //自定义的空调模式
|
| | | ((AC)locadevice).listSupportMode[i] = Convert.ToInt32(value[i].ToString());
|
| | | }
|
| | | locadevice.ReSave();
|
| | | }
|
| | | }
|
| | | }
|
| | | //空调数据
|
| | | else if (report.DeviceStatusReport.CluterID == 514)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | foreach (var attData in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | //区分是空调还是新风
|
| | | var device = Shared.Common.LocalDevice.Current.GetDevice(report.DeviceAddr, report.DeviceEpoint);
|
| | |
|
| | | if (device.Type == DeviceType.FreshAir)
|
| | | {
|
| | | if (attData.AttributeId == 0)
|
| | | {
|
| | | switch (attData.AttriButeData)
|
| | | {
|
| | | case 0:
|
| | | case 4:
|
| | | ((FreshAir)locadevice).currentFanStatus = attData.AttriButeData;
|
| | | break;
|
| | | case 1:
|
| | | case 2:
|
| | | case 3:
|
| | | ((FreshAir)locadevice).currentFanSpeed = attData.AttriButeData;
|
| | | break;
|
| | | case 5:
|
| | | case 15:
|
| | | ((FreshAir)locadevice).currentFanMode = attData.AttriButeData;
|
| | | break;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (attData.AttributeId == 0)
|
| | | {
|
| | | //风扇模式
|
| | | ((AC)locadevice).currentFanMode = attData.AttriButeData;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | else if (attData.AttributeId == 4096)
|
| | | {
|
| | | //风扇扫风
|
| | | ((AC)locadevice).currentFanSwingMode = attData.AttriButeData;
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | else if (attData.AttributeId == 4097)
|
| | | {
|
| | | //转换为二进制
|
| | | var value = Convert.ToString(attData.AttriButeData, 2).PadLeft(16, '0');
|
| | | //这个设置是放在后面的
|
| | | value = value.Substring(value.Length - 1, 1);
|
| | | //启用摆风功能
|
| | | ((AC)locadevice).UseSwingFunction = value == "1";
|
| | | locadevice.ReSave();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 亮度数据
|
| | | //亮度数据
|
| | | else if (report.DeviceStatusReport.CluterID == 8)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | if (report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
|
| | | {
|
| | | if (locadevice.Type == DeviceType.DimmableLight)
|
| | | {
|
| | | //此属性表明当前亮度程度
|
| | | ((DimmableLight)locadevice).Level = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | }
|
| | | else if (locadevice.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | //此属性表明当前亮度程度
|
| | | ((ColorTemperatureLight)locadevice).Level = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 色温数据
|
| | | //色温数据
|
| | | else if (report.DeviceStatusReport.CluterID == 768)
|
| | | {
|
| | | locadevice.DeviceStatusReport = report.DeviceStatusReport;
|
| | | if (report.DeviceStatusReport.AttriBute[0].AttributeId == 0)
|
| | | {
|
| | | if (locadevice.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | //此属性表明当前色温
|
| | | ((ColorTemperatureLight)locadevice).ColorTemperature = report.DeviceStatusReport.AttriBute[0].AttriButeData;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 温度数据
|
| | | //温度数据
|
| | | else if (report.DeviceStatusReport.CluterID == 1026)
|
| | | {
|
| | | foreach (var attData in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | //温度
|
| | | if (attData.AttributeId == (int)AttriButeId.MeasuredValue)
|
| | | {
|
| | | decimal temperatrue = 0;
|
| | | string receiptData = string.Empty;
|
| | | //两个两个位置替换
|
| | | for (int i = attData.AttriButeDataHex.Length - 1; i >= 0; i = i - 2)
|
| | | {
|
| | | receiptData += attData.AttriButeDataHex[i - 1].ToString() + attData.AttriButeDataHex[i].ToString();
|
| | | }
|
| | | //有符号(会出现负数)
|
| | | if (attData.AttriButeDataType == 40 || attData.AttriButeDataType == 41)
|
| | | {
|
| | | //小数点需要一位
|
| | | string strValue = Convert.ToInt16(receiptData, 16).ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | //无符号(不会出现负数)
|
| | | else if (attData.AttriButeDataType == 32 || attData.AttriButeDataType == 33)
|
| | | {
|
| | | ushort shortData = Convert.ToUInt16(receiptData, 16);
|
| | | if (shortData > 32767)
|
| | | {
|
| | | //负数(特殊处理)
|
| | | string strValue = (shortData - 65536).ToString();
|
| | | //小数点需要一位
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | else
|
| | | {
|
| | | //小数点需要一位
|
| | | string strValue = shortData.ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | }
|
| | |
|
| | | //温度传感器
|
| | | if (locadevice is TemperatureSensor)
|
| | | {
|
| | | ((TemperatureSensor)locadevice).Temperatrue = temperatrue;
|
| | | }
|
| | | //PM2.5传感器
|
| | | else if (locadevice is PMSensor)
|
| | | {
|
| | | ((PMSensor)locadevice).currentTemperature = (int)temperatrue;
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 湿度数据
|
| | | //湿度数据
|
| | | else if (report.DeviceStatusReport.CluterID == 1029)
|
| | | {
|
| | | foreach (var attData in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | //湿度
|
| | | if (attData.AttributeId == (int)AttriButeId.MeasuredValue)
|
| | | {
|
| | | decimal humidity = 0;
|
| | | string receiptData = string.Empty;
|
| | | //两个两个位置替换
|
| | | for (int i = attData.AttriButeDataHex.Length - 1; i >= 0; i = i - 2)
|
| | | {
|
| | | receiptData += attData.AttriButeDataHex[i - 1].ToString() + attData.AttriButeDataHex[i].ToString();
|
| | | }
|
| | | //有符号(会出现负数)
|
| | | if (attData.AttriButeDataType == 40 || attData.AttriButeDataType == 41)
|
| | | {
|
| | | //小数点需要一位
|
| | | string strValue = Convert.ToInt16(receiptData, 16).ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | //无符号(不会出现负数)
|
| | | else if (attData.AttriButeDataType == 32 || attData.AttriButeDataType == 33)
|
| | | {
|
| | | //小数点需要一位 湿度不会出现负数
|
| | | string strValue = Convert.ToUInt16(receiptData, 16).ToString();
|
| | | strValue = strValue.Substring(0, strValue.Length - 1);
|
| | | humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
|
| | | }
|
| | | //湿度传感器
|
| | | if (locadevice is TemperatureSensor)
|
| | | {
|
| | | ((TemperatureSensor)locadevice).Humidity = humidity;
|
| | | }
|
| | | //新风的湿度传感器
|
| | | else if (locadevice is HumiditySensor)
|
| | | {
|
| | | ((HumiditySensor)locadevice).Humidity = humidity;
|
| | | }
|
| | | //PM2.5传感器
|
| | | else if (locadevice is PMSensor)
|
| | | {
|
| | | ((PMSensor)locadevice).currentHumidity = (int)humidity;
|
| | | }
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ PM2.5数据
|
| | | //PM2.5数据
|
| | | else if (report.DeviceStatusReport.CluterID == 1066)
|
| | | {
|
| | | foreach (var attData in report.DeviceStatusReport.AttriBute)
|
| | | {
|
| | | //PM2.5
|
| | | if (attData.AttributeId == (int)AttriButeId.MeasuredValue)
|
| | | {
|
| | |
|
| | | if (attData.AttriButeDataType == 57)
|
| | | {
|
| | | ((PMSensor)locadevice).currentPmData = attData.AttriButeData;
|
| | | }
|
| | | }
|
| | | //已经接收到状态
|
| | | locadevice.HadReadDeviceStatu = true;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | |
|
| | | this.DeviceReportPush(report, ReceiveComandDiv.A设备属性上报);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | HdlAlarmsLogic.Current.SaveSafeguardAlarmInfo(ias);
|
| | | }
|
| | |
|
| | | //处理网关上报的数据,然后变更本地缓存
|
| | | var locadevice = Common.LocalDevice.Current.GetDevice(ias.DeviceAddr, ias.DeviceEpoint);
|
| | | if (locadevice != null)
|
| | | {
|
| | | ((IASZone)locadevice).iASInfo = ias.iASInfo;
|
| | | //如果接收到上报,即说明这个传感器是在线的
|
| | | locadevice.IsOnline = 1;
|
| | | //记录回复时间
|
| | | locadevice.LastDateTime = DateTime.Now;
|
| | | }
|
| | |
|
| | | this.DeviceReportPush(ias, ReceiveComandDiv.A传感器上报);
|
| | |
|
| | | //显示有新消息的特效
|
| | |
| | | /// <param name="receiveData"></param>
|
| | | private void DoorLockDeviceReportPush(JObject receiveData)
|
| | | {
|
| | | //保存门锁信息到本地
|
| | | HdlAlarmsLogic.Current.SaveDoorLockAlarmInfo(receiveData);
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1)
|
| | | {
|
| | | var device = Common.LocalDevice.Current.GetDevice(receiveData.Value<string>("DeviceAddr"), receiveData.Value<int>("Epoint"));
|
| | | if (device.Type != DeviceType.DoorLock)
|
| | | {
|
| | | //它不是门锁
|
| | | return;
|
| | | }
|
| | |
|
| | | //显示有新消息的特效
|
| | | this.ShowHadNewMessageAppeal();
|
| | | var info = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLockAlarmsResult>(receiveData["Data"].ToString());
|
| | | if (info.Clusterid == 257)
|
| | | {
|
| | | //216:锁上设置的常开
|
| | | if (info.AlarmCode == 216)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //更新门锁涉及的常开/常关的界面
|
| | | if (UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction != null)
|
| | | {
|
| | | UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction(device.DeviceAddr, true);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | //显示有新消息的特效
|
| | | this.ShowHadNewMessageAppeal();
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备在线状态更新反馈_______________
|
| | |
| | | /// 设备在线状态更新反馈
|
| | | /// </summary>
|
| | | /// <param name="receiveData"></param>
|
| | | private void DeviceOnlineChangePush (JObject receiveData)
|
| | | private void DeviceOnlineChangePush(JObject receiveData)
|
| | | {
|
| | | if (this.dicDeviceEvent.Count == 0)
|
| | | {
|
| | | //没有添加监听
|
| | | return;
|
| | | }
|
| | | var tempDevice = new CommonDevice() { DeviceAddr = receiveData.Value<string>("DeviceAddr"), DeviceEpoint = receiveData.Value<int>("Epoint") };
|
| | | tempDevice.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(receiveData["Data"]["IsOnline"].ToString());
|
| | | |
| | | tempDevice.IsOnline = Convert.ToInt32(receiveData["Data"]["IsOnline"].ToString());
|
| | |
|
| | | //处理网关上报的数据,然后变更本地缓存
|
| | | var locadevice = Common.LocalDevice.Current.GetDevicesByMac(tempDevice.DeviceAddr);
|
| | | for (int i = 0; i < locadevice.Count; i++)
|
| | | {
|
| | | bool onlineChanged = locadevice[i].IsOnline != tempDevice.IsOnline;
|
| | | locadevice[i].IsOnline = tempDevice.IsOnline;
|
| | | //记录回复时间
|
| | | locadevice[i].LastDateTime = DateTime.Now;
|
| | | if (onlineChanged == true)
|
| | | {
|
| | | //在线状态变更了,才保存
|
| | | locadevice[i].ReSave();
|
| | | }
|
| | | }
|
| | |
|
| | | this.DeviceReportPush(tempDevice, ReceiveComandDiv.A设备在线上报);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备控制状态反馈___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备控制状态反馈
|
| | | /// </summary>
|
| | | /// <param name="receiveData"></param>
|
| | | private void DeviceControlResponePush(JObject receiveData)
|
| | | {
|
| | | if (this.dicDeviceEvent.Count == 0)
|
| | | {
|
| | | //没有添加监听
|
| | | return;
|
| | | }
|
| | | var tempDevice = new CommonDevice() { DeviceAddr = receiveData.Value<string>("DeviceAddr"), DeviceEpoint = receiveData.Value<int>("Epoint") };
|
| | |
|
| | | this.DeviceReportPush(tempDevice, ReceiveComandDiv.A节点控制反馈);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="receiveData"></param>
|
| | | private void LogicExecutePush(JObject receiveData)
|
| | | {
|
| | | //目前不处理逻辑上报内容
|
| | |
|
| | | //显示有新消息的特效
|
| | | this.ShowHadNewMessageAppeal();
|
| | | }
|
| | |
|
| | | // 逻辑执行常开模式失效的情况
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1)
|
| | | {
|
| | | //自动化执行 常开关闭
|
| | | var data = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicPushResult>(receiveData["Data"].ToString());
|
| | | if (data != null && data.ActionData != null)
|
| | | {
|
| | | if (data.ActionData.Actiontype == 8 && data.ActionData.PassDataString == "055704010113")
|
| | | {
|
| | | var deviceAddr = data.ActionData.MacStr;
|
| | | var device = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr, false);
|
| | | if (device.Count > 0 && device[0].Type != DeviceType.DoorLock)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //提示门锁已经失效
|
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NormallyClosed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
|
| | |
|
| | | //更新门锁涉及的常开/常关的界面
|
| | | if (UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction != null)
|
| | | {
|
| | | UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction(deviceAddr, false);
|
| | | }
|
| | | });
|
| | | });
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 场景触发上报_______________________
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | |
|
| | |
|
| | | #region ■ 添加设备事件_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加获取设备属性的事件(推送已经强制指定运行于主线程,属性上报的对象:device.DeviceStatusReport)
|
| | | /// 添加获取设备属性的事件(属性上报的对象:device.DeviceStatusReport)
|
| | | /// </summary>
|
| | | /// <param name="mainKeys">标识事件的主键(可以随便填,主要是针对多个界面一起使用的情况)</param>
|
| | | /// <param name="comand">命令区分</param>
|
| | |
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备上报推送
|
| | | /// 设备上报推送(调用此方法,他会推送到各自的界面)
|
| | | /// </summary>
|
| | | /// <param name="common"></param>
|
| | | /// <param name="comand"></param>
|
| | | private void DeviceReportPush(CommonDevice common, ReceiveComandDiv comand)
|
| | | public void DeviceReportPush(CommonDevice common, ReceiveComandDiv comand)
|
| | | {
|
| | | lock (this.dicDeviceEvent)
|
| | | if (this.dicDeviceEvent.Count == 0)
|
| | | {
|
| | | if (this.dicDeviceEvent.Count == 0)
|
| | | {
|
| | | //没有添加监听
|
| | | return;
|
| | | }
|
| | |
|
| | | //没有添加监听
|
| | | return;
|
| | | }
|
| | | //lock (this.dicDeviceEvent)
|
| | | {
|
| | | var list = new List<Action<CommonDevice>>();
|
| | | foreach (string keys in this.dicDeviceEvent.Keys)
|
| | | try
|
| | | {
|
| | | if (this.dicCommandDiv[keys] != comand)
|
| | | foreach (string keys in this.dicDeviceEvent.Keys)
|
| | | {
|
| | | //命令区分不一致,则不调用回调函数
|
| | | continue;
|
| | | if (this.dicCommandDiv[keys] != comand)
|
| | | {
|
| | | //命令区分不一致,则不调用回调函数
|
| | | continue;
|
| | | }
|
| | | //命令区分一致时,则调用回调函数
|
| | | list.Add(this.dicDeviceEvent[keys]);
|
| | | }
|
| | | //命令区分一致时,则调用回调函数
|
| | | list.Add(this.dicDeviceEvent[keys]);
|
| | | }
|
| | | catch { return; }
|
| | | //有可能在回调函数中移除了事件,导致报错,所以先收集,再调用
|
| | | Application.RunOnMainThread(() =>
|
| | | foreach (var action in list)
|
| | | {
|
| | | foreach (var action in list)
|
| | | try
|
| | | {
|
| | | try
|
| | | {
|
| | | action?.Invoke(common);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | //Log出力
|
| | | string msg = "当前激活的界面[" + UserCenterResourse.NowActionFormID + "]";
|
| | | HdlLogLogic.Current.WriteLog(ex, msg);
|
| | | }
|
| | | action?.Invoke(common);
|
| | | }
|
| | | });
|
| | | catch (Exception ex)
|
| | | {
|
| | | //Log出力
|
| | | string msg = "推送错误! 当前激活的界面[" + UserCenterResourse.NowActionFormID + "]";
|
| | | HdlLogLogic.Current.WriteLog(ex, msg);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// <summary>
|
| | | /// 设备在线上报
|
| | | /// </summary>
|
| | | A设备在线上报 = 3
|
| | | A设备在线上报 = 3,
|
| | | /// <summary>
|
| | | /// 当客户端发送控制设备指令,如打开或关闭设备、调节亮度、颜色。如果被控制的节点设备在线,节点设备将反馈
|
| | | /// </summary>
|
| | | A节点控制反馈 = 4
|
| | | }
|
| | | }
|