示例#1
0
        public bool Generate(int sampleID)
        {
            wfc = new WFCOverlayMode(sampleTextures[sampleID], N, Width, Height, PeriodicInput, PeriodicOutput,
                                     Symmetry, Ground);
            bool ret = false;

            if (UseSeed)
            {
                ret = wfc.Run(Seed, Limit);
            }
            else
            {
                ret = wfc.Run(Limit);
            }

            Bitmap bmp = wfc.Graphics();

            if (wfc.Success)
            {
                _callback?.Invoke(bmp);
            }


            if (renderer != null)
            {
                Texture tex = TextureLoader.BitmapToTexture(bmp, "WFCGeneratedMap");
                ChangeTexture(tex);
            }

            return(ret);
        }
示例#2
0
        private void ScheduleCallback()
        {
            _isCallbackScheduled = true;
            var current = _context.StatementContext.SchedulingService.Time;

            if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
            {
                Log.Debug(
                    ".scheduleCallback Scheduled new callback for " +
                    " now=" + current +
                    " currentReferencePoint=" + _currentReferencePoint +
                    " spec=" + _factory.ScheduleSpec);
            }

            var callback = new ProxyScheduleHandleCallback
            {
                ProcScheduledTrigger = extensionServicesContext => Instrument.With(
                    i => i.QOutputRateConditionScheduledEval(),
                    i => i.AOutputRateConditionScheduledEval(),
                    () =>
                {
                    _isCallbackScheduled = false;
                    OutputCallback.Invoke(DO_OUTPUT, FORCE_UPDATE);
                    ScheduleCallback();
                })
            };
            var handle            = new EPStatementHandleCallback(_context.EpStatementAgentInstanceHandle, callback);
            var schedulingService = _context.StatementContext.SchedulingService;
            var nextScheduledTime = ScheduleComputeHelper.ComputeDeltaNextOccurance(
                _factory.ScheduleSpec, schedulingService.Time,
                _context.StatementContext.MethodResolutionService.EngineImportService.TimeZone);

            schedulingService.Add(nextScheduledTime, handle, _scheduleSlot);
        }
示例#3
0
        public override void UpdateOutputCondition(int newDataCount, int oldDataCount)
        {
            if (_variableReader != null)
            {
                var value = _variableReader.Value;
                if (value != null)
                {
                    _eventRate = value.AsLong();
                }
            }

            _newEventsCount += newDataCount;
            _oldEventsCount += oldDataCount;

            if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
            {
                Log.Debug(".updateBatchCondition, " +
                          "  newEventsCount==" + _newEventsCount +
                          "  oldEventsCount==" + _oldEventsCount);
            }

            if (IsSatisfied)
            {
                if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled))
                {
                    Log.Debug(".UpdateOutputCondition() condition satisfied");
                }
                _newEventsCount = 0;
                _oldEventsCount = 0;
                OutputCallback.Invoke(DO_OUTPUT, FORCE_UPDATE);
            }
        }
示例#4
0
        private void ContinueOutputProcessing(bool forceUpdate)
        {
            var doOutput = !_witnessedFirst;

            OutputCallback.Invoke(doOutput, forceUpdate);
            _witnessedFirst = false;
        }
示例#5
0
        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();
        }
示例#6
0
 public override void UpdateOutputCondition(int newEventsCount, int oldEventsCount)
 {
     if (!_witnessedFirst)
     {
         _witnessedFirst = true;
         const bool doOutput    = true;
         const bool forceUpdate = false;
         OutputCallback.Invoke(doOutput, forceUpdate);
     }
     _innerCondition.UpdateOutputCondition(newEventsCount, oldEventsCount);
 }
示例#7
0
 public void WriteLine(string line)
 {
     lock (_locker)
     {
         if (_streamWriter != null)
         {
             _streamWriter.WriteLine(line);
         }
         _callback?.Invoke(line);
     }
 }
示例#8
0
        public override void UpdateOutputCondition(int newEventsCount, int oldEventsCount)
        {
            _totalNewEventsCount += newEventsCount;
            _totalOldEventsCount += oldEventsCount;
            _totalNewEventsSum   += newEventsCount;
            _totalOldEventsSum   += oldEventsCount;

            bool isOutput = Evaluate(_parent.WhenExpressionNodeEval);

            if (isOutput)
            {
                ExecuteThenAssignments();
                OutputCallback.Invoke(true, true);
                ResetBuiltinProperties();
            }
        }
示例#9
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);
        }
示例#10
0
        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));
        }
示例#11
0
 public virtual void Terminated()
 {
     OutputCallback.Invoke(true, true);
 }
示例#12
0
 public override void Terminated()
 {
     OutputCallback.Invoke(true, true);
 }
示例#13
0
 public override void UpdateOutputCondition(int newEventsCount, int oldEventsCount)
 {
     OutputCallback.Invoke(DO_OUTPUT, FORCE_UPDATE);
 }
示例#14
0
 private void OnOutputCallback(OutputCallbackEventArgs e)
 {
     OutputCallback?.Invoke(this, e);
 }