Esempio n. 1
0
 private void bConnectGPS_Click(object sender, RoutedEventArgs e)
 {
     bConnectGPS.IsEnabled = false;
     if (tcpCli.status == 0)
     {
         tcpCli.StartClient();
     }
     else
     {
         tcpCli.CloseConnection();
     }
 }
Esempio n. 2
0
        public MainWindow()
        {
            MainWind = this;
            InitializeComponent();

            GPS.PositionReceived         += new NMEAParse.PositionReceivedEventHandler(GPS_PositionReceived);
            GPS.SatellitesInViewReceived += new NMEAParse.SatellitesInViewReceivedEventHandler(GPS_SatellitesInViewReceived);
            GPS.SatellitesUsed           += new NMEAParse.SatellitesUsedReceivedEventHandler(GPS_SatellitesUsed);
            GPS.SpeedReceived            += new NMEAParse.SpeedReceivedEventHandler(GPS_SpeedReceived);
            GPS.BearingReceived          += new NMEAParse.BearingReceivedEventHandler(GPS_BearingReceived);
            GPS.FixLost                 += new NMEAParse.FixLostEventHandler(GPS_FixLost);
            GPS.FixObtained             += new NMEAParse.FixObtainedEventHandler(GPS_FixObtained);
            GPS.HDOPReceived            += new NMEAParse.HDOPReceivedEventHandler(GPS_HDOPReceived);
            GPS.EllipsoidHeightReceived += new NMEAParse.EllipsoidHeightReceivedEventHandler(GPS_EllipsoidHeightReceived);

            SerializablePolyLine pl = new SerializablePolyLine();

            pl = (SerializablePolyLine)xmlIO.loadSettings(typeof(SerializablePolyLine), "lasttrack.xml");

            if (pl != null)
            {
                GPSTrack = pl.GetPolyLine();
            }
            else
            {
                GPSTrack.Stroke          = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
                GPSTrack.StrokeThickness = 2;
                GPSTrack.Opacity         = 0.7;
                GPSTrack.Locations       = new LocationCollection();
            }
            Map.Children.Add(GPSTrack);

            HeadingLine.Stroke          = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
            HeadingLine.StrokeThickness = 3;
            HeadingLine.Opacity         = 0.5;
            HeadingLine.Locations       = new LocationCollection();
            HeadingLine.Locations.Add(new Location(0, 0));
            HeadingLine.Locations.Add(new Location(0, 0));
            Map.Children.Add(HeadingLine);


            tcpCli = new TCPCli("192.168.0.1", 60660, MainWind.bConnectGPS, MainWind.tGPSConnStatus);
            tcpCli.StartClient();

            statusCli = new TCPCli("192.168.0.10", 9940, MainWind.bConnectStatus, MainWind.tStatusConnStatus);
            statusCli.StartClient();
            statusCli.debug = true;

            GPSParser = new Thread(new ThreadStart(HandleGPSstring));
            GPSParser.Start();

            loadPolyFromFile();
        }