示例#1
0
        private void DoCount(WI_Count req)
        {
            var promise = req.Promise;

            try {
                Channel?ch = GetChannelOrNull(req.Variable);
                if (ch == null)
                {
                    promise.SetResult(0);
                }
                else
                {
                    Timestamp     start  = req.StartInclusive;
                    Timestamp     end    = req.EndInclusive;
                    QualityFilter filter = req.Filter;

                    long res;
                    if (start == Timestamp.Empty && end == Timestamp.Max && filter == QualityFilter.ExcludeNone)
                    {
                        res = ch.CountAll();
                    }
                    else
                    {
                        res = ch.CountData(start, end, Map(filter));
                    }

                    promise.SetResult(res);
                }
            }
            catch (Exception exp) {
                promise.SetException(exp);
            }
        }
示例#2
0
        private void DoCount(WI_Count req)
        {
            var promise = req.Promise;

            try {
                Channel ch = GetChannelOrNull(req.Variable);
                if (ch == null)
                {
                    promise.SetResult(0);
                }
                else
                {
                    Timestamp start = req.StartInclusive;
                    Timestamp end   = req.EndInclusive;

                    long res;
                    if (start == Timestamp.Empty && end == Timestamp.Max)
                    {
                        res = ch.CountAll();
                    }
                    else
                    {
                        res = ch.CountData(start, end);
                    }

                    promise.SetResult(res);
                }
            }
            catch (Exception exp) {
                promise.SetException(exp);
            }
        }