public ModuleSimulationService(ModuleSettings settings, SimulationSettingsModule simulationSettings, ITelemetryMessageService telemetryMessagingService, IErrorMessageService errorMessagingService, ICommissioningMessageService commissioningMessagingService, ILoggerFactory loggerFactory) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (simulationSettings == null) { throw new ArgumentNullException(nameof(simulationSettings)); } if (telemetryMessagingService == null) { throw new ArgumentNullException(nameof(telemetryMessagingService)); } if (errorMessagingService == null) { throw new ArgumentNullException(nameof(errorMessagingService)); } if (commissioningMessagingService == null) { throw new ArgumentNullException(nameof(commissioningMessagingService)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } string logPrefix = "system".BuildLogPrefix(); ModuleSettings = settings; SimulationSettings = simulationSettings; _logger = loggerFactory.CreateLogger <ModuleSimulationService>(); _telemetryMessagingService = telemetryMessagingService; _errorMessagingService = errorMessagingService; _commissioningMessagingService = commissioningMessagingService; _telemetryInterval = 10; _stopProcessing = false; _moduleClient = ModuleClient.CreateFromConnectionString(ModuleSettings.ConnectionString, Microsoft.Azure.Devices.Client.TransportType.Mqtt); _logger.LogDebug($"{logPrefix}::{ModuleSettings.ArtifactId}::Logger created."); _logger.LogDebug($"{logPrefix}::{ModuleSettings.ArtifactId}::Module simulator created."); }
public ModuleSimulationService(ModuleSettings settings, SimulationSettingsModule simulationSettings, IDTDLMessageService dtdlMessagingService, IDTDLCommandService dtdlCommandService, ILoggerFactory loggerFactory) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (simulationSettings == null) { throw new ArgumentNullException(nameof(simulationSettings)); } if (dtdlMessagingService == null) { throw new ArgumentNullException(nameof(dtdlMessagingService)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } string logPrefix = "system".BuildLogPrefix(); ModuleSettings = settings; SimulationSettings = simulationSettings; _logger = loggerFactory.CreateLogger <ModuleSimulationService>(); _dtdlMessagingService = dtdlMessagingService; _dtdlCommandService = dtdlCommandService; _telemetryInterval = 10; _stopProcessing = false; _moduleClient = ModuleClient.CreateFromConnectionString(ModuleSettings.ConnectionString, Microsoft.Azure.Devices.Client.TransportType.Mqtt); _logger.LogDebug($"{logPrefix}::{ModuleSettings.ArtifactId}::Logger created."); _logger.LogDebug($"{logPrefix}::{ModuleSettings.ArtifactId}::Module simulator created."); //Default DTDL Model _defaultModel = ModuleSettings?.SupportedModels?.SingleOrDefault(i => i.ModelId == ModuleSettings.DefaultModelId); if (_defaultModel == null) { throw new Exception("No supported model corresponds to the default model Id."); } }
public ModuleSimulationService( ModuleSettings settings, ITelemetryMessageService telemetryMessagingService, IErrorMessageService errorMessagingService, ICommissioningMessageService commissioningMessagingService, IProvisioningService provisioningService, ILoggerFactory loggerFactory) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (settings.SimulationSettings == null) { throw new ArgumentNullException("settings.SimulationSettings"); } if (telemetryMessagingService == null) { throw new ArgumentNullException(nameof(telemetryMessagingService)); } if (errorMessagingService == null) { throw new ArgumentNullException(nameof(errorMessagingService)); } if (commissioningMessagingService == null) { throw new ArgumentNullException(nameof(commissioningMessagingService)); } if (provisioningService == null) { throw new ArgumentNullException(nameof(provisioningService)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } string logPrefix = "system".BuildLogPrefix(); ModuleSettings = settings; SimulationSettings = settings.SimulationSettings; _logger = loggerFactory.CreateLogger <ModuleSimulationService>(); _telemetryMessagingService = telemetryMessagingService; _errorMessagingService = errorMessagingService; _commissioningMessagingService = commissioningMessagingService; _provisioningService = provisioningService; _telemetryInterval = 10; _stopProcessing = false; _environmentName = Environment.GetEnvironmentVariable("ENVIRONMENT"); _logger.LogDebug($"{logPrefix}::{ModuleSettings.ArtifactId}::Logger created."); _logger.LogDebug($"{logPrefix}::{ModuleSettings.ArtifactId}::Module simulator created."); }