public void Disconnect() { if (m_connected) { m_brick.Disconnect(); } }
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(); } } }
static void Main() { Init(); brick = new NxtBrick(NxtCommLinkType.USB, 0); //brick = new NxtBrick(NxtCommLinkType.Bluetooth, 40); var sound = new NxtSoundSensor(); var touch = new NxtTouchSensor(); var sonar = new NxtUltrasonicSensor(); brick.MotorA = new NxtMotor(); brick.MotorC = new NxtMotor(); motorPair = new NxtMotorSync(brick.MotorA, brick.MotorC); brick.Sensor1 = sonar; brick.Sensor3 = touch; brick.Sensor4 = sound; sound.PollInterval = 50; sound.OnPolled += sound_OnPolled; sonar.PollInterval = 50; sonar.ThresholdDistanceCm = 25; sonar.OnPolled += sonar_OnPolled; sonar.OnWithinThresholdDistanceCm += OnWithinThreshold; sonar.ContinuousMeasurementCommand(); touch.PollInterval = 50; touch.OnPressed += OnCollision; brick.Connect(); motorPair.Run(75, 0, 0); Console.WriteLine("Press any key to stop."); Console.ReadKey(); brick.Disconnect(); }
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(); } else { Console.WriteLine("Connection Failed."); } //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(); Print(); Console.ReadKey(); brick.Disconnect(); }
public void Disconnect() { m_brick.Disconnect(); }