Ejemplo n.º 1
0
        public static object Interpolate(TimeSpan time, TimeNode currentNode, TimeNode nextNode, string propertyName)
        {
            var currentProperty = currentNode.Properties.First(prop => prop.Name == propertyName);
            var nextProperty    = nextNode.Properties.First(prop => prop.Name == propertyName);

            var currentValue = currentProperty.Value;
            var nextValue    = nextProperty.Value;

            if (currentValue == null)
            {
                return(null);
            }
            if (nextValue == null)
            {
                return(null);
            }

            if (currentValue.GetType() != nextValue.GetType())
            {
                return(null);
            }

            var percentage = GetRelTimePercentage(time, currentNode.TimeOfDay, nextNode.TimeOfDay);

            return(Interpolate(currentValue, nextValue, percentage));
        }
Ejemplo n.º 2
0
        public static TimeProfile Create()
        {
            Log.Info("Creating default time profile");

            var result = new TimeProfile();

            var wakeUpTime = new TimeNode(TimeSpan.FromHours(7));

            wakeUpTime.Properties.Add(new NodeProperty(NodeProperty.Brightness, 20));
            wakeUpTime.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 3300));
            result.AddNode(wakeUpTime);

            var morning = new TimeNode(TimeSpan.FromHours(8));

            morning.Properties.Add(new NodeProperty(NodeProperty.Brightness, 80));
            morning.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 6500));
            result.AddNode(morning);

            var srsModeOver = new TimeNode(TimeSpan.FromHours(17));

            srsModeOver.Properties.Add(new NodeProperty(NodeProperty.Brightness, 80));
            srsModeOver.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 6500));
            result.AddNode(srsModeOver);

            var afterDinner = new TimeNode(TimeSpan.FromHours(19));

            afterDinner.Properties.Add(new NodeProperty(NodeProperty.Brightness, 40));
            afterDinner.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 5000));
            result.AddNode(afterDinner);

            var bedTime = new TimeNode(TimeSpan.FromHours(22));

            bedTime.Properties.Add(new NodeProperty(NodeProperty.Brightness, 20));
            bedTime.Properties.Add(new NodeProperty(NodeProperty.ColorTemperature, 3300));
            result.AddNode(bedTime);

            return(result);
        }
Ejemplo n.º 3
0
 public void AddNode(TimeNode node)
 {
     Nodes.Add(node);
     NodeAdded?.Invoke(this, new TimeProfileNodeAddedEvent(node));
 }
Ejemplo n.º 4
0
 public TimeProfileNodeAddedEvent(TimeNode node)
 {
     Node = node;
 }