Esempio n. 1
0
        public void InsertValue(int pointId, DateTime timestamp, double value)
        {
            TSPoint point     = fDB.Get <TSPoint>(pointId);
            string  tableName = point.GetDataTableName();

            InsertValue(tableName, timestamp, value);
        }
Esempio n. 2
0
        public void DeleteValue(int pointId, DateTime timestamp)
        {
            TSPoint point     = fDB.Get <TSPoint>(pointId);
            string  tableName = point.GetDataTableName();

            string tsx = ALCore.FmtSQLiteDate(timestamp);

            fDB.Execute(string.Format("delete from {0} where Timestamp = '{1}'", tableName, tsx));
        }
Esempio n. 3
0
        public void UpdateValue(int pointId, DateTime timestamp, double value)
        {
            TSPoint point     = fDB.Get <TSPoint>(pointId);
            string  tableName = point.GetDataTableName();

            string tsx   = ALCore.FmtSQLiteDate(timestamp);
            string vx    = ALCore.FmtSQLiteFloat(value);
            string query = string.Format("update {0} set Value = '{1}' where Timestamp = '{2}'", tableName, vx, tsx);

            fDB.Execute(query);
        }
Esempio n. 4
0
        public IList <TSValue> QueryValues(int pointId, DateTime begTime, DateTime endTime)
        {
            TSPoint point     = fDB.Get <TSPoint>(pointId);
            string  tableName = point.GetDataTableName();

            string tsBeg = ALCore.FmtSQLiteDate(begTime);
            string tsEnd = ALCore.FmtSQLiteDate(endTime);
            string query = string.Format("select * from {0} where Timestamp between '{1}' and '{2}'", tableName, tsBeg, tsEnd);

            return(fDB.Query <TSValue>(query));
        }
Esempio n. 5
0
        public void DeletePoint(TSPoint point)
        {
            string tableName = point.GetDataTableName();

            string idxExpr = string.Format("drop index \"{0}_Timestamp\"", tableName);

            fDB.Execute(idxExpr);

            string tblExpr = string.Format("drop table {0}", tableName);

            fDB.Execute(tblExpr);

            fDB.Delete(point);
        }
Esempio n. 6
0
        public void AddPoint(TSPoint point)
        {
            fDB.Insert(point);

            string tableName = point.GetDataTableName();

            string tblExpr = string.Format("create table {0}(\"Timestamp\" datetime, \"Value\" float)", tableName);

            fDB.Execute(tblExpr);

            string idxExpr = string.Format("create unique index \"{0}_Timestamp\" on \"{1}\"(\"Timestamp\")", tableName, tableName);

            fDB.Execute(idxExpr);
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        public void Test_Common()
        {
            var instance = new TSDatabase();

            Assert.IsNotNull(instance);

            TSPoint point = new TSPoint();

            point.Name = "temperature test";
            point.Type = MeasurementType.Temperature;
            Assert.AreEqual("temperature test", point.ToString());
            instance.AddPoint(point);

            point.Name = "temperature test 2";
            instance.UpdatePoint(point);

            point = instance.GetPoint(point.Id);
            Assert.IsNotNull(point);
            instance.DeletePoint(point);
        }
Esempio n. 10
0
 public void UpdatePoint(TSPoint point)
 {
     fDB.Update(point);
 }