Beispiel #1
0
        private static void LoadClusters(JObject root)
        {
            foreach (JObject cluster in root.Values())
            {
                ZclCluster cl = new ZclCluster();
                cl.Name = cluster.Path;
                cl.Id   = cluster["id"].Value <ushort>();

                var attributes = cluster["attrId"];

                foreach (JProperty attr in attributes)
                {
                    ZclAttribute zclAttribute = new ZclAttribute();
                    zclAttribute.Name = attr.Name;

                    foreach (JObject info in attr)
                    {
                        zclAttribute.Id       = info.GetValue("id").Value <ushort>();
                        zclAttribute.DataType = (DataType)info.GetValue("type").Value <int>();
                    }

                    cl.Attributes.Add(zclAttribute);
                }

                JToken reqCmds = cluster["cmd"];

                foreach (JProperty cmd in reqCmds)
                {
                    ZclClusterCommand fc = ClusterCommands.SingleOrDefault(f => f.ClusterName == cl.Name && f.Name == cmd.Name && f.Direction == Direction.ClientToServer);
                    if (fc != null)
                    {
                        fc.Id      = cmd.Value.Value <byte>();
                        fc.Cluster = cl;

                        cl.Requests.Add(fc);
                    }
                }

                var rspCmds = cluster["cmdRsp"];

                foreach (JProperty cmd in rspCmds)
                {
                    ZclClusterCommand fc = ClusterCommands.SingleOrDefault(f => f.ClusterName == cl.Name && f.Name == cmd.Name && f.Direction == Direction.ServerToClient);
                    if (fc != null)
                    {
                        fc.Id      = cmd.Value.Value <byte>();
                        fc.Cluster = cl;

                        cl.Responses.Add(fc);
                    }
                }

                _clusters.Add(cl);
            }
        }
Beispiel #2
0
 public static List <ZclCommandParam> GetClusterCommandParams(ushort clusterId, byte cmdId)
 {
     return(ClusterCommands.Single(c => c.Id == cmdId && c.Cluster.Id == clusterId).Params);
 }
Beispiel #3
0
 public static ZclClusterCommand GetClusterCommand(string cluster, string cmd)
 {
     return(ClusterCommands.Single(fc => fc.Cluster.Equals(cluster) && fc.Name.Equals(cmd)));
 }
Beispiel #4
0
 private void CreateCommandClasses()
 {
     _clusterCommands = new ClusterCommands(this);
     _serverCommands  = new ServerCommands(this);
 }