Skip to content

GCSViews: Set default value to 10 in response to issue 2613 #2615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
7 changes: 5 additions & 2 deletions Controls/SerialOutputCoT.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 53 additions & 1 deletion Controls/SerialOutputCoT.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using MissionPlanner.Comms;
using MissionPlanner.Utilities;
using MissionPlanner.Utilities.CoT;
using System;
using System.Globalization;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Serialization;

namespace MissionPlanner.Controls
{
Expand Down Expand Up @@ -237,6 +241,53 @@ String getXmlString(String uid, String type, String how, double lat, double lng,
culture.NumberFormat.NumberGroupSeparator = "";

DateTime time = DateTime.UtcNow;

var cotevent = new @event()
{
uid = uid, type = type, time = time.ToString("o"), start = time.AddSeconds(-5).ToString("o"),
stale = time.AddSeconds(5).ToString("o"), how = how,
detail = new detail()
{
track = new track()
{
course = course.ToString("N2", culture), speed = speed.ToString("N2", culture)
}

},
point = new point()
{
lat = lat.ToString("N7", culture), lng = lng.ToString("N7", culture), hae = alt.ToString("N2", culture).PadLeft(5, ' ')
}
};

using(StringWriter textWriter = new StringWriter())
{
XmlWriterSettings xws = new XmlWriterSettings();
xws.OmitXmlDeclaration = false;
xws.Indent = true;
xws.Encoding = Encoding.UTF8;
xws.NewLineOnAttributes = true;

//Create our own namespaces for the output
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

//Add an empty namespace and empty value
ns.Add("", "");

var xtw = XmlTextWriter.Create(textWriter, xws);
// Then we can set our indenting options (this is, of course, optional).
XmlSerializer serializer =
new XmlSerializer(typeof(@event));

xtw.WriteStartDocument(true);

serializer.Serialize(xtw, cotevent, ns);

var ans = textWriter.ToString();

return ans;
}

StringBuilder sb = new StringBuilder();

sb.AppendLine ("<?xml version='1.0' encoding='UTF-8' standalone='yes'?>");
Expand Down Expand Up @@ -273,6 +324,7 @@ String getXmlString(String uid, String type, String how, double lat, double lng,
sb.AppendLine ("</event>");

return sb.ToString();

}

private void BTN_clear_TB_Click(object sender, EventArgs e)
Expand All @@ -296,4 +348,4 @@ private void SerialOutputCoT_FormClosing(object sender, FormClosingEventArgs e)
Settings.Instance["SerialOutputCot_TB_xml_uid"] = TB_xml_uid.Text;
}
}
}
}
Loading