public Gateway(IGatewayConfiguration gatewayConfiguration, IMessageHub messageHub) { _messageHub = messageHub; Name = gatewayConfiguration.Name; Id = new GatewayId(gatewayConfiguration.DriverName, gatewayConfiguration.Name); _state = new SynchronizedValue <ThingState>(); }
private async Task InitGatewayAsync(IGatewayConfiguration gatewayConfiguration, Action <IGateway> afterGatewayCreation) { var gateway = await _gatewayBuilder.Build(gatewayConfiguration); if (gateway == null) { return; } afterGatewayCreation(gateway); _requestDispatcher.Process(new KernelRequest($"InitGateway {gateway.Id}", () => gateway.InitAsync())); }
private IGatewayHandler CreateGatewayHandler(IGatewayConfiguration gatewayConfiguration, IGateway gateway) { var driver = _driverSubSystem.GetDriver(gatewayConfiguration.DriverName); if (driver == null) { Log.Warn($"Driver '{gatewayConfiguration.DriverName}' for gateway '{gatewayConfiguration.Name}' not found"); return(null); } var gatewayHandler = driver.CreateGatewayHandler(new GatewaySetupInfo(gatewayConfiguration, gateway.Id)); return(gatewayHandler); }
public async Task <Gateway> Build(IGatewayConfiguration gatewayConfiguration) { var gateway = new Gateway(gatewayConfiguration, _messageHub); var gatewayHandler = CreateGatewayHandler(gatewayConfiguration, gateway); if (gatewayHandler == null) { Log.Error($"Driver '{gatewayConfiguration.DriverName}' does not create gateway handler for gateway '{gatewayConfiguration.Name}'"); return(null); } Log.Info($"Gateway handler for gateway '{gatewayConfiguration.Name}' created"); gateway.SetHandler(gatewayHandler); await gatewayHandler.SetupAsync(_messageHub); await _gatewayRepository.AddAsync(gateway).ConfigureAwait(false); return(gateway); }
public GatewaySetupInfo(IGatewayConfiguration gatewayConfiguration, GatewayId id) : base(gatewayConfiguration.Settings) { Id = id; GatewayType = gatewayConfiguration.GatewayType; Address = gatewayConfiguration.Address; }
public GatewayConfigurationPackage(IGatewayConfiguration gatewayConfiguration, IEnumerable <IThingConfiguration> thingConfigurations) { GatewayConfiguration = gatewayConfiguration; ThingConfigurations = thingConfigurations; }