public SignalBase GetSignal(EPortUsage portUsage, string portName, string domainID, object initialValue)
            {
                switch (portUsage)
                {
                    case EPortUsage.Clock:
                        return _dpb._clk;

                    case EPortUsage.State:
                        if (_stateSignal == null)
                        {
                            if (initialValue == null)
                                throw new InvalidOperationException("Need initial value of state signal in order to determine its type.");
                            string id = _dpb._psName + "_" + portName;
                            _stateSignal = _dpb._host.Descriptor.CreateSignalInstance(id, initialValue).Instance;
                        }
                        return _stateSignal;

                    default:
                        {
                            string id = _dpb._psName + "_" + portName + "_fuPin" + _dpb._nextFUPinIndex;
                            var result = (SignalBase)_dpb._host.Descriptor.CreateSignalInstance(id, initialValue).Instance;
                            ++_dpb._nextFUPinIndex;
                            return result;
                        }
                }
            }
示例#2
0
 /// <summary>
 /// Constructs a descriptor instance.
 /// </summary>
 /// <param name="dir">data-flow direction of the port</param>
 /// <param name="usage">usage hint</param>
 /// <param name="domain">optional argument for future use</param>
 /// <param name="elementType">type descriptor of exchanged data</param>
 public PortBuilder(EFlowDirection dir, EPortUsage usage, string domain, TypeDescriptor elementType)
 {
     _dir         = dir;
     _usage       = usage;
     _domain      = domain;
     _elementType = elementType;
 }
            public SignalBase GetSignal(EPortUsage portUsage, string portName, string domainID, object initialValue)
            {
                switch (portUsage)
                {
                case EPortUsage.Clock:
                    return(_dpb._clk);

                case EPortUsage.State:
                    if (_stateSignal == null)
                    {
                        if (initialValue == null)
                        {
                            throw new InvalidOperationException("Need initial value of state signal in order to determine its type.");
                        }
                        string id = _dpb._psName + "_" + portName;
                        _stateSignal = _dpb._host.Descriptor.CreateSignalInstance(id, initialValue).Instance;
                    }
                    return(_stateSignal);

                default:
                {
                    string id     = _dpb._psName + "_" + portName + "_fuPin" + _dpb._nextFUPinIndex;
                    var    result = (SignalBase)_dpb._host.Descriptor.CreateSignalInstance(id, initialValue).Instance;
                    ++_dpb._nextFUPinIndex;
                    return(result);
                }
                }
            }
示例#4
0
        public ISignalOrPortDescriptor GetSignal(EBinderFlags flags, EPortUsage portUsage, string name, string domainID, object initialValue)
        {
            if (portUsage == EPortUsage.Clock)
            {
                return(FindClock(domainID).Descriptor);
            }
            else if (portUsage == EPortUsage.State)
            {
                throw new NotSupportedException("State signal is not supported by default auto-binder");
            }
            else
            {
                if (flags.HasFlag(EBinderFlags.ExistingSignal))
                {
                    var result = _host.Descriptor.FindSignal(name);
                    if (result != null)
                    {
                        return(null);
                    }
                }

                if (flags.HasFlag(EBinderFlags.CreateNewPort))
                {
                    EFlowDirection dir = EFlowDirection.In;
                    if (flags.HasFlag(EBinderFlags.In))
                    {
                        dir = EFlowDirection.In;
                    }
                    if (flags.HasFlag(EBinderFlags.Out))
                    {
                        dir = EFlowDirection.Out;
                    }
                    if (flags.HasFlag(EBinderFlags.InOut))
                    {
                        dir = EFlowDirection.InOut;
                    }
                    int id   = _id++;
                    var port = _host.Descriptor.CreatePort("agp" + id + "_" + name, dir,
                                                           TypeDescriptor.GetTypeOf(initialValue));
                    return(port);
                }

                if (flags.HasFlag(EBinderFlags.CreateNewSignal))
                {
                    int id     = _id++;
                    var signal = _host.Descriptor.CreateSignalInstance("ags" + id + "_" + name,
                                                                       TypeDescriptor.GetTypeOf(initialValue));
                    return(signal);
                }

                return(null);
            }
        }
示例#5
0
 public SignalBase GetSignal(EPortUsage portUsage, string portName, string domainID, object initialValue)
 {
     if (portUsage == EPortUsage.Clock)
     {
         return(FindClock(domainID));
     }
     else if (portUsage == EPortUsage.State)
     {
         throw new NotSupportedException("State signal is not supported by default auto-binder");
     }
     else
     {
         int id = _id++;
         return(_host.Descriptor.CreateSignalInstance("ags" + id + "_" + portName, initialValue).Instance);
     }
 }
            public SignalBase GetSignal(EPortUsage portUsage, string portName, string domainID, object initialValue)
            {
                switch (portUsage)
                {
                case EPortUsage.Clock:
                    return(_dpb._clk);

                case EPortUsage.State:
                    throw new InvalidOperationException("State signal is not available to interconnect builder");

                default:
                {
                    string id     = _dpb._psName + "_icr" + _dpb._nextICRIndex + "_" + portName;
                    var    result = (SignalBase)_dpb._host.Descriptor.CreateSignalInstance(id, initialValue).Instance;
                    ++_dpb._nextICRIndex;
                    return(result);
                }
                }
            }
示例#7
0
        /// <summary>
        /// Creates and adds a new port.
        /// </summary>
        /// <param name="me">component descriptor to host the new port</param>
        /// <param name="name">name of new port</param>
        /// <param name="dir">data-flow direction</param>
        /// <param name="usage">usage hint</param>
        /// <param name="dataType">type descriptor of exchanged data</param>
        /// <returns>the descriptor of the newly created port</returns>
        public static PortBuilder CreatePort(this IComponentDescriptor me, string name, EFlowDirection dir, EPortUsage usage, TypeDescriptor dataType)
        {
            Contract.Requires <ArgumentNullException>(me != null);
            Contract.Requires <ArgumentNullException>(name != null);
            Contract.Requires <ArgumentNullException>(dataType != null);

            PortBuilder result = new PortBuilder(dir, usage, null, dataType);

            me.AddChild(result, name);
            return(result);
        }
 public ISignalOrPortDescriptor GetSignal(EBinderFlags flags, EPortUsage portUsage, string name, string domainID, object initialValue)
 {
     return(_orgBinder.GetSignal(flags, portUsage, name, domainID, initialValue));
 }
示例#9
0
        /// <summary>
        /// Creates and adds a new port.
        /// </summary>
        /// <param name="me">component descriptor to host the new port</param>
        /// <param name="name">name of new port</param>
        /// <param name="dir">data-flow direction</param>
        /// <param name="usage">usage hint</param>
        /// <param name="dataType">type descriptor of exchanged data</param>
        /// <returns>the descriptor of the newly created port</returns>
        public static PortBuilder CreatePort(this IComponentDescriptor me, string name, EFlowDirection dir, EPortUsage usage, TypeDescriptor dataType)
        {
            Contract.Requires<ArgumentNullException>(me != null);
            Contract.Requires<ArgumentNullException>(name != null);
            Contract.Requires<ArgumentNullException>(dataType != null);

            PortBuilder result = new PortBuilder(dir, usage, null, dataType);
            me.AddChild(result, name);
            return result;
        }
示例#10
0
 /// <summary>
 /// Constructs a descriptor instance.
 /// </summary>
 /// <param name="dir">data-flow direction of the port</param>
 /// <param name="usage">usage hint</param>
 /// <param name="domain">optional argument for future use</param>
 /// <param name="elementType">type descriptor of exchanged data</param>
 public PortBuilder(EFlowDirection dir, EPortUsage usage, string domain, TypeDescriptor elementType)
 {
     _dir = dir;
     _usage = usage;
     _domain = domain;
     _elementType = elementType;
 }
 public ISignalOrPortDescriptor GetSignal(EBinderFlags flags, EPortUsage portUsage, string name, string domainID, object initialValue)
 {
     return _orgBinder.GetSignal(flags, portUsage, name, domainID, initialValue);
 }
            public SignalBase GetSignal(EPortUsage portUsage, string portName, string domainID, object initialValue)
            {
                switch (portUsage)
                {
                    case EPortUsage.Clock:
                        return _dpb._clk;

                    case EPortUsage.State:
                        throw new InvalidOperationException("State signal is not available to interconnect builder");

                    default:
                        {
                            string id = _dpb._psName + "_icr" + _dpb._nextICRIndex + "_" + portName;
                            var result = (SignalBase)_dpb._host.Descriptor.CreateSignalInstance(id, initialValue).Instance;
                            ++_dpb._nextICRIndex;
                            return result;
                        }
                }
            }
示例#13
0
 public SignalBase GetSignal(EPortUsage portUsage, string portName, string domainID, object initialValue)
 {
     return(Signals.CreateInstance(initialValue));
 }
 /// <summary>
 /// Creates the attribute
 /// </summary>
 /// <param name="usage">usage class</param>
 /// <param name="domain">reserved for future extensions</param>
 public PortUsage(EPortUsage usage, string domain)
 {
     Usage = usage;
     Domain = domain;
 }
 /// <summary>
 /// Creates the attribute.
 /// </summary>
 /// <param name="usage">usage class</param>
 public PortUsage(EPortUsage usage)
 {
     Usage = usage;
 }
示例#16
0
 /// <summary>
 /// Retrieves an existing or creates a new typed signal/port, depending on specified flags.
 /// </summary>
 /// <typeparam name="T">type of signal data</typeparam>
 /// <param name="binder">binder service</param>
 /// <param name="flags">creation flags</param>
 /// <param name="portUsage">intended usage</param>
 /// <param name="portName">desired name</param>
 /// <param name="domainID">reserved for future extensions</param>
 /// <param name="initialValue">initial data value</param>
 public static Signal <T> GetSignal <T>(this IAutoBinder binder, EBinderFlags flags, EPortUsage portUsage, string portName, string domainID, T initialValue)
 {
     return((Signal <T>)binder.GetSignal(flags, portUsage, portName, domainID, initialValue));
 }