| | |
| | | |
| | | #region 优化区域 2021-02-25 |
| | | /// <summary> |
| | | /// 更新的最后时间 |
| | | /// </summary> |
| | | public string time_stamp = "1615261019796"; |
| | | |
| | | public string GeteTime() |
| | | { |
| | | try |
| | | { |
| | | DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区 |
| | | return startTime.AddMilliseconds(Convert.ToDouble(time_stamp)).ToString("s"); |
| | | } |
| | | catch { |
| | | return DateTime.MinValue.ToString("s"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 获取属性列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | |
| | | return attrs; |
| | | } |
| | | /// <summary> |
| | | /// 获取制定属性 |
| | | /// 获取指定属性 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public FunctionAttributes GetAttribute(string key) |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取属性状态 |
| | | /// 获取属性当前状态 |
| | | /// </summary> |
| | | /// <param name="key"></param> |
| | | /// <returns></returns> |
| | | public string GetAttrState(string key) |
| | | { |
| | | var attrState = status.Find((s) => s.key == key.ToString()); |
| | | if(attrState == null) |
| | | var attrState = attributes.Find((s) => s.key == key.ToString()); |
| | | if (attrState == null || string.IsNullOrEmpty(attrState.state)) |
| | | { |
| | | return ""; |
| | | return "0"; |
| | | } |
| | | return attrState.value; |
| | | return attrState.state; |
| | | } |
| | | /// <summary> |
| | | /// 设置属性状态 |
| | |
| | | /// <param name="key"></param> |
| | | /// <param name="value"></param> |
| | | /// <returns>修改结果</returns> |
| | | public bool SetAttrState(string key, string value) |
| | | public bool SetAttrState(string key, object value) |
| | | { |
| | | var attrState = status.Find((s) => s.key == key.ToString()); |
| | | if (attrState == null) |
| | | //var attrState = status.Find((s) => s.key == key.ToString()); |
| | | var attr = attributes.Find((s) => s.key == key); |
| | | if (attr == null) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | attrState.value = value; |
| | | attr.state = value.ToString(); |
| | | attr.curValue = value.ToString(); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 上一次打开的亮度 |
| | | /// 灯光私有属性 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int lastBrightness = 100; |
| | | |
| | | /// <summary> |
| | | /// 工作模式对应的工作温度 |
| | | /// 地热私有属性 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public Dictionary<string, byte> Fh_Mode_Temp = new Dictionary<string, byte>(); |
| | | #endregion |
| | | |
| | | |
| | | #region base info |
| | | /// <summary> |
| | | /// HDL统一协议格式:14bytes |
| | | /// 举例: 来源 厂商代码 通讯方式 产品时间戳 产品类别 物模型类 通道号 大小类别 |
| | | /// 1byte 1byte 1byte 4byte 1byte 2byte 2byte 2byte |
| | | /// 来源:00 默认原生态系统数据 、01 网关或者其他A设备、02 调试软件、03 APP应用程序、04 第三方网关或者平台 |
| | | /// 厂商代码:01 HDL |
| | | /// 通讯方式:01 HDL Bus、02 Zigbee、03 KNX、04 Z-Wave |
| | | /// 产品时间戳:4bytes 以2020年1月1日算出的时间戳0.1s为单位 |
| | | /// 产品类别:01 调光器、02 继电器、03 干接点模块、04 传感器、05 面板 |
| | | /// 物模型类型: |
| | | /// 01 开关类:01 开关、02 插座、03 |
| | | /// 02 照明: 01 开关、02 调光、03 色温、04 LED |
| | | /// 03 遮阳: 01 窗帘电机、02 百叶窗、03 开合帘、04 卷帘 |
| | | /// 04 恒温器:01 空调、02 地暖、03 毛细空调 |
| | | /// 05 新风 |
| | | /// 06 影音 |
| | | /// 07 音乐 |
| | | /// 08 能源 |
| | | /// 09 安防 |
| | | /// 大类别 1bytes (预留) |
| | | /// 小类别 1byte (预留) |
| | | /// </summary> “0001021599F98A04050300010000” |
| | | public string sid = "0301011234567801012301230123"; |
| | | /// <summary> |
| | | /// 备注 |
| | |
| | | /// attri |
| | | /// </summary> |
| | | public List<FunctionAttributes> attributes = new List<FunctionAttributes>(); |
| | | /// <summary> |
| | | /// 功能状态列表 |
| | | /// </summary> |
| | | public List<AttributesStatus> status = new List<AttributesStatus>(); |
| | | /// <summary> |
| | | /// 获取状态值 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public string GetStatusValus(string key) |
| | | { |
| | | var d = status.Find((obj) => obj.key == key); |
| | | if(d==null) |
| | | { |
| | | return null; |
| | | } |
| | | return d.value; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 房间ID列表 |
| | |
| | | public void CollectFunction() |
| | | { |
| | | var result = ""; |
| | | //var waitPage = new Loading(); |
| | | |
| | | new System.Threading.Thread(() => |
| | | { |
| | |
| | | { |
| | | collect = !collect; |
| | | IMessageCommon.Current.ShowErrorInfoAlter(result); |
| | | }); |
| | | }else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | UI.HomePage.RefreshFunctionView(); |
| | | }); |
| | | } |
| | | }) |
| | |
| | | { |
| | | var sendDataObj = new AlinkFunctionStatusObj(); |
| | | sendDataObj.id = Control.Ins.msg_id.ToString(); |
| | | sendDataObj.time_stamp = Control.Ins.Get_TimeStamp(); |
| | | sendDataObj.time_stamp = Utlis.GetTimestamp(); |
| | | |
| | | |
| | | var acd = new AlinkControlData(); |
| | | var acd = new AlinkStatusData(); |
| | | acd.sid = sid; |
| | | foreach (var dic in commandDictionary) |
| | | { |
| | |
| | | /// </summary> |
| | | public class AlinkFunctionStatusObj |
| | | { |
| | | public List<AlinkControlData> objects = new List<AlinkControlData>(); |
| | | public List<AlinkStatusData> objects = new List<AlinkStatusData>(); |
| | | |
| | | public string time_stamp = ""; |
| | | public string id = ""; |
| | |
| | | public string time_stamp = ""; |
| | | } |
| | | /// <summary> |
| | | /// A协议控制数据 |
| | | /// A协议状态数据 |
| | | /// </summary> |
| | | public class AlinkControlData |
| | | public class AlinkStatusData |
| | | { |
| | | /* |
| | | mqtt接收的状态数据没有deviceId |
| | | 接口反馈的数据有 |
| | | */ |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string sid = ""; |
| | | /// <summary> |
| | | /// 设备ID |
| | | /// 云端负责生成 |
| | | /// </summary> |
| | | public string deviceId = "0"; |
| | | public List<AttributesStatus> status = new List<AttributesStatus>(); |
| | | } |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public string data_type = ""; |
| | | /// <summary> |
| | | /// 当前状态 |
| | | /// </summary> |
| | | public string state = ""; |
| | | /// <summary> |
| | | /// 当前值 |
| | | /// </summary> |
| | | public object curValue = new object(); |
| | |
| | | /// </summary> |
| | | public const string Mode = "mode"; |
| | | /// <summary> |
| | | /// 工作模式 |
| | | /// 地热/地冷/功率地热/功率地冷 |
| | | /// </summary> |
| | | public const string WorkMode = "mode_work"; |
| | | /// <summary> |
| | | /// 风速 |
| | | /// </summary> |
| | | public const string FanSpeed = "fan"; |
| | |
| | | /// 设置温度 |
| | | /// </summary> |
| | | public const string SetTemp = "set_temp"; |
| | | /// <summary> |
| | | /// 温度模式 |
| | | /// 空调、地热//app自加 |
| | | /// </summary> |
| | | public const string TempType = "temperature_type"; |
| | | /// <summary> |
| | | /// 时间标记 |
| | | /// 地热//app自加 |
| | | /// </summary> |
| | | public const string TimeFlag = "time_flag"; |
| | | /// <summary> |
| | | /// 延时 |
| | | /// </summary> |
| | |
| | | /// 消毒剩余时间 |
| | | /// </summary> |
| | | public const string DisinfectTimeLeft = "disinfect_time_surplus"; |
| | | |
| | | /// <summary> |
| | | /// 负离子 |
| | | /// </summary> |
| | | public const string Anion = "anion"; |
| | | /// <summary> |
| | | /// 负离子时间 |
| | | /// </summary> |
| | | public const string AnionTime = "anion_time"; |
| | | /// <summary> |
| | | /// 负离子剩余时间 |
| | | /// </summary> |
| | | public const string AnionTimeLeft = "anion_time_surplus"; |
| | | /// <summary> |
| | | /// 打开登记(风扇) |
| | | /// </summary> |
| | | public const string OpenLevel = "openLevel"; |
| | | |
| | | |
| | | #region tuya |
| | |
| | | /// 凉霸 |
| | | /// </summary> |
| | | public const string ClothesHanger = "electrical.racks"; |
| | | /// <summary> |
| | | /// 红外宝 |
| | | /// </summary> |
| | | public const string IrModule = "ir.module"; |
| | | /// <summary> |
| | | /// 红外空调 |
| | | /// </summary> |
| | | public const string IrAC = "ir.ac"; |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | /// 家电 |
| | | /// </summary> |
| | | public const string Electric = "electrical"; |
| | | /// <summary> |
| | | /// 红外设备 |
| | | /// </summary> |
| | | public const string IR = "ir"; |
| | | |
| | | //Music = 0x09, |
| | | |
| | | |
| | | |
| | | } |