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); }
/// <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); } }
public void SendMessage(CCSCommandModel message) { _messageStack.Add(message); if (_messageStack.Count > 0) { _timer.Start(); } }
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); }
/// <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); } }
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); }
/// <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); } }
/// <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); } }
/// <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); } }
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; }
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; }
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; }
/// <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); } }
public void SendMessage(CCSCommandModel message) { _messageStack.Add(message); if (_messageStack.Count > 0) _timer.Start(); }