Пример #1
0
        private void GPSStatusChangedEventHandler(object sender, EventArgs e)
        {
            NMEAGPSClient.NMEAGPSClient.GPSStatusEvent gpsStatus = (NMEAGPSClient.NMEAGPSClient.GPSStatusEvent)e;
            mGPSStatus = gpsStatus.Status;
            if (mGPSStatus < NMEAGPSClient.NMEAGPSClient.GPS_STATUS.Fix)
            {
                GPSPosition.Position position = ((NMEAGPSClient.NMEAGPSClient)sender).Position;
                // publish the new position to CAN clients.
                CANFrame frame = CNXCANMsgHelper.PackGPSFrame((byte)mGPSStatus, position.Latitude, position.Longitude, 0);
                int      count = mCANClient.Send(frame);
            }

            CNXLog.Debug("GPSStatusChangedEventHandler");
        }
Пример #2
0
        public CANCommsServer(CANClient client, NMEAGPSClient.NMEAGPSClient gpsClient)
        {
            mCANClient = client;
            mGpsClient = gpsClient;

            // make a device catalogue
            mDeviceCatalogue = CreateCatalogue(TrackingService.VarPath + mCatalogueFilename);

            // start time for cataloge and status reporting
            mCatalogueTimer = new Timer(OnTimedEvent, null, CatalogueTime, CatalogueTime);

            // subscribe to gps events
            mGpsClient.RaiseGPSPositionChangedEvent += GPSPositionChangedEventHandler;
            // get the current gps status
            mGPSStatus = mGpsClient.Status;
            mGpsClient.RaiseGPSStatusChangedEvent += GPSStatusChangedEventHandler;

            // subscribe to CAN frame events
            mCANClient.RaiseFrameReceivedEvent += FrameReceivedEventHandler;
        }