Exemple #1
0
 /// <summary>method to register a port (with index) 
 /// </summary>
 protected internal Port Port(string name, int index)
 {
     if (!name.Equals("*") && -1 != name.IndexOf('*'))
     {
         FlowError.Complain("Stray * in port name " + name);
     }
     Port p = new Port(name, index);
     //p.displayName = String.Format("{0}[{1}]", name, index);
     return p;
 }
Exemple #2
0
 protected internal Connection Connect(string sender, Component receiver, Port inP, bool IPCount, int arraySize)
 {
     string[] parts = CPSplit(sender);
     return Connect(Component(parts[0]), Port(parts[1]), receiver, inP, arraySize, IPCount);
 }
Exemple #3
0
        /// <summary>Build InitializationConnection object
        /// </summary>
        /// <summary>Build InitializationConnection object
        /// </summary>
        protected internal void Initialize(System.Object content, Component receiver, Port inP)
        {
            IInputPort ip = receiver._inputPorts[inP._displayName];
            if (ip == null)
            {
                FlowError.Complain("Input port not defined in metadata: " + receiver._name + "." + inP._displayName);
            }
            if (ip is Connection || ip is ConnArray)
            {
                FlowError.Complain("IIP port cannot be shared: " + receiver._name + "." + inP._displayName);
            }

            if (ip is InitializationConnection)
            {
                FlowError.Complain("IIP port already used: " + 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);
            }

            InitializationConnection ic = new InitializationConnection(content, receiver);
            ic._name = receiver._name + "." + inP._displayName;
            //ic.network = this;

            receiver._inputPorts.Remove(inP._displayName);
            receiver._inputPorts.Add(inP._displayName, ic);
        }
Exemple #4
0
 //---//
 protected internal Connection Connect(Component sender, Port outP, Component receiver, Port inP, bool IPCount, int arraySize)
 {
     return Connect(sender, outP, receiver, inP, arraySize, IPCount);
 }
Exemple #5
0
 protected internal Connection Connect(Component sender, Port outP, string receiver, bool IPCount, int arraySize)
 {
     string[] parts = CPSplit(receiver);
     return Connect(sender, outP, Component(parts[0]), Port(parts[1]), arraySize, IPCount);
 }
Exemple #6
0
 protected internal Connection Connect(string sender, Component receiver, Port inP)
 {
     string[] parts = CPSplit(sender);
     return Connect(Component(parts[0]), Port(parts[1]), receiver, inP, 0, false);
 }
Exemple #7
0
 protected internal Connection Connect(Component sender, Port outP, string receiver)
 {
     string[] parts = CPSplit(receiver);
     return Connect(sender, outP, Component(parts[0]), Port(parts[1]), 0, false);
 }
Exemple #8
0
 //---//
 protected internal Connection Connect(Component sender, Port outP, Component receiver, Port inP)
 {
     return Connect(sender, outP, receiver, inP, 0, false);
 }
Exemple #9
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;
        }
Exemple #10
0
 /// <summary>method to register a port name  
 /// </summary>
 public Port Port(string name)
 {
     if (!name.Equals("*") && !name.Equals("*SUBEND") && -1 != name.IndexOf('*'))
     {
         FlowError.Complain("Stray * in port name " + name);
     }
     Port p = new Port(name, -1);
     //p.displayName = String.Format("{0}", name);
     return p;
 }