public void Finish()
 {
     if (_serialMonitor != null) {
         _serialMonitor.Stop ();
         _serialMonitor = null;
     }
 }
Beispiel #2
0
 public void Finish()
 {
     if (_serialMonitor != null)
     {
         _serialMonitor.Stop();
         _serialMonitor.Dispose();
         _serialMonitor = null;
     }
 }
        public SerialControllerReader(string portName, ISerialControllerState controller)
        {
            _controller = controller;

            _serialMonitor = new SerialMonitor (portName);
            _serialMonitor.PacketReceived += serialMonitor_PacketReceived;
            _serialMonitor.Disconnected += serialMonitor_Disconnected;
            _serialMonitor.Start ();
        }
        public SerialControllerReader(string portName, Func <byte[], ControllerState> packetParser)
        {
            _packetParser = packetParser;

            _serialMonitor = new SerialMonitor(portName);
            _serialMonitor.PacketReceived += serialMonitor_PacketReceived;
            _serialMonitor.Disconnected   += serialMonitor_Disconnected;
            _serialMonitor.Start();
        }
Beispiel #5
0
        public SerialControllerReader(string portName, bool useLagFix, Func <byte[], ControllerStateEventArgs> packetParser)
        {
            _packetParser = packetParser;

            _serialMonitor = new SerialMonitor(portName, useLagFix);
            _serialMonitor.PacketReceived += SerialMonitor_PacketReceived;
            _serialMonitor.Disconnected   += SerialMonitor_Disconnected;
            _serialMonitor.Start();
        }
        public SerialControllerReader (string portName, Func <byte[], ControllerState> packetParser) 
        {
            _packetParser = packetParser;

            _serialMonitor = new SerialMonitor (portName);
            _serialMonitor.PacketReceived += serialMonitor_PacketReceived;
            _serialMonitor.Disconnected += serialMonitor_Disconnected;
            _serialMonitor.Start ();
        }
        void konekin_NewSerialDataReceived(object sender, Koneksi.SerialDataEventArgs e)
        {
            Thread.Sleep(1000);
            try
            {
                pesan = e.Data;
            }
            catch { }

            {
                //pesan = pesan.Replace('.', ',');
                data = pesan.Split(' ');
                Dispatcher.Invoke((Action)(() => SerialMonitor.Text += pesan + " " + data.Length.ToString() + "\n"));


                try
                {
                    // 0        1   2   3       4       5           6          7
                    //GPSTIME Lat Long  Suhu Tekananan Kelembaban Ketinggian CO2
                    if (data.Length == 8)
                    {
                        try
                        {
                            double distance = GeoCalculator.GetDistance(Convert.ToDouble(data[1]), Convert.ToDouble(data[2]), -7.76395814, 110.3767115, 4);
                            double bearing  = GeoCalculator.GetBearing(-7.76395814, 110.3767115, Convert.ToDouble(data[1]), Convert.ToDouble(data[2]));
                            double vertikal = itung(distance * 1609.34, Convert.ToDouble(data[6]));
                            this.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate()
                            {
                                #region terminal text
                                try
                                {
                                    //SerialMonitor.AppendText("MAHESWARA_KOMBAT2016 " + " " + data[4] + " " + data[6] + " " + data[5] + " " + data[3] +  " " + data[2] + " " + data[1] + "\n");
                                    using (StreamWriter writer = File.AppendText(logName))
                                    {
                                        //konekin.tulis(data[9] + " " + data[10]);
                                        writer.WriteLine("MAHESWARAUGM" + " " + data[0] + " " + data[1] + " " + data[2] + " " + data[3] + " " + data[4] + " " + data[5] + " " + data[6] + " " + data[7] + " " + bearing + " " + vertikal + " " + distance * 1609.34);
                                    }
                                }
                                catch { }
                                inpulat.Text  = bearing.ToString("F0");
                                inputver.Text = vertikal.ToString("F0");
                                SerialMonitor.ScrollToEnd();
                                Dispatcher.Invoke((Action)(() => konekin.tulis(bearing.ToString("F0") + " " + inputver.Text)));
                                #endregion
                            }));
                        }
                        catch (Exception) { }
                    }
                }
                catch (Exception) { }
            }
        }
Beispiel #8
0
        public void Finish()
        {
            if (_serialMonitor != null)
            {
                _serialMonitor.Stop();
                _serialMonitor = null;
            }

            if (_serialMonitor2 != null)
            {
                _serialMonitor2.Stop();
                _serialMonitor2 = null;
            }
        }
Beispiel #9
0
        public SerialControllerReader2(string portName, string port2Name, Func <byte[], ControllerState> packetParser, Func <byte[], ControllerState> packet2Parser)
        {
            _packetParser  = packetParser;
            _packet2Parser = packet2Parser;

            _serialMonitor = new SerialMonitor(portName);
            _serialMonitor.PacketReceived += SerialMonitor_PacketReceived;
            _serialMonitor.Disconnected   += SerialMonitor_Disconnected;
            _serialMonitor.Start();

            if (port2Name != "Not Connected")
            {
                _serialMonitor2 = new SerialMonitor(port2Name);
                _serialMonitor2.PacketReceived += SerialMonitor2_PacketReceived;
                _serialMonitor2.Disconnected   += SerialMonitor2_Disconnected;
                _serialMonitor2.Start();
            }
            else
            {
                _serialMonitor2 = null;
            }
        }
Beispiel #10
0
 private void LogMessage(string Msg)
 {
     SerialMonitor.AppendText(Msg + "\n");
     SerialMonitor.SelectionStart = SerialMonitor.Text.Length;
     SerialMonitor.ScrollToCaret();
 }
Beispiel #11
0
 private void LogMessageSafe(string Msg)
 {
     SerialMonitor.BeginInvoke(new InvokeDelegate(LogMessage), new string[] { Msg });
 }