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

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

            if (!(o is ConnArray))
            {
                FlowError.Complain("Port not defined as input array in metadata: " + this._name + "." + name);
            }
            var ca = o as ConnArray;

            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)
                {
                    array[i] = new NullConnection {
                        Name = Name + "." + name + "[" + i + "]"
                    }
                }
                ;
            }
            _inputPorts.Remove(name);
            return(array);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
        public bool CheckPorts()
        {
            bool res = true;

            foreach (KeyValuePair <String, IInputPort> kvp in _inputPorts)
            {
                if (kvp.Value is NullConnection)
                {
                    NullConnection nc = (NullConnection)kvp.Value;
                    if (nc._optional)
                    {
                        continue;
                    }
                    Console.WriteLine("Input port specified in metadata, but not connected: " + Name + "." +
                                      kvp.Value.Name);
                    res = false;
                }
            }

            foreach (KeyValuePair <String, OutputPort> kvp in _outputPorts)
            {
                if (kvp.Value is NullOutputPort)
                {
                    NullOutputPort nop = (NullOutputPort)kvp.Value;
                    if (nop._optional)
                    {
                        continue;
                    }

                    Console.WriteLine("Output port specified in metadata, but not connected: " + Name + "." +
                                      kvp.Value.Name);
                    res = false;
                }
            }
            return(res);
        }