public void UnsubscribeFromEvents(InPort InPort)
 {
     if (Subscribers.Contains(InPort))
     {
         Subscribers.Remove(InPort);
     }
     if (SubscribedComponents.Contains(InPort.Component))
     {
         SubscribedComponents.Remove(InPort.Component);
     }
 }
예제 #2
0
        public override void Process(ExecutionContext context)
        {
            InPort In = Input.GetPort("In");

            if (In.HasData())
            {
                object data = In.GetData();
                Debug.Log(data.ToString());
                Output.SendDone("PassOn", data, context);
            }
        }
예제 #3
0
        public Action DisconnectInPort(string portName, Edge edge)
        {
            InPort port = Input.GetPort(portName);

            port.RemoveConnection(edge);
            return(() => {
                if (port.ProcessDisconnection != null)
                {
                    port.ProcessDisconnection.Invoke(edge.Source);
                }
            });
        }
예제 #4
0
        public override void Process(ExecutionContext context)
        {
            InPort firstPort  = Input.GetPort("First");
            InPort secondPort = Input.GetPort("Second");

            if (firstPort.HasData() && secondPort.HasData())
            {
                object first  = firstPort.GetData();
                object second = secondPort.GetData();
                Output.SendDone("Out", first.ToString() + second.ToString(), context);
            }
        }
예제 #5
0
        public void RemoveDefaultValue(string NodeName, string PortName)
        {
            Component Component;

            if (!NodesByName.TryGetValue(NodeName, out Component))
            {
                throw new Exception("");
            }

            InPort Port = Component.Input.GetPort(PortName);

            RemoveDefaultValue(Port);
        }
예제 #6
0
        public Action ConnectToInPort(string portName, Edge edge)
        {
            InPort port = Input.GetPort(portName);

            port.AddConnection(edge);
            edge.Target = port;
            return(() => {
                if (port.ProcessConnection != null)
                {
                    port.ProcessConnection.Invoke(edge.Source);
                }
            });
        }
예제 #7
0
        public void AddDefaultValue(object Data, string NodeName, string PortName)
        {
            Component Component;

            if (!NodesByName.TryGetValue(NodeName, out Component))
            {
                throw new Exception("Could not find node: " + NodeName);
            }

            InPort Port = Component.Input.GetPort(PortName);

            AddDefaultValue(Data, Port);
        }
        public void SubscribeToEvents(InPort InPort)
        {
            if (Subscribers.Contains(InPort))
            {
                throw new Exception("TODO");
            }

            Subscribers.Add(InPort);

            if (!SubscribedComponents.Contains(InPort.Component)) // TODO take advantage of list indexing. Add the corresponding component at the same index as the port in it's own list
            {
                SubscribedComponents.Add(InPort.Component);
            }
        }
예제 #9
0
        public void RemoveDefaultValue(InPort Port)
        {
            DefaultValue defaultValue;

            if (!DefaultValuesByInPort.TryGetValue(Port, out defaultValue))
            {
                throw new Exception("TODO");
            }

            DefaultValuesByInPort.Remove(Port);

            if (GraphEditor != null)
            {
                GraphEditor.EventOptions.DefaultValueRemoved.Invoke(defaultValue);
            }
        }
예제 #10
0
        public void SetDefaultValue(object Data, InPort Port)
        {
            DefaultValue defaultValue;

            if (DefaultValuesByInPort.TryGetValue(Port, out defaultValue))
            {
                DefaultValuesByInPort.Remove(Port);

                if (GraphEditor != null)
                {
                    GraphEditor.EventOptions.DefaultValueRemoved.Invoke(defaultValue);
                }
            }

            AddDefaultValue(Data, Port);
        }
예제 #11
0
        protected override void SetupInterfaces()
        {
            DoorPort = Input.AddPort(new InPort()
            {
                Name                 = "Door",
                Description          = "The controller of the door to be used",
                Types                = new string[] { "Door Controller" },
                ProcessConnection    = (OutPort otherPort) => {
                },
                ProcessDisconnection = (OutPort otherPort) => {
                },
            });
            TogglePort = Input.AddPort(new InPort()
            {
                Name                 = "Toggle",
                Description          = "On receiving any input to this port, the door's state will be toggled",
                Types                = new string[] { "All" },
                ProcessConnection    = (OutPort otherPort) => {
                },
                ProcessDisconnection = (OutPort otherPort) => {
                },
            });
            DoorEventsPort = Input.AddPort(new InPort()
            {
                Name                 = "DoorEventsPort",
                Description          = "On receiving any input to this port, the door's state will be toggled",
                Types                = new string[] { "All" },
                ProcessConnection    = (OutPort otherPort) => {
                },
                ProcessDisconnection = (OutPort otherPort) => {
                },
                Hidden               = true,
            });

            StatePort = Output.AddPort(new OutPort()
            {
                Name                 = "State",
                Description          = "The state of the door is sent on when changed as Opened or Closed",
                Types                = new string[] { "Text" },
                ProcessConnection    = (InPort otherPort) => {
                },
                ProcessDisconnection = (InPort otherPort) => {
                },
            });
        }
예제 #12
0
        public override void Process(ExecutionContext context)
        {
            InPort firstPort  = Input.GetPort("Delimiter");
            InPort secondPort = Input.GetPort("String");

            if (firstPort.HasData() && secondPort.HasData())
            {
                string delimiter = firstPort.GetData().ToString();
                string str       = secondPort.GetData().ToString();

                string[] strs = str.Split(new string[] { delimiter }, new StringSplitOptions());

                for (int i = 0; i < strs.Length; i++)
                {
                    Output.SendDone("Out", strs[i], context);
                }
            }
        }
        public void EnqueueNextInitialisingTask()
        {
            InPort port = DefaultPortQueue.Dequeue();

            if (Graph.InDebugMode())
            {
                port.DebugHighlight();
            }

            Graph.AddData(port, Graph.DefaultValuesByInPort[port].Data);

            if (Graph.InDebugMode())
            {
                port.DebugUnhighlight();
            }

            context.QueueTask(port.Component);
            context.SwitchToNewlyEnqueuedTasks();
        }
예제 #14
0
        public void AddDefaultValue(object Data, InPort Port)
        {
            DefaultValue defaultValue = new DefaultValue()
            {
                Data      = Data,
                Component = Port.Component,
                Port      = Port
            };

            if (DefaultValuesByInPort.ContainsKey(Port))
            {
                throw new Exception("");
            }

            DefaultValuesByInPort.Add(Port, defaultValue);

            if (GraphEditor != null)
            {
                GraphEditor.EventOptions.DefaultValueAdded.Invoke(defaultValue);
            }
        }
예제 #15
0
 protected override void SetupInterfaces()
 {
     EventNamePort = Input.AddPort(new InPort()
     {
         Name                 = "EventName",
         Description          = "The name of the event",
         Types                = new string[] { "Text" },
         ProcessConnection    = (OutPort otherPort) => {
         },
         ProcessDisconnection = (OutPort otherPort) => {
         },
         RememberOnlyLatest   = true
     });
     DataPort = Input.AddPort(new InPort()
     {
         Name                 = "Data",
         Description          = "The data to send with the event",
         Types                = new string[] { "All" },
         ProcessConnection    = (OutPort otherPort) => {
         },
         ProcessDisconnection = (OutPort otherPort) => {
         },
     });
 }
예제 #16
0
        protected override void SetupInterfaces()
        {
            DelayPort = Input.AddPort(new InPort()
            {
                Name                 = "Delay",
                Description          = "The period to wait before sending messages on",
                Types                = new string[] { "Number" },
                ProcessConnection    = (OutPort otherPort) => {
                },
                ProcessDisconnection = (OutPort otherPort) => {
                },
                RememberOnlyLatest   = true
            });

            InPort = Input.AddPort(new InPort()
            {
                Name                 = "In",
                Description          = "The data that will be sent on",
                Types                = new string[] { "All" },
                ProcessConnection    = (OutPort otherPort) => {
                },
                ProcessDisconnection = (OutPort otherPort) => {
                }
            });

            OutPort = Output.AddPort(new OutPort()
            {
                Name                 = "Out",
                Description          = "The delayed data",
                Types                = new string[] { "All" },
                ProcessConnection    = (InPort otherPort) => {
                },
                ProcessDisconnection = (InPort otherPort) => {
                },
            });
        }
예제 #17
0
        protected override void SetupInterfaces()
        {
            EventNamePort = Input.AddPort(new InPort()
            {
                Name                 = "EventName",
                Description          = "The name of the event to listen for",
                Types                = new string[] { "Text" },
                ProcessConnection    = (OutPort otherPort) => {
                },
                ProcessDisconnection = (OutPort otherPort) => {
                },
                RememberOnlyLatest   = true
            });
            EventPort = Input.AddPort(new InPort()
            {
                Name                 = "Event",
                Description          = "The data that was sent with the event",
                Types                = new string[] { "All" },
                ProcessConnection    = (OutPort otherPort) => {
                },
                ProcessDisconnection = (OutPort otherPort) => {
                },
                Hidden               = true
            });

            OutPort = Output.AddPort(new OutPort()
            {
                Name                 = "Out",
                Description          = "Sends event data when an event of the given name is received",
                Types                = new string[] { "Text" },
                ProcessConnection    = (InPort otherPort) => {
                },
                ProcessDisconnection = (InPort otherPort) => {
                },
            });
        }
예제 #18
0
        public void AcceptDataOnPort(string portName, object data, HashSet <Component> Targets)
        {
            InPort port = Input.GetPort(portName);

            port.Accept(data);
        }
예제 #19
0
 public void AddData(InPort port, object data)
 {
     port.Accept(data);
 }
예제 #20
0
 public InPort AddPort(InPort port)
 {
     port.Component = Component;
     Ports.Add(port.Name, port);
     return(port);
 }