| | |
| | | { |
| | | public GroupControl() |
| | | { |
| | | spk = "GroupControl"; |
| | | spk = "groupControl"; |
| | | } |
| | | /// <summary> |
| | | /// 群控ID |
| | |
| | | /// </summary> |
| | | public string NewGroupControlSid() |
| | | { |
| | | string sceneId = ""; |
| | | string Id = ""; |
| | | try |
| | | { |
| | | string sOidBeginsWith = "000101";//厂商 + 通讯方式 |
| | |
| | | //sTimeSpan = "00000000"; |
| | | } |
| | | |
| | | sceneId = sOidBeginsWith + sTimeSpan; |
| | | Id = sOidBeginsWith + sTimeSpan; |
| | | |
| | | sceneId += "AA"; |
| | | sceneId += "AA01"; |
| | | Id += "AA"; |
| | | Id += "AA01"; |
| | | int maxId = 1; |
| | | |
| | | Random random = new Random(Guid.NewGuid().GetHashCode()); |
| | | maxId = random.Next(10); |
| | | |
| | | sceneId += (maxId + 1).ToString("X4"); |
| | | sceneId += "0000"; |
| | | Id += (maxId + 1).ToString("X4"); |
| | | Id += "0000"; |
| | | } |
| | | catch |
| | | { |
| | | return sceneId; |
| | | return Id; |
| | | } |
| | | return sceneId; |
| | | return Id; |
| | | } |
| | | /// <summary> |
| | | /// 群控名称 |
| | |
| | | /// 群控控制 |
| | | /// </summary> |
| | | /// <param name="pairs"></param> |
| | | public void Control(Dictionary<string,object> pairs) |
| | | public void Control(Dictionary<string,string> pairs) |
| | | { |
| | | try |
| | | { |
| | | |
| | | if (DriverLayer.Control.Ins.GatewayOnline_Local) |
| | | { |
| | | var controlValues = new Dictionary<string, string>(); |
| | | foreach (var p in pairs) |
| | | { |
| | | controlValues.Add("key", p.Key); |
| | | controlValues.Add("value", p.Value.ToString()); |
| | | } |
| | | var functionControlDataObj = GetGatewayAlinkControlData(controlValues); |
| | | var functionControlDataObj = GetGatewayAlinkControlData(pairs); |
| | | var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj); |
| | | var sendBytes = DriverLayer.Control.Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson); |
| | | var sendBytes = DriverLayer.Control.Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlGroupControlTopic, functionControlDataJson); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, 3); |
| | | MainPage.Log($"本地通讯 发送HDL-Link数据:{functionControlDataJson}"); |
| | | } |
| | |
| | | MainPage.Log($"群控控制失败: {ex.Message}"); |
| | | } |
| | | } |
| | | |
| | | |
| | | public new List<FunctionAttributes> attributes { |
| | | get |
| | | { |
| | | var list = new List<FunctionAttributes>(); |
| | | |
| | | foreach (var temp in sids) |
| | | { |
| | | var light = FunctionList.List.GetLightList().Find((obj) => obj.sid == temp.sid); |
| | | if (light != null) |
| | | { |
| | | foreach(var attr in light.attributes) |
| | | { |
| | | if(list.Find((obj)=>obj.key == attr.key) == null) |
| | | { |
| | | list.Add(attr); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public class GroupControlFunction |