Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <param name="id"></param>
        /// <param name="times"></param>
        /// <param name="result"></param>
        private void Read(string file, int id, List <DateTime> times, NumberStatisticsQueryResult result)
        {
            using (var ss = DataFileSeriserManager.manager.GetDefaultFileSersie())
            {
                ss.OpenForReadOnly(file);
                int  icount = id % TagCountOneFile;
                long laddr  = ss.ReadLong(icount * 8 + 72 + 4);

                laddr += TagCountOneFile * 8 + 8 + 72;

                var res = ss.Read(laddr, 48 * 24);

                foreach (var vv in times)
                {
                    long lltmp = vv.Hour * 48;


                    var cmd = res.ReadByte(lltmp);

                    var avgvalue = res.ReadDouble(lltmp + 8);
                    var maxtime  = res.ReadDateTime();
                    var maxvalue = res.ReadDouble();
                    var mintime  = res.ReadDateTime();
                    var minvalue = res.ReadDouble();

                    if (cmd > 0)
                    {
                        result.AddValue(vv, avgvalue, maxvalue, maxtime, minvalue, mintime);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="times"></param>
        /// <returns></returns>
        public NumberStatisticsQueryResult Read(int id, IEnumerable <DateTime> times)
        {
            NumberStatisticsQueryResult result;

            var valcount = times.Count();

            result = new NumberStatisticsQueryResult(valcount);

            Dictionary <DateTime, List <DateTime> > mFileMap = new Dictionary <DateTime, List <DateTime> >();

            foreach (var stime in times)
            {
                var vdd = stime.Date;
                if (!mFileMap.ContainsKey(vdd))
                {
                    mFileMap.Add(vdd, new List <DateTime>()
                    {
                        stime
                    });
                }
                else
                {
                    mFileMap[vdd].Add(stime);
                }
            }

            foreach (var vv in mFileMap)
            {
                Read(id, vv.Key, vv.Value, result);
            }

            return(result);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        public NumberStatisticsQueryResult  Read(int id, DateTime startTime, DateTime endTime)
        {
            NumberStatisticsQueryResult result;

            var valcount = (int)Math.Ceiling((endTime - startTime).TotalHours) + 1;

            result = new NumberStatisticsQueryResult(valcount);

            Dictionary <DateTime, List <DateTime> > mFileMap = new Dictionary <DateTime, List <DateTime> >();

            DateTime stime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, 0, 0);

            while (stime <= endTime)
            {
                var vdd = stime.Date;
                if (!mFileMap.ContainsKey(vdd))
                {
                    mFileMap.Add(vdd, new List <DateTime>()
                    {
                        stime
                    });
                }
                else
                {
                    mFileMap[vdd].Add(stime);
                }
                stime = stime.AddHours(1);
            }

            if (stime > endTime)
            {
                stime = new DateTime(stime.Year, stime.Month, stime.Day, stime.Hour, 0, 0);
                var etime = new DateTime(endTime.Year, endTime.Month, endTime.Day, endTime.Hour, 0, 0);
                if (stime == endTime)
                {
                    var vdd = stime.Date;
                    if (!mFileMap.ContainsKey(vdd))
                    {
                        mFileMap.Add(vdd, new List <DateTime>()
                        {
                            stime
                        });
                    }
                    else
                    {
                        mFileMap[vdd].Add(stime);
                    }
                }
            }

            foreach (var vv in mFileMap)
            {
                Read(id, vv.Key, vv.Value, result);
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="target"></param>
        public void CloneTo(NumberStatisticsQueryResult target)
        {
            if (target.mLimite < this.mLimite)
            {
                target.Resize(this.mLimite);
            }

            Buffer.MemoryCopy((void *)handle, (void *)target.handle, mLimite, this.mSize);
            target.mCount = this.mCount;
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="time"></param>
        /// <param name="times"></param>
        /// <param name="result"></param>
        private void Read(int id, DateTime time, List <DateTime> times, NumberStatisticsQueryResult result)
        {
            string sfile = GetStatisticsFileName(id, time);
            string ss    = System.IO.Path.Combine(GetPrimaryHisDataPath(), sfile);

            if (System.IO.File.Exists(ss))
            {
                Read(ss, id, times, result);
            }
            else
            {
                ss = System.IO.Path.Combine(GetBackUpHisDataPath(), sfile);
                if (System.IO.File.Exists(ss))
                {
                    Read(ss, id, times, result);
                }
            }
        }