Exemplo n.º 1
0
        public void WeekDataPoolTester()
        {
            BaseAggConfig config = CreateCommonConfig(AggType.Week);

            config.TimeRange = new AggTimeRange {
                DataBeginHour = 1, DataEndHour = 2, DateBegin = 1, DateEnd = 1
            };

            DataPoolFactory.Init();
            IDataPool dataPool = DataPoolFactory.GetDataPool(config);

            Assert.IsNotNull(dataPool);

            DateTime   time  = new DateTime(2015, 2, 15);
            AggRawData data  = dataPool.GetAggRawData(time);
            int        count = 0;

            foreach (var tmp in data.Datas)
            {
                count += tmp.Values.Count;
            }
            Console.WriteLine(string.Format("共读取{0}条数据", count));
            Assert.IsTrue(data.TimeTag == "2015W7");
            Assert.IsTrue(data.FactorId == config.FactorId);
            Assert.IsTrue(data.Datas.Count > 0);
            //Assert.IsTrue(data.LastAggDatas != null);
        }
Exemplo n.º 2
0
        public void MonthDataPoolTester()
        {
            BaseAggConfig config = CreateCommonConfig(AggType.Month);

            config.TimeRange = new AggTimeRange {
                DataBeginHour = 1, DataEndHour = 3, DateBegin = 1, DateEnd = 1
            };

            DataPoolFactory.Init();
            IDataPool dataPool = DataPoolFactory.GetDataPool(config);

            Assert.IsNotNull(dataPool);

            DateTime  time = new DateTime(2015, 2, 15);
            Stopwatch sw   = new Stopwatch();

            sw.Start();
            AggRawData data = dataPool.GetAggRawData(time);

            sw.Stop();
            Console.WriteLine(string.Format("MonthDataPoolTester 耗时:{0}ms", sw.ElapsedMilliseconds));
            int count = 0;

            foreach (var tmp in data.Datas)
            {
                count += tmp.Values.Count;
            }
            Console.WriteLine(string.Format("共读取{0}条数据", count));
            Assert.IsTrue(data.TimeTag == "201502");
            Assert.IsTrue(data.FactorId == config.FactorId);
            Assert.IsTrue(data.Datas.Count > 0);
            //Assert.IsTrue(data.LastAggDatas != null);
        }
Exemplo n.º 3
0
        public override void PowerOn()
        {
            Log.Info("PowerOn");
            List <BaseAggConfig> configs = BaseAggConfig.Create(SeclureCloudDbHelper.Instance().Accessor.GetConfig());

            jobManage = new AggJobManage(configs);
            jobManage.StartWork();
        }
Exemplo n.º 4
0
        private static BaseAggConfig CreateCommonConfig(AggType type)
        {
            BaseAggConfig config = new BaseAggConfig(new AggTaskKey(90, 42, type));

            /// 家乐福项目配置
            //  config.TimeRange = new AggTimeRange();


            return(config);
        }
Exemplo n.º 5
0
 public void OnMessageReceived(string buff)
 {
     try
     {
         FsMessage msg = FsMessage.FromJson(buff);
         // real-time DAC: // body:{"dtu":1,"sensors":[17,20]}
         Log.InfoFormat("pull({0})", buff);
         if (msg != null && msg.Header.R == @"/agg/config/")
         {
             jobManage.StopWork();
             List <BaseAggConfig> configs = BaseAggConfig.Create(SeclureCloudDbHelper.Instance().Accessor.GetConfig());
             jobManage.ReStart(configs);
         }
     }
     catch (Exception ce)
     {
         Log.ErrorFormat("err {0}!", ce.Message);
     }
 }
Exemplo n.º 6
0
        public void CreateDataPoolTester()
        {
            BaseAggConfig config = CreateCommonConfig(AggType.Day);

            config.TimeRange = new AggTimeRange {
                DataBeginHour = 1, DataEndHour = 2, DateBegin = 0, DateEnd = 0
            };
            DataPoolFactory.Init();
            IDataPool dataPool = DataPoolFactory.GetDataPool(config);

            Assert.IsNotNull(dataPool);

            config   = CreateCommonConfig(AggType.Week);
            dataPool = DataPoolFactory.GetDataPool(config);
            Assert.IsNotNull(dataPool);

            config   = CreateCommonConfig(AggType.Month);
            dataPool = DataPoolFactory.GetDataPool(config);
            Assert.IsNotNull(dataPool);
        }
Exemplo n.º 7
0
        //public TaskManage Instance()
        //{
        //    if (instance == null)
        //    {
        //        lock (_lock)
        //        {
        //            if (instance == null)
        //            {
        //                instance = new TaskManage();
        //            }
        //        }
        //    }
        //    return instance;
        //}

        public void UpdateAggConfig(BaseAggConfig config)
        {
        }