Ejemplo 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);
        }
Ejemplo 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));
        }
Ejemplo 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);
        }
Ejemplo 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));
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
            }
        }