// test initialization public KioskDeviceTest() { deviceconfig = new KioskDeviceConfig() { DeviceId = "myFakeDevice", DeviceType = DeviceType.TicketKiosk, InitialStockCount = 100, LowStockThreshold = 98 }; }
public KioskDevice(KioskDeviceConfig deviceConfig, IDeviceClient client, IEventScheduler eventScheduler) : base(deviceConfig, client, eventScheduler) { this.deviceConfig = deviceConfig; this.TicketStockCount = deviceConfig.InitialStockCount; // set up any simulated events for this device this._EventScheduler.Add(new TimedSimulatedEvent(5000, 2500, this.SendPurchaseTicketMessageToCloud)); // register any direct methods we're to recieve this._DeviceClient.RegisterDirectMethodAsync(ReceivePurchaseTicketResponse).Wait(); }
private static void Main(string[] args) { Console.WriteLine("Transportation Demo- Simulated device. Ctrl-C to exit.\n"); // setup the items used by the simulated device TransportationDeviceClient myClient = new TransportationDeviceClient(ConfigurationHandler.getConfig("AppSettings", "IoTConnectionString")); EventScheduler myScheduler = new EventScheduler(); // get device configuration details from JSON file KioskDeviceConfig deviceConfig = JsonConvert.DeserializeObject <KioskDeviceConfig>(ConfigurationHandler.GetDeviceRuntimeSettings("deviceConfig")); // create our simulated device myKiosk = new KioskDevice(deviceConfig, myClient, myScheduler); myKiosk.InitializeAsync().Wait(); // start the device running myKiosk.StartAllEvents(); while (true) { Thread.Sleep(30000); } }