private void nmea_Grav(object sender, GravEventArgs e) { switch (gravType) { case 0: // Feey this.gravity = string.Format("{0:0.000}", e.Gravity); this.Gravity = e.Gravity; this.AvgGrav = e.AvgGrav; this.avgGrav = string.Format("{0:0.000}", e.AvgGrav); this.gravLabel.Invoke(new EventHandler(WorkerUpdate)); break; case 1: // Meters gravLabel.Text = string.Format("{0:0.0} m", e.CrossLevel); if (gravChart == null) { gravChart = new LogChart(gravPictureBox.Width, gravPictureBox.Height, -50, 0, 10, 180, 60); } //gravChart.AddValue(-(int)e.CrossLevel); break; case 2: // Fathoms gravLabel.Text = string.Format("{0:0.0} fm", e.LongLevel); if (gravChart == null) { gravChart = new LogChart(gravPictureBox.Width, gravPictureBox.Height, -30, 0, 10, 180, 60); } //gravChart.AddValue(-(int)e.LongLevel); break; } this.gravPictureBox.Invoke(new EventHandler(ChartUpdate)); //gravPictureBox.Image = gravChart.Paint(); }
private void MainForm_Load(object sender, System.EventArgs e) { PowerNotifications pn = new PowerNotifications(); pn.Start(); pn.PowerStatusChanged += new PowerNotifications.PowerStatusChangeEventHandler(this.PowerNotifications_PowerStatusChanged); this.secondPanel.Left = 0; this.secondPanel.Top = 0; gravChart = new LogChart(gravPictureBox.Width, gravPictureBox.Height, 1, 2, 0.2, 90, 60); _serialPort = new SerialPort("COM8", 9600); if (connected) { _serialPort = new SerialPort("COM8", 9600); _serialPort.Handshake = Handshake.RequestToSend; _serialPort.ReceivedBytesThreshold = 1; _serialPort.DataReceived += new SerialDataReceivedEventHandler(_serialPort_DataReceived); //_serialPort.Open(); //serialPort_open = true; } else { testFileName = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + Path.DirectorySeparatorChar + testFileName; Thread simulationThread = new Thread(new ThreadStart(simulation)); simulationThreadActive = true; simulationThread.Start(); } // Set up the NMEA helper nmea = new NmeaHelper(); nmea.Grav += new NmeaHelper.GravEventHandler(nmea_Grav); this.radLogOff.Checked = true; }
private void nmea_Grav(object sender, GravEventArgs e) { switch(gravType) { case 0: // Feey this.gravity = string.Format("{0:0.000}", e.Gravity); this.Gravity = e.Gravity; this.AvgGrav = e.AvgGrav; this.avgGrav = string.Format("{0:0.000}", e.AvgGrav); this.gravLabel.Invoke(new EventHandler(WorkerUpdate)); break; case 1: // Meters gravLabel.Text = string.Format("{0:0.0} m", e.CrossLevel); if(gravChart == null) gravChart = new LogChart(gravPictureBox.Width, gravPictureBox.Height, -50, 0, 10, 180, 60); //gravChart.AddValue(-(int)e.CrossLevel); break; case 2: // Fathoms gravLabel.Text = string.Format("{0:0.0} fm", e.LongLevel); if(gravChart == null) gravChart = new LogChart(gravPictureBox.Width, gravPictureBox.Height, -30, 0, 10, 180, 60); //gravChart.AddValue(-(int)e.LongLevel); break; } this.gravPictureBox.Invoke(new EventHandler(ChartUpdate)); //gravPictureBox.Image = gravChart.Paint(); }
private void MainForm_Load(object sender, System.EventArgs e) { PowerNotifications pn = new PowerNotifications(); pn.Start(); pn.PowerStatusChanged += new PowerNotifications.PowerStatusChangeEventHandler(this.PowerNotifications_PowerStatusChanged); this.secondPanel.Left = 0; this.secondPanel.Top = 0; gravChart = new LogChart(gravPictureBox.Width, gravPictureBox.Height, 1, 2, 0.2, 90, 60); _serialPort = new SerialPort("COM8", 9600); if(connected) { _serialPort = new SerialPort("COM8", 9600); _serialPort.Handshake = Handshake.RequestToSend; _serialPort.ReceivedBytesThreshold = 1; _serialPort.DataReceived += new SerialDataReceivedEventHandler(_serialPort_DataReceived); //_serialPort.Open(); //serialPort_open = true; } else { testFileName = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + Path.DirectorySeparatorChar + testFileName; Thread simulationThread = new Thread(new ThreadStart(simulation)); simulationThreadActive = true; simulationThread.Start(); } // Set up the NMEA helper nmea = new NmeaHelper(); nmea.Grav += new NmeaHelper.GravEventHandler(nmea_Grav); this.radLogOff.Checked = true; }