/* 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; }