コード例 #1
0
        public CCSCommandModel GetIntesnityModel(int intensity, string channel)
        {
            var instruction = "F";

            if (intensity < 0)
            {
                intensity = 0;
            }
            if (intensity > 255)
            {
                intensity = 255;
            }

            var data  = intensity.ToString().PadLeft(3, '0');
            var model = new CCSCommandModel()
            {
                ChannelCommands = new Dictionary <string, InstructionModel>()
                {
                    { channel, new InstructionModel()
                      {
                          Instruction = instruction, Data = data
                      } }
                },
            };

            return(model);
        }
コード例 #2
0
        /// <summary>
        /// 設定光源亮度, 非同步方法
        /// </summary>
        /// <param name="intensity"></param>
        /// <param name="channel"></param>
        public void SetLightIntensityAsync(int intensity, string channel)
        {
            var instruction = "F";

            if (intensity < 0 || intensity > 255)
            {
                return;
            }

            var data  = intensity.ToString().PadLeft(3, '0');
            var model = new CCSCommandModel()
            {
                ChannelCommands = new Dictionary <string, InstructionModel>()
                {
                    { channel, new InstructionModel()
                      {
                          Instruction = instruction, Data = data
                      } }
                },
            };

            if (!_bgWorker.IsBusy)
            {
                _bgWorker.RunWorkerAsync(model);
            }
        }
コード例 #3
0
 public void SendMessage(CCSCommandModel message)
 {
     _messageStack.Add(message);
     if (_messageStack.Count > 0)
     {
         _timer.Start();
     }
 }
コード例 #4
0
        public CCSCommandModel GetLightOnOffModel(LightSwitch onOff, string channel)
        {
            var instruction = "L";
            var model       = new CCSCommandModel()
            {
                ChannelCommands = new Dictionary <string, InstructionModel>()
                {
                    { channel, new InstructionModel()
                      {
                          Instruction = instruction, Data = ((int)onOff).ToString()
                      } }
                },
            };

            return(model);
        }
コード例 #5
0
        /// <summary>
        /// 設定光源 on/off, 非同步方法
        /// </summary>
        /// <param name="onOff"></param>
        /// <param name="channel"></param>
        public void SetLightOnOffAsync(LightSwitch onOff, string channel)
        {
            var instruction = "L";
            var model       = new CCSCommandModel()
            {
                ChannelCommands = new Dictionary <string, InstructionModel>()
                {
                    { channel, new InstructionModel()
                      {
                          Instruction = instruction, Data = ((int)onOff).ToString()
                      } }
                },
            };

            if (!_bgWorker.IsBusy)
            {
                _bgWorker.RunWorkerAsync(model);
            }
        }
コード例 #6
0
        public CCSCommandModel GetChannelStatusModel(string[] channels)
        {
            var instruction     = "M";
            var channelsCommand = new Dictionary <string, InstructionModel>();

            foreach (var channel in channels)
            {
                channelsCommand.Add(channel, new InstructionModel()
                {
                    Instruction = instruction, Data = ""
                });
            }
            //prepare data
            var model = new CCSCommandModel()
            {
                ChannelCommands = channelsCommand,
            };

            return(model);
        }
コード例 #7
0
        /// <summary>
        /// 取得 Channel 狀態
        /// </summary>
        /// <param name="channel">00, 01, 02</param>
        /// <returns></returns>
        public void GetChannelStatusAsync(string[] channels)
        {
            var instruction     = "M";
            var channelsCommand = new Dictionary <string, InstructionModel>();

            foreach (var channel in channels)
            {
                channelsCommand.Add(channel, new InstructionModel()
                {
                    Instruction = instruction, Data = ""
                });
            }
            //prepare data
            var model = new CCSCommandModel()
            {
                ChannelCommands = channelsCommand,
            };

            if (!_bgWorker.IsBusy)
            {
                _bgWorker.RunWorkerAsync(model);
            }
        }
コード例 #8
0
        /// <summary>
        /// 設定光源 on/off, 非同步方法
        /// </summary>
        /// <param name="onOff"></param>
        /// <param name="channel"></param>
        public void SetLightOnOffAsync(LightSwitch onOff, string channel)
        {
            var instruction = "L";
            var model = new CCSCommandModel()
            {
                ChannelCommands = new Dictionary<string, InstructionModel>()
                {
                    {channel, new InstructionModel(){Instruction = instruction, Data = ((int)onOff).ToString()}}
                },
            };

            if (!_bgWorker.IsBusy)
            {
                _bgWorker.RunWorkerAsync(model);
            }
        }
コード例 #9
0
        /// <summary>
        /// 設定光源亮度, 非同步方法
        /// </summary>
        /// <param name="intensity"></param>
        /// <param name="channel"></param>
        public void SetLightIntensityAsync(int intensity, string channel)
        {
            var instruction = "F";
            if (intensity < 0 || intensity > 255) return;

            var data = intensity.ToString().PadLeft(3, '0');
            var model = new CCSCommandModel()
            {
                ChannelCommands = new Dictionary<string, InstructionModel>()
                {
                    {channel, new InstructionModel(){Instruction = instruction, Data = data}}
                },
            };

            if (!_bgWorker.IsBusy)
            {
                _bgWorker.RunWorkerAsync(model);
            }
        }
コード例 #10
0
 public CCSCommandModel GetLightOnOffModel(LightSwitch onOff, string channel)
 {
     var instruction = "L";
     var model = new CCSCommandModel()
     {
         ChannelCommands = new Dictionary<string, InstructionModel>()
         {
             {channel, new InstructionModel(){Instruction = instruction, Data = ((int)onOff).ToString()}}
         },
     };
     return model;
 }
コード例 #11
0
        public CCSCommandModel GetIntesnityModel(int intensity, string channel)
        {
            var instruction = "F";
            if (intensity < 0) intensity = 0;
            if (intensity > 255) intensity = 255;

            var data = intensity.ToString().PadLeft(3, '0');
            var model = new CCSCommandModel()
            {
                ChannelCommands = new Dictionary<string, InstructionModel>()
                {
                    {channel, new InstructionModel(){Instruction = instruction, Data = data}}
                },
            };
            return model;
        }
コード例 #12
0
        public CCSCommandModel GetChannelStatusModel(string[] channels)
        {
            var instruction = "M";
            var channelsCommand = new Dictionary<string, InstructionModel>();

            foreach (var channel in channels)
            {
                channelsCommand.Add(channel, new InstructionModel() { Instruction = instruction, Data = "" });
            }
            //prepare data
            var model = new CCSCommandModel()
            {
                ChannelCommands = channelsCommand,
            };
            return model;
        }
コード例 #13
0
        /// <summary>
        /// 取得 Channel 狀態
        /// </summary>
        /// <param name="channel">00, 01, 02</param>
        /// <returns></returns>
        public void GetChannelStatusAsync(string[] channels)
        {
            var instruction = "M";
            var channelsCommand = new Dictionary<string, InstructionModel>();

            foreach (var channel in channels)
            {
                channelsCommand.Add(channel, new InstructionModel() { Instruction = instruction, Data = "" });
            }
            //prepare data
            var model = new CCSCommandModel()
            {
                ChannelCommands = channelsCommand,
            };
            if (!_bgWorker.IsBusy)
            {
                _bgWorker.RunWorkerAsync(model);
            }
        }
コード例 #14
0
 public void SendMessage(CCSCommandModel message)
 {
     _messageStack.Add(message);
     if (_messageStack.Count > 0) _timer.Start();
 }