public void Test_Common() { // DS18B20: -55°C до +125°C, ±0.5°C var instance = new SDCompression(0.5, 3600); Assert.IsNotNull(instance); DateTime timestamp; double value; timestamp = new DateTime(2019, 08, 02, 20, 00, 00); value = 22.0; Assert.AreEqual(true, instance.ReceivePoint(ref timestamp, ref value)); var timestamp2 = new DateTime(2019, 08, 02, 20, 00, 01); var value2 = 22.1; Assert.AreEqual(false, instance.ReceivePoint(ref timestamp2, ref value2)); timestamp = new DateTime(2019, 08, 02, 20, 00, 02); value = 23.8; Assert.AreEqual(true, instance.ReceivePoint(ref timestamp, ref value)); Assert.AreEqual(timestamp2, timestamp); Assert.AreEqual(value2, value); }
public void ReceivePointValue(int pointId, DateTime timestamp, double value) { TSPoint point = fDB.Get <TSPoint>(pointId); SDCompression compression; if (!fCompressionCache.TryGetValue(pointId, out compression)) { compression = new SDCompression(point.Deviation, 60 * 10); // default: 60sec * 10min fCompressionCache.Add(pointId, compression); } if (compression.ReceivePoint(ref timestamp, ref value)) { string tableName = point.GetDataTableName(); InsertValue(tableName, timestamp, value); } }
public double GetCurrentValue(int pointId) { TSPoint point = fDB.Get <TSPoint>(pointId); SDCompression compression; if (!fCompressionCache.TryGetValue(pointId, out compression)) { compression = new SDCompression(point.Deviation, 60 * 10); // default: 60sec * 10min fCompressionCache.Add(pointId, compression); } if (compression != null) { return(compression.CurrentPoint.Value); } return(double.NaN); }