/// <summary>
        ///
        /// </summary>
        /// <param name="bucketIntervalInSec">if == 1 - do not dillute</param>
        public void SaveAs(string fileName, double bucketIntervalInSec)
        {
            BMDatabase             db      = new BMDatabase(this);
            List <BMRecordCurrent> records = new List <BMRecordCurrent>(db.Records);

            db.Records.Clear();
            db.Records.AddRange(DilluteByTime(records, bucketIntervalInSec));

            Save(fileName, db);
        }
        public void Merge(BMDatabase db)
        {
            lock (Records)
            {
                List <BMRecordCurrent> records = MergeLinear(Records, db.Records);

                Records.Clear();
                Records.AddRange(records);
            }
        }
Exemple #3
0
        public BMDatabase Merge(BMDatabase db)
        {
            if (!_map.ContainsKey(db.Device.Address))
            {
                _map[db.Device.Address] = db;
            }
            else
            {
                _map[db.Device.Address].Merge(db);
            }

            return(_map[db.Device.Address]);
        }
Exemple #4
0
        public void Load()
        {
            const string  PATTERN = "BMDatabase_*_Main.xml";
            List <string> files   = new List <string>(Directory.GetFiles(BMDatabase.DataFolder, PATTERN));

            files.Sort();

            foreach (string file in files)
            {
                BMDatabase db = BMDatabase.Open(file);
                if (db != null)
                {
                    Merge(db);
                }
            }
        }
        public static BMDatabase Open(string fileName)
        {
            try
            {
                BMDatabase db = XmlHelper.Open <BMDatabase>(fileName);
                if (db.Device == null)
                {
                    throw new Exception("Old file format");
                }

                return(db);
            }
            catch (Exception err)
            {
                Log.e("File: {0} Error: {1}", fileName, err);
                return(null);
            }
        }
 public BMDatabase(BMDatabase db)
 {
     Device = db.Device;
     Records.AddRange(db.Records);
     Units = new UnitsDescriptor(db.Units);
 }
 public static void Save(string fileName, BMDatabase db)
 {
     XmlHelper.Save(fileName, db);
 }