Changeset - 2f841e844536
[Not reviewed]
default
0 2 0
mkanning@CL-ENS241-10.cedarville.edu - 13 years ago 2013-02-14 15:21:33
mkanning@CL-ENS241-10.cedarville.edu
fixed the problem of two forms being created. still need to fix the addToChart()
and addMarker()
2 files changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
Demo.WindowsForms/Forms/MainForm.cs
Show inline comments
 
@@ -2552,62 +2552,62 @@ namespace Demo.WindowsForms
 
 
            //put chart displays in a ready state
 
            ResetChartColors();
 
        }
 
        string latitude;
 
        string longitude;
 
        //handle line of input data and put into chart
 
 
        //parses transmissions and saves data to CSV file
 
        public void ParseIncomingData(string rawDataReceived)
 
        {
 
            //check to see if data should be processed
 
            if (!cboxCollectData.Checked)
 
            {
 
                return;
 
            }
 
            //if (!cboxCollectData.Checked)
 
            //{
 
            //    return;
 
            //}
 
            /* sample stansmission
 
            KD8TDF-9>APRS,WIDE2-1:/151916z3944.87N/08348.75WO005/0.013 SV:09 A-30.5 B45.64 C99542
 
                                          ^char 31 ^char 40            ^60
 
            */
 
 
            //TODO: verify index charcter accuracy with real transmission
 
            int indexStart = rawDataReceived.IndexOf("z");
 
            int indexEnd = rawDataReceived.IndexOf("N/");
 
            latitude = rawDataReceived.Substring(indexStart + 1, indexEnd - indexStart - 1);
 
 
            indexStart = rawDataReceived.IndexOf("N/");
 
            indexEnd = rawDataReceived.IndexOf("WO");
 
            longitude = rawDataReceived.Substring(indexStart + 2, indexEnd - indexStart - 2);
 
 
            addMarkerFromTransmit(latitude, longitude);
 
            //addMarkerFromTransmit(latitude, longitude);
 
            AddText(rawDataReceived + "\r\n");
 
 
            rawDataReceived = rawDataReceived.Substring(59); //remove APRS overhead from string
 
 
            //place each datum in its own variable
 
            string[] dataTransmission;
 
            dataTransmission = rawDataReceived.Split(' ');
 
 
            //parse out the data type - should be a single letter
 
            string typeCode;
 
            double data;
 
            string csvData = "";
 
 
            //loop through all datums in the transmission and send them to the chart builder
 
            for (int i = 1; i < dataTransmission.Length; i++)
 
            {
 
                typeCode = dataTransmission[i].Substring(0, 1);
 
                data = double.Parse(dataTransmission[i].Substring(1));
 
                addToChart(typeCode, data);
 
                //addToChart(typeCode, data);
 
                csvData += typeCode + data + ",";
 
            }
 
 
            //write the data to CSV file
 
            WriteToCSV(csvData);
 
        }
 
 
        //write the data to CSV file
 
        private void WriteToCSV(string data)
 
        {
 
            using (StreamWriter writer = new StreamWriter("debug.csv", true))
 
            {
Demo.WindowsForms/Source/Program.cs
Show inline comments
 
@@ -22,26 +22,26 @@ namespace Demo.WindowsForms
 
       // Instantiate the communications port 
 
       private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
 
       static MainForm windowGUI;
 
 
      [STAThread]
 
      static void Main()
 
      {
 
          Application.SetCompatibleTextRenderingDefault(false);
 
          var program = new Program();
 
          windowGUI = new MainForm();
 
          program.SerialInitialize();
 
         Application.EnableVisualStyles();
 
         
 
         Application.Run(new MainForm());
 
 
         Application.Run(windowGUI);
 
      }
 
 
      //inits the serial port and event handler
 
      private void SerialInitialize()
 
      {
 
          // http://msmvps.com/blogs/coad/archive/2005/03/23/SerialPort-_2800_RS_2D00_232-Serial-COM-Port_2900_-in-C_2300_-.NET.aspx
 
          // Attach a method to be called when there is data waiting in the port's buffer
 
          port.DataReceived += new SerialDataReceivedEventHandler(ReceiveData);
 
 
          // Open the port for communications
 
          port.Open();
 
0 comments (0 inline, 0 general)