Exemple #1
0
        /// <summary>
        /// Disconnect from NXT Brick.
        /// </summary>
        public void Disconnect()
        {
            StopReadingSensorValues();
            //while (_sensorPollingThread != null)
            //{
            //}
            SetBatteryLevelUpdateTimer(0);

            if (_brick != null)
            {
                _brick.Disconnect();
            }

            IsConnected = false;
        }
Exemple #2
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     // Disconnect from the NXT.
     if (brick != null)
     {
         if (brick.IsConnected)
         {
             brick.Disconnect();
         }
     }
     if (McBrick != null)
     {
         if (McBrick.IsConnected)
         {
             McBrick.Disconnect();
         }
     }
 }
Exemple #3
0
        static void Main(string[] args)
        {
            VertsX = new float[0];
            VertsY = new float[0];
            VertsZ = new float[0];
            FacesA = new int[0];
            FacesB = new int[0];
            FacesC = new int[0];

            Console.WriteLine("\n=== === ===\nWELCOME\n=== === ===");
            Console.WriteLine("Welcome to ProjectX 3D Printing Software!");
            Console.WriteLine("Press any Key to start print Configuration.");
            Console.ReadKey();
            Console.WriteLine("\n\n");

            Console.WriteLine("\n=== === ===\nCONNECTION SETUP\n=== === ===");
            Console.WriteLine("ProjectX will now detect your NXT Device.");
            Console.WriteLine("Type 'B' if you are using a Bluetooth Connection,");
            Console.WriteLine("or 'U' if you are using a USB Cable.");
            Console.WriteLine("Make sure your NXT is turned on and connected properly before continuing.");
            bool hasChosen = false;

            while (!hasChosen)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                if (key.Key == ConsoleKey.B)
                {
                    hasChosen = true;
                    SetupBluetoothConnection();
                }
                if (key.Key == ConsoleKey.U)
                {
                    hasChosen = true;
                    SetupUSBConnection();
                }
            }

            //Verbindungskontrolle
            Console.WriteLine("Trying to connect to NXT ...");
            brick.Connect();
            int       timeout = 5000;
            Stopwatch sw      = Stopwatch.StartNew();

            while (sw.ElapsedMilliseconds < timeout && !brick.IsConnected)
            {
                System.Threading.Thread.Sleep(100);
            }
            if (brick.IsConnected)
            {
                PingNXT(false);
            }
            else
            {
                Console.WriteLine("Connection Failed.");
            }

            brick.CommLink.StartProgram("MotorControl22.rxe");

            //Einlesen Der .obj-Datei
            Console.WriteLine("\n=== === ===\nMODEL SELECTION\n=== === ===");
            Console.WriteLine("\n\nPlease give the Path of the 3D model you are willing to print. OBJ Format is supported.");
            string       objPath   = Console.ReadLine();
            StreamReader objReader = new StreamReader(objPath);

            DecodeObjFile(objReader);
            Console.WriteLine("Object with name " + objName + " found.");
            Console.WriteLine("A total of " + VertsX.Length + " Vertices and " + FacesA.Length + " faces were found.");

            //Kalibrierung der Motoren
            Console.WriteLine("\n=== === ===\nMOTOR CALIBRATION\n=== === ===");
            LinkMotorAxis();
            Calibrate();
            SetDimensions();

            //Einstellung der Auflösung
            Console.WriteLine("\n=== === ===\nRESOLUTION\n=== === ===");
            SetResolution();

            //Anpassen der modellgröße
            FindScale();

            //Drucken
            PreparePrint();
            Console.WriteLine("\n=== === ===\nPRINTING\n=== === ===");
            Print();

            Console.ReadKey();
            brick.Disconnect();

            //Credits
            Console.WriteLine("And .... Did it work ?? ('y'/'n')");
            if (Console.ReadKey().KeyChar == 'y')
            {
                Credits(); Console.ReadKey();
            }
        }