private static async Task Main(string[] args) { var configuration = new ConfigurationBuilder() .AddJsonFile("appSettings.json") .AddEnvironmentVariables() .Build(); ProxyFactory.Configure(configuration["IotHubConnectionString"], configuration["DeviceId"]); while (true) { Console.WriteLine("Select Action: (T)emperatureSensorTwin, (E)xit"); var res = Console.ReadLine()?.ToUpper(); switch (res) { case "T": await SetTemperatureSensorTwin(); break; case "E": return; } } }
private static async Task Main(string[] args) { var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddEnvironmentVariables() .Build(); ProxyFactory.Configure(configuration["IotHubConnectionString"], configuration["DeviceId"]); while (true) { Console.WriteLine("Select Action: (O)rchestratorTwin, (A)nomaly, (E)xit"); var res = Console.ReadLine(); switch (res.ToUpper()) { case "O": await SetOrchestratorTwin(); break; case "A": ProxyFactory.GetModuleProxy <ITemperatureSensor>().GenerateAnomaly(40); break; case "E": return; default: break; } } }
public void TestSingleModule() { var configuration = new ConfigurationBuilder() .AddJsonFile("appSettings.json") .AddEnvironmentVariables() .Build(); var host = new TypeEdgeHost(configuration); //register the modules host.RegisterModule <ITestModule, TestModule>(); host.Upstream.Subscribe(host.GetProxy <ITestModule>().Output); //customize the runtime configuration var dockerRegistry = configuration.GetValue <string>("DOCKER_REGISTRY") ?? ""; var manifest = host.GenerateDeviceManifest((e, settings) => { //this is the opportunity for the host to change the hosting settings of the module e if (!settings.IsExternalModule) { settings.Config = new DockerConfig($"{dockerRegistry}{e}:latest", settings.Config.CreateOptions); } return(settings); }); //provision a new device with the new manifest var sasToken = host.ProvisionDevice(manifest); //build an emulated device in memory host.BuildEmulatedDevice(sasToken); //run the emulated device var task = host.RunAsync(); Console.WriteLine("Waiting for 20 seconds..."); Thread.Sleep(20 * 1000); ProxyFactory.Configure(configuration["IotHubConnectionString"], configuration["DeviceId"]); var testModule = ProxyFactory.GetModuleProxy <ITestModule>(); var offset = new Random().Next(0, 1000); var lastTwin = testModule.Twin.GetAsync().Result; lastTwin.Offset = offset; var res = testModule.Twin.PublishAsync(lastTwin).Result; var res2 = testModule.TestDirectMethod(10); Assert.Equal(res.Offset, offset); Assert.Equal(10, res2); }
private static async Task Main(string[] args) { Console.WriteLine("Press <ENTER> to start.."); Console.ReadLine(); var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddEnvironmentVariables() .Build(); ProxyFactory.Configure(configuration["IotHubConnectionString"], configuration["DeviceId"]); //TODO: Get your module proxies by contract var proxy = ProxyFactory.GetModuleProxy <ITypeEdgeModule1>(); Console.WriteLine("Press <ENTER> to exit.."); Console.ReadLine(); }
private static void Main(string[] args) { Console.WriteLine("Press <ENTER> to start.."); Console.ReadLine(); var configuration = new ConfigurationBuilder() .AddJsonFile("appSettings.json") .AddEnvironmentVariables() .Build(); ProxyFactory.Configure(configuration["IotHubConnectionString"], configuration["DeviceId"]); //TODO: Get your module proxies by contract //var result = ProxyFactory.GetModuleProxy<ITemperatureModule>().ResetSensor(10); Console.WriteLine("Press <ENTER> to exit.."); Console.ReadLine(); }