public InputChannel(PythonConnection pyConn, string ipAddress, int port)
        {
            IPAddress ip = IPAddress.Parse(ipAddress);

            using (var sr = new System.IO.StreamReader("setup_socket.py"))
            {
                String line;
                while ((line = sr.ReadLine ()) != null) {
                    if (line.Contains ("sock_port = "))
                        line = String.Format ("sock_port = {0}", port);
                    pyConn.execute (line);
                }
            }

            dataConnection = new Socket(AddressFamily.InterNetwork, SocketType.Stream,ProtocolType.Tcp);
            dataConnection.Connect(new IPEndPoint(ip, port));
            pyConn.execute("connection, _ = sock.accept()");
        }
Exemplo n.º 2
0
        public InputChannel(PythonConnection pyConn, string ipAddress, int port)
        {
            IPAddress ip = IPAddress.Parse(ipAddress);

            using (var sr = new System.IO.StreamReader("setup_socket.py"))
            {
                String line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Contains("sock_port = "))
                    {
                        line = String.Format("sock_port = {0}", port);
                    }
                    pyConn.execute(line);
                }
            }

            dataConnection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            dataConnection.Connect(new IPEndPoint(ip, port));
            pyConn.execute("connection, _ = sock.accept()");
        }
Exemplo n.º 3
0
 public JointControl(PythonConnection connection, string joint, double max, double speed)
 {
     this.connection = connection;
     this.command = String.Format("print startMove(\"{0}\", {1}, {2})", joint, toString(max), toString(speed));
 }
Exemplo n.º 4
0
 public WalkControl(PythonConnection connection, double deltaSpeed, double deltaAngle, double deltaFrequency)
 {
     this.connection = connection;
     this.deltaSpeed = deltaSpeed;
     this.deltaAngle = deltaAngle;
     this.deltaFrequency = deltaFrequency;
 }
Exemplo n.º 5
0
    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;
    }