public LiveRunnerServices(EngineController controller) { this.controller = controller; liveRunner = LiveRunnerFactory.CreateLiveRunner(controller); liveRunner.GraphUpdateReady += GraphUpdateReady; liveRunner.NodeValueReady += NodeValueReady; }
internal QueryMirrorDataAsyncTask(QueryMirrorDataParams initParams) : base(initParams.Scheduler) { if (initParams.EngineController == null) throw new ArgumentNullException("initParams.EngineController"); if (string.IsNullOrEmpty(initParams.VariableName)) throw new ArgumentNullException("initParams.VariableName"); variableName = initParams.VariableName; engineController = initParams.EngineController; }
/// <summary> /// This method is called by task creator to associate the trace data with /// the current instance of virtual machine. The given WorkspaceModel can /// optionally contain saved trace data in a previous execution session. As /// a side-effect, this method resets "WorkspaceModel.PreloadedTraceData" /// data member to ensure the correctness of the execution flow. /// </summary> /// <param name="controller">Reference to the EngineController on which the /// loaded trace data should be set.</param> /// <param name="workspace">The workspace from which the trace data should /// be retrieved.</param> /// <returns>If the given WorkspaceModel contains saved trace data, this /// method returns true, in which case the task needs to be scheduled. /// Otherwise, the method returns false.</returns> /// internal bool Initialize(EngineController controller, WorkspaceModel workspace) { if (controller == null || (controller.LiveRunnerCore == null)) return false; engineController = controller; traceData = workspace.PreloadedTraceData; TargetedWorkspace = workspace; workspace.PreloadedTraceData = null; return ((traceData != null) && traceData.Any()); }
public void CancelAsync(EngineController engineController) { if (Running) { cancelSet = true; engineController.LiveRunnerCore.RequestCancellation(); // We need to wait for evaluation thread to complete after a cancellation // until the LR and Engine controller are reset properly if (evaluationThread != null) evaluationThread.Join(); } }
/// <summary> /// Call this method to intialize a CompileCustomNodeAsyncTask with an /// EngineController, nodes from the corresponding CustomNodeWorkspaceModel, /// and inputs/outputs of the CustomNodeDefinition. /// </summary> /// <param name="initParams">Input parameters required for compilation of /// the CustomNodeDefinition.</param> /// <returns>Returns true if GraphSyncData is generated successfully and /// that the CompileCustomNodeAsyncTask should be scheduled for execution. /// Returns false otherwise.</returns> /// internal bool Initialize(CompileCustomNodeParams initParams) { engineController = initParams.EngineController; try { graphSyncData = engineController.ComputeSyncData(initParams); return graphSyncData != null; } catch (Exception) { return false; } }
/// <summary> /// This method is called by codes that intent to start a graph update. /// This method is called on the main thread where node collection in a /// WorkspaceModel can be safely accessed. /// </summary> /// <param name="controller">Reference to an instance of EngineController /// to assist in generating GraphSyncData object for the given set of nodes. /// </param> /// <param name="workspace">Reference to the WorkspaceModel from which a /// set of updated nodes is computed. The EngineController generates the /// resulting GraphSyncData from this list of updated nodes.</param> /// <param name="dynamoLogger"> Logs the error message</param> /// <returns>Returns the list of node id's that will be executed in the next run /// for execution).</returns> internal List<Guid> Initialize(EngineController controller, WorkspaceModel workspace) { try { engineController = controller; TargetedWorkspace = workspace; modifiedNodes = ComputeModifiedNodes(workspace); previewGraphData = engineController.PreviewGraphSyncData(modifiedNodes,verboseLogging); return previewGraphData; } catch (Exception e) { return null; } }
/// <summary> /// This method is called by codes that intent to start a graph update. /// This method is called on the main thread where node collection in a /// WorkspaceModel can be safely accessed. /// </summary> /// <param name="controller">Reference to an instance of EngineController /// to assist in generating GraphSyncData object for the given set of nodes. /// </param> /// <param name="workspace">Reference to the WorkspaceModel from which a /// set of updated nodes is computed. The EngineController generates the /// resulting GraphSyncData from this list of updated nodes.</param> /// <returns>Returns true if there is any GraphSyncData, or false otherwise /// (in which case there will be no need to schedule UpdateGraphAsyncTask /// for execution).</returns> /// internal bool Initialize(EngineController controller, WorkspaceModel workspace) { try { engineController = controller; TargetedWorkspace = workspace; modifiedNodes = ComputeModifiedNodes(workspace); graphSyncData = engineController.ComputeSyncData(modifiedNodes); return graphSyncData != null; } catch (Exception) { return false; } }
/// <summary> /// This method is called by code that intends to start a graph update. /// This method is called on the main thread where node collection in a /// WorkspaceModel can be safely accessed. /// </summary> /// <param name="controller">Reference to an instance of EngineController /// to assist in generating GraphSyncData object for the given set of nodes. /// </param> /// <param name="workspace">Reference to the WorkspaceModel from which a /// set of updated nodes is computed. The EngineController generates the /// resulting GraphSyncData from this list of updated nodes.</param> /// <returns>Returns true if there is any GraphSyncData, or false otherwise /// (in which case there will be no need to schedule UpdateGraphAsyncTask /// for execution).</returns> /// internal bool Initialize(EngineController controller, WorkspaceModel workspace) { try { engineController = controller; TargetedWorkspace = workspace; ModifiedNodes = ComputeModifiedNodes(workspace); graphSyncData = engineController.ComputeSyncData(workspace.Nodes, ModifiedNodes, verboseLogging); return graphSyncData != null; } catch (Exception e) { System.Diagnostics.Debug.WriteLine("UpgradeGraphAsyncTask saw: " + e.ToString()); return false; } }
public static List<IGraphicItem> GeneratedGraphicItems(this NodeModel node, EngineController engineController) { var ids = node.GetAllOutportAstIdentifiers(); var results = new List<IGraphicItem>(); foreach (var id in ids) { var mirror = engineController.GetMirror(id); if (mirror == null) continue; var mirrorData = mirror.GetData(); if (mirrorData == null) continue; GetGraphicItemsFromMirrorData(mirrorData, results); } return results; }
/// <summary> /// Call this method to intialize a CompileCustomNodeAsyncTask with an /// EngineController and an GraphSyncData that is required to compile the /// associated custom node. /// </summary> /// <param name="initParams">Input parameters required for custom node /// graph updates.</param> /// <returns>Returns true if GraphSyncData is not empty and that the /// CompileCustomNodeAsyncTask should be scheduled for execution. Returns /// false otherwise.</returns> /// internal bool Initialize(CompileCustomNodeParams initParams) { if (initParams == null) throw new ArgumentNullException("initParams"); engineController = initParams.EngineController; graphSyncData = initParams.SyncData; if (engineController == null) throw new ArgumentNullException("engineController"); if (graphSyncData == null) throw new ArgumentNullException("graphSyncData"); var added = graphSyncData.AddedSubtrees; var deleted = graphSyncData.DeletedSubtrees; var modified = graphSyncData.ModifiedSubtrees; // Returns true if there is any actual data. return ((added != null && added.Count > 0) || (modified != null && modified.Count > 0) || (deleted != null && deleted.Count > 0)); }
/// <summary> /// Call this method to reset the virtual machine, avoiding a race /// condition by using a thread join inside the vm executive. /// TODO(Luke): Push this into a resync call with the engine controller /// </summary> /// <param name="controller"></param> /// <param name="markNodesAsDirty">Set this parameter to true to force /// reset of the execution substrait. Note that setting this parameter /// to true will have a negative performance impact.</param> public void ResetEngine(EngineController controller, bool markNodesAsDirty = false) { if (EngineController != null) { EngineController.MessageLogged -= Log; EngineController.LibraryServices.LibraryLoaded -= LibraryLoaded; } EngineController = controller; controller.MessageLogged += Log; controller.LibraryServices.LibraryLoaded += LibraryLoaded; if (markNodesAsDirty) { // Mark all nodes as dirty so that AST for the whole graph will be // regenerated. MarkNodesAsModifiedAndRequestRun(Nodes); } if (RunSettings.RunType == RunType.Automatic) Run(); }
public HomeWorkspaceModel( EngineController engine, DynamoScheduler scheduler, NodeFactory factory, IEnumerable<KeyValuePair<Guid, List<string>>> traceData, IEnumerable<NodeModel> e, IEnumerable<NoteModel> n, IEnumerable<AnnotationModel> a, IEnumerable<PresetModel> presets, ElementResolver resolver, WorkspaceInfo info, bool verboseLogging, bool isTestMode) : base(e, n,a, info, factory,presets, resolver) { EvaluationCount = 0; // This protects the user from a file that might have crashed during // its last run. As a side effect, this also causes all files set to // run auto but lacking the HasRunWithoutCrash flag to run manually. if (info.RunType == RunType.Automatic && !info.HasRunWithoutCrash) { info.RunType = RunType.Manual; } RunSettings = new RunSettings(info.RunType, info.RunPeriod); PreloadedTraceData = traceData; this.scheduler = scheduler; this.verboseLogging = verboseLogging; IsTestMode = isTestMode; EngineController = engine; // The first time the preloaded trace data is set, we cache // the data as historical. This will be used after the initial // run of this workspace, when the PreloadedTraceData has been // nulled, to check for node deletions and reconcile the trace data. // We do a deep copy of this data because the PreloadedTraceData is // later set to null before the graph update. var copiedData = new List<KeyValuePair<Guid, List<string>>>(); foreach (var kvp in PreloadedTraceData) { var strings = kvp.Value.Select(string.Copy).ToList(); copiedData.Add(new KeyValuePair<Guid, List<string>>(kvp.Key, strings)); } historicalTraceData = copiedData; }
public HomeWorkspaceModel(EngineController engine, DynamoScheduler scheduler, NodeFactory factory, bool verboseLogging, bool isTestMode, string fileName="") : this( engine, scheduler, factory, Enumerable.Empty<KeyValuePair<Guid, List<string>>>(), Enumerable.Empty<NodeModel>(), Enumerable.Empty<NoteModel>(), Enumerable.Empty<AnnotationModel>(), Enumerable.Empty<PresetModel>(), new ElementResolver(), new WorkspaceInfo(){FileName = fileName, Name = "Home"}, verboseLogging, isTestMode) { }
protected void ResetEngineInternal() { if (EngineController != null) { EngineController.TraceReconcliationComplete -= EngineController_TraceReconcliationComplete; EngineController.MessageLogged -= LogMessage; EngineController.Dispose(); EngineController = null; } EngineController = new EngineController( LibraryServices, geometryFactoryPath, DebugSettings.VerboseLogging); EngineController.MessageLogged += LogMessage; EngineController.TraceReconcliationComplete += EngineController_TraceReconcliationComplete; foreach (var def in CustomNodeManager.LoadedDefinitions) RegisterCustomNodeDefinitionWithEngine(def); }
/// <summary> /// Call this method to asynchronously regenerate render package for /// this node. This method accesses core properties of a NodeModel and /// therefore is typically called on the main/UI thread. /// </summary> /// <param name="engine"></param> /// <param name="scheduler"></param> /// <param name="maxTessellationDivisions">The maximum number of /// tessellation divisions to use for regenerating render packages.</param> public void RequestVisualUpdateAsync(IScheduler scheduler, EngineController engine, IRenderPackageFactory factory) { //if (Workspace.DynamoModel == null) // return; // Imagine a scenario where "NodeModel.RequestVisualUpdateAsync" is being // called in quick succession from the UI thread -- the first task may // be updating '_renderPackages' when the second call gets here. In // this case '_renderPackages' should be protected against concurrent // accesses. // lock (RenderPackagesMutex) { renderPackages.Clear(); HasRenderPackages = false; } RequestVisualUpdateAsyncCore(scheduler, engine, factory); }
public ZeroTouchNodeController( EngineController engineController, FunctionDescriptor zeroTouchDef) : base(zeroTouchDef) { this.engineController = engineController; }
internal void ConvertNodesToCodeInternal(EngineController engineController) { var selectedNodes = DynamoSelection.Instance .Selection .OfType<NodeModel>() .Where(n => n.IsConvertible); if (!selectedNodes.Any()) return; var cliques = NodeToCodeUtils.GetCliques(selectedNodes).Where(c => !(c.Count == 1 && c.First() is CodeBlockNodeModel)); var codeBlockNodes = new List<CodeBlockNodeModel>(); //UndoRedo Action Group---------------------------------------------- NodeToCodeUndoHelper undoHelper = new NodeToCodeUndoHelper(); // using (UndoRecorder.BeginActionGroup()) { foreach (var nodeList in cliques) { //Create two dictionarys to store the details of the external connections that have to //be recreated after the conversion var externalInputConnections = new Dictionary<ConnectorModel, string>(); var externalOutputConnections = new Dictionary<ConnectorModel, string>(); //Also collect the average X and Y co-ordinates of the different nodes int nodeCount = nodeList.Count; var nodeToCodeResult = engineController.ConvertNodesToCode(this.nodes, nodeList); #region Step I. Delete all nodes and their connections double totalX = 0, totalY = 0; foreach (var node in nodeList) { #region Step I.A. Delete the connections for the node foreach (var connector in node.AllConnectors.ToList()) { if (!IsInternalNodeToCodeConnection(nodeList, connector)) { //If the connector is an external connector, the save its details //for recreation later var startNode = connector.Start.Owner; int index = startNode.OutPorts.IndexOf(connector.Start); //We use the varibleName as the connection between the port of the old Node //to the port of the new node. var variableName = startNode.GetAstIdentifierForOutputIndex(index).Value; //Store the data in the corresponding dictionary if (startNode == node) { if (nodeToCodeResult.OutputMap.ContainsKey(variableName)) variableName = nodeToCodeResult.OutputMap[variableName]; externalOutputConnections.Add(connector, variableName); } else { if (nodeToCodeResult.InputMap.ContainsKey(variableName)) variableName = nodeToCodeResult.InputMap[variableName]; externalInputConnections.Add(connector, variableName); } } //Delete the connector undoHelper.RecordDeletion(connector); connector.Delete(); } #endregion #region Step I.B. Delete the node totalX += node.X; totalY += node.Y; undoHelper.RecordDeletion(node); Nodes.Remove(node); #endregion } #endregion #region Step II. Create the new code block node var outputVariables = externalOutputConnections.Values; var newResult = NodeToCodeUtils.ConstantPropagationForTemp(nodeToCodeResult, outputVariables); NodeToCodeUtils.ReplaceWithUnqualifiedName(engineController.LibraryServices.LibraryManagementCore, newResult.AstNodes); var codegen = new ProtoCore.CodeGenDS(newResult.AstNodes); var code = codegen.GenerateCode(); var codeBlockNode = new CodeBlockNodeModel( code, System.Guid.NewGuid(), totalX / nodeCount, totalY / nodeCount, engineController.LibraryServices); undoHelper.RecordCreation(codeBlockNode); Nodes.Add(codeBlockNode); this.RegisterNode(codeBlockNode); codeBlockNodes.Add(codeBlockNode); #endregion #region Step III. Recreate the necessary connections var newInputConnectors = ReConnectInputConnections(externalInputConnections, codeBlockNode); foreach (var connector in newInputConnectors) { undoHelper.RecordCreation(connector); } var newOutputConnectors = ReConnectOutputConnections(externalOutputConnections, codeBlockNode); foreach (var connector in newOutputConnectors) { undoHelper.RecordCreation(connector); } #endregion } } undoHelper.ApplyActions(UndoRecorder); DynamoSelection.Instance.ClearSelection(); DynamoSelection.Instance.Selection.AddRange(codeBlockNodes); RequestRun(); }
public virtual void ResetEngine() { if (EngineController != null) { EngineController.Dispose(); EngineController = null; } EngineController = new EngineController(this); CustomNodeManager.RecompileAllNodes(EngineController); }
ShutDown(bool shutDownHost, EventArgs args = null) { EngineController.Dispose(); EngineController = null; PreferenceSettings.Save(); dynSettings.Controller.DynamoModel.OnCleanup(args); dynSettings.Controller = null; ((DynamoLogger)dynSettings.DynamoLogger).Dispose(); }
/// <summary> /// Class constructor /// </summary> public DynamoController(string context, IUpdateManager updateManager, IWatchHandler watchHandler, IPreferences preferences, string corePath) { DebugSettings = new DebugSettings(); IsCrashing = false; dynSettings.Controller = this; Context = context; PreferenceSettings = preferences; ((PreferenceSettings) PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged; SIUnit.LengthUnit = PreferenceSettings.LengthUnit; SIUnit.AreaUnit = PreferenceSettings.AreaUnit; SIUnit.VolumeUnit = PreferenceSettings.VolumeUnit; SIUnit.NumberFormat = PreferenceSettings.NumberFormat; UpdateManager = updateManager; UpdateManager.CheckForProductUpdate(new UpdateRequest(new Uri(Configurations.UpdateDownloadLocation),dynSettings.DynamoLogger, UpdateManager.UpdateDataAvailable)); WatchHandler = watchHandler; //Start heartbeat reporting //This needs to be done after the update manager has been initialised //so that the version number can be reported InstrumentationLogger.Start(); //create the model DynamoModel = new DynamoModel (); DynamoModel.AddHomeWorkspace(); SearchViewModel = new SearchViewModel(DynamoModel); DynamoModel.CurrentWorkspace = DynamoModel.HomeSpace; DynamoModel.CurrentWorkspace.X = 0; DynamoModel.CurrentWorkspace.Y = 0; // custom node loader CustomNodeManager = new CustomNodeManager(DynamoPathManager.Instance.UserDefinitions); dynSettings.PackageLoader = new PackageLoader(); dynSettings.PackageLoader.DoCachedPackageUninstalls(); dynSettings.PackageLoader.LoadPackages(); DisposeLogic.IsShuttingDown = false; EngineController = new EngineController(this); CustomNodeManager.RecompileAllNodes(EngineController); //This is necessary to avoid a race condition by causing a thread join //inside the vm exec //TODO(Luke): Push this into a resync call with the engine controller ResetEngine(); dynSettings.DynamoLogger.Log(String.Format( "Dynamo -- Build {0}", Assembly.GetExecutingAssembly().GetName().Version)); DynamoLoader.ClearCachedAssemblies(); DynamoLoader.LoadNodeModels(); MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations)); Runner = new DynamoRunner(); }
/// <summary> /// Gets the most recent value of this node stored in an EngineController that has evaluated it. /// </summary> /// <param name="outPortIndex"></param> /// <param name="engine"></param> /// <returns></returns> public MirrorData GetValue(int outPortIndex, EngineController engine) { return engine.GetMirror(GetAstIdentifierForOutputIndex(outPortIndex).Value).GetData(); }
/// <summary> /// WARNING: This method is meant for unit test only. It directly accesses /// the EngineController for the mirror data without waiting for any /// possible execution to complete (which, in single-threaded nature of /// unit test, is an okay thing to do). The right way to get the cached /// value for a NodeModel is by going through its RequestValueUpdateAsync /// method). /// </summary> /// <param name="engine">Instance of EngineController from which the node /// value is to be retrieved.</param> /// <returns>Returns the MirrorData if the node's value is computed, or /// null otherwise.</returns> /// internal MirrorData GetCachedValueFromEngine(EngineController engine) { if (cachedMirrorData != null) return cachedMirrorData; // Do not have an identifier for preview right now. For an example, // this can be happening at the beginning of a code block node creation. if (AstIdentifierForPreview.Value == null) return null; cachedMirrorData = null; var runtimeMirror = engine.GetMirror(AstIdentifierForPreview.Value); if (runtimeMirror != null) cachedMirrorData = runtimeMirror.GetData(); return cachedMirrorData; }
RequestVisualUpdateAsyncCore(IScheduler scheduler, EngineController engine, IRenderPackageFactory factory) { var initParams = new UpdateRenderPackageParams() { Node = this, RenderPackageFactory = factory, EngineController = engine, DrawableIds = GetDrawableIds(), PreviewIdentifierName = AstIdentifierForPreview.Name }; var task = new UpdateRenderPackageAsyncTask(scheduler); if (task.Initialize(initParams)) { task.Completed += OnRenderPackageUpdateCompleted; scheduler.ScheduleForExecution(task); } }
/// <summary> /// Compiles this custom node definition, updating all UI instances to match /// inputs and outputs and registering new definition with the EngineController. /// </summary> public void Compile(DynamoModel dynamoModel, EngineController controller) { // If we are loading dyf file, dont compile it until all nodes are loaded // otherwise some intermediate function defintions will be created. // TODO: This is a hack, in reality we should be preventing this from being called at the Workspace.RequestSync() level --SJE if (IsBeingLoaded || IsProxy) return; #region Outputs and Inputs and UI updating #region Find outputs // Find output elements for the node List<Output> outputs = WorkspaceModel.Nodes.OfType<Output>().ToList(); var topMost = new List<Tuple<int, NodeModel>>(); List<string> outNames; // if we found output nodes, add select their inputs // these will serve as the function output if (outputs.Any()) { topMost.AddRange( outputs.Where(x => x.HasInput(0)).Select(x => Tuple.Create(0, x as NodeModel))); outNames = outputs.Select(x => x.Symbol).ToList(); } else { outNames = new List<string>(); // if there are no explicitly defined output nodes // get the top most nodes and set THEM as the output IEnumerable<NodeModel> topMostNodes = WorkspaceModel.GetTopMostNodes(); var rtnPorts = //Grab multiple returns from each node topMostNodes.SelectMany( topNode => //If the node is a recursive instance... topNode is Function && (topNode as Function).Definition == this // infinity output ? new[] { new { portIndex = 0, node = topNode, name = "∞" } } // otherwise, grab all ports with connected outputs and package necessary info : topNode.OutPortData .Select( (port, i) => new { portIndex = i, node = topNode, name = port.NickName }) .Where(x => !topNode.HasOutput(x.portIndex))); foreach (var rtnAndIndex in rtnPorts.Select((rtn, i) => new { rtn, idx = i })) { topMost.Add(Tuple.Create(rtnAndIndex.rtn.portIndex, rtnAndIndex.rtn.node)); outNames.Add(rtnAndIndex.rtn.name ?? rtnAndIndex.idx.ToString()); } } var nameDict = new Dictionary<string, int>(); foreach (var name in outNames) { if (nameDict.ContainsKey(name)) nameDict[name]++; else nameDict[name] = 0; } nameDict = nameDict.Where(x => x.Value != 0).ToDictionary(x => x.Key, x => x.Value); outNames.Reverse(); var keys = new List<string>(); foreach (var name in outNames) { int amt; if (nameDict.TryGetValue(name, out amt)) { nameDict[name] = amt - 1; keys.Add(name == "" ? amt + ">" : name + amt); } else keys.Add(name); } keys.Reverse(); ReturnKeys = keys; #endregion //Find function entry point, and then compile var inputNodes = WorkspaceModel.Nodes.OfType<Symbol>().ToList(); var parameters = inputNodes.Select(x => x.GetAstIdentifierForOutputIndex(0).Value); Parameters = inputNodes.Select(x => x.InputSymbol); //Update existing function nodes which point to this function to match its changes var customNodeInstances = dynamoModel.AllNodes .OfType<Function>() .Where(el => el.Definition != null && el.Definition == this); foreach (var node in customNodeInstances) node.ResyncWithDefinition(); //Call OnSave for all saved elements foreach (var node in WorkspaceModel.Nodes) node.OnSave(); #endregion var outputNodes = topMost.Select((x) => { var n = x.Item2.GetAstIdentifierForOutputIndex(x.Item1); return n as AssociativeNode; }); controller.GenerateGraphSyncDataForCustomNode( this, WorkspaceModel.Nodes.Where(x => !(x is Symbol)), outputNodes, parameters); // Not update graph until Run // if (success) // controller.UpdateGraph(); }
public LiveRunnerServices(EngineController controller, string geometryFactoryFileName) { liveRunner = LiveRunnerFactory.CreateLiveRunner(controller, geometryFactoryFileName); }
/// <summary> /// Recompile all custom nodes /// </summary> public void RecompileAllNodes(EngineController engine) { HashSet<Guid> compiledNodes = new HashSet<Guid>(); foreach (var idDefPair in LoadedCustomNodes) { if (!compiledNodes.Contains(idDefPair.Key)) { idDefPair.Value.Compile(engine); compiledNodes.Add(idDefPair.Key); } } }
public LiveRunnerServices(DynamoModel dynamoModel, EngineController controller, string geometryFactoryFileName) { this.dynamoModel = dynamoModel; liveRunner = LiveRunnerFactory.CreateLiveRunner(controller, geometryFactoryFileName); }
protected override void RequestVisualUpdateAsyncCore( IScheduler scheduler, EngineController engine, IRenderPackageFactory factory) { // Do nothing }
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer) { bool pass = false; var valueMap = new Dictionary<Guid, String>(); if (node.OutPorts.Count > 0) { var firstNodeConnectors = node.AllConnectors.ToList(); //Get node connectors foreach (ConnectorModel connector in firstNodeConnectors) { Guid guid = connector.Start.Owner.GUID; if (!valueMap.ContainsKey(guid)) { Object data = connector.Start.Owner.GetValue(0, engine).Data; String val = data != null ? data.ToString() : "null"; valueMap.Add(guid, val); writer.WriteLine(guid + " :: " + val); writer.Flush(); } } } int numberOfUndosNeeded = Mutate(node); Thread.Sleep(100); writer.WriteLine("### - Beginning undo"); for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++) { DynamoViewModel.UIDispatcher.Invoke(new Action(() => { DynamoModel.UndoRedoCommand undoCommand = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo); DynamoViewModel.ExecuteCommand(undoCommand); })); Thread.Sleep(100); } writer.WriteLine("### - undo complete"); writer.Flush(); DynamoViewModel.UIDispatcher.Invoke(new Action(() => { DynamoModel.RunCancelCommand runCancel = new DynamoModel.RunCancelCommand(false, false); DynamoViewModel.ExecuteCommand(runCancel); })); while (!DynamoViewModel.HomeSpace.RunSettings.RunEnabled) { Thread.Sleep(10); } writer.WriteLine("### - Beginning test of NumberSequence"); if (node.OutPorts.Count > 0) { try { var firstNodeConnectors = node.AllConnectors.ToList(); foreach (ConnectorModel connector in firstNodeConnectors) { String valmap = valueMap[connector.Start.Owner.GUID].ToString(); Object data = connector.Start.Owner.GetValue(0, engine).Data; String nodeVal = data != null ? data.ToString() : "null"; if (valmap != nodeVal) { writer.WriteLine("!!!!!!!!!!! - test of NumberSequence is failed"); writer.WriteLine(node.GUID); writer.WriteLine("Was: " + nodeVal); writer.WriteLine("Should have been: " + valmap); writer.Flush(); return pass; } } } catch (Exception) { writer.WriteLine("!!!!!!!!!!! - test of NumberSequence is failed"); writer.Flush(); return pass; } } writer.WriteLine("### - test of NumberSequence complete"); writer.Flush(); return pass = true; }
internal static ILiveRunner CreateLiveRunner(EngineController controller, string geometryFactoryFileName) { LiveRunner.Configuration configuration = new LiveRunner.Configuration(); configuration.PassThroughConfiguration.Add(Autodesk.DesignScript.Interfaces.ConfigurationKeys.GeometryFactory, geometryFactoryFileName); return(new LiveRunner(configuration)); }
/// <summary> /// Recompile all custom nodes /// </summary> public void RecompileAllNodes(EngineController engine) { var compiledNodes = new HashSet<Guid>(); foreach ( var idDefPair in LoadedCustomNodes.Where(idDefPair => !compiledNodes.Contains(idDefPair.Key))) { idDefPair.Value.Compile(this.dynamoModel, engine); compiledNodes.Add(idDefPair.Key); } }
internal static ILiveRunner CreateLiveRunner(EngineController controller) { LiveRunner.Options option = new LiveRunner.Options(); return(new LiveRunner(option)); }
internal static ILiveRunner CreateLiveRunner(EngineController controller) { LiveRunner.Options option = new LiveRunner.Options(); return new LiveRunner(option); }
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer) { bool pass = false; var valueMap = new Dictionary<Guid, String>(); if (node.OutPorts.Count > 0) { Guid guid = node.GUID; Object data = node.GetValue(0, engine).Data; String val = data != null ? data.ToString() : "null"; valueMap.Add(guid, val); writer.WriteLine(guid + " :: " + val); writer.Flush(); } int numberOfUndosNeeded = Mutate(node); Thread.Sleep(100); writer.WriteLine("### - Beginning undo"); for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++) { DynamoViewModel.UIDispatcher.Invoke(new Action(() => { DynamoModel.UndoRedoCommand undoCommand = new DynamoModel.UndoRedoCommand( DynamoModel.UndoRedoCommand.Operation.Undo); DynamoViewModel.ExecuteCommand(undoCommand); })); } Thread.Sleep(100); writer.WriteLine("### - undo complete"); writer.Flush(); writer.WriteLine("### - Beginning re-exec"); DynamoViewModel.UIDispatcher.Invoke(new Action(() => { DynamoModel.RunCancelCommand runCancel = new DynamoModel.RunCancelCommand(false, false); DynamoViewModel.ExecuteCommand(runCancel); })); Thread.Sleep(10); while (!DynamoViewModel.HomeSpace.RunSettings.RunEnabled) { Thread.Sleep(10); } writer.WriteLine("### - re-exec complete"); writer.Flush(); writer.WriteLine("### - Beginning readback"); writer.WriteLine("### - Beginning test of DirectoryPath"); if (node.OutPorts.Count > 0) { try { string valmap = valueMap[node.GUID].ToString(); object data = node.GetValue(0, engine).Data; string nodeVal = data != null ? data.ToString() : "null"; if (valmap != nodeVal) { writer.WriteLine("!!!!!!!!!!! - test of DirectoryPath is failed"); writer.WriteLine(node.GUID); writer.WriteLine("Was: " + nodeVal); writer.WriteLine("Should have been: " + valmap); writer.Flush(); return pass; } } catch (Exception) { writer.WriteLine("!!!!!!!!!!! - test of DirectoryPath is failed"); writer.Flush(); return pass; } } writer.WriteLine("### - test of DirectoryPath complete"); writer.Flush(); return pass = true; }