Beispiel #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);
        }
Beispiel #2
0
        //private Com com;

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

            InitializeComponent();

            lib = new Library(grdLeft, grdMid, this.Resources["MyContentTray"] as Style);
        }
Beispiel #3
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;
            }
        }
Beispiel #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);
        }