Пример #1
0
        private PortManagementFacade Setup(out IInputPort in0, out IInputPort in1, out IOutputPort out0, out IOutputPort out1, out InputPortManager facadeIn0, out InputPortManager facadeIn1, out OutputPortManager facadeOut0, out OutputPortManager facadeOut1, out SimpleOutputPort entryPoint0, out SimpleOutputPort entryPoint1)
        {
            ManagementFacadeBlock mfb = new ManagementFacadeBlock();

            out0 = new SimpleOutputPort(null, "Out0", Guid.NewGuid(), mfb, null, null);
            out1 = new SimpleOutputPort(null, "Out1", Guid.NewGuid(), mfb, null, null);
            in0  = new SimpleInputPort(null, "In0", Guid.NewGuid(), mfb, null);
            in1  = new SimpleInputPort(null, "In1", Guid.NewGuid(), mfb, null);

            int i0 = 0;

            entryPoint0 = new SimpleOutputPort(null, "", Guid.NewGuid(), null, delegate(IOutputPort iop, object selector) { return(string.Format("Src0 ({0})", i0++)); }, null);
            ConnectorFactory.Connect(entryPoint0, in0);

            int i1 = 0;

            entryPoint1 = new SimpleOutputPort(null, "", Guid.NewGuid(), null, delegate(IOutputPort iop, object selector) { return(string.Format("Src1 ({0})", i1++)); }, null);
            ConnectorFactory.Connect(entryPoint1, in1);

            out0.PortDataPresented += new PortDataEvent(delegate(object data, IPort where) { Console.WriteLine(string.Format("{0} presented at {1}.", data.ToString(), where.Name)); });
            out1.PortDataPresented += new PortDataEvent(delegate(object data, IPort where) { Console.WriteLine(string.Format("{0} presented at {1}.", data.ToString(), where.Name)); });

            PortManagementFacade pmf = new PortManagementFacade(mfb);

            facadeIn0  = pmf.ManagerFor(in0);
            facadeIn1  = pmf.ManagerFor(in1);
            facadeOut0 = pmf.ManagerFor(out0);
            facadeOut1 = pmf.ManagerFor(out1);

            return(pmf);
        }
Пример #2
0
        public OnePullValue(IModel model, string name, string description, Guid guid)
        {
            m_output = new SimpleOutputPort(null, "Output", Guid.NewGuid(), this, null, null);

            PortManagementFacade pmf = new PortManagementFacade(this);

            m_opm = pmf.ManagerFor(m_output);

            m_opm.DataBufferPersistence = PortManager.BufferPersistence.UntilWrite; // Output value is reusable. We never use the compute function.
        }
Пример #3
0
        public OneInOneOutPushPullTransform(IModel model, string name, string description, Guid guid)
        {
            m_output = new SimpleOutputPort(null, "Output", Guid.NewGuid(), this, null, null);
            m_input  = new SimpleInputPort(null, "Input", Guid.NewGuid(), this, null);

            m_input.PortDataPresented += new PortDataEvent(delegate(object data, IPort where) { Console.WriteLine(data.ToString() + " presented to " + where.Name); });

            PortManagementFacade pmf = new PortManagementFacade(this);

            m_ipm = pmf.ManagerFor(m_input);
            m_opm = pmf.ManagerFor(m_output);

            m_ipm.WriteAction           = InputPortManager.DataWriteAction.Push;   // When a value is written into the input buffer, we push the resultant transform out the output port.
            m_ipm.DataBufferPersistence = InputPortManager.BufferPersistence.None; // The input buffer is re-read with every pull.
            m_ipm.ReadSource            = InputPortManager.DataReadSource.Pull;    // We'll always pull a new value.
            m_ipm.SetDependents(m_opm);                                            // A new value written to ipm impacts opm.

            m_opm.ComputeFunction       = new Action(ComputeFuction);
            m_opm.DataBufferPersistence = PortManager.BufferPersistence.None; // Output value is always recomputed.
        }