Ejemplo n.º 1
0
        /**
         * Executes the automated system
         */
        public void Execute()
        {
            InputThread a = new InputThread(PYT.Properties.Settings.Default.IncomingHost, PYT.Properties.Settings.Default.IncomingCommandPort);
            Thread aThread = new Thread(new ThreadStart(a.process));
            aThread.Start();
            Console.WriteLine("Waiting for Automated Input Command thread to start...");
            while (!aThread.IsAlive) ;
            Console.WriteLine("Automated input command thread started");

            Coordinate previous = new Coordinate(this.coordinates);
            foreach (string coord in this.coordinates)
            {
                previous.setCoordinate(coord, -1000.0);
            }

            TrajectoryDispatcher tjd = new TrajectoryDispatcher(this.coordinates, ref this.i);

            while (true)
            {
                try
                {
                    Coordinate next = Coordinate.fromString(this.coordinates, a.getLastReceived());
                    if (next.getCompareString() != previous.getCompareString())
                    {
                        previous = next;
                        // wait for the last one to finish excuting
                        tjd.wait();
                        tjd.setData(next, 1, 35);
                        Coordinate last = Coordinate.fromString(this.coordinates, this.i.getLastReceived());
                        //last.setCoordinate("y", last.getCoordinate("y") - 6);
                        tjd.Execute(last);
                    }

                }
                catch (Exception e) { }
            }
        }