private void ScheduleCallback() { _isCallbackScheduled = true; long current = _agentInstanceContext.StatementContext.SchedulingService.Time; if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled)) { Log.Debug( ".scheduleCallback Scheduled new callback for " + " afterMsec=" + 0 + " now=" + current); } ScheduleHandleCallback callback = new ProxyScheduleHandleCallback() { ProcScheduledTrigger = extensionServicesContext => Instrument.With( i => i.QOutputRateConditionScheduledEval(), i => i.AOutputRateConditionScheduledEval(), () => { _isCallbackScheduled = false; OutputCallback.Invoke(true, true); ResetBuiltinProperties(); }) }; _scheduleHandle = new EPStatementHandleCallback( _agentInstanceContext.EpStatementAgentInstanceHandle, callback); _agentInstanceContext.StatementContext.SchedulingService.Add(0, _scheduleHandle, _scheduleSlot); _agentInstanceContext.AddTerminationCallback(Stop); // execute assignments ExecuteThenAssignments(); }
public OutputConditionExpression( OutputCallback outputCallback, AgentInstanceContext agentInstanceContext, OutputConditionExpressionFactory parent) : base(outputCallback) { this.agentInstanceContext = agentInstanceContext; this.parent = parent; scheduleSlot = agentInstanceContext.StatementContext.ScheduleBucket.AllocateSlot(); eventsPerStream = new EventBean[1]; if (parent.BuiltinPropertiesEventType != null) { builtinProperties = new ObjectArrayEventBean( OutputConditionExpressionTypeUtil.OAPrototype, parent.BuiltinPropertiesEventType); lastOutputTimestamp = agentInstanceContext.StatementContext.SchedulingService.Time; } if (parent.Variables != null && parent.Variables.Length > 0) { // if using variables, register a callback on the change of the variable foreach (var variable in parent.Variables) { var theVariableDepId = variable.DeploymentId; var theVariableName = variable.MetaData.VariableName; agentInstanceContext.VariableManagementService.RegisterCallback( theVariableDepId, theVariableName, agentInstanceContext.AgentInstanceId, this); agentInstanceContext.AddTerminationCallback( new ProxyAgentInstanceMgmtCallback { ProcStop = services => { services.AgentInstanceContext.VariableManagementService.UnregisterCallback( theVariableDepId, theVariableName, agentInstanceContext.AgentInstanceId, this); } }); } } if (parent.IsStartConditionOnCreation) { Update(0, 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.OAPrototype, 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( new ProxyStopCallback( () => _agentInstanceContext.StatementContext.VariableService.UnregisterCallback( theVariableName, agentInstanceContext.AgentInstanceId, Update))); } } if (isStartConditionOnCreation) { Update(0, 0); } }
private void ScheduleCallback() { _isCallbackScheduled = true; var current = _context.StatementContext.SchedulingService.Time; var delta = _parent.TimePeriod.NonconstEvaluator().DeltaAddWReference(current, _currentReferencePoint.Value, null, true, _context); var deltaTime = delta.Delta; _currentReferencePoint = delta.LastReference; _currentScheduledTime = deltaTime; if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled)) { Log.Debug(".scheduleCallback Scheduled new callback for " + " afterMsec=" + deltaTime + " now=" + current + " currentReferencePoint=" + _currentReferencePoint); } var callback = new ProxyScheduleHandleCallback { ProcScheduledTrigger = (extensionServicesContext) => { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QOutputRateConditionScheduledEval(); } _isCallbackScheduled = false; OutputCallback.Invoke(DO_OUTPUT, FORCE_UPDATE); ScheduleCallback(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AOutputRateConditionScheduledEval(); } } }; _handle = new EPStatementHandleCallback(_context.EpStatementAgentInstanceHandle, callback); _context.StatementContext.SchedulingService.Add(deltaTime, _handle, _scheduleSlot); _context.AddTerminationCallback(this); }
private void ScheduleCallback() { _isCallbackScheduled = true; long current = _context.StatementContext.SchedulingService.Time; ExprTimePeriodEvalDeltaResult delta = _parent.TimePeriod.NonconstEvaluator().DeltaMillisecondsAddWReference( current, _currentReferencePoint.Value, null, true, _context); long afterMSec = delta.Delta; _currentReferencePoint = delta.LastReference; _currentScheduledTime = afterMSec; if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled)) { Log.Debug( ".scheduleCallback Scheduled new callback for " + " afterMsec=" + afterMSec + " now=" + current + " currentReferencePoint=" + _currentReferencePoint); } ScheduleHandleCallback callback = new ProxyScheduleHandleCallback { ProcScheduledTrigger = extensionServicesContext => Instrument.With( i => i.QOutputRateConditionScheduledEval(), i => i.AOutputRateConditionScheduledEval(), () => { _isCallbackScheduled = false; OutputCallback.Invoke(DO_OUTPUT, FORCE_UPDATE); ScheduleCallback(); }) }; _handle = new EPStatementHandleCallback(_context.EpStatementAgentInstanceHandle, callback); _context.StatementContext.SchedulingService.Add(afterMSec, _handle, _scheduleSlot); _context.AddTerminationCallback(new ProxyStopCallback(Stop)); }