Esempio n. 1
0
        private void StartApp()
        {
            try
            {
                xrc = new MotomanConnection((short)portNumber.Value);
                ioClient.SetXrc(xrc);

                xrc.StatusChanged           += new EventHandler(StatusChanged);
                xrc.ConnectionStatus        += new EventHandler(rc1_connectionStatus);
                xrc.EventStatus             += new EventHandler(rc1_eventStatus);
                xrc.ConnectionError         += new EventHandler(rc1_errorStatus);
                xrc.DispatchCurrentPosition += new EventHandler(
                    (object sender, EventArgs e) => { UpdateUiCurrentPosition(); }
                    );
                xrc.MovingToPosition += new EventHandler(
                    (object sender, EventArgs e) => { UpdateUiSetpointPosition(); }
                    );

                WriteLine("XRC Starting connection");
                xrc.Connect();



                UpdateUiSetpointPosition();
            } catch (Exception ex)
            {
                MessageBox.Show("StartApp(): " + ex.Message);
            }
        }
Esempio n. 2
0
        private async void button7_Click(object sender, EventArgs e)
        {
            if (xrc == null)
            {
                return;
            }
            button7.Enabled = false;
            await xrc.Disconnect();

            xrc = null;
            btnConnect.Enabled = true;
        }
Esempio n. 3
0
        private async void Form1_FormClosing(object sender, EventArgs e)
        {
            if (ioClient != null)
            {
                Console.WriteLine("Stopping Socket IO");
                await ioClient.Disconnect();
            }
            if (xrc != null)
            {
                await xrc.Disconnect();

                xrc = null;
                Console.WriteLine("Stopping XRC connection");
            }
        }
        //public NodeTcpListener(string ip, int port)
        public NodeTcpListener(Form1 form, MotomanConnection xrc, int port)
        {
            this.form = form;
            this.xrc  = xrc;

            mainTread = new Thread(delegate()
            {
                //IPAddress localAddr = IPAddress.Parse(ip);
                server      = new TcpListener(IPAddress.Any, port);
                isListening = true;
                server.Start();
                StartListener();
            });
            mainTread.Start();
            if (form != null)
            {
                form.WriteLine("    TCP is listening");
            }
        }
Esempio n. 5
0
        public void SetXrc(MotomanConnection xrc)
        {
            this.xrc = xrc;

            xrc.StatusChanged += new System.EventHandler(
                (object sender, EventArgs e) => { if (xrc != null)
                                                  {
                                                      SendStatus(xrc.GetCopyOfRobotStatus());
                                                  }
                }
                );
            xrc.DispatchCurrentPosition += new System.EventHandler(
                (object sender, EventArgs e) => { if (xrc != null)
                                                  {
                                                      SendPosition(xrc.GetCurrentPositionCached());
                                                  }
                }
                );
            xrc.ConnectionError += new System.EventHandler(
                (object sender, EventArgs e) => { if (xrc != null)
                                                  {
                                                      EmitWrapperError(xrc.CurrentError);
                                                  }
                }
                );
            //xrc.EventStatus += new System.EventHandler(
            //    (object sender, EventArgs e) => { if (xrc != null) EmitWrapperStatus(xrc.CurrentEvent); }
            //);
            xrc.ConnectionStatus += new System.EventHandler(
                (object sender, EventArgs e) => { if (xrc != null)
                                                  {
                                                      EmitWrapperStatus(xrc.CurrentConnection);
                                                  }
                }
                );
        }
Esempio n. 6
0
 public void DisposeXrc()
 {
     this.xrc = null;
 }