private void PopulateBuiltinProperties()
 {
     OutputConditionExpressionTypeUtil.Populate(
         _builtinProperties.Properties,
         _totalNewEventsCount,
         _totalOldEventsCount,
         _totalNewEventsSum,
         _totalOldEventsSum,
         _lastOutputTimestamp);
 }
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="whenExpressionNode">the expression to evaluate, returning true when to output</param>
        /// <param name="assignments">is the optional then-clause variable assignments, or null or empty if none</param>
        /// <param name="agentInstanceContext">The agent instance context.</param>
        /// <throws><seealso cref="ExprValidationException" /> when validation fails</throws>
        public OutputConditionPolledExpression(ExprNode whenExpressionNode, IList <OnTriggerSetAssignment> assignments, AgentInstanceContext agentInstanceContext)
        {
            _whenExpressionNode   = whenExpressionNode.ExprEvaluator;
            _agentInstanceContext = agentInstanceContext;
            _eventsPerStream      = new EventBean[1];

            // determine if using properties
            var containsBuiltinProperties = false;

            if (ContainsBuiltinProperties(whenExpressionNode))
            {
                containsBuiltinProperties = true;
            }
            else
            {
                if (assignments != null)
                {
                    foreach (OnTriggerSetAssignment assignment in assignments)
                    {
                        if (ContainsBuiltinProperties(assignment.Expression))
                        {
                            containsBuiltinProperties = true;
                        }
                    }
                }
            }

            if (containsBuiltinProperties)
            {
                EventType oatype = agentInstanceContext.StatementContext.EventAdapterService.CreateAnonymousObjectArrayType(
                    typeof(OutputConditionPolledExpression).FullName, OutputConditionExpressionTypeUtil.TYPEINFO);
                _builtinProperties   = new ObjectArrayEventBean(OutputConditionExpressionTypeUtil.GetOAPrototype(), oatype);
                _lastOutputTimestamp = agentInstanceContext.StatementContext.SchedulingService.Time;
            }

            if (assignments != null)
            {
                _variableReadWritePackage = new VariableReadWritePackage(assignments, agentInstanceContext.StatementContext.VariableService, agentInstanceContext.StatementContext.EventAdapterService);
            }
            else
            {
                _variableReadWritePackage = null;
            }
        }
Exemple #3
0
        public OutputConditionExpression(
            OutputCallback outputCallback,
            AgentInstanceContext agentInstanceContext,
            OutputConditionExpressionFactory parent,
            bool isStartConditionOnCreation)
            : base(outputCallback)
        {
            _agentInstanceContext = agentInstanceContext;
            _parent = parent;

            _scheduleSlot    = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot();
            _eventsPerStream = new EventBean[1];

            if (parent.BuiltinPropertiesEventType != null)
            {
                _builtinProperties = new ObjectArrayEventBean(
                    OutputConditionExpressionTypeUtil.GetOAPrototype(), parent.BuiltinPropertiesEventType);
                _lastOutputTimestamp = agentInstanceContext.StatementContext.SchedulingService.Time;
            }

            if (parent.VariableNames != null)
            {
                // if using variables, register a callback on the change of the variable
                foreach (String variableName in parent.VariableNames)
                {
                    var theVariableName = variableName;
                    agentInstanceContext.StatementContext.VariableService.RegisterCallback(
                        variableName, agentInstanceContext.AgentInstanceId, Update);
                    agentInstanceContext.AddTerminationCallback(
                        () => _agentInstanceContext.StatementContext.VariableService.UnregisterCallback(
                            theVariableName, agentInstanceContext.AgentInstanceId, Update));
                }
            }

            if (isStartConditionOnCreation)
            {
                Update(0, 0);
            }
        }