/// <summary> /// Swiches receivers with specific device code off. /// </summary> /// <param name="deviceCode">Device code of receivers.</param> /// <param name="commandStyle">Does specify how much information is send.</param> public void SwitchOff(int deviceCode, CommandStyle commandStyle) { lock (this.locker) { this.SendCommand(deviceCode, Command.Off, commandStyle); } }
/// <summary> /// Adjusts dim level on receivers with specific device code. /// </summary> /// <param name="deviceCode">Device code of receivers.</param> /// <param name="commandStyle">Does specify how much information is send.</param> /// <param name="amount">Amount of dim. A value between 1 an 8.</param> public void AdjustDim(int deviceCode, CommandStyle commandStyle, int amount) { if (!Command.IsValidDim(amount)) { throw new ArgumentOutOfRangeException("amount", "Must be value between " + Command.MinDim + " and " + Command.MaxDim + "."); } lock (this.locker) { this.SendCommand(deviceCode, Convert.ToString(amount, CultureInfo.InvariantCulture), commandStyle); } }
/// <summary> /// Parse command line arguments. /// </summary> /// <param name="args">Command line arguments.</param> private void ParseStyle(string[] args) { this.Style = CommandStyle.Comprehensive; foreach (string arg in args) { if (arg == Short) { this.Style = CommandStyle.Short; break; } } }
/// <summary> /// Encodes and sends a command in text form to the HE853 device. /// </summary> /// <param name="deviceCode">Device code of receivers.</param> /// <param name="command">Text command to send.</param> /// <param name="commandStyle">Does specify how much information is send.</param> private void SendCommand(int deviceCode, string command, CommandStyle commandStyle) { if (!Command.IsValidDeviceCode(deviceCode)) { throw new ArgumentOutOfRangeException("deviceCode", "Must be value between " + Command.MinDeviceCode + " and " + Command.MaxDeviceCode + "."); } this.TestStatus(); this.SendCommand(this.commandCN.Build(deviceCode, command)); if (commandStyle == CommandStyle.Comprehensive && (command == Command.On || command == Command.Off)) { this.SendCommand(this.commandUK.Build(deviceCode, command)); this.SendCommand(this.commandEU.Build(deviceCode, command)); } }
private static vsCommandStyle ToVsCommandStyle(CommandStyle style) { switch (style) { case CommandStyle.PictureAndText: return(vsCommandStyle.vsCommandStylePictAndText); case CommandStyle.Picture: return(vsCommandStyle.vsCommandStylePict); case CommandStyle.Text: return(vsCommandStyle.vsCommandStyleText); default: throw new ArgumentOutOfRangeException("style"); } }
private static vsCommandStyle ToVsCommandStyle(CommandStyle style) { switch (style) { case CommandStyle.PictureAndText: return vsCommandStyle.vsCommandStylePictAndText; case CommandStyle.Picture: return vsCommandStyle.vsCommandStylePict; case CommandStyle.Text: return vsCommandStyle.vsCommandStyleText; default: throw new ArgumentOutOfRangeException("style"); } }