예제 #1
0
        public RebootEdm(ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.GetLoggerFor(GetType());

            Identifier      = new RebootEdmIdentifier(GetType().FullName);
            _rebootCommnand = new SgetCommandDefinition(new Guid("{f54b990d-25f5-430d-8428-44ab74ed8509}"), UicUriBuilder.CommandFrom(this, "reboot"), "Reboot System", "reboot", UicDataType.String, "Reboots the system", null, null);
            CommandDefinition[] commandDefinitios =
            {
                _rebootCommnand
            };
            AttributeDefinition[] attribtueDefinitions = new AttributeDefinition[0];
            DatapointDefinition[] datapointDefinitions = new DatapointDefinition[0];
            _edmCapability = new RebootEdmEdmCapability(Identifier, commandDefinitios, attribtueDefinitions, datapointDefinitions);
        }
예제 #2
0
        private EdmCapability CreateEdmCapability()
        {
            var dataPoints = new List <DatapointDefinition>();
            var commands   = new List <CommandDefinition>();

            foreach (EapiGpioId pin in Enum.GetValues(typeof(EapiGpioId)))
            {
                string pinname = "Pin" + (int)pin;
                string uri     = UicUriBuilder.DatapointFrom(this, pinname);
                _gpioIdMap[uri] = pin;

                var pinDef = new SgetDatapointDefinition(pin.ToGuid(), uri, UicDataType.Bool, pinname, string.Empty);
                dataPoints.Add(pinDef);


                if ((int)pin > (int)EapiGpioId.EAPI_ID_GPIO_GPIO07)
                {
                    var onCommand = new SgetCommandDefinition(
                        pin.ToOnCommandGuid(),
                        UicUriBuilder.CommandFrom(this, pinname + ".on"),
                        "Set " + pinname,
                        pinname + "@set",
                        UicDataType.Bool,
                        string.Empty,
                        pinDef
                        , new[] { "On" });
                    commands.Add(onCommand);
                    _onCommandMap.Add(onCommand.Uri, pin);
                    var offCommand = new SgetCommandDefinition(
                        pin.ToOffCommandGuid(),
                        UicUriBuilder.CommandFrom(this, pinname + ".off"),
                        "Reset " + pinname,
                        pinname + "@reset",
                        UicDataType.Bool,
                        string.Empty,
                        pinDef
                        , new[] { "Off" });
                    commands.Add(offCommand);
                    _offCommandMap.Add(offCommand.Uri, pin);
                }
            }

            return(new GpioEdmCapability(Identifier, dataPoints.ToArray(), new AttributeDefinition[0], commands.ToArray()));
        }