// ----------------------------------------------------------------------------------------- /// <summary> /// Creates the ports on the Subscriber Nodes. /// </summary> /// <param name="subscriberNode">The Node to which we want to attach this port to.</param> /// <param name="tranzmitEvent">The Event that will be associated with this port.</param> /// <returns>The created port</returns> private Port GenerateTranzmitSubscriberInputPorts(Tranzmit_Node subscriberNode, Tranzmit.EventData tranzmitEvent) { var inputPort = Port_Generate_SUBSCRIBER(subscriberNode, Direction.Input, Port.Capacity.Single); inputPort.portName = tranzmitEvent.Info.EventName.ToString(); inputPort.portColor = SilentColor.PropertyValue; subscriberNode.inputContainer.Add(inputPort); subscriberNode.RefreshExpandedState(); subscriberNode.RefreshPorts(); return(inputPort); }
// ----------------------------------------------------------------------------------------- /// <summary> /// Generates ALL Subscriber Nodes /// </summary> /// <param name="tranzmitNode">The Tanzmit Node to connect to</param> /// <param name="coreNodePort">The Tanzmit Port to connect to</param> /// <param name="tranzmitEvent">The associated event</param> private void Generate_Nodes_Subscriber(Tranzmit_Node tranzmitNode, Port coreNodePort, Tranzmit.EventData tranzmitEvent) { if (tranzmitEvent != null) { // Iterate Subscribers in the Event foreach (Delegate subscriber in tranzmitEvent.GetSubscribers()) { bool found = false; // Iterate through our list of generated Subscriber Nodes foreach (SubscriberNodeData subNode in SubscriberNodes) { // Check if the subscription objects are the same if (subscriber.Target == subNode.Subscriber) { found = true; // We just add a port onto the existing graph node var SubscriberPort = GenerateTranzmitSubscriberInputPorts(subNode.Node, tranzmitEvent); var edge = SubscriberPort.ConnectTo(coreNodePort); SubscriberPort.edgeConnector.target.Add(edge); subNode.PortEdgeEvent.Add(new PortEdgeEventData() { SubscriberPort = SubscriberPort, TranzmitPort = coreNodePort, Edge = edge, EventName = tranzmitEvent.Info.EventName }); } } // No graph node exists for the Subscription object so we create it and add / connect the edge. if (found == false) { var subscriberNode = GenerateTranzmitSubscriberNode(subscriber.Target.ToString()); SubscriberNodeData newSubscriberNode = new SubscriberNodeData(); newSubscriberNode.Node = subscriberNode; newSubscriberNode.Subscriber = subscriber.Target; var button = new Button(clickEvent: () => { SelectObject(subscriber.Target); }); button.text = "Find"; newSubscriberNode.Node.mainContainer.Add(button); // Connect Ports var SubscriberPort = GenerateTranzmitSubscriberInputPorts(subscriberNode, tranzmitEvent); // Build Edge var edge = SubscriberPort.ConnectTo(coreNodePort); SubscriberPort.edgeConnector.target.Add(edge); // Add connected port to new entry newSubscriberNode.PortEdgeEvent.Add(new PortEdgeEventData() { SubscriberPort = SubscriberPort, TranzmitPort = coreNodePort, Edge = edge, EventName = tranzmitEvent.Info.EventName }); // Add Entry SubscriberNodes.Add(newSubscriberNode); } } // Update the node when we are done with it tranzmitNode.RefreshExpandedState(); tranzmitNode.RefreshPorts(); } else { Debug.Log("No subscribers were found!"); } }