Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-1706 Make Automatic Run Type honor RunEnabled settings #9680

Merged
merged 5 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml;
using Dynamo.Core;
using Dynamo.Core;
using Dynamo.Engine;
using Dynamo.Graph.Annotations;
using Dynamo.Graph.Nodes;
Expand All @@ -17,6 +10,13 @@
using Newtonsoft.Json;
using ProtoCore;
using ProtoCore.Namespace;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml;
reddyashish marked this conversation as resolved.
Show resolved Hide resolved

namespace Dynamo.Graph.Workspaces
{
Expand All @@ -31,6 +31,7 @@ public class HomeWorkspaceModel : WorkspaceModel
private PulseMaker pulseMaker;
private readonly bool verboseLogging;
private bool graphExecuted;
private bool executingTask;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
private IEnumerable<KeyValuePair<Guid, List<CallSite.RawTraceData>>> historicalTraceData;

/// <summary>
Expand Down Expand Up @@ -331,9 +332,16 @@ internal override void RequestRun()
{
base.RequestRun();

if (RunSettings.RunEnabled && RunSettings.RunType != RunType.Manual)
if (RunSettings.RunType != RunType.Manual)
{
Run();
// TODO for Dynamo 3.0: The boolean "executingTask" that is used here is a make-do fix.
// We will be needing a separate variable(boolean) to check for RunEnabled flag from external applications and
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
// not confuse it with the internal flag RunEnabled which is associated with the Run button in Dynamo.
// Make this RunSettings.RunEnabled private, introduce the new flag and remove the "executingTask" variable.
if (RunSettings.RunEnabled || executingTask)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be !executingTask?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because this boolean tracks if the previous run is completely executed or not. In the case, where OnUpdateGraphCompleted event is not completed, we want to trigger the next runs. In the end the executing task will be set to false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, since we are using ||, normal case it will just be dominated by RunSettings.RunEnabled which is always true. But once RunEnabled become false, run() can't be called at all

{
Run();
}
}
}

Expand Down Expand Up @@ -579,6 +587,7 @@ private void OnUpdateGraphCompleted(AsyncTask task)

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

//set the node execution preview to false;
OnSetNodeDeltaState(new DeltaComputeStateEventArgs(new List<Guid>(), graphExecuted));
Expand Down Expand Up @@ -663,6 +672,7 @@ public void Run()

OnEvaluationStarted(EventArgs.Empty);
scheduler.ScheduleForExecution(task);
executingTask = true;
}
else
{
Expand Down
33 changes: 26 additions & 7 deletions test/DynamoCoreWpfTests/RecordedTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml;
using CoreNodeModels.Input;
using CoreNodeModels.Input;
using Dynamo;
using Dynamo.Configuration;
using Dynamo.Controls;
Expand All @@ -22,6 +16,12 @@
using DynamoShapeManager;
using NUnit.Framework;
using PythonNodeModels;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml;
using SystemTestServices;
using TestServices;
using IntegerSlider = CoreNodeModels.Input.IntegerSlider;
Expand Down Expand Up @@ -1425,6 +1425,25 @@ public void TestPreviewToggleConnectionMultiOutputNode()
});
}

[Test, RequiresSTA]
public void TestAddingAndRemovingConnectors()
aparajit-pratap marked this conversation as resolved.
Show resolved Hide resolved
{
RunCommandsFromFile("TestAddingAndRemovingConnectors.xml", (commandTag) =>
{
if (commandTag == "FirstRun")
{
AssertPreviewValue("42001c91-7faa-43a5-9978-eea5e0a2bd0c", "abc");
}
else if (commandTag == "SecondRun")
{
AssertPreviewValue("42001c91-7faa-43a5-9978-eea5e0a2bd0c", "12345");
}
else if (commandTag == "ThirdRun")
{
AssertPreviewValue("42001c91-7faa-43a5-9978-eea5e0a2bd0c", "abc");
}
});
}
#endregion
}

Expand Down
61 changes: 61 additions & 0 deletions test/core/recorded/TestAddingAndRemovingConnectors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<Commands ExitAfterPlayback="true" PauseAfterPlaybackInMs="10" CommandIntervalInMs="20">
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<CreateNodeCommand X="190" Y="167" DefaultPosition="false" TransformCoordinates="true">
<ModelGuid>0be4c94a-da23-4178-9f52-cb612062dcec</ModelGuid>
<Dynamo.Graph.Nodes.CodeBlockNodeModel guid="0be4c94a-da23-4178-9f52-cb612062dcec" type="Dynamo.Graph.Nodes.CodeBlockNodeModel" nickname="Code Block" x="98" y="136" isVisible="true" lacing="Disabled" isSelectedInput="False" isSelectedOutput="False" IsFrozen="false" isPinned="false" CodeText="&quot;abc&quot;;" ShouldFocus="false">
<OutPortInfo LineIndex="0" />
</Dynamo.Graph.Nodes.CodeBlockNodeModel>
</CreateNodeCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<UpdateModelValueCommand Name="Code" Value="&quot;abc&quot;" WorkspaceGuid="b3fe6494-214a-4f04-8dd8-88aa6778e7a8">
<ModelGuid>0be4c94a-da23-4178-9f52-cb612062dcec</ModelGuid>
</UpdateModelValueCommand>
<SelectInRegionCommand X="319" Y="225" Width="1" Height="0" IsCrossSelection="false" />
<CreateNodeCommand X="320" Y="225" DefaultPosition="false" TransformCoordinates="true">
<ModelGuid>42001c91-7faa-43a5-9978-eea5e0a2bd0c</ModelGuid>
<Dynamo.Graph.Nodes.ZeroTouch.DSVarArgFunction guid="42001c91-7faa-43a5-9978-eea5e0a2bd0c" type="Dynamo.Graph.Nodes.ZeroTouch.DSVarArgFunction" nickname="String.Concat" x="320" y="225" isVisible="true" lacing="Auto" isSelectedInput="False" isSelectedOutput="False" IsFrozen="false" isPinned="false" assembly="DSCoreNodes.dll" function="DSCore.String.Concat@string[]" inputcount="1">
<PortInfo index="0" default="False" />
</Dynamo.Graph.Nodes.ZeroTouch.DSVarArgFunction>
</CreateNodeCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<CreateNodeCommand X="146" Y="331" DefaultPosition="false" TransformCoordinates="true">
<ModelGuid>4aa6ef10-0a0a-414c-8a47-b059b02d05af</ModelGuid>
<Dynamo.Graph.Nodes.CodeBlockNodeModel guid="4aa6ef10-0a0a-414c-8a47-b059b02d05af" type="Dynamo.Graph.Nodes.CodeBlockNodeModel" nickname="Code Block" x="54" y="300" isVisible="true" lacing="Disabled" isSelectedInput="False" isSelectedOutput="False" IsFrozen="false" isPinned="false" CodeText="&quot;12345&quot;;" ShouldFocus="false">
<OutPortInfo LineIndex="0" />
</Dynamo.Graph.Nodes.CodeBlockNodeModel>
</CreateNodeCommand>
<SelectModelCommand Modifiers="0">
<ModelGuid>00000000-0000-0000-0000-000000000000</ModelGuid>
</SelectModelCommand>
<UpdateModelValueCommand Name="Code" Value="&quot;12345&quot;" WorkspaceGuid="b3fe6494-214a-4f04-8dd8-88aa6778e7a8">
<ModelGuid>4aa6ef10-0a0a-414c-8a47-b059b02d05af</ModelGuid>
</UpdateModelValueCommand>
<SelectInRegionCommand X="146" Y="331" Width="0" Height="0" IsCrossSelection="false" />
<MakeConnectionCommand PortIndex="0" Type="1" ConnectionMode="0">
<ModelGuid>0be4c94a-da23-4178-9f52-cb612062dcec</ModelGuid>
</MakeConnectionCommand>
<MakeConnectionCommand PortIndex="0" Type="0" ConnectionMode="1">
<ModelGuid>42001c91-7faa-43a5-9978-eea5e0a2bd0c</ModelGuid>
</MakeConnectionCommand>
<PausePlaybackCommand Tag="FirstRun" PauseDurationInMs="20" />
<MakeConnectionCommand PortIndex="0" Type="1" ConnectionMode="0">
<ModelGuid>4aa6ef10-0a0a-414c-8a47-b059b02d05af</ModelGuid>
</MakeConnectionCommand>
<MakeConnectionCommand PortIndex="0" Type="0" ConnectionMode="1">
<ModelGuid>42001c91-7faa-43a5-9978-eea5e0a2bd0c</ModelGuid>
</MakeConnectionCommand>
<PausePlaybackCommand Tag="SecondRun" PauseDurationInMs="20" />
<MakeConnectionCommand PortIndex="0" Type="1" ConnectionMode="0">
<ModelGuid>0be4c94a-da23-4178-9f52-cb612062dcec</ModelGuid>
</MakeConnectionCommand>
<MakeConnectionCommand PortIndex="0" Type="0" ConnectionMode="1">
<ModelGuid>42001c91-7faa-43a5-9978-eea5e0a2bd0c</ModelGuid>
</MakeConnectionCommand>
<PausePlaybackCommand Tag="ThirdRun" PauseDurationInMs="20" />
</Commands>