Exemplo n.º 1
0
        public DeviceArm() : base()
        {
            string cmd;

            driver = new ServoDriver();
            driver.Run();
            while (true)
            {
                cmd = Console.ReadLine();
                if (cmd.Equals("x"))
                {
                    break;
                }

                if (cmd.Equals("r"))
                {
                    com.Send(ComData.RequestReset());
                    continue;
                }

                com.Send(new ComData(cmd));
            }

            EventBulletin.GetInstance().Notify(EventBulletin.Event.CLOSE, null, null);
            Environment.Exit(0);
        }
Exemplo n.º 2
0
        public Device()
        {
            com = ComFactory.MakeDefault();
            com.setOnRead(onComRead);

            EventBulletin.Subscribe(EventBulletin.Event.CLOSE, (o, e) => { onClose(); });
        }
Exemplo n.º 3
0
        //private Com com;

        public MainWindow(Controller mainController)
        {
            controller    = mainController;
            eventBulletin = EventBulletin.GetInstance();

            InitializeComponent();

            lib = new Library(grdLeft, grdMid, this.Resources["MyContentTray"] as Style);
        }
Exemplo n.º 4
0
        public ControllerKeyboard(Com com) : base(com)
        {
            kpPosDir = new PosDirProcessor();
            kpRaw    = new RawAnglesProcessor();

            keysDown   = new Collection <Key>();
            keysToggle = new Collection <Key>();

            EventBulletin.Subscribe(EventBulletin.Event.KEY_DOWN, (o, e) =>
            {
                keyDown((KeyEventArgs)e);
            });
            EventBulletin.Subscribe(EventBulletin.Event.KEY_UP, (o, e) =>
            {
                keyUp((KeyEventArgs)e);
            });
        }
Exemplo n.º 5
0
        private void init()
        {
            lastPacketKey = new PacketKey(0); // is time

            writeThread = new Thread(writeLoop);

            sendQ           = new LinkedList <Packet>();
            writeResetEvent = new AutoResetEvent(false);

            EventBulletin.Subscribe(EventBulletin.Event.CLOSE, (o, e) => { Close(); });

            Task.Delay(0).ContinueWith((t) =>
            {
                connectProcedure();
                running = true;

                beginRead(incommingRead);
                writeThread.Start();
            });
        }
Exemplo n.º 6
0
        private void SocketExceptionContainer(Action fn)
        {
            try
            {
                fn();
            }
            catch (Exception e)
            {
                foreach (string m in acceptedSocketExceptions)
                {
                    if (e.Message.Contains(m))
                    {
                        Console.WriteLine("Connection terminated");
                        EventBulletin.GetInstance().Notify(EventBulletin.Event.CLOSE, null, null);
                        return;
                    }
                }

                throw e;
            }
        }
Exemplo n.º 7
0
        private Program()
        {
            //com = ComFactory.MakeDefault();
            com = ComFactory.MakeDummy();
            com.setOnRead(tempOnRead);

            Task.Delay(0).ContinueWith((t) =>
            {
                string cmd;
                while (true)
                {
                    cmd = Console.ReadLine();
                    Console.WriteLine("echo: " + cmd);
                    if (cmd.Equals("x"))
                    {
                        break;
                    }

                    if (cmd.Equals("r"))
                    {
                        com.Send(ComData.RequestClose());
                        continue;
                    }

                    com.Send(new ComData(cmd));
                }

                Console.WriteLine("close");
                EventBulletin.GetInstance().Notify(EventBulletin.Event.CLOSE, null, null);
            });

            controllerDefault = ControllerFactory.MakeDefault(com);
            mainWindow        = new MainWindow(controllerDefault);
            mainWindow.Show();

            EventBulletin.Subscribe(EventBulletin.Event.CLOSE, (o, e) => { tempOnClose(); });

            app = new Application();
            app.Run(mainWindow);
        }