protected void InternalMapDevice(IChannelIdentity channelIdentity, DeviceController device)
        {
            HashSet <DeviceController> devices;

            if (!mappedDevices.TryGetValue(channelIdentity, out devices))
            {
                devices = new HashSet <DeviceController>();
                mappedDevices[channelIdentity] = devices;
            }
            devices.Add(device);

            if (device is IControlledDevice)
            {
                this.controlledDevices.Add((IControlledDevice)device);
            }
            if (device is LogicalDevice.IHasControlledDevice)
            {
                this.controlledDevices.Add(((LogicalDevice.IHasControlledDevice)device).ControlledDevice);
            }

            var channelData = this.channelData[channelIdentity];

            channelData.Mapped = true;

            if (!channelData.HasEffects)
            {
                this.log.Warning("Channel {0}/{1} is mapped, but has no effects", channelIdentity, channelData.Name);
            }
        }
Example #2
0
        public void MapDevice(IChannelIdentity channelIdentity, LogicalDevice.IHasBrightnessControl device)
        {
            var mappedDevice = new MappedDeviceDimmer(device);

            InternalMapDevice(channelIdentity, mappedDevice);

            device.Brightness = 0.0;
        }
 public RGBChannelIdentity(
     IChannelIdentity r,
     IChannelIdentity g,
     IChannelIdentity b)
 {
     this.R = r;
     this.G = g;
     this.B = b;
 }
Example #4
0
 public RGBChannelIdentity(
     IChannelIdentity r,
     IChannelIdentity g,
     IChannelIdentity b)
 {
     this.R = r;
     this.G = g;
     this.B = b;
 }
Example #5
0
        public T MapDevice <T>(IChannelIdentity channelIdentity, Func <string, T> logicalDevice) where T : LogicalDevice.IHasBrightnessControl
        {
            string name = GetChannelName(channelIdentity);

            var device = logicalDevice.Invoke(name);

            MapDevice(channelIdentity, device);

            return(device);
        }
Example #6
0
        public void MapDevice(
            IChannelIdentity channelIdentityR,
            IChannelIdentity channelIdentityG,
            IChannelIdentity channelIdentityB,
            LogicalDevice.IHasColorControl device)
        {
            var mappedDevice = new MappedDeviceRGB(device);

            InternalMapDevice(new RGBChannelIdentity(channelIdentityR, channelIdentityG, channelIdentityB), mappedDevice);

            device.Color = Color.Black;
        }
Example #7
0
        private void AddEffectData(IChannelIdentity channelIdentity, IEnumerable <DeviceController> devices, ChannelEffectInstance.DeviceType deviceType)
        {
            foreach (var effectData in this.channelEffectsPerChannel[channelIdentity])
            {
                var effectInstance = new ChannelEffectInstance
                {
                    Devices = devices,
                    Effect  = effectData,
                    Type    = deviceType
                };

                timeline.AddMs(effectData.StartMs, effectInstance);
            }
        }
Example #8
0
        public T MapDevice <T>(
            IChannelIdentity channelIdentityR,
            IChannelIdentity channelIdentityG,
            IChannelIdentity channelIdentityB,
            Func <string, T> logicalDevice) where T : LogicalDevice.IHasColorControl
        {
            string name = string.Format("{0}/{1}/{2}",
                                        GetChannelName(channelIdentityR), GetChannelName(channelIdentityG), GetChannelName(channelIdentityB));

            var device = logicalDevice.Invoke(name);

            MapDevice(channelIdentityR, channelIdentityG, channelIdentityB, device);

            return(device);
        }
        protected void AddChannelData(IChannelIdentity channelIdentity, ChannelData data)
        {
            string originalName = data.Name;
            int    suffixNumber = 0;

            while (ChannelNameExists(data.Name))
            {
                suffixNumber++;

                data.ChangeName(string.Format("{0} ({1})", originalName, suffixNumber));
            }

            if (this.channelData.ContainsKey(channelIdentity))
            {
                this.log.Warning("Channel id {0} already exists", channelIdentity);
            }

            this.channelData[channelIdentity] = data;
            //            this.channels.Add(channelIdentity);
        }
Example #10
0
        /// <summary>
        /// Create.
        /// </summary>
        /// <param name="subject">The subject of the notification.</param>
        /// <param name="templateKey">The key of the template.</param>
        /// <param name="source">The source specifying the sender or system generating the notification.</param>
        /// <param name="destination">The destination of the notification.</param>
        /// <param name="time">The generation date of the notification, in UTC.</param>
        /// <param name="dynamicProperties">The dynamic properties.</param>
        /// <param name="topic">The topic which the notification serves.</param>
        public ChannelMessage(
            string subject,
            string templateKey,
            IChannelIdentity source,
            IChannelDestination destination,
            DateTime time,
            IReadOnlyDictionary <string, object> dynamicProperties,
            T topic = default(T))
        {
            if (subject == null)
            {
                throw new ArgumentNullException(nameof(subject));
            }
            if (templateKey == null)
            {
                throw new ArgumentNullException(nameof(templateKey));
            }
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }
            if (time.Kind != DateTimeKind.Utc)
            {
                throw new ArgumentException("Time is not in UTC.", nameof(time));
            }

            this.Guid = Guid.NewGuid();

            this.Subject           = subject;
            this.TemplateKey       = templateKey;
            this.Source            = source;
            this.Destination       = destination;
            this.Topic             = topic;
            this.Time              = time;
            this.Time              = time;
            this.DynamicProperties = dynamicProperties;
        }
Example #11
0
        protected void InternalMapDevice(IChannelIdentity channelIdentity, MappedDeviceDimmer device)
        {
            HashSet <MappedDeviceDimmer> devices;

            if (!mappedDevices.TryGetValue(channelIdentity, out devices))
            {
                devices = new HashSet <MappedDeviceDimmer>();
                mappedDevices[channelIdentity] = devices;
            }
            devices.Add(device);

            this.channelData[channelIdentity].Mapped = true;

            if (device.Device is IControlledDevice)
            {
                this.controlledDevices.Add((IControlledDevice)device.Device);
            }
            if (device.Device is LogicalDevice.IHasControlledDevice)
            {
                this.controlledDevices.Add(((LogicalDevice.IHasControlledDevice)device.Device).ControlledDevice);
            }
        }
        //public IEnumerable<IChannelIdentity> GetChannels
        //{
        //    get
        //    {
        //        return this.channels;
        //    }
        //}

        public string GetChannelName(IChannelIdentity channelIdentity)
        {
            var channel = this.channelData[channelIdentity];

            return(channel.Name);
        }
Example #13
0
        private void AddEffectData(IChannelIdentity channelIdentity, IEnumerable<DeviceController> devices, ChannelEffectInstance.DeviceType deviceType)
        {
            foreach (var effectData in this.channelEffectsPerChannel[channelIdentity])
            {
                var effectInstance = new ChannelEffectInstance
                {
                    Devices = devices,
                    Effect = effectData,
                    Type = deviceType
                };

                timeline.AddMs(effectData.StartMs, effectInstance);
            }
        }
Example #14
0
 protected void AddChannelData(IChannelIdentity channelIdentity, ChannelData data)
 {
     this.channelData[channelIdentity] = data;
     this.channels.Add(channelIdentity);
 }
Example #15
0
 private System.Net.Mail.MailAddress GetMailAddress(IChannelIdentity notificationIdentity)
 => new System.Net.Mail.MailAddress(notificationIdentity.Email, notificationIdentity.Name, Encoding.UTF8);
Example #16
0
 /// <summary>
 /// Override to extract e-mail sender from a source object and a topic.
 /// </summary>
 protected abstract Task <IChannelIdentity> GetSenderIdentityAsync(IChannelIdentity source, T topic);