コード例 #1
0
 public ThingSetupInfo(IThingConfiguration thingConfiguration, IThingTemplate thingTemplate, IThing thing)
     : base(thingConfiguration.Settings)
 {
     Address  = thingConfiguration.Address;
     Template = thingTemplate;
     Id       = thing.Id;
 }
コード例 #2
0
        public Thing(string thingName, GatewayId gatewayId,
                     IThingTemplate thingTemplate, IThingChannelBuilder thingChannelBuilder, IMessageHub messageHub)
        {
            _thingTemplate       = thingTemplate;
            _thingChannelBuilder = thingChannelBuilder;
            _messageHub          = messageHub;
            Name = thingName;
            Id   = new ThingId(gatewayId, thingName);

            _channels = new ConcurrentList <IThingChannel>();
            _state    = new SynchronizedValue <ThingState>();
        }
コード例 #3
0
 protected Thing(ulong instanceId, [CanBeNull] IThingTemplate template) : base(instanceId, template)
 {
 }
コード例 #4
0
        private async Task <Thing> CreateThing(IThingConfiguration thingConfiguration, IThingTemplate thingTemplate, IGateway gateway)
        {
            var thing = new Thing(thingConfiguration.Name, gateway.Id, thingTemplate, _thingChannelBuilder, _messageHub);

            var thingHandler = gateway.CreateThingHandler(new ThingSetupInfo(thingConfiguration, thingTemplate, thing));

            if (thingHandler == null)
            {
                Log.Error($"Gateway '{thingConfiguration.GatewayName}' does not create thing handler for thing '{thingConfiguration.Name}'");

                return(null);
            }

            Log.Info($"Thing handler for thing '{thingConfiguration.Name}' created");

            thing.SetHandler(thingHandler);

            await thingHandler.SetupAsync(_messageHub).ConfigureAwait(false);

            await _thingRepository.AddAsync(thing).ConfigureAwait(false);

            return(thing);
        }