public NaoConnection(string hostName, string userName, string password) : base(hostName, userName, password) { ip = hostName; dc = new InputChannel (this, ip, 4712); using (var sr = new System.IO.StreamReader("queryJoints.py")) { String line; while ((line = sr.ReadLine()) != null) execute(line); } }
protected void OnConnectionToggleToggled(object sender, EventArgs e) { bool active = connectionToggle.Active; if (active) { commandConnection = new PythonConnection(ipEntry.Text, userNameEntry.Text, passwordEntry.Text); // Open a separate data connection: // Has to be done before sending prep_code.py as it defines necessary variables for prep_code.py videoChannel = new InputChannel (commandConnection, ipEntry.Text, 4711); using (var sr = new System.IO.StreamReader("prep_code.py")) { String line; while ((line = sr.ReadLine()) != null) commandConnection.execute(line); } } else { controlToggle.Active = false; cameraToggle.Active = false; commandConnection.execute("close()"); commandConnection.Dispose(); videoChannel.Dispose(); commandConnection = null; videoChannel = null; } stiffnessToggle.Sensitive = active; cameraToggle.Sensitive = active; ttsButton.Sensitive = active; ipEntry.Sensitive = !active; userNameEntry.Sensitive = !active; passwordEntry.Sensitive = !active; }