Esempio n. 1
0
        private void CommandService_CommandsChanged()
        {
            GlobalCommands.Clear();
            foreach (var delegateCommand in _commandService.GetForRole(AppUserModel.RoleModel))
            {
                GlobalCommands.Add(delegateCommand);
            }

            SendPropertyChanged(() => GlobalCommands);
        }
Esempio n. 2
0
        private static void LoadGlobalCommands(JObject root)
        {
            JToken jFoundation = root.GetValue("foundation");

            foreach (JProperty command in jFoundation)
            {
                ZclGlobalCommand zclCommand = new ZclGlobalCommand();

                zclCommand.Id          = command.Value["id"].Value <byte>();
                zclCommand.Name        = command.Name;
                zclCommand.KnownBufLen = command.Value["knownBufLen"].Value <int>();

                var paramCollection = command.Value["params"];

                foreach (JObject pObject in paramCollection)
                {
                    foreach (var p in pObject)
                    {
                        ZclCommandParam param = new ZclCommandParam()
                        {
                            Name = p.Key
                        };
                        if (p.Value.Type == JTokenType.Integer)
                        {
                            param.DataType = (DataType)p.Value.ToObject <int>();
                        }
                        else if (p.Value.Type == JTokenType.String)
                        {
                            param.SpecialType = p.Value.ToObject <string>();
                        }
                        else
                        {
                            throw new NotImplementedException($"Param type {p.Value.Type.ToString()} not implemented");
                        }

                        zclCommand.Params.Add(param);
                    }
                }

                GlobalCommands.Add(zclCommand);
            }
        }