Пример #1
0
        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();
        }
Пример #2
0
 private void ProcessReset(BlyncClient blyncClient, Options options)
 {
     foreach (var device in options.Device)
     {
         blyncClient.ResetLight(Int32.Parse(device));
     }
 }
Пример #3
0
        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);
            }
        }
Пример #4
0
 public Application(BlyncClient blyncClient, TcpClientSettings tcpClientSettings)
 {
     _blyncClient         = blyncClient;
     _blyncTcpClient      = new BlyncTcpClient(tcpClientSettings);
     _keepAlive           = true;
     _instructionExecuter = new InstructionExecuter(_blyncClient);
 }
Пример #5
0
        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);
            }
        }
Пример #6
0
        private void ProcessFlash(BlyncClient blyncClient, Options options)
        {
            var enable = options.Flash ?? false;

            foreach (var device in options.Device)
            {
                blyncClient.SetFlash(Int32.Parse(device), enable);
            }
        }
Пример #7
0
        private void ProcessDim(BlyncClient blyncClient, Options options)
        {
            bool enable = options.Dim ?? false;

            foreach (var device in options.Device)
            {
                blyncClient.SetDim(Int32.Parse(device), enable);
            }
        }
Пример #8
0
        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));
            }
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
            }
        }
Пример #11
0
        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);
        }
Пример #12
0
 private void When_I_initalize_a_new_client()
 {
     _blyncClient = new BlyncClient();
 }
Пример #13
0
 private void Given_that_I_have_a_client()
 {
     _blyncClient = new BlyncClient();
 }
Пример #14
0
 public InstructionExecuter(BlyncClient blyncClient)
 {
     _blyncClient = blyncClient;
 }
Пример #15
0
 public OptionsExecuter(BlyncClient blyncClient)
 {
     _blyncClient = blyncClient;
 }
Пример #16
0
 private void When_I_initalize_a_new_disposable_client()
 {
     using (_blyncClient = new BlyncClient())
     {
     }
 }