public override void Process(ExecutionContext context)
        {
            // Deal with new button controllers
            if (ButtonPort.HasData())
            {
                // Unsubscribe from the previous button if necessary
                if (button != null)
                {
                    button.UnsubscribeFromEvents(ButtonEventsPort);
                }

                // Get the button
                button = (ButtonController)ButtonPort.GetData();

                // Subscribe to the new button
                button.SubscribeToEvents(ButtonEventsPort);
            }

            // Send a kick for each button event received
            for (int i = 0; i < ButtonEventsPort.GetDataCount(); i++)
            {
                Output.Send(OnPressPort, Kick.Instance, context);
            }
            ButtonEventsPort.ClearData();
        }
Exemplo n.º 2
0
 public override void Process(ExecutionContext context)
 {
     if (ObjectPort.HasData())
     {
         object data = ObjectPort.GetData();
         for (int i = 0; i < SendPort.GetDataCount(); i++)
         {
             OutPort.Send(data, context);
         }
         SendPort.ClearData();
     }
     Output.Done(context);
 }
Exemplo n.º 3
0
        public override void Process(ExecutionContext context)
        {
            // Update the door controller
            if (DoorPort.HasData())
            {
                if (Door != null)
                {
                    Door.UnsubscribeFromEvents(DoorEventsPort);
                }

                object data = DoorPort.GetData();
                if (data is DoorController)
                {
                    Door = (DoorController)data;
                }
                else
                {
                    throw new Exception("TODO"); // TODO Send exception to graph for display within graph editor
                }
                Door.SubscribeToEvents(DoorEventsPort);
            }

            // Toggle the doors state once if there are any instructions to do so
            if (TogglePort.HasData())
            {
                TogglePort.ClearData();
                if (Door != null)
                {
                    Door.Toggle();
                }
            }

            // Send on any state change notifications
            while (DoorEventsPort.HasData())
            {
                Output.Send(StatePort, DoorEventsPort.GetData(), context);
            }

            Output.Done(context);
        }