Beispiel #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;
        }
Beispiel #2
0
        /* Connects */

        /// <summary>Connect an output port of one Component to an input port
        /// of another
        /// </summary>

        protected internal Connection Connect(Component sender, Port outP, Component receiver, Port inP, int size, bool IPCount)
        {
            int cap = size;

            if (size == 0)
            {
                cap = _defaultCapacity;
            }

            //string outName = outPort.displayName;
            //string inName = inPort.displayName;

            if (outP._displayName.Equals("*"))
            {
                outP._name        = "*OUT";
                outP._displayName = "*OUT";
            }
            if (inP._displayName.Equals("*"))
            {
                inP._name        = "*IN";
                inP._displayName = "*IN";
            }

            OutputPort op = null;

            if (!outP._displayName.Substring(0, 1).Equals("*"))
            {
                op = sender._outputPorts[outP._name]; // try to find output port with port name - no index
                if (op == null)
                {
                    FlowError.Complain("Output port not defined in metadata: " + sender._name + "." + outP._displayName);
                }

                if (op is OutArray && outP._index == -1)
                {
                    outP._index       = 0;
                    outP._displayName = outP._name + "[" + outP._index + "]";
                }



                if (outP._index > -1 && !(op is OutArray))
                {
                    FlowError.Complain("Output port not defined as array in metadata: " + sender._name + "." + outP._displayName);
                }

                if (!(op is NullOutputPort) && !(op is OutArray) && op._cnxt != null)
                {
                    FlowError.Complain("Multiple connections to output port:" + sender._name + ' ' + outP._displayName);
                }
            }

            op = new OutputPort();
            op.SetSender(sender);
            op._name         = outP._displayName;
            op._connected    = true;
            op._fullName     = sender._name + "." + outP._displayName;
            op._traceNetwork = sender._mother;

            sender._outputPorts.Remove(op._name);
            sender._outputPorts.Add(op._name, op);

            /* start processing input port */

            IInputPort ip = null;

            if (!inP._displayName.Substring(0, 1).Equals("*"))
            {
                ip = receiver._inputPorts[inP._name];
                if (ip == null)
                {
                    FlowError.Complain("Input port not defined in metadata: " + receiver._name + "." + inP._displayName);
                }

                if (ip is ConnArray && inP._index == -1)
                {
                    inP._index       = 0;
                    inP._displayName = inP._name + "[" + inP._index + "]";
                }

                if (inP._index > -1 && !(ip is ConnArray))
                {
                    FlowError.Complain("Input port not defined as array in metadata: " + receiver._name + "." + inP._displayName);
                }
            }
            Connection c;

            if (ip is Connection)
            {
                if (size != 0 && size != cap)
                {
                    FlowError.Complain("Connection capacity does not agree with previous specification\n " + receiver._name
                                       + "." + inP._displayName);
                }
                c = (Connection)ip;
            }
            else
            {
                if (ip is InitializationConnection)
                {
                    FlowError.Complain("Mixed connection to input port: " + receiver._name + "." + inP._displayName);
                }
                c = new Connection(cap);
                c.SetReceiver(receiver);
                c._name     = inP._displayName;
                c._IPCount  = IPCount;
                c._fullName = receiver._name + "." + c._name;
                receiver._inputPorts.Remove(c._name);
                receiver._inputPorts.Add(c._name, c);
            }

            c.BumpSenderCount();
            op._cnxt    = c;
            c._receiver = receiver;
            c._fullName = receiver.Name + "." + inP._displayName;
            return(c);
        }
Beispiel #3
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;
        }
Beispiel #4
0
        /* Connects */
        /// <summary>Connect an output port of one Component to an input port
        /// of another
        /// </summary>
        protected internal Connection Connect(Component sender, Port outP, Component receiver, Port inP, int size, bool IPCount)
        {
            int cap = size;
            if (size == 0)
                cap = _defaultCapacity;

            //string outName = outPort.displayName;
            //string inName = inPort.displayName;

            if (outP._displayName.Equals("*"))
            {
                outP._name = "*OUT";
                outP._displayName = "*OUT";
            }
            if (inP._displayName.Equals("*"))
            {
                inP._name = "*IN";
                inP._displayName = "*IN";
            }

            OutputPort op = null;
            if (!outP._displayName.Substring(0, 1).Equals("*"))
            {
                op = sender._outputPorts[outP._name]; // try to find output port with port name - no index
                if (op == null)
                {
                    FlowError.Complain("Output port not defined in metadata: " + sender._name + "." + outP._displayName);
                }

                if (op is OutArray && outP._index == -1)
                {
                    outP._index = 0;
                    outP._displayName = outP._name + "[" + outP._index + "]";
                }

                if (outP._index > -1 && !(op is OutArray))
                {
                    FlowError.Complain("Output port not defined as array in metadata: " + sender._name + "." + outP._displayName);
                }

                if (!(op is NullOutputPort) && !(op is OutArray) && op._cnxt != null)
                {
                    FlowError.Complain("Multiple connections to output port:" + sender._name + ' ' + outP._displayName);
                }
            }

            op = new OutputPort();
            op.SetSender(sender);
            op._name = outP._displayName;
            op._connected = true;
            op._fullName = sender._name + "." + outP._displayName;
            op._traceNetwork = sender._mother;

            sender._outputPorts.Remove(op._name);
            sender._outputPorts.Add(op._name, op);

            /* start processing input port */

            IInputPort ip = null;
            if (!inP._displayName.Substring(0, 1).Equals("*"))
            {
                ip = receiver._inputPorts[inP._name];
                if (ip == null)
                {
                    FlowError.Complain("Input port not defined in metadata: " + receiver._name + "." + inP._displayName);
                }

                if (ip is ConnArray && inP._index == -1)
                {
                    inP._index = 0;
                    inP._displayName = inP._name + "[" + inP._index + "]";
                }

                if (inP._index > -1 && !(ip is ConnArray))
                {
                    FlowError.Complain("Input port not defined as array in metadata: " + receiver._name + "." + inP._displayName);
                }
            }
            Connection c;
            if (ip is Connection)
            {
                if (size != 0 && size != cap)
                {
                    FlowError.Complain("Connection capacity does not agree with previous specification\n " + receiver._name
                        + "." + inP._displayName);
                }
                c = (Connection)ip;
            }
            else
            {
                if (ip is InitializationConnection)
                {
                    FlowError.Complain("Mixed connection to input port: " + receiver._name + "." + inP._displayName);
                }
                c = new Connection(cap);
                c.SetReceiver(receiver);
                c._name = inP._displayName;
                c._IPCount = IPCount;
                c._fullName = receiver._name + "." + c._name;
                receiver._inputPorts.Remove(c._name);
                receiver._inputPorts.Add(c._name, c);
            }

            c.BumpSenderCount();
            op._cnxt = c;
            c._receiver = receiver;
            c._fullName = receiver.Name + "." + inP._displayName;
            return c;
        }