Пример #1
0
        public static void Main()
        {
            blinker = new Blinker();

            WakeupBlink();

            try
            {
                //var network = new StaticEthernetNetwork("192.168.1.199","255.255.255.0","192.168.1.1");
                var network = new DynamicEthernetNetwork();

                var buzzer = new Buzzer(Pins.GPIO_PIN_D6);
                buzzer.Buzz(150, 1000);

                var servo = new RadioShackMicroServo(Pins.GPIO_PIN_D9);
                servo.Center();
                Thread.Sleep(1000);

                servo.Left();
                Thread.Sleep(1000);
                servo.Right();
                Thread.Sleep(1000);
                servo.Center();
                Thread.Sleep(1000);

                var server = new WebServer(80, servo, buzzer, new FeederTrainingBeep(buzzer), blinker);
                server.Wait();

                ShutdownBlink();
            }
            catch
            {
                ErrorBlink();
            }
        }
Пример #2
0
        public WebServer(int port, RadioShackMicroServo servo, Buzzer buzzer, FeederTrainingBeep training, Blinker blinker)
        {
            _servo    = servo;
            _buzzer   = buzzer;
            _training = training;
            _blinker  = blinker;

            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _socket.Bind(new IPEndPoint(IPAddress.Any, port));
            _socket.Listen(Backlog);

            _listenerThread = new Thread(new ThreadStart(ListenForClients));
            _listenerThread.Start();
        }
 public FeederTrainingBeep(Buzzer buzzer)
 {
     _buzzer = buzzer;
 }