Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        public void Merge(BMDatabase db)
        {
            lock (Records)
            {
                List <BMRecordCurrent> records = MergeLinear(Records, db.Records);

                Records.Clear();
                Records.AddRange(records);
            }
        }
Ejemplo n.º 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]);
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 public BMDatabase(BMDatabase db)
 {
     Device = db.Device;
     Records.AddRange(db.Records);
     Units = new UnitsDescriptor(db.Units);
 }
Ejemplo n.º 7
0
 public static void Save(string fileName, BMDatabase db)
 {
     XmlHelper.Save(fileName, db);
 }