Beispiel #1
0
 /// <remarks>needs to be called as soon as soon as it becomes disconnected through its driven port to an output signal -> run with each output signal as source parameter.</remarks>
 public int RemoveCycles(MathNet.Symbolics.Signal source, int tag)
 {
     if (this == source)
     {
         System.Diagnostics.Debug.Assert(_cycleCount >= 1);
         _cycleCount--;
         return(1);
     }
     if (IsSourceSignal || !IsDriven)
     {
         return(0);
     }
     else
     {
         int ret = 0;
         if (!((IPort_CycleAnalysis)_drivenByPort).TagWasTagged(tag)) //was not tagged with this tag before.
         {
             foreach (Signal item in _drivenByPort.InputSignals)
             {
                 ret += item.RemoveCycles(source, tag);
             }
             ((IPort_CycleAnalysis)_drivenByPort).DeTag(tag);
         }
         System.Diagnostics.Debug.Assert(_cycleCount >= ret);
         _cycleCount -= ret;
         return(ret);
     }
 }
Beispiel #2
0
 /// <remarks>needs to be called as soon as soon as it becomes connected through its driven port to an output signal -> run with each output signal as source parameter.</remarks>
 public int AddCycles(MathNet.Symbolics.Signal source, int tag)
 {
     if (this == source)
     {
         _cycleCount++;
         return(1);
     }
     if (IsSourceSignal || !IsDriven)
     {
         return(0);
     }
     else
     {
         int ret = 0;
         if (!((IPort_CycleAnalysis)_drivenByPort).TagWasTagged(tag)) //was not tagged with this tag before.
         {
             foreach (Signal item in _drivenByPort.InputSignals)
             {
                 if (item != null)
                 {
                     ret += item.AddCycles(source, tag);
                 }
             }
             ((IPort_CycleAnalysis)_drivenByPort).DeTag(tag);
         }
         _cycleCount += ret;
         return(ret);
     }
 }
Beispiel #3
0
 public override int IndexOfOutputSignal(MathNet.Symbolics.Signal signal)
 {
     for (int i = 0; i < _outputSignalSet.Count; i++)
     {
         if (_outputSignalSet[i] == signal)
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #4
0
 public override void RemoveOutputSignalBinding(int index)
 {
     MathNet.Symbolics.Signal signal = _outputSignalSet[index];
     _outputSignalSet[index] = null;
     _completelyConnected    = false;
     RemoveLinkedArchitecture();
     if (signal != null)
     {
         for (int i = 0; i < _inputSignalSet.Count; i++)
         {
             if (_inputSignalSet[i] != null)
             {
                 ((ISignal_CycleAnalysis)_inputSignalSet[i]).RemoveCycles(signal, Config.Random.Next());
             }
         }
         ((ISignal_Drive)signal).UndriveSignal(index);
     }
 }
Beispiel #5
0
        public override void RemoveInputSignalBinding(int index)
        {
            MathNet.Symbolics.Signal signal = _inputSignalSet[index];
            _inputSignalSet[index] = null;
            _completelyConnected   = false;
            RemoveLinkedArchitecture();
            if (signal != null)
            {
                for (int i = 0; i < _outputSignalSet.Count; i++)
                {
                    if (_outputSignalSet[i] != null)
                    {
                        ((ISignal_CycleAnalysis)signal).RemoveCycles(_outputSignalSet[i], Config.Random.Next());
                    }
                }

                OnInputTreeChanged(index);
                Service <IMediator> .Instance.NotifySignalDrivesPortNoLonger(signal, this, index);
            }
        }
Beispiel #6
0
 public override void AddOutputSignalBinding(int index, MathNet.Symbolics.Signal signal)
 {
     if (signal == null)
     {
         throw new ArgumentNullException("signal");
     }
     if (_outputSignalSet[index] == null)
     {
         _outputSignalSet[index] = signal;
         for (int i = 0; i < _inputSignalSet.Count; i++)
         {
             if (_inputSignalSet[i] != null)
             {
                 ((ISignal_CycleAnalysis)_inputSignalSet[i]).AddCycles(_outputSignalSet[index], Config.Random.Next());
             }
         }
         if (UpdateIsCompletelyConnected())
         {
             LookupAndLinkNewArchitecture();
         }
     }
     else
     {
         _outputSignalSet[index] = signal;
         for (int i = 0; i < _inputSignalSet.Count; i++)
         {
             if (_inputSignalSet[i] != null)
             {
                 ((ISignal_CycleAnalysis)_inputSignalSet[i]).AddCycles(_outputSignalSet[index], Config.Random.Next());
             }
         }
         if (_completelyConnected && _currentArchitecture != null && !_currentArchitecture.RebindToPortIfSupported(this))
         {
             LookupAndLinkNewArchitecture();
         }
     }
     ((ISignal_Drive)signal).DriveSignal(this, index);
 }
Beispiel #7
0
        public override void AddInputSignalBinding(int index, MathNet.Symbolics.Signal signal)
        {
            if (_inputSignalSet[index] == null)
            {
                _inputSignalSet[index] = signal;
                for (int i = 0; i < _outputSignalSet.Count; i++)
                {
                    if (_outputSignalSet[i] != null)
                    {
                        ((ISignal_CycleAnalysis)_inputSignalSet[index]).AddCycles(_outputSignalSet[i], Config.Random.Next());
                    }
                }
                if (UpdateIsCompletelyConnected())
                {
                    LookupAndLinkNewArchitecture();
                }
            }
            else
            {
                _inputSignalSet[index] = signal;
                for (int i = 0; i < _outputSignalSet.Count; i++)
                {
                    if (_outputSignalSet[i] != null)
                    {
                        ((ISignal_CycleAnalysis)_inputSignalSet[index]).AddCycles(_outputSignalSet[i], Config.Random.Next());
                    }
                }
                if (_completelyConnected && _currentArchitecture != null && !_currentArchitecture.RebindToPortIfSupported(this))
                {
                    LookupAndLinkNewArchitecture();
                }
            }

            OnInputTreeChanged(index);
            Service <IMediator> .Instance.NotifySignalDrivesPort(signal, this, index);
        }
Beispiel #8
0
 protected void SenseSignal(MathNet.Symbolics.Signal signal)
 {
     signal.ValueChanged += signal_SignalValueChanged;
     sensitiveSignals.Add(signal);
 }
Beispiel #9
0
 /// <param name="origin">note: may be null if not applicable</param>
 protected abstract void Action(bool isInit, MathNet.Symbolics.Signal origin);
Beispiel #10
0
 protected void StopSenseSignal(MathNet.Symbolics.Signal signal)
 {
     signal.ValueChanged -= signal_SignalValueChanged;
     sensitiveSignals.Remove(signal);
 }
Beispiel #11
0
 public override bool DependsOn(MathNet.Symbolics.Signal signal)
 {
     return(Service <IScanner> .Instance.ExistsSignal(this, signal.Equals, true));
 }
Beispiel #12
0
 public override void ReplaceOutputSignalBinding(int index, MathNet.Symbolics.Signal replacement)
 {
     // TODO: could be optimized...
     RemoveOutputSignalBinding(index);
     AddOutputSignalBinding(index, replacement);
 }
Beispiel #13
0
 protected override MathNet.Symbolics.Signal DivideSignalCore(MathNet.Symbolics.Signal divisor)
 {
     return(Std.Divide(this, divisor));
 }
Beispiel #14
0
 protected override MathNet.Symbolics.Signal MultiplySignalCore(MathNet.Symbolics.Signal multiplier)
 {
     return(Std.Multiply(this, multiplier));
 }
Beispiel #15
0
 protected override MathNet.Symbolics.Signal SubtractSignalCore(MathNet.Symbolics.Signal subtrahend)
 {
     return(Std.Subtract(this, subtrahend));
 }
Beispiel #16
0
 protected override MathNet.Symbolics.Signal AddSignalCore(MathNet.Symbolics.Signal summand)
 {
     return(Std.Add(this, summand));
 }