public async Task SimulateDevice(string deviceType, int messageDelay, int n, string caFile) { var producer = new IoTHubProducerCommands(CurrentContext, service); if (!String.IsNullOrWhiteSpace(caFile)) { Console.WriteLine($"Registering CA certificate: {caFile}"); var caCert = await CertificateUtilities.LoadPemCACertificate(caFile, null); CertificateUtilities.RegisterCert2(caCert); } if (string.Compare(deviceType, "temperature", true) == 0) { await producer. SimulateTemperatureSensor(messageDelay, n); } else if (string.Compare(deviceType, "temperature_pair", true) == 0) { await producer. SimulateTemperatureSensorPair(messageDelay, n); } else { Console.WriteLine($"No matching device type: {deviceType}"); } await Task.CompletedTask; }
public async Task SimulateDevice(string deviceType, int messageDelay, int n, string caFile, string[] deviceContext, string pattern, string patternPeriod, string output) { bool isJson = String.Compare(output, "json", true) == 0; bool isCsv = String.Compare(output, "csv", true) == 0; OutputFormat of; if (isJson) { of = OutputFormat.Json; } else if (isCsv) { of = OutputFormat.Csv; } else { Console.WriteLine($"No matching output format: {output}"); return; } var producer = new IoTHubProducerCommands(CurrentContext, service); if (!String.IsNullOrWhiteSpace(caFile)) { Console.WriteLine($"Registering CA certificate: {caFile}"); var caCert = await CertificateUtilities.LoadPemCACertificate(caFile, null); CertificateUtilities.RegisterCert2(caCert); } if (string.Compare(deviceType, "temperature", true) == 0) { if (deviceContext == null || deviceContext.Length == 0) { await producer. SimulateTemperatureSensor(messageDelay, n, pattern, patternPeriod); } else { await producer.SimulateMultipleTemperatureSensors(deviceContext, messageDelay, n, pattern, patternPeriod, of); } } else if (string.Compare(deviceType, "temperature_pair", true) == 0) { await producer. SimulateTemperatureSensorPair(messageDelay, n); } else { Console.WriteLine($"No matching device type: {deviceType}"); } await Task.CompletedTask; }