public void Close(JaguarCtrl jc, RobotConfig robotCfg, string configFile) { double centerLat = double.Parse(centerLatitude); double centerLong = double.Parse(centerLongitude); try { centerLat = double.Parse(jc.txtStartLat.Text); } catch { } try { centerLong = double.Parse(jc.txtStartLong.Text); } catch { } jc.jaguarSetting.GoogleEarthStartLat = centerLat; jc.jaguarSetting.GoogleEarthStartLong = centerLong; try { robotCfg.WriteXml(configFile); } catch { } try { PostMessage(googleEarth.GetMainHwnd(), WM_QUIT, 0, 0); } catch { } }
private void connectRobot() { //save any change to xml file row.LaserRangeIP = txtRobotIP.Text; row.RobotID = txtRobotID.Text; row.RobotIP = txtRobotIP.Text; row.GPSIP = txtGPSIP.Text; row.IMUIP = txtGPSIP.Text; row.CameraIP = txtCameraIP.Text; //row.CameraPWD = txtCameraPWD.Text; row.CameraUser = txtCameraID.Text; try { robotConfig.WriteXml(configFile); } catch { } //write gateway config file XmlTextWriter textWriter = new XmlTextWriter("C:\\DrRobotAppFile\\gatewayConfig.xml", null); textWriter.WriteStartDocument(); // Write comments textWriter.WriteComment("For Gateway Communication"); // Write first element textWriter.WriteStartElement("GateWaySetting", ""); // Write next element textWriter.WriteStartElement("RobotID", ""); textWriter.WriteString(row.RobotID); textWriter.WriteEndElement(); textWriter.WriteStartElement("RobotMethod", ""); textWriter.WriteString("WiFi"); //textWriter.WriteString("Serial"); textWriter.WriteEndElement(); textWriter.WriteStartElement("RobotCom", ""); textWriter.WriteString("COM1"); textWriter.WriteEndElement(); textWriter.WriteStartElement("RobotIP", ""); textWriter.WriteString(row.RobotIP); textWriter.WriteEndElement(); textWriter.WriteStartElement("RobotPort", ""); textWriter.WriteString("10001"); textWriter.WriteEndElement(); // Ends the document. textWriter.WriteEndElement(); textWriter.WriteEndDocument(); // close writer textWriter.Close(); Thread.Sleep(1000); //start one gateway p1 = new Process(); p1.StartInfo.FileName = "C:\\DrRobotAppFile\\WirobotGateway.exe"; p1.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; p1.Start(); Thread.Sleep(1000); controlForm = new JaguarCtrl(this, robotConfig); controlForm.Show(); }