Example #1
0
        public LampNode SetLampStateExtended(string id, SetLampDataExtended data)
        {
            LampNode record = null;

            RuntimeMonitor.Monitor.RegisterCall("LampSet");

            record = GetLamp(id);
            record.ProcessStateChanges(data);

            RequestSequencer.Sequencer.Schedule(new LampRequest(id, data));

            return(record);
        }
Example #2
0
        public void ProcessStateChanges(SetLampDataExtended data)
        {
            if (data.OnChanged)
            {
                On = Convert.ToBoolean(data.On);
            }
            if (data.ColorChanged)
            {
                if (data.Red >= 0 && data.Red <= 255)
                {
                    Red = Convert.ToByte(data.Red);
                }
                if (data.Green >= 0 && data.Green <= 255)
                {
                    Green = Convert.ToByte(data.Green);
                }
                if (data.Blue >= 0 && data.Blue <= 255)
                {
                    Blue = Convert.ToByte(data.Blue);
                }
            }
            if (data.BrightnessChanged)
            {
                var rgb = new Rgb {
                    R = Red, G = Green, B = Blue
                };
                var hsb = rgb.To <Hsb>();

                hsb.B = data.Brightness;
                rgb   = hsb.To <Rgb>();

                Red   = Convert.ToByte(rgb.R);
                Green = Convert.ToByte(rgb.G);
                Blue  = Convert.ToByte(rgb.B);
            }
        }
Example #3
0
 public LampRequest(String id, SetLampDataExtended data)
 {
     Id   = id;
     Data = data;
 }