Example #1
0
        protected internal IInputPort[] OpenInputArray(string name, int arraySize)
        {
            if (name.StartsWith("*"))
            {
                FlowError.Complain("Attempt to open * port: " + this + "." + name);
            }

            ConnArray ca = null;

            if (!_inputPorts.ContainsKey(name))
            {
                FlowError.Complain("Port not defined as input array in metadata: " + this._name + "." + name);
            }
            Object o = _inputPorts[name];

            if (!(o is ConnArray))
            {
                FlowError.Complain("Port not defined as input array in metadata: " + this._name + "." + name);
            }
            ca = (ConnArray)o;
            if (!(ca._fixedSize ^ arraySize == 0))
            {
                FlowError.Complain("Array port fixedSize option in metadata doesn't match specified size: " + this._name
                                   + "." + name);
            }
            IInputPort[] array = GetPortArray(_inputPorts, name);

            if (arraySize > 0 && array.Length > arraySize)
            {
                FlowError.Complain("Number of elements specified for array port less than actual number used: "
                                   + this._name + "." + name);
            }

            if (arraySize > 0 && array.Length < arraySize)
            {
                Array.Resize(ref array, arraySize);
            }

            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] == null)
                {
                    NullConnection nc = new NullConnection();
                    nc.Name  = Name + "." + name + "[" + i + "]";
                    array[i] = nc;
                }
            }
            _inputPorts.Remove(name);
            return(array);
        }
Example #2
0
        protected internal void ProcIpty(string s, InPort ipt)
        {
            ConnArray ca = null;

            if (ipt.arrayPort)
            {
                ca = new ConnArray();
                _inputPorts.Add(s, ca);
                ca._fixedSize = ipt.fixedSize;
                ca._name      = s;
            }
            else
            {
                NullConnection nc = new NullConnection();
                nc._name = s;
                _inputPorts.Add(s, nc);
            }
        }