Esempio n. 1
0
        /// <summary>
        /// This method is typically called from the main application thread (as
        /// a result of user actions such as button click or node UI changes) to
        /// schedule an update of the graph. This call may or may not represent
        /// an actual update. In the event that the user action does not result
        /// in actual graph update (e.g. moving of node on UI), the update task
        /// will not be scheduled for execution.
        /// </summary>
        public void Run()
        {
            var traceData = PreloadedTraceData;

            if ((traceData != null) && traceData.Any())
            {
                // If we do have preloaded trace data, set it here first.
                var setTraceDataTask = new SetTraceDataAsyncTask(scheduler);
                if (setTraceDataTask.Initialize(EngineController, this))
                {
                    scheduler.ScheduleForExecution(setTraceDataTask);
                }
            }

            // If one or more custom node have been updated, make sure they
            // are compiled first before the home workspace gets evaluated.
            //
            EngineController.ProcessPendingCustomNodeSyncData(scheduler);

            var task = new UpdateGraphAsyncTask(scheduler, VerboseLogging);

            if (task.Initialize(EngineController, this))
            {
                task.Completed += OnUpdateGraphCompleted;
                RunEnabled      = false; // Disable 'Run' button.
                scheduler.ScheduleForExecution(task);
            }
            else
            {
                // Notify handlers that evaluation did not take place.
                var e = new EvaluationCompletedEventArgs(false);
                OnEvaluationCompleted(e);
            }
        }
Esempio n. 2
0
        public virtual void OnEvaluationCompleted(EvaluationCompletedEventArgs e)
        {
            this.HasRunWithoutCrash = e.EvaluationSucceeded;

            var handler = EvaluationCompleted;
            if (handler != null) handler(this, e);

        }
Esempio n. 3
0
        public virtual void OnRefreshCompleted(EvaluationCompletedEventArgs e)
        {
            var handler = RefreshCompleted;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 4
0
        protected virtual void OnEvaluationCompleted(EvaluationCompletedEventArgs e)
        {
            var handler = EvaluationCompleted;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// This method is typically called from the main application thread (as
        /// a result of user actions such as button click or node UI changes) to
        /// schedule an update of the graph. This call may or may not represent
        /// an actual update. In the event that the user action does not result
        /// in actual graph update (e.g. moving of node on UI), the update task
        /// will not be scheduled for execution.
        /// </summary>
        public void Run()
        {
            graphExecuted = true;

            // When Dynamo is shut down, the workspace is cleared, which results
            // in Modified() being called. But, we don't want to run when we are
            // shutting down so we check whether an engine controller is available.
            if (this.EngineController == null)
            {
                return;
            }

            var traceData = PreloadedTraceData;

            if ((traceData != null) && traceData.Any())
            {
                // If we do have preloaded trace data, set it here first.
                var setTraceDataTask = new SetTraceDataAsyncTask(scheduler);
                if (setTraceDataTask.Initialize(EngineController, this))
                {
                    scheduler.ScheduleForExecution(setTraceDataTask);
                }
            }

            // If one or more custom node have been updated, make sure they
            // are compiled first before the home workspace gets evaluated.
            //
            EngineController.ProcessPendingCustomNodeSyncData(scheduler);

            var task = new UpdateGraphAsyncTask(scheduler, verboseLogging);

            if (task.Initialize(EngineController, this))
            {
                task.Completed        += OnUpdateGraphCompleted;
                RunSettings.RunEnabled = false; // Disable 'Run' button.

                // Reset node states
                foreach (var node in Nodes)
                {
                    node.IsUpdated = false;
                }

                // The workspace has been built for the first time
                silenceNodeModifications = false;

                OnEvaluationStarted(EventArgs.Empty);
                scheduler.ScheduleForExecution(task);
            }
            else
            {
                // Notify handlers that evaluation did not take place.
                var e = new EvaluationCompletedEventArgs(false);
                OnEvaluationCompleted(e);
            }
        }
Esempio n. 6
0
        public virtual void OnEvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
        {
            if (!e.EvaluationSucceeded)
            {
                Action showFailureMessage = () => DisplayEngineFailureMessage(e.Error);
                OnRequestDispatcherBeginInvoke(showFailureMessage);
            }

            if (EvaluationCompleted != null)
            {
                EvaluationCompleted(sender, e);
            }
        }
 protected virtual void OnEvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
 {
     // Override in derived classes
 }
Esempio n. 8
0
        internal void OnRefreshCompleted(object sender,
            EvaluationCompletedEventArgs evaluationCompletedEventArgs)
        {
            lock (stateMutex)
            {
                // Mark evaluation as being done.
                evaluationInProgress = false;

                // If there is no pending request to perform another round of 
                // evaluation (i.e. the timer has not ticked while evaluation 
                // was taking place), then bail.
                // 
                if (!evaluationRequestPending)
                    return;

                // Further evaluation was requested.
                evaluationRequestPending = false;
                BeginRun();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// This callback method is invoked in the context of ISchedulerThread
        /// when UpdateGraphAsyncTask is completed.
        /// </summary>
        /// <param name="task">The original UpdateGraphAsyncTask instance.</param>
        private void OnUpdateGraphCompleted(AsyncTask task)
        {
            var updateTask = (UpdateGraphAsyncTask)task;
            var messages   = new Dictionary <Guid, string>();

            // Runtime warnings take precedence over build warnings.
            foreach (var warning in updateTask.RuntimeWarnings)
            {
                var message = string.Join("\n", warning.Value.Select(w => w.Message));
                messages.Add(warning.Key, message);
            }

            foreach (var warning in updateTask.BuildWarnings)
            {
                // If there is already runtime warnings for
                // this node, then ignore the build warnings.
                if (messages.ContainsKey(warning.Key))
                {
                    continue;
                }

                var message = string.Join("\n", warning.Value.Select(w => w.Message));
                messages.Add(warning.Key, message);
            }

            var workspace = updateTask.TargetedWorkspace;

            foreach (var message in messages)
            {
                var guid = message.Key;
                var node = workspace.Nodes.FirstOrDefault(n => n.GUID == guid);
                if (node == null)
                {
                    continue;
                }

                node.Warning(message.Value); // Update node warning message.
            }

            foreach (var node in Nodes)
            {
                node.ClearDirtyFlag();
            }

            // Notify listeners (optional) of completion.
            RunSettings.RunEnabled = true; // Re-enable 'Run' button.

            //set the node execution preview to false;
            OnSetNodeDeltaState(new DeltaComputeStateEventArgs(new List <Guid>(), graphExecuted));

            // This method is guaranteed to be called in the context of
            // ISchedulerThread (for Revit's case, it is the idle thread).
            // Dispatch the failure message display for execution on UI thread.
            //
            EvaluationCompletedEventArgs e = task.Exception == null || IsTestMode
                ? new EvaluationCompletedEventArgs(true)
                : new EvaluationCompletedEventArgs(true, task.Exception);

            EvaluationCount++;

            OnEvaluationCompleted(e);

            if (EngineController.IsDisposed)
            {
                return;
            }

            EngineController.ReconcileTraceDataAndNotify();

            // Refresh values of nodes that took part in update.
            foreach (var modifiedNode in updateTask.ModifiedNodes)
            {
                modifiedNode.RequestValueUpdateAsync(scheduler, EngineController);
            }

            scheduler.Tasks.AllComplete(_ =>
            {
                OnRefreshCompleted(e);
            });
        }
Esempio n. 10
0
        /// <summary>
        /// This method is typically called from the main application thread (as 
        /// a result of user actions such as button click or node UI changes) to
        /// schedule an update of the graph. This call may or may not represent 
        /// an actual update. In the event that the user action does not result 
        /// in actual graph update (e.g. moving of node on UI), the update task 
        /// will not be scheduled for execution.
        /// </summary>
        public void Run()
        {
            graphExecuted = true;

            // When Dynamo is shut down, the workspace is cleared, which results
            // in Modified() being called. But, we don't want to run when we are
            // shutting down so we check whether an engine controller is available.
            if (this.EngineController == null)
            {
                return;
            }

            var traceData = PreloadedTraceData;
            if ((traceData != null) && traceData.Any())
            {
                // If we do have preloaded trace data, set it here first.
                var setTraceDataTask = new SetTraceDataAsyncTask(scheduler);
                if (setTraceDataTask.Initialize(EngineController, this))
                    scheduler.ScheduleForExecution(setTraceDataTask);
            }

            // If one or more custom node have been updated, make sure they
            // are compiled first before the home workspace gets evaluated.
            // 
            EngineController.ProcessPendingCustomNodeSyncData(scheduler);

            var task = new UpdateGraphAsyncTask(scheduler, verboseLogging);
            if (task.Initialize(EngineController, this))
            {
                task.Completed += OnUpdateGraphCompleted;
                RunSettings.RunEnabled = false; // Disable 'Run' button.

                // Reset node states
                foreach (var node in Nodes)
                {
                    node.IsUpdated = false;
                }

                // The workspace has been built for the first time
                silenceNodeModifications = false;

                OnEvaluationStarted(EventArgs.Empty);
                scheduler.ScheduleForExecution(task);
            }
            else
            {
                // Notify handlers that evaluation did not take place.
                var e = new EvaluationCompletedEventArgs(false);
                OnEvaluationCompleted(e);
            }
        }
Esempio n. 11
0
 public virtual void OnRefreshCompleted(EvaluationCompletedEventArgs e)
 {
     var handler = RefreshCompleted;
     if (handler != null) handler(this, e);
 }
Esempio n. 12
0
        public virtual void OnEvaluationCompleted(EvaluationCompletedEventArgs e)
        {
            this.HasRunWithoutCrash = e.EvaluationSucceeded;

            var handler = EvaluationCompleted;
            if (handler != null) handler(this, e);

        }
Esempio n. 13
0
        public virtual void OnEvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
        {
            if (!e.EvaluationSucceeded)
            {
                Action showFailureMessage = () => DisplayEngineFailureMessage(e.Error);
                OnRequestDispatcherBeginInvoke(showFailureMessage);
           }

            if (EvaluationCompleted != null)
                EvaluationCompleted(sender, e);
        }
        void hwm_EvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
        {
            bool hasWarnings = Model.Nodes.Any(n => n.State == ElementState.Warning);

            if (!hasWarnings)
            {
                SetCurrentWarning(NotificationLevel.Mild, Properties.Resources.RunCompletedMessage);
            }
            else
            {
                SetCurrentWarning(NotificationLevel.Moderate, Properties.Resources.RunCompletedWithWarningsMessage); 
            }
        }
 private void CurrentWorkspaceModel_EvaluationCompleted(object sender, Dynamo.Models.EvaluationCompletedEventArgs e)
 {
     // TODO: We may need to update node values after graph execution,
     // Depending on if we display node values at all.
 }