Exemplo n.º 1
0
        public IList <Port> FindAllPorts(IEnumerable <Signal> rootSignals, Predicate <Port> match, bool ignoreHold)
        {
            ICollectVisitor visitor  = Binder.GetInstance <ICollectVisitor, Predicate <Port> >(match);
            IScanStrategy   strategy = Binder.GetSpecificInstance <IScanStrategy>(new MathIdentifier("AllPortsStrategy", "Traversing"));

            strategy.Traverse(rootSignals, visitor, ignoreHold);
            return(visitor.Ports);
        }
Exemplo n.º 2
0
        public IList <Signal> FindAllSignals(Port rootPort, Predicate <Signal> match, bool ignoreHold)
        {
            ICollectVisitor visitor  = Binder.GetInstance <ICollectVisitor, Predicate <Signal> >(match);
            IScanStrategy   strategy = Binder.GetSpecificInstance <IScanStrategy>(new MathIdentifier("AllSignalsStrategy", "Traversing"));

            strategy.Traverse(rootPort, visitor, ignoreHold);
            return(visitor.Signals);
        }
Exemplo n.º 3
0
        public IList <Port> FindAllPorts(Port rootPort, bool ignoreHold)
        {
            ICollectVisitor visitor  = Binder.GetInstance <ICollectVisitor>();
            IScanStrategy   strategy = Binder.GetSpecificInstance <IScanStrategy>(new MathIdentifier("AllPortsStrategy", "Traversing"));

            strategy.Traverse(rootPort, visitor, ignoreHold);
            return(visitor.Ports);
        }
Exemplo n.º 4
0
        public IList <Signal> FindAllSignals(IEnumerable <Signal> rootSignals, bool ignoreHold)
        {
            ICollectVisitor visitor  = Binder.GetInstance <ICollectVisitor>();
            IScanStrategy   strategy = Binder.GetSpecificInstance <IScanStrategy>(new MathIdentifier("AllSignalsStrategy", "Traversing"));

            strategy.Traverse(rootSignals, visitor, ignoreHold);
            return(visitor.Signals);
        }
Exemplo n.º 5
0
        public Signal Manipulate(Signal rootSignal, IManipulationVisitor visitor, bool ignoreHold)
        {
            IScanStrategy allPathsStrat = Binder.GetSpecificInstance <IScanStrategy>(new MathIdentifier("AllPathsStrategy", "Traversing"));

            Dictionary <Guid, ManipulationPlan> plans = new Dictionary <Guid, ManipulationPlan>();
            Dictionary <Guid, Signal>           signalReplacements = new Dictionary <Guid, Signal>();
            Dictionary <Guid, Signal>           sentinels          = new Dictionary <Guid, Signal>();

            // ## ESTIMATE MANIPULATION PLAN
            _scanner.ForEachPort(rootSignal, delegate(Port p)
            {
                if (!plans.ContainsKey(p.InstanceId))
                {
                    plans.Add(p.InstanceId, visitor.EstimatePlan(p));
                }
                return(true);
            }, ignoreHold);

            // ## OPTIMIZE MANIPULATION PLAN (cycle analysis)
            ManipulatorPlanReducer reducer = new ManipulatorPlanReducer(plans, ignoreHold);

            allPathsStrat.Traverse(rootSignal, reducer, ignoreHold);

            // ## EXECUTE MANIPULATION
            ManipulatorPlanExecutor executor = new ManipulatorPlanExecutor(plans, signalReplacements, sentinels, visitor);

            allPathsStrat.Traverse(rootSignal, executor, ignoreHold);

            // ## SELECT NEW SYSTEM
            Signal ret;

            if (!signalReplacements.TryGetValue(rootSignal.InstanceId, out ret))
            {
                ret = rootSignal;
            }

            // ## FIX SENTINELS ON SELECTED NEW SYSTEM
            _scanner.ForEachPort(ret, delegate(Port p)
            {
                // look for sentinels on all input signals
                ReadOnlySignalSet inputs = p.InputSignals;
                for (int i = 0; i < inputs.Count; i++)
                {
                    Signal input = inputs[i];
                    if (FixSentinel(ref input, sentinels, signalReplacements))
                    {
                        p.ReplaceInputSignalBinding(i, input);
                    }
                }
                return(true);
            }, ignoreHold);
            FixSentinel(ref ret, sentinels, signalReplacements);

            // ## RETURN SELECTED NEW SYSTEM AS RESULT
            return(ret);
        }
Exemplo n.º 6
0
 public void Traverse(IEnumerable <Signal> rootSignals, IScanStrategy strategy, IScanVisitor visitor, bool ignoreHold)
 {
     if (visitor == null)
     {
         throw new ArgumentNullException("visitor");
     }
     if (strategy == null)
     {
         throw new ArgumentNullException("strategy");
     }
     strategy.Traverse(rootSignals, visitor, ignoreHold);
 }
Exemplo n.º 7
0
 public void Traverse(Port rootPort, IScanStrategy strategy, IScanVisitor visitor, bool ignoreHold)
 {
     if (visitor == null)
     {
         throw new ArgumentNullException("visitor");
     }
     if (strategy == null)
     {
         throw new ArgumentNullException("strategy");
     }
     strategy.Traverse(rootPort, visitor, ignoreHold);
 }
Exemplo n.º 8
0
 public void Traverse(IEnumerable<Signal> rootSignals, IScanStrategy strategy, IScanVisitor visitor, bool ignoreHold)
 {
     if(visitor == null) throw new ArgumentNullException("visitor");
     if(strategy == null) throw new ArgumentNullException("strategy");
     strategy.Traverse(rootSignals, visitor, ignoreHold);
 }
Exemplo n.º 9
0
 public void Traverse(Port rootPort, IScanStrategy strategy, IScanVisitor visitor, bool ignoreHold)
 {
     if(visitor == null) throw new ArgumentNullException("visitor");
     if(strategy == null) throw new ArgumentNullException("strategy");
     strategy.Traverse(rootPort, visitor, ignoreHold);
 }