예제 #1
0
 private void StartGps()
 {
     if (null == m_Gps)
     {
         m_Gps = new GPS();
         //m_Gps.DeviceStateChanged += new DeviceStateChangedEventHandler(Gps_DeviceStateChanged);
         //m_Gps.LocationChanged += new LocationChangedEventHandler(Gps_LocationChanged);
         m_Gps.LocationChanged += Gps_LocationChanged;
     }
     m_Gps.Open();
 }
예제 #2
0
        public MyGpsSensor(int hubPort, string type, double distanceThreshold)
        {
            device                 = new GPS();
            device.HubPort         = hubPort;
            device.IsHubPortDevice = false;
            device.PositionChange += Device_PositionChange;

            // create a VOC alert timer for instance of sensor
            _GPSAlerts           = new Timer(100000);
            _GPSAlerts.AutoReset = true;
            _GPSAlerts.Elapsed  += _GPSAlerts_Elapsed;

            this.distanceThreshold = (distanceThreshold / Math.PI / 6378 * 360);

            //Open the connection
            try
            {
                device.Open(4000);
            }
            catch (Exception ex)
            {
                throw new Exception($"There was an error with the {type} sensor. Check connections and try again. \n \n System Error Message: \n" + ex.Message);
            }
        }