public ScriptGatewayNodeEntity(ScriptGatewayNodeData gatewayData, INodeGraph graph) : base(gatewayData, graph) { connectionPoints = new List <ConnectionPoint>(); ConnectionPointDirection direction; if (gatewayData.serializedNode.data.gatewayType == GatewayType.Entrance) { isInputNode = true; direction = ConnectionPointDirection.Out; nodeName = "Event Start"; } else { isInputNode = false; direction = ConnectionPointDirection.In; nodeName = "Event End"; } for (int i = 0; i < gatewayData.connections.Count; ++i) { var connection = gatewayData.connections[i]; connectionPoints.Add(new ConnectionPoint(this, direction, connection)); } }
public static bool TryConnectCom <OUT, IN>(INodeGraph bp, NodeBase begin, NodeBase end) where OUT : INodeOutput where IN : INodeInput { OUT OutCom = null; IN InCom = null; foreach (var pair in begin.m_ComManager.m_RightComponents) { if (pair.Value is OUT) { OutCom = (OUT)pair.Value; } } foreach (var pair in end.m_ComManager.m_LeftComponents) { if (pair.Value is IN) { InCom = (IN)pair.Value; } } if (OutCom != null && InCom != null) { bp.ngLinkManager.TryCreateLink(OutCom.ID, InCom.ID); return(bp.ngLinkManager.IsConnect(OutCom.ID, InCom.ID)); } else { return(false); } }
void Bind(INodeGraph nodeGraph) { if (!string.IsNullOrWhiteSpace(ContentFile)) { // TODO: Load the file } }
public VarGetter(INodeGraph bp, IVar variable) : base(bp) { Assert.IsNotNull(variable); m_Var = variable; AddBaseComponet(); }
public MethodEntryNode(INodeGraph bp) : base(bp) { AddComponet(m_TextTitleBar); AddComponet(m_ExecOC); Style.AddStyle(StyleManager.StyleType.TitleBar, m_TitleBarColor); //Style.AddStyle(ColorStyle.Pin, m_PinColor); }
public override void Bind(INodeGraph nodeGraph) { _nextNode = nodeGraph.NodeByName(OutputNode); _logLevelsMessage = LogTypes == null || LogTypes.Length == 0 ? "all log types" : string.Join(", ", LogTypes); }
public override void Bind(INodeGraph nodeGraph) { OutputNodes = Outputs.Select(name => new NodeOutput { Name = name, Node = nodeGraph.NodeByName(name), }).ToArray(); }
public OperationNoExecNode(INodeGraph bp) : base(bp) { m_ObjectIC_Left.Text = "Left".PadRight(8); m_ObjectOC.Text = "Result"; m_ObjectIC_Right.Text = "Right".PadRight(8); Style.AddStyle(StyleManager.StyleType.TitleBar, m_TitleBarColor); }
public EventBranchObjectData(ScenimaticSerializedNode branchData, INodeGraph graph) : base(graph) { this.serializedNode = branchData; GUID = branchData.GUID; inputConnections = branchData.data.connectionInputs; outputConnections = branchData.data.connectionOutputs; nodeStyle = ScenimaticScriptEditor.branchWindowStyle; windowRect = new Rect(branchData.position, nodeStyle.size); }
public ScriptGatewayNodeData(INodeGraph graph, GatewaySerializedNode serializedData) : base(graph) { serializedNode = serializedData; GUID = serializedData.GUID; connections = serializedData.data.connections; nodeStyle = new GraphEntityStyle(); nodeStyle.Init(new Vector2(250, 50), Color.cyan, Color.blue, Color.blue, Color.white); windowRect = new Rect(serializedData.position, nodeStyle.size); }
public WhileLoopNode(INodeGraph bp) : base(bp) { m_TextTitleBar.Title = "While Loop"; m_ExecOC_LoopBody.Text = "Loop Body".PadLeft(21); m_ExecOC_Completed.Text = "Completed"; m_Condition.Text = "Condition"; AddComponet(m_ExecOC_LoopBody); AddComponet(m_Condition); AddComponet(m_ExecOC_Completed); }
public BranchNode(INodeGraph bp) : base(bp) { m_TextTitleBar.Title = "Branch"; m_ExecOC_True.Text = "True".PadLeft(20); m_ExecOC_False.Text = "False".PadLeft(8); m_Condition.Text = "Condition"; AddComponet(m_ExecOC_True); AddComponet(m_Condition); AddComponet(m_ExecOC_False); }
public FlipFlopNode(INodeGraph bp) : base(bp) { m_TextTitleBar.Title = "Flip Flop"; m_ExecOC_A.Text = "A".PadLeft(9); m_ExecOC_B.Text = "B".PadLeft(10); m_IsA_OC.Text = "Is A".PadLeft(10); AddComponet(m_ExecOC_A); AddComponet(m_ExecOC_B); AddComponet(m_IsA_OC); }
public GraphEntity(GraphEntityData data, INodeGraph graph) { nodeGraph = graph; entityData = data; nodeStyle = entityData.nodeStyle; currentStyle = nodeStyle.defaultStyle; titleBarStyle = nodeStyle.defaultLabelStyle; defaultBGColor = nodeStyle.defaultBGColor; selectedBGColor = nodeStyle.selectedBGColor; }
public override void Bind(INodeGraph nodeGraph) { _nextNode = nodeGraph.NodeByName(OutputNode); // This is the only supported content type in this version ContentType = "text/plain"; _fileWriter = new LogFileWriter( new DirectoryInfo(Directory), FileNamePrefix, MaximumLogFileAge, MaximumLogFileSize, true); }
public override void Bind(INodeGraph nodeGraph) { _nextNode = nodeGraph.NodeByName(OutputNode); if (!string.IsNullOrEmpty(RequestScript)) { using (var stream = new MemoryStream()) { var writer = new StreamWriter(stream); writer.Write(RequestScript); writer.Flush(); stream.Position = 0; ParseRequestStream(stream, writer.Encoding); } } else if (!string.IsNullOrEmpty(RequestScriptFile)) { var filePath = _hostingEnvironment.MapPath(RequestScriptFile); using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { ParseRequestStream(stream, Encoding.UTF8); } } if (!string.IsNullOrEmpty(ResponseScript)) { using (var stream = new MemoryStream()) { var writer = new StreamWriter(stream); writer.Write(ResponseScript); writer.Flush(); stream.Position = 0; ParseResponseStream(stream, writer.Encoding); } } else if (!string.IsNullOrEmpty(ResponseScriptFile)) { var filePath = _hostingEnvironment.MapPath(ResponseScriptFile); using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { ParseResponseStream(stream, Encoding.UTF8); } } }
public NodeWindow(NodeObjectData <T> nodeData, INodeGraph graph) : base(nodeData, graph) { this.nodeData = nodeData; inConnectionPoints = new List <ConnectionPoint>(); outConnectionPoints = new List <ConnectionPoint>(); foreach (var connection in nodeData.inputConnections) { inConnectionPoints.Add(new ConnectionPoint(this, ConnectionPointDirection.In, connection)); } foreach (var connection in nodeData.outputConnections) { outConnectionPoints.Add(new ConnectionPoint(this, ConnectionPointDirection.Out, connection)); } }
public override void Bind(INodeGraph nodeGraph) { _outputRule = new GroupRule[Outputs.Length]; OutputNodes = new NodeOutput[Outputs.Length]; for (var i = 0; i < Outputs.Length; i++) { var outputConfiguration = Outputs[i]; OutputNodes[i] = new NodeOutput { Name = outputConfiguration.RouteTo, Node = nodeGraph.NodeByName(outputConfiguration.RouteTo), }; _outputRule[i] = new GroupRule(outputConfiguration, _expressionParser); } }
protected override int GetProperty() { int result = 0; INodeGraph graph = base.Graph; BufferInfo bufferInfo = graph?.GetVariable <BufferInfo>("BufferInfo"); if (bufferInfo != null) { Data.Faction faction = bufferInfo.Unit.faction; foreach (WuxiaUnit unit in bufferInfo.Manager.UnitGenerator.WuxiaUnits) { if (!unit.IsDead && !unit.IsEnemy(faction)) { result++; } } } return(result); }
public DiagramGenerator( IConfiguration configuration, IRequestListener requestListener, INodeGraph nodeGraph) { _requestListener = requestListener; _nodeGraph = nodeGraph; _dashboardConfig = configuration.Register( "/gravity/ui/dashboards", c => { foreach (var dashboardConfiguration in c) { dashboardConfiguration.Sanitize(); } _dashboardConfigurations = c; }, new [] { new DashboardConfiguration() }); }
protected override int GetProperty() { INodeGraph graph = base.Graph; BufferInfo bufferInfo = graph?.GetVariable <BufferInfo>("BufferInfo"); if (bufferInfo != null) { if (Game.GameData.Character.ContainsKey(bufferInfo.Unit.CharacterInfoId)) { if (Game.GameData.Character[bufferInfo.Unit.CharacterInfoId].Skill.ContainsKey(this.SkillId)) { return(Game.GameData.Character[bufferInfo.Unit.CharacterInfoId].Skill[this.SkillId].Level); } } else if (bufferInfo.Unit.LearnedSkills.ContainsKey(this.SkillId)) { return(bufferInfo.Unit.LearnedSkills[this.SkillId].Level); } } return(0); }
protected override int GetProperty() { INodeGraph graph = base.Graph; BufferInfo bufferInfo = graph?.GetVariable <BufferInfo>("BufferInfo"); if (bufferInfo != null) { if (Game.GameData.Character.ContainsKey(bufferInfo.Unit.CharacterInfoId)) { if (Game.GameData.Character[bufferInfo.Unit.CharacterInfoId].Mantra.ContainsKey(this.MantraId)) { return(Game.GameData.Character[bufferInfo.Unit.CharacterInfoId].Mantra[this.MantraId].Level); } } else if (bufferInfo.Unit.CurrentMantra.Id == this.MantraId) { return(bufferInfo.Unit.CurrentMantra.Level); } } return(0); }
public static void DrawSerializableNode(this INode node, INodeGraph graph) { var graphAsset = graph as NodeGraph; if (!graphAsset) { return; } var isSerializable = node is SerializableNode; var collection = isSerializable ? graphAsset.serializableNodes: graphAsset.ObjectNodes; var index = -1; for (int i = 0; i < collection.Count; i++) { var nodeItem = collection[i]; if (nodeItem != node && nodeItem.Id != node.Id) { continue; } index = i; break; } if (index < 0) { return; } var nodeType = isSerializable ? graphAsset.serializableNodes.GetType() : graphAsset.nodes.GetType(); graphAsset.DrawAssetChildWithOdin(nodeType, index); }
public static void SubmitGraph(INodeGraph nodeGraph) => m_NodeGraph = nodeGraph;
public RequestListener( IConfiguration configuration, INodeGraph nodeGraph, ILogFactory logFactory) { _nodeGraph = nodeGraph; _logFactory = logFactory; _configurationRegistration = configuration.Register( "/gravity/listener", c => { Trace.WriteLine("[CONFIG] New listener configuration"); _newConfiguration = c.Sanitize(); if (ReferenceEquals(_currentConfiguration, null)) { Trace.WriteLine("[CONFIG] There is no current listener configuration, the new configuration will be adopted immediately"); _currentConfiguration = _newConfiguration; } }, new ListenerConfiguration()); _trafficUpdateThread = new Thread(() => { while (true) { try { Thread.Sleep(3000); var endpoints = _currentConfiguration.Endpoints; if (endpoints != null) { foreach (var endpoint in endpoints) { endpoint.ProcessingNode?.TrafficAnalytics.Recalculate(); } } if (!ReferenceEquals(_currentConfiguration, _newConfiguration)) { endpoints = _newConfiguration.Endpoints; if (endpoints != null) { var offline = false; foreach (var endpoint in endpoints) { endpoint.ProcessingNode = new NodeOutput { Name = endpoint.NodeName, Node = _nodeGraph.NodeByName(endpoint.NodeName), }; if (endpoint.ProcessingNode.Node == null) { Trace.WriteLine($"[CONFIG] Listener endpoint {endpoint.Name ?? endpoint.IpAddress} has no node attached in the new configuration"); offline = true; } else { if (endpoint.ProcessingNode.Node.Offline) { Trace.WriteLine($"[CONFIG] Listener endpoint {endpoint.Name ?? endpoint.IpAddress} processing node is not ready to accept traffic yet"); offline = true; } } } if (!offline) { Trace.WriteLine("[CONFIG] Bringing new listener configuration online"); _currentConfiguration = _newConfiguration; } } } } catch (ThreadAbortException) { return; } catch { } } }) { IsBackground = true, Priority = ThreadPriority.Lowest }; _trafficUpdateThread.Start(); }
public override void Bind(INodeGraph nodeGraph) { _nextNode = nodeGraph.NodeByName(OutputNode); _allowedOriginsRegex = new Regex(AllowedOrigins, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); Offline = true; }
public NodeGraph( IConfiguration configuration, IExpressionParser expressionParser, IHostingEnvironment hostingEnvironment, IFactory factory, IBufferPool bufferPool, ILogFactory logFactory) { _expressionParser = expressionParser; _hostingEnvironment = hostingEnvironment; _factory = factory; _bufferPool = bufferPool; _logFactory = logFactory; _disposeQueue = new Queue <DisposeQueueItem>(); _configuration = configuration.Register( "/gravity/nodeGraph", Configure, new NodeGraphConfiguration()); _thread = new Thread(() => { while (true) { try { Thread.Sleep(100); bool UpdateGraph(INodeGraph graph, bool logActions) { if (graph == null) { return(false); } var offline = false; var nodes = graph.GetNodes(n => n); foreach (var node in nodes) { try { node.UpdateStatus(); if (logActions) { if (node.Offline && !node.Disabled) { Trace.WriteLine($"[CONFIG] Node {node.Name} is OFFLINE"); offline = true; } else { Trace.WriteLine($"[CONFIG] Node {node.Name} is online"); } } else { if (node.Offline && !node.Disabled) { offline = true; } } } catch (Exception ex) { Trace.WriteLine($"[EXCEPTION] Failed to update {node.Name} node status. {ex.Message}"); } } return(!offline); } UpdateGraph(_currentInstance, false); if (!ReferenceEquals(_currentInstance, _newInstance)) { Trace.WriteLine($"[CONFIG] Checking new node graph to see if it online yet"); if (UpdateGraph(_newInstance, true)) { Trace.WriteLine($"[CONFIG] Bringing new node graph online"); var prior = _currentInstance as NodeGraphInstance; _currentInstance = _newInstance; if (prior != null) { // Make sure nodes have finished processing current requests before disposing foreach (var node in prior.Nodes) { lock (_disposeQueue) _disposeQueue.Enqueue(new DisposeQueueItem { #if DEBUG WhenUtc = DateTime.UtcNow.AddSeconds(30), #else WhenUtc = DateTime.UtcNow.AddMinutes(5), #endif Disposable = node }); } } } } lock (_disposeQueue) { if (_disposeQueue.Count > 0) { var next = _disposeQueue.Peek(); if (next != null && DateTime.UtcNow >= next.WhenUtc) { Trace.WriteLine($"[DISPOSE] Disposing of " + next.Disposable); next.Disposable.Dispose(); _disposeQueue.Dequeue(); } } } } catch (ThreadAbortException) { return; } catch (Exception ex) { Trace.WriteLine($"[EXCEPTION] Node graph update thread {ex.Message}"); } } }) { Name = "Update availability", IsBackground = true, Priority = ThreadPriority.BelowNormal }; _thread.Start(); }
public void Configure(NodeGraphConfiguration configuration) { Trace.WriteLine($"[CONFIG] There is a new node graph configuration"); try { configuration = configuration.Sanitize(); } catch (Exception ex) { Trace.WriteLine($"[CONFIG] Exception processing node graph configuration. " + ex.Message); throw new Exception("There was a problem with sanitizing the configuration data", ex); } var nodes = new List <INode>(); try { ConfigureCorsNodes(configuration, nodes); ConfigureInternalPageNodes(configuration, nodes); ConfigureLeastConnectionsNodes(configuration, nodes); ConfigureResponseNodes(configuration, nodes); ConfigureRoundRobinNodes(configuration, nodes); ConfigureRouterNodes(configuration, nodes); ConfigureServerNodes(configuration, nodes); ConfigureStickySessionNodes(configuration, nodes); ConfigureTransformNodes(configuration, nodes); ConfigureChangeLogFilterNodes(configuration, nodes); ConfigureCustomLogNodes(configuration, nodes); } catch (Exception ex) { Trace.WriteLine($"[CONFIG] Exception configuring node graph nodes. " + ex.Message); throw new Exception("There was a problem re-configuring nodes", ex); } var instance = new NodeGraphInstance { Nodes = nodes.ToArray() }; try { foreach (var node in nodes) { node.Bind(instance); } } catch (Exception ex) { Trace.WriteLine($"[CONFIG] Exception binding nodes into a graph. " + ex.Message); throw new Exception("There was a problem with binding nodes into a graph", ex); } _newInstance = instance; if (_currentInstance == null) { Trace.WriteLine($"[CONFIG] There is no current node graph instance, the new configuration will be applied immediately"); _currentInstance = instance; } else { Trace.WriteLine($"[CONFIG] Waiting for new node graph to come online"); } }
public override void Bind(INodeGraph nodeGraph) { _backgroundThread.Start(); }
public NodeObjectData(INodeGraph graph) : base(graph) { }