static void Main(string[] args) { var hostname = args[0]; var port = Int32.Parse(args[1]); var blyncClient = new BlyncClient(); var tcpClientSettings = new TcpClientSettings { ConnectionTimeoutPeriod = 30000, Hostname = hostname, Port = port, PacketStreamFactory = new JsonPacketStreamFactory() }; if (blyncClient.NumberOfDevices == 0) { Console.WriteLine("No devices found"); return; } Console.WriteLine("Devices found: {0}", blyncClient.NumberOfDevices); for (int id = 0; id < blyncClient.NumberOfDevices; id++) { Console.WriteLine(" [{0}] {1}", id, blyncClient.GetDeviceType(id)); } Console.WriteLine("Connecting to {0}:{1}", hostname, port); new Application(blyncClient, tcpClientSettings).Run(); }
private void ProcessReset(BlyncClient blyncClient, Options options) { foreach (var device in options.Device) { blyncClient.ResetLight(Int32.Parse(device)); } }
private static void Main(string[] args) { int i = 120; if (args.Length == 1) { i = int.Parse(args[0]); } var client = new BlyncClient(); var hsvColor = new HsvColor { Hue = 1, Saturation = 1, Value = 1 }; while (true) { var rgbColor = hsvColor.ToRgbColor(); client.SetColor(0, rgbColor.Red, rgbColor.Green, rgbColor.Blue); hsvColor.Hue++; if (hsvColor.Hue > 360) { hsvColor.Hue = 1; } Thread.Sleep((i * 1000) / 360); } }
public Application(BlyncClient blyncClient, TcpClientSettings tcpClientSettings) { _blyncClient = blyncClient; _blyncTcpClient = new BlyncTcpClient(tcpClientSettings); _keepAlive = true; _instructionExecuter = new InstructionExecuter(_blyncClient); }
private void ProcessFlashSpeed(BlyncClient blyncClient, Options options) { var flashSpeed = options.FlashSpeed ?? 1; BlyncClient.Speed speed; switch (flashSpeed) { case 1: speed = BlyncClient.Speed.Low; break; case 2: speed = BlyncClient.Speed.Medium; break; case 3: speed = BlyncClient.Speed.High; break; default: throw new ArgumentOutOfRangeException(); } foreach (var device in options.Device) { blyncClient.SetFlashSpeed(Int32.Parse(device), speed); } }
private void ProcessFlash(BlyncClient blyncClient, Options options) { var enable = options.Flash ?? false; foreach (var device in options.Device) { blyncClient.SetFlash(Int32.Parse(device), enable); } }
private void ProcessDim(BlyncClient blyncClient, Options options) { bool enable = options.Dim ?? false; foreach (var device in options.Device) { blyncClient.SetDim(Int32.Parse(device), enable); } }
public void DisplayConnectedDevices(BlyncClient client) { Console.WriteLine("Number of devices connected: {0}", client.NumberOfDevices); for (var deviceId = 0; deviceId < client.NumberOfDevices; deviceId++) { Console.WriteLine("Device ID: {0}, Device Type: {1}", deviceId, client.GetDeviceType(deviceId)); } }
private List <string> ProcessDevices(BlyncClient blyncClient) { var devices = new List <string>(); for (var i = 0; i < blyncClient.NumberOfDevices; i++) { devices.Add(i.ToString()); } return(devices); }
private void ProcessColor(BlyncClient blyncClient, Options options) { BlyncClient.Color color; switch (options.Color.ToLower()) { case "red": color = BlyncClient.Color.Red; break; case "green": color = BlyncClient.Color.Green; break; case "blue": color = BlyncClient.Color.Blue; break; case "cyan": color = BlyncClient.Color.Cyan; break; case "magenta": color = BlyncClient.Color.Magenta; break; case "yellow": color = BlyncClient.Color.Yellow; break; case "white": color = BlyncClient.Color.White; break; case "orange": color = BlyncClient.Color.Orange; break; default: throw new ArgumentOutOfRangeException(); } foreach (var device in options.Device) { blyncClient.SetColor(Int32.Parse(device), color); } }
private static void Main(string[] args) { var client = new BlyncClient(); var optionsExecuter = new OptionsExecuter(client); var consoleDisplay = new ConsoleDisplay(); Console.WriteLine("Blync stand alone console"); if (client.NumberOfDevices <= 0) { consoleDisplay.DisplayDeviceNotFoundError(); return; } consoleDisplay.DisplayConnectedDevices(client); bool keepAlive; do { keepAlive = Run(consoleDisplay, optionsExecuter); } while (keepAlive); }
private void When_I_initalize_a_new_client() { _blyncClient = new BlyncClient(); }
private void Given_that_I_have_a_client() { _blyncClient = new BlyncClient(); }
public InstructionExecuter(BlyncClient blyncClient) { _blyncClient = blyncClient; }
public OptionsExecuter(BlyncClient blyncClient) { _blyncClient = blyncClient; }
private void When_I_initalize_a_new_disposable_client() { using (_blyncClient = new BlyncClient()) { } }