Ejemplo n.º 1
0
        private void NumericIntervalDialog_OK_Click(object sender, EventArgs e)
        {
            Decimal intervalSize;

            if (!Decimal.TryParse(IntervalSize.Text, out intervalSize) || intervalSize <= 0)
            {
                MessageBoxMx.ShowError("The interval size must be a positive number");
                IntervalSize.Focus();
                return;
            }

// Update the aggregation def

            AggregationDef ad = AggregationDef;

            if (!ad.IsGroupingType)
            {
                ad.Role = AggregationRole.RowGrouping;
            }

            ad.GroupingType = GroupingTypeEnum.NumericInterval;
            AggregationDef.NumericIntervalSize = intervalSize;
            DialogResult = DialogResult.OK;
            return;

            //UpdateGrid();
            //Hide();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Insert an item which is known to be contained in the tree rooted at the given Noed.
        /// Lower levels of the tree will be created it necessary to hold the item.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="itemInterval"></param>
        /// <param name="item"></param>
        private void InsertContained(Node tree, Interval itemInterval, object item)
        {
            Debug.Assert(tree.Interval.Contains(itemInterval));

            // Do NOT create a new node for zero-area intervals - this would lead
            // to infinite recursion. Instead, use a heuristic of simply returning
            // the smallest existing node containing the query
            bool     isZeroArea = IntervalSize.IsZeroWidth(itemInterval.Min, itemInterval.Max);
            NodeBase node;

            if (isZeroArea)
            {
                node = tree.Find(itemInterval);
            }
            else
            {
                node = tree.GetNode(itemInterval);
            }
            node.Add(item);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Insert an item which is known to be contained in the tree rooted at
        /// the given Node.  Lower levels of the tree will be created
        /// if necessary to hold the item.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="itemInterval"></param>
        /// <param name="item"></param>
        private static void InsertContained(Node <T> tree, Interval itemInterval, T item)
        {
            Assert.IsTrue(tree.Interval.Contains(itemInterval));

            /*
             * Do NOT create a new node for zero-area intervals - this would lead
             * to infinite recursion. Instead, use a heuristic of simply returning
             * the smallest existing node containing the query
             */
            bool         isZeroArea = IntervalSize.IsZeroWidth(itemInterval.Min, itemInterval.Max);
            NodeBase <T> node;

            if (isZeroArea)
            {
                node = tree.Find(itemInterval);
            }
            else
            {
                node = tree.GetNode(itemInterval);
            }
            node.Add(item);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Query for aggregation of count, min, max, sum and average for all active
        /// nodes of the given OPC UA server in the given search span as time histogram
        /// with interval
        /// </summary>
        /// <param name="searchSpan">Date and time span for the query</param>
        /// <param name="appUri">The OPC UA server application Uri</param>
        /// <param name="interval">Interval for Date Time Histogram</param>
        /// <returns>The aggregated nodes</returns>
        public async Task <AggregateResult> GetAllAggregatedNodesWithInterval(DateTimeRange searchSpan, string appUri, string nodeId, TimeSpan interval)
        {
            try
            {
                string id = TimeSpanToId(interval);

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                PredicateStringExpression predicate = new PredicateStringExpression(
                    String.Format(OpcServerNodePredicate, appUri, nodeId));
                Aggregate aggregate = new Aggregate(
                    Expression.UniqueValues(OpcMonitoredItemId, PropertyType.String, opcMaxMonitoredItemId),
                    new Aggregate(Expression.DateHistogram(BuiltInProperty.Timestamp, IntervalSize.FromId(id)),
                                  new Aggregate(
                                      Expression.Count(),
                                      Expression.Min(OpcMonitoredItemValue, PropertyType.Double),
                                      Expression.Max(OpcMonitoredItemValue, PropertyType.Double),
                                      Expression.Average(OpcMonitoredItemValue, PropertyType.Double),
                                      Expression.Sum(OpcMonitoredItemValue, PropertyType.Double)
                                      )));

                AggregatesResult aggregateResults = await RDXQueryClient.GetAggregatesAsync(
                    searchSpan,
                    predicate,
                    new[] { aggregate },
                    _cancellationToken);

                // Since there was 1 top level aggregate in request, there is 1 aggregate result.
                AggregateResult aggregateResult = aggregateResults[0];

                stopwatch.Stop();
                RDXTrace.TraceInformation("GetAllAggregatedNodes query took {0} ms", stopwatch.ElapsedMilliseconds);

                return(aggregateResult);
            }
            catch (Exception e)
            {
                RDXTrace.TraceError("GetAllAggregatedNodes: Exception {0}", e.Message);
                return(null);
            }
        }