예제 #1
0
파일: Device.cs 프로젝트: Phyberosis/ArmP2
        public Device()
        {
            com = ComFactory.MakeDefault();
            com.setOnRead(onComRead);

            EventBulletin.Subscribe(EventBulletin.Event.CLOSE, (o, e) => { onClose(); });
        }
예제 #2
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);
            });
        }
예제 #3
0
파일: Com.cs 프로젝트: Phyberosis/ArmP2
        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();
            });
        }
예제 #4
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);
        }