Ejemplo n.º 1
0
 private static void RenamingDemo(SmartPlug plugToPlayWith)
 {
      System.Console.WriteLine(string.Format("First let's give the smart plug \"{0}\"", plugToPlayWith.Name));
      System.Console.Write("Please enter a new name and hit return: ");
      string newPlugName = System.Console.ReadLine();
      plugToPlayWith.Name = newPlugName;
      System.Console.WriteLine(string.Format("The new name of the plug is now: \"{0}\". Hit Enter key to continue!", plugToPlayWith.Name));
      System.Console.ReadLine();
 }
Ejemplo n.º 2
0
        static void PlugPlayDemo(SmartPlug smartPlug )
        {
            // initializing adapter
            //SmartPlug smartPlug = new SmartPlug(new IPAddress(new byte[] {a, b, c, d}), "lala", "9999"); //Please use your IP, UserName, PassWord...       

            //displaying current state on the 
            System.Console.WriteLine(string.Format("Current state of the smartplug is: {0}. Hit Enter key to continue!", smartPlug.Status.ToString()));
            System.Console.ReadLine();
            if (smartPlug.Status == SmartPlugState.Off)
            {
                smartPlug.Status = SmartPlugState.On;
            }
            else
            {
                smartPlug.Status = SmartPlugState.Off;
            }
            System.Console.WriteLine(string.Format("Now the state of the smartplug is: {0}. Hit Enter key to continue!", smartPlug.Status.ToString()));
            System.Console.ReadLine();

            //smartPlug.GetEntireSchedule();

            System.Console.WriteLine("Old schedule for Monday:");
            ShowSchedule(DayOfWeek.Monday, smartPlug);
            System.Console.WriteLine("Hit Enter key to continue!");
            System.Console.ReadLine();

            List<ScheduledEntry> newSchedule = new List<ScheduledEntry>();
            newSchedule.Add(new ScheduledEntry(new TimePeriod(new PointInTime(2, 0), new PointInTime(3, 0)),true));
            newSchedule.Add(new ScheduledEntry(new TimePeriod(new PointInTime(12, 0), new PointInTime(14, 30)),true));
            newSchedule.Add(new ScheduledEntry(new TimePeriod(new PointInTime(17, 10), new PointInTime(17, 45)),false));
            newSchedule.Add(new ScheduledEntry(new TimePeriod(new PointInTime(20, 20), new PointInTime(23, 13)),true));

            smartPlug.SetScheduleForWeekDay(DayOfWeek.Monday, newSchedule);

            System.Console.WriteLine("New schedule for Monday:");
            ShowSchedule(DayOfWeek.Monday, smartPlug);
            System.Console.WriteLine("Hit Enter key to continue!");
            System.Console.ReadLine();

            decimal thisMonthPowerConsumption = smartPlug.GetCummulatedPowerConsumption(EnergyPeriods.Month);
            System.Console.WriteLine(string.Format("The power consumption during this month has been {0} [kWh]. Hit Enter key to continue!",thisMonthPowerConsumption));
            System.Console.ReadLine();

        }
Ejemplo n.º 3
0
 static void ShowSchedule(DayOfWeek dayOfWeek, SmartPlug smartPlug)
 {
     IEnumerable<ScheduledEntry> entriesForDay = smartPlug.GetScheduleForWeekDay(dayOfWeek);
     foreach (ScheduledEntry entry in entriesForDay)
     {
         System.Console.WriteLine(string.Format("Entry\tStart:{0}:{1}\tEnd:{2}:{3}\t{4}",
                                   entry.Period.Begin.Hour.ToString("D2"), entry.Period.Begin.Minute.ToString("D2"),
                                   entry.Period.End.Hour.ToString("D2"), entry.Period.End.Minute.ToString("D2"),
                                   entry.Enabled ? "enabled" : "disabled"));
     }
 }