public async Task GetDevice() { DeviceTwinData result = new DeviceTwinData(); var twin = await registryManager.GetTwinAsync(deviceId); var deviceTwin = await registryManager.GetTwinAsync(twin.DeviceId); if (deviceTwin != null) { result.deviceJson = deviceTwin.ToJson(); result.tagsJson = deviceTwin.Tags.ToJson(); result.reportedPropertiesJson = deviceTwin.Properties.Reported.ToJson(); result.desiredPropertiesJson = deviceTwin.Properties.Desired.ToJson(); } //System.Diagnostics.Debug.WriteLine(result.deviceJson); //System.Diagnostics.Debug.WriteLine(result.tagsJson); //System.Diagnostics.Debug.WriteLine(result.reportedPropertiesJson); //System.Diagnostics.Debug.WriteLine(result.desiredPropertiesJson); System.Diagnostics.Debug.WriteLine("Device JSON"); System.Diagnostics.Debug.WriteLine(result.tagsJson); string Json = result.tagsJson; MyMachine TestMachine = JsonConvert.DeserializeObject <MyMachine>(Json); //string MachineLocation = TestMachine.location; //string MachineSettings = TestMachine.settings; System.Diagnostics.Debug.WriteLine(TestMachine); System.Diagnostics.Debug.WriteLine(TestMachine.settings.PresserFreq); System.Diagnostics.Debug.WriteLine(TestMachine.settings.RollerFreq); Text_FirstRow.Text = "Press Freq: " + TestMachine.settings.PresserFreq; Text_SecondRow.Text = "Roller Freq: " + TestMachine.settings.RollerFreq; blinkTimer.Interval = TimeSpan.FromSeconds(TestMachine.settings.RollerFreq); //RollerFreq: 44, // PresserFreq: 22 }
/// <summary> /// The override of ExecuteSelection handles whatever selection was made by the user. /// This is where any business logic is executed. /// </summary> /// <param name="choice">"Key" of the user's menu selection</param> /// <returns></returns> protected override bool ExecuteSelection(string choice) { switch (choice) { case "1": // Display output of file containing Position # and Item List <string> listToDisplay = new List <string>(); listToDisplay = MyMachine.GiveMenuProductList(); foreach (string word in listToDisplay) { Console.WriteLine(word); } Pause(""); return(true); case "2": // Sends user to the purchase menu PurchaseMenu menu = new PurchaseMenu(this.MyMachine); menu.Run(); return(true); } return(true); }
protected override bool ExecuteSelection(string choice) { Console.WriteLine($"Your balance is ${MyMachine.UserBalance}"); switch (choice) { case "1": Console.WriteLine("Please input your money($1.00, $2.00, $5.00, $10.00): "); string givenMoney = Console.ReadLine(); decimal moneyToDecimal = decimal.Parse(givenMoney); //if (moneyToDecimal == 1.00M || moneyToDecimal == 2.00M || moneyToDecimal == 5.00M || moneyToDecimal == 10.00M) try { MyMachine.FeedMoney(moneyToDecimal); } catch (Exception ex) { Console.WriteLine(ex.Message); } Pause("Want to try another bill?"); return(true); case "2": List <string> listToDisplay = new List <string>(); listToDisplay = MyMachine.GiveMenuProductList(); foreach (string word in listToDisplay) { Console.WriteLine(word); } Pause(""); Console.WriteLine("Please enter the letter and digit code for product location e.g. A4"); string userInputLocation = Console.ReadLine(); try { MyMachine.VendItem(userInputLocation); MyMachine.AddToUserCart(userInputLocation); Console.WriteLine(""); foreach (string item in userCartList) { Console.WriteLine(item); } } catch (Exception ex) { Console.WriteLine(ex.Message); } Pause(""); return(true); case "3": Console.WriteLine("Enjoy your food!"); Change change = MyMachine.GiveChange(); Console.WriteLine($"{change.Quarters} Quarters, {change.Dimes} Dimes, {change.Nickels} Nickels Returned"); string[] sounds = MyMachine.userEats(); foreach (string sound in sounds) { Console.WriteLine(sound); } Pause(""); return(true); } return(true); }