Example #1
0
        public override void Execute()
        {
            Packet np = _nameport.Receive();

            if (np == null)
            {
                return;
            }
            _nameport.Close();
            string pname = np.Content as string;

            Drop(np);

            _inport = (_mother._inputPorts)[pname] as IInputPort;
            _mother.Trace(Name + ": Accessing input port: " + _inport.Name);
            Packet p;
            // I think this works!
            Component oldReceiver = _inport.Receiver;

            if (_inport is InitializationConnection)
            {
                InitializationConnection iico = (InitializationConnection)_inport;
                InitializationConnection iic  = new InitializationConnection(
                    iico.Content, this);
                iic.Name = iico.Name;
                // iic.network = iico.network;

                p       = iic.Receive();
                p.Owner = this;
                _outport.Send(p);
                iic.Close();
            }
            else
            {
                Connection cnxt = _inport as Connection;
                cnxt.SetReceiver(this);
                while ((p = cnxt.Receive()) != null)
                {
                    p.Owner = this;
                    _outport.Send(p);
                }
                // cnxt.setReceiver(oldReceiver); // moved down, as per JavaFBP
            }

            // inport.close();

            _mother.Trace(Name + ": Releasing input port: " + _inport.Name);
            _inport.SetReceiver(oldReceiver);
            // inport = null;
        }
Example #2
0
        public override void Execute()
        {
            Packet np = _nameport.Receive();

            if (np == null)
            {
                return;
            }
            _nameport.Close();
            string pname = np.Content as string;

            Drop(np);

            _inport = (_mother._inputPorts)[pname] as IInputPort;
            _mother.Trace(Name + ": Accessing input port: " + _inport.Name);
            Packet p;
            int    level = 0;
            // I think this works!
            Component oldReceiver = _inport.Receiver;

            if (_inport is InitializationConnection)
            {
                FlowError.Complain("SubinSS cannot support IIP - use Subin");
            }
            Connection cnxt = _inport as Connection;

            cnxt.SetReceiver(this);
            while ((p = cnxt.Receive()) != null)
            {
                p.Owner = this;
                if (p.Type == Packet.Types.Open)
                {
                    if (level == 0)
                    {
                        Drop(p);
                        _network.Trace("{0}: Open bracket detected", Name);
                    }
                    else
                    {
                        _outport.Send(p);
                    }
                    level++;
                }
                else if (p.Type == Packet.Types.Close)
                {
                    level--;
                    if (level == 0)
                    {
                        Drop(p);
                        _network.Trace("{0}: Close bracket detected", Name);
                    }
                    else
                    {
                        _outport.Send(p);
                    }

                    break;
                }
                else
                {
                    _outport.Send(p);
                }
            }


            // inport.close();
            _mother.Trace(Name + ": Releasing input port: " + _inport.Name);
            cnxt.SetReceiver(oldReceiver);

            // inport = null;
        }