Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using ProtoCore.AST.AssociativeAST;
using NodeModelsEssentials.Functions;
using System.Linq;
using Newtonsoft.Json;
namespace NodeModelsEssentials
// <summary>
// Sample Node Model called MultiplyMulti.
// It returns the product of two numbers and a verbose string.
// </summary>
[NodeDescription("Sleeps for a bit and throws an error if the sleeping times out. Determine the maximum duration a node can run for (and time out if it surpasses it).")]
[InPortNames("Sleep", "Timeout")]
[InPortTypes("int", "int")]
[InPortDescriptions("Sleep duration.", "Timeout duration")]
[OutPortDescriptions("Resulting string.")]
public class Timeout : NodeModel
private Timeout(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
public Timeout()
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAsNodes)
if (!InPorts[0].Connectors.Any() || !InPorts[1].Connectors.Any())
return new[] {
AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode())
var timeoutFunctionNode =
new Func<int, int, string>(NodeModelsEssentialsFunctions.Timeout),
new List<AssociativeNode> { inputAsNodes[0], inputAsNodes[1] });
return new[] {
AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), timeoutFunctionNode)