diff --git a/SourceCode/AgDiag/AgDiag.csproj b/SourceCode/AgDiag/AgDiag.csproj
index 81ab2e179..e8170edc3 100644
--- a/SourceCode/AgDiag/AgDiag.csproj
+++ b/SourceCode/AgDiag/AgDiag.csproj
@@ -20,17 +20,9 @@
FormLoop.cs
-
- FormLoop.cs
-
FormLoop.cs
-
- True
- True
- gStr.resx
-
True
True
@@ -43,10 +35,6 @@
-
- ResXFileCodeGenerator
- gStr.Designer.cs
-
ResXFileCodeGenerator
Resources.Designer.cs
diff --git a/SourceCode/AgDiag/App.config b/SourceCode/AgDiag/App.config
index d1d685243..6eb6c18ca 100644
--- a/SourceCode/AgDiag/App.config
+++ b/SourceCode/AgDiag/App.config
@@ -1,18 +1,8 @@
-
-
-
-
-
-
- False
-
-
-
diff --git a/SourceCode/AgDiag/Classes/CGLM.cs b/SourceCode/AgDiag/Classes/CGLM.cs
deleted file mode 100644
index fd8022faa..000000000
--- a/SourceCode/AgDiag/Classes/CGLM.cs
+++ /dev/null
@@ -1,222 +0,0 @@
-using System;
-using System.Windows.Forms;
-
-namespace AgDiag
-{
- public static class NudChk
- {
- public static bool CheckValue(this NumericUpDown numericUpDown, ref decimal value)
- {
- if (value < numericUpDown.Minimum)
- {
- value = numericUpDown.Minimum;
- MessageBox.Show("Serious Settings Problem with - " + numericUpDown.Name
- + " \n\rMinimum has been exceeded\n\rDouble check ALL your Settings and \n\rFix it and Resave Vehicle File",
- "Critical Settings Warning",
- MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- return true;
- }
- else if (value > numericUpDown.Maximum)
- {
- value = numericUpDown.Maximum;
- MessageBox.Show("Serious Settings Problem with - " + numericUpDown.Name
- + " \n\rMaximum has been exceeded\n\rDouble check ALL your Settings and \n\rFix it and Resave Vehicle File",
- "Critical Settings Warning",
- MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- return true;
- }
-
- //value is ok
- return false;
- }
-
- public static bool CheckValueCm(this NumericUpDown numericUpDown, ref double value)
- {
- //convert to cm
- value *= 100;
- bool isChanged = false;
-
- if (value < (double)numericUpDown.Minimum)
- {
- value = (double)numericUpDown.Minimum / 2.4;
- MessageBox.Show("Serious Settings Problem with - " + numericUpDown.Name
- + " \n\rMinimum has been exceeded\n\rDouble check ALL your Settings and \n\rFix it and Resave Vehicle File",
- "Critical Settings Warning",
- MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- isChanged = true;
- }
- else if (value > (double)numericUpDown.Maximum)
- {
- value = (double)numericUpDown.Maximum / 2.6;
- MessageBox.Show("Serious Settings Problem with - " + numericUpDown.Name
- + " \n\rMaximum has been exceeded\n\rDouble check ALL your Settings and \n\rFix it and Resave Vehicle File",
- "Critical Settings Warning",
- MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- isChanged = true;
- }
-
- //revert back to meters
- value *= 0.01;
-
- //value is ok
- return isChanged;
- }
- }
-
- public static class glm
- {
- public static byte[] Combine(byte[] first, byte[] second)
- {
- byte[] ret = new byte[first.Length + second.Length];
- Buffer.BlockCopy(first, 0, ret, 0, first.Length);
- Buffer.BlockCopy(second, 0, ret, first.Length, second.Length);
- return ret;
- }
-
- //Regex file expression
- public static string fileRegex = "(^(PRN|AUX|NUL|CON|COM[1-9]|LPT[1-9]|(\\.+)$)(\\..*)?$)|(([\\x00-\\x1f\\\\?*:\";|/<>])+)|([\\.]+)";
-
- //inches to meters
- public static double in2m = 0.0254;
-
- //meters to inches
- public static double m2in = 39.3701;
-
- //meters to feet
- public static double m2ft = 3.28084;
-
- //Hectare to Acres
- public static double ha2ac = 2.47105;
-
- //Acres to Hectare
- public static double ac2ha = 0.404686;
-
- //Meters to Acres
- public static double m2ac = 0.000247105;
-
- //Meters to Hectare
- public static double m2ha = 0.0001;
-
- // liters per hectare to us gal per acre
- public static double galAc2Lha = 9.35396;
-
- //us gal per acre to liters per hectare
- public static double LHa2galAc = 0.106907;
-
- //Liters to Gallons
- public static double L2Gal = 0.264172;
-
- //Gallons to Liters
- public static double Gal2L = 3.785412534258;
-
- //the pi's
- public static double twoPI = 6.28318530717958647692;
-
- public static double PIBy2 = 1.57079632679489661923;
-
-
-
-
- //Degrees Radians Conversions
- public static double toDegrees(double radians)
- {
- return radians * 57.295779513082325225835265587528;
- }
-
- public static double toRadians(double degrees)
- {
- return degrees * 0.01745329251994329576923690768489;
- }
-
- //Distance calcs of all kinds
- public static double Distance(double east1, double north1, double east2, double north2)
- {
- return Math.Sqrt(
- Math.Pow(east1 - east2, 2)
- + Math.Pow(north1 - north2, 2));
- }
-
-
- //float functions
- public static float acos(float x)
- {
- return (float)Math.Acos(x);
- }
-
- public static float acosh(float x)
- {
- if (x < 1f) return 0f;
- return (float)Math.Log(x + Math.Sqrt((x * x) - 1f));
- }
-
- public static float asin(float x)
- {
- return (float)Math.Asin(x);
- }
-
- public static float asinh(float x)
- {
- return (x < 0f ? -1f : (x > 0f ? 1f : 0f)) * (float)Math.Log(Math.Abs(x) + Math.Sqrt(1f + (x * x)));
- }
-
- public static float atan(float y, float x)
- {
- return (float)Math.Atan2(y, x);
- }
-
- public static float atan(float y_over_x)
- {
- return (float)Math.Atan(y_over_x);
- }
-
- public static float atanh(float x)
- {
- if (Math.Abs(x) >= 1f) return 0;
- return 0.5f * (float)Math.Log((1f + x) / (1f - x));
- }
-
- public static float cos(float angle)
- {
- return (float)Math.Cos(angle);
- }
-
- public static float cosh(float angle)
- {
- return (float)Math.Cosh(angle);
- }
-
- public static float toDegrees(float radians)
- {
- return radians * 57.295779513082325225835265587528f;
- }
-
- public static float toRadians(float degrees)
- {
- return degrees * 0.01745329251994329576923690766743f;
- }
-
- public static float sin(float angle)
- {
- return (float)Math.Sin(angle);
- }
-
- public static float sinh(float angle)
- {
- return (float)Math.Sinh(angle);
- }
-
- public static float tan(float angle)
- {
- return (float)Math.Tan(angle);
- }
-
- public static float tanh(float angle)
- {
- return (float)Math.Tanh(angle);
- }
- }
-}
\ No newline at end of file
diff --git a/SourceCode/AgDiag/Classes/CSettings.cs b/SourceCode/AgDiag/Classes/CSettings.cs
deleted file mode 100644
index b044d14f9..000000000
--- a/SourceCode/AgDiag/Classes/CSettings.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System;
-using System.Configuration;
-using System.IO;
-using System.Linq;
-using System.Xml.Linq;
-using System.Xml.XPath;
-
-
-namespace AgDiag
-{
- public static class SettingsIO
- {
- ///
- /// Import an XML and save to 1 section of user.config
- ///
- /// Either Settings or Vehicle or Tools
- /// Usually Documents.Drive.Folder
- internal static void ImportSettings(string settingsFilePath)
- {
- if (!File.Exists(settingsFilePath))
- {
- throw new FileNotFoundException();
- }
-
- //var appSettings = Properties.Settings.Default;
- try
- {
- Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
-
- string sectionName = "";
-
- sectionName = Properties.Settings.Default.Context["GroupName"].ToString();
-
- XDocument document = XDocument.Load(Path.Combine(settingsFilePath));
- string settingsSection = document.XPathSelectElements($"//{sectionName}").Single().ToString();
- config.GetSectionGroup("userSettings").Sections[sectionName].SectionInformation.SetRawXml(settingsSection);
- config.Save(ConfigurationSaveMode.Modified);
-
- {
- Properties.Settings.Default.Reload();
- }
- }
- catch (Exception) // Should make this more specific
- {
- // Could not import settings.
- {
- Properties.Settings.Default.Reload();
- }
- }
- }
-
- internal static void ExportSettings(string settingsFilePath)
- {
- Properties.Settings.Default.Save();
-
- //Export the entire settings as an xml
- Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
- config.SaveAs(settingsFilePath);
- }
- }
-}
diff --git a/SourceCode/AgDiag/Forms/Controls.Designer.cs b/SourceCode/AgDiag/Forms/Controls.Designer.cs
deleted file mode 100644
index 38b39e1e2..000000000
--- a/SourceCode/AgDiag/Forms/Controls.Designer.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Drawing;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Net.Sockets;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace AgDiag
-{
-
- public partial class FormLoop
- {
- public void TimedMessageBox(int timeout, string s1, string s2)
- {
- var form = new FormTimedMessage(timeout, s1, s2);
- form.Show();
- }
- }
-}
diff --git a/SourceCode/AgDiag/Forms/FormLoop.cs b/SourceCode/AgDiag/Forms/FormLoop.cs
index d12ddb759..f064277a6 100644
--- a/SourceCode/AgDiag/Forms/FormLoop.cs
+++ b/SourceCode/AgDiag/Forms/FormLoop.cs
@@ -1,5 +1,4 @@
using System;
-using System.Diagnostics;
using System.Drawing;
using System.Net.Sockets;
using System.Windows.Forms;
@@ -8,20 +7,11 @@ namespace AgDiag
{
public partial class FormLoop : Form
{
- [System.Runtime.InteropServices.DllImport("User32.dll")]
- private static extern bool SetForegroundWindow(IntPtr handle);
-
- [System.Runtime.InteropServices.DllImport("User32.dll")]
- private static extern bool ShowWindow(IntPtr hWind, int nCmdShow);
-
public FormLoop()
{
InitializeComponent();
-
}
- public double secondsSinceStart, lastSecond, currentLat, currentLon;
-
private static string ByteArrayToHex(byte[] barray)
{
char[] c = new char[barray.Length * 3];
@@ -37,16 +27,8 @@ private static string ByteArrayToHex(byte[] barray)
return new string(c);
}
- private void btnDeviceManager_Click(object sender, EventArgs e)
- {
- Process.Start("devmgmt.msc");
- }
private void timer1_Tick(object sender, EventArgs e)
{
- secondsSinceStart = (DateTime.Now - Process.GetCurrentProcess().StartTime).TotalSeconds;
-
- DoTraffic();
-
if ((asData.pgn[asData.sc1to8] & 1) == 1) lblSection1.BackColor = Color.Green;
else lblSection1.BackColor = Color.Red;
if ((asData.pgn[asData.sc1to8] & 2) == 2) lblSection2.BackColor = Color.Green;
@@ -113,14 +95,10 @@ private void timer1_Tick(object sender, EventArgs e)
//machine bytes
lblPNGMachine.Text = ByteArrayToHex(maData.pgn);
TreeLbl.Text = maData.pgn[maData.tree].ToString();
-
-
-
}
private void FormLoop_Load(object sender, EventArgs e)
{
-
timer1.Enabled = true;
LoadLoopback();
}
@@ -135,42 +113,7 @@ private void FormLoop_FormClosing(object sender, FormClosingEventArgs e)
}
finally { recvFromLoopBackSocket.Close(); }
}
-
-
- if (sendToLoopBackSocket != null)
- {
- try
- {
- sendToLoopBackSocket.Shutdown(SocketShutdown.Both);
- }
- finally { sendToLoopBackSocket.Close(); }
- }
-
- if (sendSocket != null)
- {
- try
- {
- sendSocket.Shutdown(SocketShutdown.Both);
- }
- finally { sendSocket.Close(); }
- }
-
- if (recvSocket != null)
- {
- try
- {
- recvSocket.Shutdown(SocketShutdown.Both);
- }
- finally { recvSocket.Close(); }
- }
}
-
- private void DoTraffic()
- {
- }
-
-
-
}
}
diff --git a/SourceCode/AgDiag/Forms/FormTimedMessage.Designer.cs b/SourceCode/AgDiag/Forms/FormTimedMessage.Designer.cs
deleted file mode 100644
index 571f62a73..000000000
--- a/SourceCode/AgDiag/Forms/FormTimedMessage.Designer.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-namespace AgDiag
-{
- partial class FormTimedMessage
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.lblMessage = new System.Windows.Forms.Label();
- this.timer1 = new System.Windows.Forms.Timer(this.components);
- this.lblMessage2 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // lblMessage
- //
- this.lblMessage.AutoSize = true;
- this.lblMessage.Font = new System.Drawing.Font("Tahoma", 18F, System.Drawing.FontStyle.Bold);
- this.lblMessage.Location = new System.Drawing.Point(12, 20);
- this.lblMessage.Name = "lblMessage";
- this.lblMessage.Size = new System.Drawing.Size(115, 29);
- this.lblMessage.TabIndex = 0;
- this.lblMessage.Text = "Message";
- //
- // timer1
- //
- this.timer1.Enabled = true;
- this.timer1.Interval = 3000;
- this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
- //
- // lblMessage2
- //
- this.lblMessage2.AutoSize = true;
- this.lblMessage2.Font = new System.Drawing.Font("Tahoma", 18F);
- this.lblMessage2.Location = new System.Drawing.Point(75, 71);
- this.lblMessage2.Name = "lblMessage2";
- this.lblMessage2.Size = new System.Drawing.Size(127, 29);
- this.lblMessage2.TabIndex = 1;
- this.lblMessage2.Text = "Message 2";
- //
- // FormTimedMessage
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 23F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(272, 151);
- this.ControlBox = false;
- this.Controls.Add(this.lblMessage2);
- this.Controls.Add(this.lblMessage);
- this.Font = new System.Drawing.Font("Tahoma", 14.25F);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.Margin = new System.Windows.Forms.Padding(6);
- this.Name = "FormTimedMessage";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "Drive Message";
- this.TopMost = true;
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Label lblMessage;
- private System.Windows.Forms.Timer timer1;
- private System.Windows.Forms.Label lblMessage2;
- }
-}
\ No newline at end of file
diff --git a/SourceCode/AgDiag/Forms/FormTimedMessage.cs b/SourceCode/AgDiag/Forms/FormTimedMessage.cs
deleted file mode 100644
index 2bab3c206..000000000
--- a/SourceCode/AgDiag/Forms/FormTimedMessage.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using System.Windows.Forms;
-
-namespace AgDiag
-{
- public partial class FormTimedMessage : Form
- {
- //class variables
- //private FormGPS mf = null;
-
- public FormTimedMessage(int timeInMsec, string str, string str2)
- {
- InitializeComponent();
-
- //get copy of the calling main form
- //mf = callingForm as FormGPS;
-
- lblMessage.Text = str;
- lblMessage2.Text = str2;
-
- timer1.Interval = timeInMsec;
-
- int messWidth = str2.Length;
- Width = messWidth * 15 + 120;
- }
-
- private void timer1_Tick(object sender, EventArgs e)
- {
- timer1.Enabled = false;
- timer1.Dispose();
- Dispose();
- Close();
- }
- }
-}
\ No newline at end of file
diff --git a/SourceCode/AgDiag/Forms/SerialComm.Designer.cs b/SourceCode/AgDiag/Forms/SerialComm.Designer.cs
index 0be609296..2622ee1bb 100644
--- a/SourceCode/AgDiag/Forms/SerialComm.Designer.cs
+++ b/SourceCode/AgDiag/Forms/SerialComm.Designer.cs
@@ -1,46 +1,7 @@
-//Please, if you use this, share the improvements
-
-using System;
-
-namespace AgDiag
+namespace AgDiag
{
public partial class FormLoop
{
- //Latitude
- //public class CPGN_D0
- //{
- // ///
- // /// Latitude Longitude 8 bytes as modified float
- // /// double lat = (encodedAngle / (0x7FFFFFFF / 90.0));
- // /// double lon = (encodedAngle / (0x7FFFFFFF / 180.0));
- // ///
- // public byte[] latLong = new byte[] { 0x80, 0x81, 0x7F, 0xD0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0xCC };
-
-
- // public void LoadLatitudeLongitude(double lat, double lon)
- // {
-
- // int encodedAngle = (int)(lat * (0x7FFFFFFF / 90.0));
- // //double angle = (encodedAngle / (0x7FFFFFFF / 90.0));
-
- // byte[] lat6 = BitConverter.GetBytes(encodedAngle);
- // Array.Copy(lat6, 0, latLong, 5, 4);
-
- // encodedAngle = (int)(lon * (0x7FFFFFFF / 180.0));
- // //double angle = (encodedAngle / (0x7FFFFFFF / 180.0));
-
- // lat6 = BitConverter.GetBytes(encodedAngle);
- // Array.Copy(lat6, 0, latLong, 9, 4);
-
- // //crc = 0;
- // //for (int i = 2; i < latLong.Length - 1; i++)
- // //{
- // // crc += latLong[i];
- // //}
- // //latLong[latLong.Length - 1] = (byte)crc;
- // }
- //}
-
//AutoSteerData
public class CPGN_FE
{
@@ -57,10 +18,6 @@ public class CPGN_FE
//public int = 10;
public int sc1to8 = 11;
public int sc9to16 = 12;
-
- public void Reset()
- {
- }
}
public class CPGN_FD
@@ -77,10 +34,6 @@ public class CPGN_FD
public int rollHi = 10;
public int switchStatus = 11;
public int pwm = 12;
-
- public void Reset()
- {
- }
}
//AutoSteer Settings
@@ -99,10 +52,6 @@ public class CPGN_FC
public int wasOffsetLo = 10;
public int wasOffsetHi = 11;
public int ackerman = 12;
-
- public CPGN_FC()
- {
- }
}
//Autosteer Board Config
@@ -117,11 +66,6 @@ public class CPGN_FB
public int set0 = 5;
public int maxPulse = 6;
public int minSpeed = 7;
- //public int = 8;
- //public int = 9;
- //public int = 10;
- //public int = 11;
- //public int = 12;
public CPGN_FB()
{
@@ -143,18 +87,8 @@ public class CPGN_EF
public int tree = 6;
public int hydLift = 7;
public int tram = 8;
- //public int = 9;
- //public int = 10;
public int sc1to8 = 11;
public int sc9to16 = 12;
-
- public CPGN_EF()
- {
- }
-
- public void Reset()
- {
- }
}
//Machine Config
@@ -169,22 +103,6 @@ public class CPGN_EE
public int lowerTime = 6;
public int enableHyd = 7;
public int set0 = 8;
- //public int = 9;
- //public int = 10;
- //public int = 11;
- //public int = 12;
-
- public CPGN_EE()
- {
- //machineConfig[raiseTime] = Properties.Vehicle.Default.setArdMac_hydRaiseTime;
- //machineConfig[lowerTime] = Properties.Vehicle.Default.setArdMac_hydLowerTime;
- //machineConfig[enableHyd] = Properties.Vehicle.Default.setArdMac_isHydEnabled;
- //machineConfig[set0] = Properties.Vehicle.Default.setArdMac_setting0;
- }
-
- public void Reset()
- {
- }
}
@@ -220,13 +138,5 @@ public void Reset()
/// machineConfig PGN - 238 - EE
///
public CPGN_EE maConfig = new CPGN_EE();
-
-
- /////
- ///// LatitudeLongitude - D0 -
- /////
- //public CPGN_D0 p_D0 = new CPGN_D0();
-
}
}
-
diff --git a/SourceCode/AgDiag/Forms/UDP.designer.cs b/SourceCode/AgDiag/Forms/UDP.designer.cs
index 1723d86a0..a50a24a16 100644
--- a/SourceCode/AgDiag/Forms/UDP.designer.cs
+++ b/SourceCode/AgDiag/Forms/UDP.designer.cs
@@ -1,102 +1,26 @@
using System;
-using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
-using System.Text;
using System.Windows.Forms;
namespace AgDiag
{
- public class CTraffic
- {
- public int cntrPGNFromAOG = 0;
- public int cntrPGNToAOG = 0;
-
- public int cntrUDPOut = 0;
- public int cntrUDPIn = 0;
-
- public bool isTrafficOn = true;
-
- public int enableCounter = 0;
- }
public partial class FormLoop
{
// Server socket
private Socket recvFromLoopBackSocket;
- private Socket sendToLoopBackSocket;
-
- CTraffic traffic = new CTraffic();
-
- IPEndPoint epAgIO;
- IPEndPoint epModule;
+ private EndPoint epSender = new IPEndPoint(IPAddress.Any, 0);
// Data stream
private byte[] buffer = new byte[1024];
- // Send and Recv socket for udp network
- private Socket sendSocket;
- private Socket recvSocket;
- private bool isUDPNetworkConnected;
-
- //list of bytes to send out serial ports
- private List serList = new List();
-
- //IP address and port of Auto Steer server
- IPAddress epIP = IPAddress.Parse("192.168.1.3");
-
- // Status delegate
- private delegate void UpdateRecvMessageDelegate(int port, byte[] msg);
- private UpdateRecvMessageDelegate updateRecvMessageDelegate = null;
-
- //initialize loopback and udp network
- private void LoadUDPNetwork()
- {
- try //udp network
- {
- // Initialise the delegate which updates the message received
- updateRecvMessageDelegate = ReceiveFromUDP;
-
- // Initialise the socket
- sendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
- sendSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
-
- //module endpoint
- epModule = new IPEndPoint(epIP, 28888);
-
- //Initialize Recv socket
- recvSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
- recvSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
-
- // Modules send to this IP address and port
- recvSocket.Bind(new IPEndPoint(IPAddress.Any, 29999));
-
- // Initialise the IPEndPoint for async listener!
- EndPoint client = new IPEndPoint(IPAddress.Any, 0);
-
- // Start listening for incoming data
- recvSocket.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref client, new AsyncCallback(ReceiveDataUDPAsync), recvSocket);
- isUDPNetworkConnected = true;
- }
- catch (Exception e)
- {
- //WriteErrorLog("UDP Server" + e);
- MessageBox.Show("Load Error: " + e.Message, "UDP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
+ private int cntr;
private void LoadLoopback()
{
try //loopback
{
- // Initialise the socket
- sendToLoopBackSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
- sendToLoopBackSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
-
- //IP address and port that AgIO listens on, we send to it
- epAgIO = new IPEndPoint(IPAddress.Parse("127.255.255.255"), 17777);
-
// Initialise the socket
recvFromLoopBackSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
@@ -118,84 +42,12 @@ private void LoadLoopback()
}
//loopback functions
- #region Send And Receive
-
- public byte[] nmeaHeader = new byte[] { 0x80, 0x81, 0x7F, 0xCF };
-
- private void SendToLoopBackMessage(string message)
- {
- try
- {
- // Get packet as byte array
- byte[] byteData = Encoding.ASCII.GetBytes(message);
-
- //if (byteData.Length != 0)
- //{
- // traffic.cntrPGNToAOG += byteData.Length;
-
- // // Send packet to the zero
- // sendToLoopBackSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None, epAgOpen,
- // new AsyncCallback(SendDataLoopAsync), null);
- //}
-
-
- byte[] nmeaData = glm.Combine(nmeaHeader, byteData);
-
- if (nmeaData.Length != 0)
- {
- traffic.cntrPGNToAOG += nmeaData.Length;
-
- // Send packet to the zero
- sendToLoopBackSocket.BeginSendTo(nmeaData, 0, nmeaData.Length, SocketFlags.None, epAgIO,
- new AsyncCallback(SendDataLoopAsync), null);
- }
-
- }
- catch (Exception ex)
- {
- MessageBox.Show("Send Error: " + ex.Message, "UDP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
- private void SendToLoopBackMessage(byte[] byteData)
- {
- try
- {
- if (byteData.Length != 0)
- {
- traffic.cntrPGNToAOG += byteData.Length;
-
- // Send packet to the zero
- sendToLoopBackSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None, epAgIO,
- new AsyncCallback(SendDataLoopAsync), null);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("Send Error: " + ex.Message, "UDP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
private void ReceiveFromLoopBack(int port, byte[] data)
{
- traffic.cntrPGNFromAOG += data.Length;
-
-
if (data[0] == 0x80 && data[1] == 0x81)
{
switch (data[3])
{
- //the lat lon from AOG
- case 0xD0:
- {
- int encAngle = BitConverter.ToInt32(data, 5);
- currentLat = (encAngle / (0x7FFFFFFF / 90.0));
-
- encAngle = BitConverter.ToInt32(data, 9);
- currentLon = (encAngle / (0x7FFFFFFF / 180.0));
-
- break;
- }
case 253:
{
for (int i = 5; i < data.Length; i++)
@@ -246,8 +98,6 @@ private void ReceiveFromLoopBack(int port, byte[] data)
break;
}
-
-
default:
{
lblDefaultSends.Text = data.Length.ToString();
@@ -255,7 +105,6 @@ private void ReceiveFromLoopBack(int port, byte[] data)
}
}
}
-
else
{
cntr += data.Length;
@@ -263,20 +112,6 @@ private void ReceiveFromLoopBack(int port, byte[] data)
}
}
- int cntr;
- public void SendDataLoopAsync(IAsyncResult asyncResult)
- {
- try
- {
- sendToLoopBackSocket.EndSend(asyncResult);
- }
- catch (Exception ex)
- {
- MessageBox.Show("SendData Error: " + ex.Message, "UDP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
- private EndPoint epSender = new IPEndPoint(IPAddress.Any, 0);
private void ReceiveDataLoopAsync(IAsyncResult asyncResult)
{
try
@@ -303,98 +138,5 @@ private void ReceiveDataLoopAsync(IAsyncResult asyncResult)
//MessageBox.Show("ReceiveData Error: " + ex.Message, "UDP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
-
- #endregion
-
- //udp network functions
- public void SendUDPMessage(string message)
- {
- if (isUDPNetworkConnected)
- {
- try
- {
- // Get packet as byte array to send
- byte[] byteData = Encoding.ASCII.GetBytes(message);
- if (byteData.Length != 0)
- sendSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None,
- epModule, new AsyncCallback(SendDataUDPAsync), null);
-
- traffic.cntrUDPOut+=byteData.Length;
- }
- catch (Exception)
- {
- //WriteErrorLog("Sending UDP Message" + e.ToString());
- //MessageBox.Show("Send Error: " + e.Message, "UDP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
-
- //sends byte array
- public void SendUDPMessage(byte[] byteData)
- {
- if (isUDPNetworkConnected)
- {
- try
- {
- // Send packet to the zero
- if (byteData.Length != 0)
- sendSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None,
- epModule, new AsyncCallback(SendDataUDPAsync), null);
-
- traffic.cntrUDPOut+=byteData.Length;
- }
- catch (Exception)
- {
- //WriteErrorLog("Sending UDP Message" + e.ToString());
- //MessageBox.Show("Send Error: " + e.Message, "UDP Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
-
- private void ReceiveFromUDP(int port, byte[] data)
- {
- traffic.cntrUDPIn += data.Length;
- }
-
- private void SendDataUDPAsync(IAsyncResult asyncResult)
- {
- try
- {
- sendSocket.EndSend(asyncResult);
- }
- catch (Exception)
- {
- //WriteErrorLog(" UDP Send Data" + e.ToString());
- //MessageBox.Show("SendData Error: " + e.Message, "UDP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
-
- private void ReceiveDataUDPAsync(IAsyncResult asyncResult)
- {
- try
- {
- // Initialise the IPEndPoint for the client
- EndPoint epSender = new IPEndPoint(IPAddress.Any, 0);
-
- // Receive all data
- int msgLen = recvSocket.EndReceiveFrom(asyncResult, ref epSender);
-
- byte[] localMsg = new byte[msgLen];
- Array.Copy(buffer, localMsg, msgLen);
-
- // Listen for more connections again...
- recvSocket.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref epSender, new AsyncCallback(ReceiveDataUDPAsync), recvSocket);
-
- //string text = Encoding.ASCII.GetString(localMsg);
-
- int port = ((IPEndPoint)epSender).Port;
- BeginInvoke((MethodInvoker)(() => ReceiveFromUDP(port, localMsg)));
- }
- catch (Exception)
- {
- //WriteErrorLog("UDP Recv data " + e.ToString());
- //MessageBox.Show("ReceiveData Error: " + e.Message, "UDP Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
}
}
diff --git a/SourceCode/AgDiag/Program.cs b/SourceCode/AgDiag/Program.cs
index 346bba29f..3176eeb5f 100644
--- a/SourceCode/AgDiag/Program.cs
+++ b/SourceCode/AgDiag/Program.cs
@@ -16,17 +16,10 @@ private static void Main()
{
if (Mutex.WaitOne(TimeSpan.Zero, true))
{
- ////opening the subkey
- //if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
-
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormLoop());
}
- //else
- //{
- // MessageBox.Show("AgDiag is Already Running");
- //}
}
}
}
diff --git a/SourceCode/AgDiag/Properties/Settings.Designer.cs b/SourceCode/AgDiag/Properties/Settings.Designer.cs
index 9fcfd8f87..f0dd36ee7 100644
--- a/SourceCode/AgDiag/Properties/Settings.Designer.cs
+++ b/SourceCode/AgDiag/Properties/Settings.Designer.cs
@@ -22,17 +22,5 @@ public static Settings Default {
return defaultInstance;
}
}
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("False")]
- public bool setUDP_isOn {
- get {
- return ((bool)(this["setUDP_isOn"]));
- }
- set {
- this["setUDP_isOn"] = value;
- }
- }
}
}
diff --git a/SourceCode/AgDiag/Properties/Settings.settings b/SourceCode/AgDiag/Properties/Settings.settings
index 6edf7fe8e..8e615f25f 100644
--- a/SourceCode/AgDiag/Properties/Settings.settings
+++ b/SourceCode/AgDiag/Properties/Settings.settings
@@ -1,9 +1,5 @@
-
+
-
-
- False
-
-
+
\ No newline at end of file
diff --git a/SourceCode/AgDiag/gStr.Designer.cs b/SourceCode/AgDiag/gStr.Designer.cs
deleted file mode 100644
index ab173e0ee..000000000
--- a/SourceCode/AgDiag/gStr.Designer.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace AgDiag {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class gStr {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal gStr() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AgDiag.gStr", typeof(gStr).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to Authourizing.
- ///
- internal static string gsAuthourizing {
- get {
- return ResourceManager.GetString("gsAuthourizing", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Listening.
- ///
- internal static string gsListening {
- get {
- return ResourceManager.GetString("gsListening", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to NTRIP.
- ///
- internal static string gsNTRIP {
- get {
- return ResourceManager.GetString("gsNTRIP", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Save And Return.
- ///
- internal static string gsSaveAndReturn {
- get {
- return ResourceManager.GetString("gsSaveAndReturn", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Save Comms.
- ///
- internal static string gsSaveComms {
- get {
- return ResourceManager.GetString("gsSaveComms", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to Waiting.
- ///
- internal static string gsWaiting {
- get {
- return ResourceManager.GetString("gsWaiting", resourceCulture);
- }
- }
- }
-}
diff --git a/SourceCode/AgDiag/gStr.resx b/SourceCode/AgDiag/gStr.resx
deleted file mode 100644
index 69989cb65..000000000
--- a/SourceCode/AgDiag/gStr.resx
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- Authourizing
-
-
- Listening
-
-
- NTRIP
-
-
- Save And Return
-
-
- Save Comms
-
-
- Waiting
-
-
\ No newline at end of file