Пример #1
0
 /// <summary>
 /// Returns network data up until the specified time
 /// </summary>
 /// <param name="time">The earliest time to get data</param>
 /// <returns></returns>
 public NetworkData[] GetDataUntilTime(DateTime time)
 {
     lock (MyNetworkDataCollection)
     {
         return(MyNetworkDataCollection.Where(nd => nd.MyTimestamp > time).ToArray());
     }
 }
Пример #2
0
 /// <summary>
 /// Removed data older than the date specified
 /// </summary>
 /// <param name="date">The oldest data to keep</param>
 public void DeleteOldData(DateTime date)
 {
     lock (MyNetworkDataCollection)
     {
         MyNetworkDataCollection.RemoveAll(nd => nd.MyTimestamp < date);
     }
 }
Пример #3
0
        /// <summary>
        /// Clones and then adds data to this AP
        /// </summary>
        /// <param name="data">The data to add</param>
        /// <param name="gpsData">The GPS data to go with</param>
        public void AddData(NetworkData data, GpsData gpsData)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (gpsData == null)
            {
                throw new ArgumentNullException("gpsData");
            }

            NetworkData nd2 = (NetworkData)data.Clone();

            lock (MyNetworkDataCollection)
            {
                //Check if the RSSI had been consistently stronger and stronger than the strongest reading before updating the GPS data
                //This means if this reading and the last reading are both higher than 2 readings ago, update the GPS data
                if ((MyNetworkDataCollection.Count > 1 && nd2.Rssi > MyNetworkDataCollection.Max(nd => nd.Rssi) &&
                     (nd2.Rssi > MyNetworkDataCollection[MyNetworkDataCollection.Count - 2].Rssi &&
                      MyNetworkDataCollection[MyNetworkDataCollection.Count - 1].Rssi >
                      MyNetworkDataCollection[MyNetworkDataCollection.Count - 2].Rssi)) ||
                    (nd2.Rssi > -100 && GpsData.SatelliteTime == DateTime.MinValue))
                {
                    //Update GPS data
                    GpsData = gpsData;
                }
                //Add the data
                MyNetworkDataCollection.Add(nd2);
            }
            Timestamp         = nd2.MyTimestamp;
            LastSeenTimestamp = nd2.MyTimestamp;

            //Remove old data, if any
            DeleteOldData(Timestamp - TimeSpan.FromMinutes(8));
        }
Пример #4
0
        /// <summary>
        /// Clones and then adds data to this AP
        /// </summary>
        /// <param name="data"></param>
        public void AddData(NetworkData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            lock (MyNetworkDataCollection)
            {
                MyNetworkDataCollection.Add((NetworkData)data.Clone());
            }
            Timestamp = data.MyTimestamp;

            //Remove old data, if any
            DeleteOldData(Timestamp - TimeSpan.FromMinutes(8));
        }
Пример #5
0
 /// <summary>
 /// Adds filler(-100 rssi) data at the specified time
 /// </summary>
 /// <param name="time">The timestamp to add this data at</param>
 public void AddFiller(DateTime time)
 {
     lock (MyNetworkDataCollection)
     {
         MyNetworkDataCollection.Add(new NetworkData(time,
                                                     MacAddress.Bytes,
                                                     Security,
                                                     Ssid,
                                                     Channel,
                                                     LastData.Rssi,
                                                     0,
                                                     _orignalData.SupportedRates,
                                                     _orignalData.NetworkType,
                                                     (int)(time - LastSeenTimestamp).TotalSeconds));
     }
     Timestamp = time;
 }
Пример #6
0
 public override int GetHashCode()
 {
     return(MyNetworkDataCollection.First().GetHashCode());
 }