예제 #1
0
        public List <CollectValue> GetCollectValues(string meters, string meterparams, string startTime, string endTime)
        {
            DateTime start = Util.ConvertString2DateTime(startTime, "yyyy-MM-dd HH:mm:ss");
            DateTime end   = Util.ConvertString2DateTime(endTime, "yyyy-MM-dd HH:mm:ss");

            string[] meterArray  = meters.Split(';');
            string[] paramsArray = meterparams.Split(';');

            List <HistoryValue> startValues = context.GetHistoryValues(meterArray, paramsArray, start);
            List <HistoryValue> endValues   = context.GetHistoryValues(meterArray, paramsArray, end);


            return(null);
        }
예제 #2
0
        public void TestGetHistoryValue()
        {
            HistoryDbContext    context = new HistoryDbContext();
            List <HistoryValue> list    = context.GetHistoryValues(new string[] { "000001G0010001", "000001G0010002" }, new string[] { "31000000000711" }, new DateTime(2018, 4, 27, 10, 30, 0));

            for (int i = 0; i < list.Count; i++)
            {
                Console.WriteLine("MeterID:{0};MeterParamID:{1};Value:{2}", list[i].MeterID, list[i].MeterParamID, list[i].Value);
            }
        }
예제 #3
0
        public CircuitCollectViewModel GetViewModel(string buildId, string energyCode, string[] circuitIDs, string startDate, string endDate)
        {
            CircuitCollectViewModel viewModel = new CircuitCollectViewModel();
            DateTime startTime = Util.ConvertString2DateTime(startDate, "yyyy-MM-dd HH:mm:ss");
            DateTime endTime   = Util.ConvertString2DateTime(endDate, "yyyy-MM-dd HH:mm:ss");

            List <CircuitMeterInfo> circuitMeterInfos = context.GetCircuitMeterInfoList(buildId, circuitIDs);

            string[]            meterIDs      = GetMeterIDs(circuitMeterInfos);
            string[]            meterParamIDs = GetMeterParamIDs(circuitMeterInfos);
            List <HistoryValue> startValue    = context.GetHistoryValues(meterIDs, meterParamIDs, startTime);
            List <HistoryValue> endValue      = context.GetHistoryValues(meterIDs, meterParamIDs, endTime);
            List <CollectValue> data          = new List <CollectValue>();

            foreach (var meterID in startValue)
            {
                CollectValue collect = new CollectValue();
                collect.Name       = circuitMeterInfos.Find(x => x.MeterID.Equals(meterID.MeterID)).CircuitName;
                collect.StartValue = meterID.Value;
                collect.EndValue   = endValue.Find(x => x.MeterID.Equals(meterID.MeterID)).Value;
                collect.DiffValue  = collect.EndValue - collect.StartValue;

                data.Add(collect);
            }
            viewModel.Data = data;

            return(viewModel);
        }