public SmcTicketThread(SmcDto smcDto, ClientSettings clientSettings, BrokerSettings brokerSettings, IMqttClientConfiguration mqttClientConfiguration, IMqttClientMethods mqttClientMethods, Topic topic, CommandRules commandRules, IEventService eventService, IForwarderSenderService forwarderSenderService) { Smc = smcDto; _eventService = eventService; _forwarderSenderService = forwarderSenderService; Tickets = new ConcurrentPriorityQueue <TicketThreadObject>(); _executingCommandSemaphore = new SemaphoreSlim(1, 1); _waitingCommandMessageSemaphore = new SemaphoreSlim(1, 1); _answerSemaphore = new SemaphoreSlim(1, 1); var localClientSettings = new ClientSettings { ClientId = clientSettings.ClientId, ClientName = clientSettings.ClientName }; localClientSettings.ClientId = localClientSettings.ClientId.Replace("serial", smcDto.Serial); localClientSettings.ClientName = localClientSettings.ClientName.Replace("serial", smcDto.Serial); localClientSettings.DebugMode = clientSettings.DebugMode; localClientSettings.AutoReconnectDelayInSeconds = clientSettings.AutoReconnectDelayInSeconds; var localTopic = new Topic { Address = topic.Address, QoS = topic.QoS }; localTopic.Address = localTopic.Address .Replace("{smc-or-meter}", CommandDeviceType.Smc.ToString().ToLower()) .Replace("{serial}", smcDto.Serial); _mqttClient = new IoGMqttClient(localClientSettings, brokerSettings, mqttClientConfiguration, mqttClientMethods); _mqttClient.Subscribe(localTopic); _mqttClient.MessageReceivedHandler += ReceivedUpdate; _commandRules = commandRules; }
public MeterForwarderService( IMapper mapper, IForwarderSenderService forwarderSenderService, IMiddlewareProviderService middlewareProviderService) { _forwarderSenderService = forwarderSenderService; _middlewareProviderService = middlewareProviderService; _mapper = mapper; }
public SmcForwarderService( IMapper mapper, ISmcService smcService, IForwarderSenderService forwarderSenderService, IMiddlewareProviderService middlewareProviderService) { _forwarderSenderService = forwarderSenderService; _middlewareProviderService = middlewareProviderService; _smcService = smcService; _mapper = mapper; }
public ThreadService(IMqttClientMethods mqttClientMethods, IMqttClientConfiguration mqttClientConfiguration, IOptions <Forwarder> forwarderConfig, IServiceProvider serviceProvider, ISmcService smcService, IOptions <CommandRules> commandRules, IEventService eventService, IForwarderSenderService forwarderSenderService, IMeterService meterService) { _mqttClientConfiguration = mqttClientConfiguration; _mqttClientMethods = mqttClientMethods; _brokerSettings = forwarderConfig.Value.Mqtt.BrokerSettings; _baseClientSettings = forwarderConfig.Value.Mqtt.CommandsBaseClientSettings; _subscribeTopic = forwarderConfig.Value.Mqtt.BaseCommandsSubscribeTopic; _smcService = smcService; _commandRules = commandRules.Value; _eventService = eventService; _eventService.AThreadIsShuttingDown += AThreadIsShuttingDown; _forwarderSenderService = forwarderSenderService; _meterService = meterService; }