/// <summary> /// Initializes the BaseStation GUI. /// Attempts to connect to the Python server. If successful, the GUI opens up for use. /// </summary> public BaseStationGUI() { InitializeComponent(); // IPModeWindow ipMode = new IPModeWindow(); robotConnection = new UdpClient(4444); /* if (ipMode.ShowDialog() != DialogResult.OK) System.Environment.Exit(0); else { if (ipMode.check == 1) { getIP = new GetRobotIP(robotConnection); robotIP = getIP.GetIP(); robotConnection.Connect(IPAddress.Parse(robotIP), 4444); } else { robotIP = ipMode.IP; robotConnection.Connect(IPAddress.Parse(robotIP), 4444); } } string baseip = ""; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily.ToString() == "InterNetwork") { baseip = ip.ToString(); } } byte[] buff = Encoding.ASCII.GetBytes(baseip); robotConnection.Send(buff, buff.Length); sensorData = new SensorData(robotIP); sensorData.SensorUpdate += SensorData_SensorDataUpdate; */ commands = new KeyCommand(); xboxController = new GamepadState(SlimDX.XInput.UserIndex.One); xboxController.ControllerUpdate += xboxController_ControllerUpdate; xcontroller = new MotorControl(); kcontroller = new MotorControl(); /* ffplay = new Process(); ffplay.StartInfo.Arguments = "http://192.168.2.29:8090/live.mpg"; ffplay.StartInfo.FileName = "ffplay.exe"; ffplay.Start(); */ this.Activate(); }
/// <summary> /// Sends a Motor Control packet to the Python Server /// </summary> /// <param name="controller">Packet to send.</param> private void SendMotorControllerPacket(MotorControl controller) { byte[] dataBuffer = controller.ToArray(); // robotConnection.Send(dataBuffer, dataBuffer.Length); }