Пример #1
0
        public void Add(DataPoint point)
        {
            try
            {
                switch (point.Type)
                {
                case DataPointType.Temperature:
                    this.Temperature.Add(point.Time, point.Value);
                    break;

                case DataPointType.CO2:
                    this.Co2.Add(point.Time, point.Value);
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }
            catch (IOException ex)
            {
                this.Logger.Error("Could not write series data: " + ex);
            }

            this.LastTime = point.Time;
            DataPointAdded?.Invoke();
        }
 private static void OnDataPointAdded(IDataStructure datastructure, IDataPoint datapoint)
 {
     if (datapoints.Contains(datapoint))
     {
         return;
     }
     datapoints.Add(datapoint);
     DataPointAdded?.Invoke(null, datapoint);
 }
Пример #3
0
        //public static DirectoryInfo GetLogDirectory()
        //{
        //    var assembly = new FileInfo(Assembly.GetExecutingAssembly().Location);
        //    var folder = assembly.Directory;
        //    var logs = Path.Combine(folder.FullName, "Logs");
        //    return new DirectoryInfo(logs);
        //}
        //public static Target[] GetLogTargets()
        //{
        //    var directory = GetLogDirectory();
        //    if (!directory.Exists) return new Target[0];
        //    var targets = new List<Target>();
        //    foreach (var file in directory.GetFiles("*.ipt"))
        //    {
        //        targets.Add(new Target(file));
        //    }
        //    return targets.ToArray();
        //}
        //public static FileInfo GetLogFilePath(IPAddress address)
        //{
        //    var fileName = string.Format("{0}.ipt",
        //        string.Join("-", address.GetAddressBytes().Select(x => x.ToString()).ToArray()));
        //    return new FileInfo(Path.Combine(GetLogDirectory().FullName, fileName));
        //}

        public void AddDataPoint(short latency, IPStatus status)
        {
            var dp = new DataPoint(latency, status, DateTime.Now);

            lock (_lock)
            {
                dataPoints.Add(dp);
            }
            sync.Add(dp);
            LatestDataPoint = dp;
            DataPointAdded?.Invoke(this, new EventArgs());
        }
Пример #4
0
 protected virtual void OnDataPointAdded(IDataStructure sender, IDataPoint datapoint)
 {
     DataPointAdded?.Invoke(sender, datapoint);
 }