| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using HDL_ON.Common; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.DriverLayer; |
| | | using Shared; |
| | | |
| | |
| | | /// bus协议数据格式 |
| | | /// 使用A协议控制时,改属性为空 |
| | | /// </summary> |
| | | public BusData bus_Data; |
| | | public BusData bus; |
| | | /// <summary> |
| | | /// 是否收藏 |
| | | /// </summary> |
| | |
| | | { |
| | | if (_trait_on_off == null) |
| | | { |
| | | _trait_on_off = attributes.Find((obj) => obj.key == "on_off"); |
| | | _trait_on_off = attributes.Find((obj) => obj.key == FunctionAttributeKey.OnOff); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (_trait_on_off == null) |
| | | { |
| | |
| | | max = 1, |
| | | min = 0, |
| | | }; |
| | | _trait_on_off.curValue = "off"; |
| | | } |
| | | _trait_on_off.curValue = "on"; |
| | | } |
| | | if(_trait_on_off.curValue.ToString() != "on"&& _trait_on_off.curValue.ToString() != "off") |
| | | { |
| | | _trait_on_off.curValue = "off"; |
| | | } |
| | | return _trait_on_off; |
| | | } |
| | |
| | | /// <summary> |
| | | /// 使用次数 |
| | | /// </summary> |
| | | public double usageCount = 0; |
| | | public double controlCounter = 0; |
| | | /// <summary> |
| | | /// 使用频率 |
| | | /// </summary> |
| | |
| | | { |
| | | get |
| | | { |
| | | return usageCount / 7; |
| | | return controlCounter / 7; |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public int fixedSerialNumber = int.MaxValue; |
| | | |
| | | /// <summary> |
| | | /// 收藏功能 |
| | | /// </summary> |
| | | public void CollectFunction() |
| | | { |
| | | var result = ""; |
| | | //var waitPage = new Loading(); |
| | | |
| | | new System.Threading.Thread(() => |
| | | { |
| | | if (collect) |
| | | { |
| | | result = ApiUtlis.Ins.HttpRequest.CollectDevice(deviceId).Code; |
| | | } |
| | | else |
| | | { |
| | | result = ApiUtlis.Ins.HttpRequest.CancelCollectDevice(deviceId).Code; |
| | | } |
| | | //提示错误 |
| | | if (result != StateCode.SUCCESS) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | collect = !collect; |
| | | IMessageCommon.Current.ShowErrorInfoAlter(result); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | /// <summary> |
| | | /// 编辑功能绑定房间信息 |
| | | /// </summary> |
| | | public void EditBindRoomInfo(string roomId) |
| | | { |
| | | var result = ""; |
| | | |
| | | new System.Threading.Thread(() => |
| | | { |
| | | if (collect) |
| | | { |
| | | result = ApiUtlis.Ins.HttpRequest.BindDeviceToRoom(new List<string>() { deviceId }, new List<string>() { roomId }).Code; |
| | | } |
| | | else |
| | | { |
| | | result = ApiUtlis.Ins.HttpRequest.UnbindDeviceToRoom(deviceId,roomId); |
| | | } |
| | | //提示错误 |
| | | if (result != StateCode.SUCCESS) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | collect = !collect; |
| | | IMessageCommon.Current.ShowErrorInfoAlter(result); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | public string GetBusId() |
| | | { |
| | | string busId = ""; |
| | | if (bus_Data != null) |
| | | if (bus != null) |
| | | { |
| | | busId = bus_Data.SubnetID + "_" + bus_Data.DeviceID + "_" + bus_Data.loopId; |
| | | busId = bus.SubnetID + "_" + bus.DeviceID + "_" + bus.LoopId; |
| | | } |
| | | return busId; |
| | | } |
| | |
| | | { |
| | | roomNameList += ","; |
| | | } |
| | | roomNameList += findRoom.floorName + findRoom.roomName; |
| | | roomNameList += findRoom.floorName +"-"+ findRoom.roomName; |
| | | } |
| | | if (roomNameList == "" && functionType == FunctionType.Scene) |
| | | { |
| | | roomNameList = Language.StringByID(StringId.WholeHouseScene); |
| | | roomNameList = Language.StringByID(StringId.WholeZone); |
| | | } |
| | | return roomNameList; |
| | | } |
| | |
| | | { |
| | | if (upSevser) |
| | | { |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var pm = new HttpServerRequest(); |
| | | var pack = pm.UpdataDevcieInfo(this); |
| | | if (pack.Code == DAL.Server.StateCode.SUCCESS) |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); |
| | | Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | } |
| | | else |
| | | { |
| | | Utlis.ShowTip(Language.StringByID(StringId.EditFunctionInfoFail) + "\r\nCode:" + pack.Code); |
| | | IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); |
| | | Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | } |
| | | } |
| | | |
| | |
| | | var sFunc = new SceneFunction(); |
| | | foreach (var attr in attributes) |
| | | { |
| | | if (attr.key == FunctionAttributeKey.SetTemp) |
| | | switch (attr.key) |
| | | { |
| | | var vv = Convert.ToDouble(attr.value); |
| | | sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString() }); |
| | | } |
| | | else |
| | | { |
| | | sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() }); |
| | | case FunctionAttributeKey.OnOff: |
| | | case FunctionAttributeKey.Brightness: |
| | | case FunctionAttributeKey.Mode: |
| | | case FunctionAttributeKey.SetTemp: |
| | | case FunctionAttributeKey.FanSpeed: |
| | | case FunctionAttributeKey.Percent: |
| | | //case FunctionAttributeKey.FadeTime: |
| | | if (attr.curValue.ToString() == "{}") |
| | | { |
| | | if (attr.key == FunctionAttributeKey.OnOff) |
| | | { |
| | | attr.curValue = "off"; |
| | | } |
| | | else |
| | | { |
| | | attr.curValue = "0"; |
| | | } |
| | | } |
| | | if (attr.key == FunctionAttributeKey.SetTemp) |
| | | { |
| | | double vv = 16; |
| | | Double.TryParse(attr.curValue.ToString(), out vv); |
| | | sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString() }); |
| | | } |
| | | else |
| | | { |
| | | sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() }); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | sFunc.sid = this.sid; |
| | |
| | | |
| | | var acd = new AlinkControlData(); |
| | | acd.sid = sid; |
| | | var aca = new AlinkControlAttributes(); |
| | | foreach (var dic in commandDictionary) |
| | | { |
| | | var aca = new AlinkControlAttributes(); |
| | | aca.key = dic.Key; |
| | | aca.value = dic.Value; |
| | | acd.status.Add(aca); |
| | |
| | | ApiAlinkControlActionObj aaao = new ApiAlinkControlActionObj(); |
| | | aaao.deviceId = this.deviceId; |
| | | aaao.spk = this.spk; |
| | | aaao.bus = this.bus; |
| | | foreach (var kv in keyValues) |
| | | { |
| | | aaao.attributes.Add(new AlinkControlAttributes() |
| | |
| | | /// 功能属性 |
| | | /// 属性字段解析:attri :属性内容,value 属性的值,max 最大值 min 最小值 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class FunctionAttributes |
| | | { |
| | | /// <summary> |
| | |
| | | /// 室内温度 |
| | | /// </summary> |
| | | public const string IndoorTemp = "room_temp"; |
| | | /// <summary> |
| | | /// value |
| | | /// </summary> |
| | | public const string Value = "value"; |
| | | } |
| | | /// <summary> |
| | | /// 设备功能oid |
| | |
| | | return Convert.ToByte(addresses.Substring(2, 2), 16); |
| | | } |
| | | } |
| | | public byte loopId; |
| | | public byte LoopId |
| | | { |
| | | get |
| | | { |
| | | return Convert.ToByte(loopId, 16); |
| | | } |
| | | } |
| | | |
| | | public string loopId; |
| | | } |
| | | |
| | | public static class SPK |