Example #1
0
        //public void navigategui()
        //{
        //    roboctrl = new RoboCtrl();
        //    roboctrl.Nav.pathx.s = Convert.ToInt32(textBox2.Text);
        //    roboctrl.Nav.pathx.d = Convert.ToInt32(textBox3.Text);
        //    roboctrl.startpathcalc();
        //    foreach (string value in roboctrl.Nav.pathx.displays)
        //    {
        //       // textBox1.AppendText(value.ToString());
        //        SetText1(value.ToString());
        //    }
        //    readthread = new Thread(new ThreadStart(rthread));
        //    readthread.Start();
        //    int ind = 0;
        //    for (int i = 0; i < roboctrl.Nav.pathx.xdcords.Count; i++)
        //    {
        //        //roboctrl.goForward(i);
        //        roboctrl.Com.serialtty.writetest(roboctrl.Nav.makecomtest(i));
        //        //while (roboctrl.Com.serialtty.destReached==false) {
        //        navthread.Suspend();
        //        //}
        //    }
        //}
        public void reNav()
        {
            ReNav = true;

            roboctrl = new RoboCtrl();

            if(navalive == true)
            {
                try
                {
                    navthread.Resume();
                    navthread.Abort();
                    //SetText7("navthread running and killed");
                    Console.WriteLine("navthread running and killed in renav");
                }
                catch(Exception thr)
                {
                    //SetText7(thr.ToString());
                }

            }
            Console.WriteLine("renav running");
            navthread = new Thread(new ThreadStart(navigate));
            navalive = true;
            navthread.Start();

            // startall();

            //portstart();
        }
Example #2
0
        public void mainthrd()
        {
            currentx = Convert.ToInt32(textBox2.Text);
            currenty = Convert.ToInt32(textBox3.Text);

            if(connectedToServ==true)
            {

                initWritesToServ();

                while(true)
                {
                if(anchorRecived==true)
                {
                    anchorRecived = false;
                    break;
                }
                Thread.Sleep(500);
                }
            for(int i = 0; i < anchorx.Count-1;i++)
            {

                roboctrl = new RoboCtrl();
                //RoboNav.currentdir = Convert.ToInt32(textBox12.Text);
                if(navalive == true)
                {
                    try
                    {
                        navthread.Resume();
                        navthread.Abort();
                        SetText7("navthread running and killed");
                    }
                    catch(Exception thr)
                    {
                        SetText7(thr.ToString());
                    }

                }

                navthread = new Thread(new ThreadStart(navigate));
                navalive = true;

                // startall();
                navthread.Start();
                while(true)
                {
                    if(anchornext == true)
                    {
                        anchornext = false;
                        Console.WriteLine("in IF");
                        break;
                    }
                    Console.WriteLine("in while");
                    Thread.Sleep(500);
                }
                //portstart();
            }
            }
            else if(connectedToServ==false)
            {
                roboctrl = new RoboCtrl();
               // RoboApp.offset = Convert.ToInt32(textBox12.Text);
                if(navalive == true)
                {
                    try
                    {
                        navthread.Resume();
                        navthread.Abort();
                        SetText7("navthread running and killed");
                    }
                    catch(Exception thr)
                    {
                        SetText7(thr.ToString());
                    }

                }

                navthread = new Thread(new ThreadStart(navigate));
                navalive = true;

                // startall();
                navthread.Start();

            }
        }