Example #1
0
        private void WriteInternal(BusData value)
        {
            Value = value;

            if (IsConnected)
            {
                _bus.OnMasterValueChanged(this);
            }
        }
Example #2
0
        private bool AreMultipleMastersActive(BusMaster currentMaster)
        {
            var floating = new BusData(BusWidth);

            return(_masters
                   .Where(m => !m.Value.Equals(floating))
                   .Except(new[] { currentMaster })
                   .Any());
        }
Example #3
0
        public void Write(BusData value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            ThrowIfNotEnabled();

            WriteInternal(value);
        }
Example #4
0
        private void ApplyValue(BusData value)
        {
            int index = 0;

            foreach (var level in value.Signals)
            {
                _signals[index].Level = level;
                index++;
            }
        }
Example #5
0
        internal void OnMasterValueChanged(BusMaster busMaster)
        {
            ThrowIfMultipleMastersAreActive(busMaster);
            var value = busMaster.Value;

            if (!Value.Equals(value))
            {
                _value = value;
                ApplyValue(value);
                NotifyChange(busMaster);
            }
        }
Example #6
0
        public void ConnectToByIndex(Bus bus, params int[] indexes)
        {
            ThrowIfBusWidthIsTooSmall(bus);

            SourceBus = bus;

            SignalList.Clear();
            foreach (var index in indexes)
            {
                SignalList.Add(SignalList[index]);
            }

            _prevValue = ValueFromSignals();
        }
Example #7
0
        protected void ApplyValue(BusData value)
        {
            //int index = 0;
            //foreach (var level in value.Signals)
            //{
            //    _signals[index].Level = level;
            //    index++;
            //}

            for (int i = 0; i < value.Width; i++)
            {
                _signals[i].Level = value[i];
            }
        }
Example #8
0
        public bool Equals(BusData that)
        {
            if (this.Width != that.Width)
            {
                return(false);
            }

            for (int i = 0; i < Width; i++)
            {
                if (this._signals[i] != that._signals[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Example #9
0
        public void ConnectTo(Bus bus, int offset = 0, int count = 0)
        {
            ThrowIfBusWidthIsTooSmall(bus);

            SourceBus = bus;

            if (count == 0)
            {
                count = BusWidth;
            }

            SignalList.Clear();
            var signals = bus.Signals.Skip(offset).Take(count);

            foreach (var signal in signals)
            {
                SignalList.Add(signal);
            }

            _prevValue = ValueFromSignals();
        }
Example #10
0
 public BusChangedEventArgs(BusMaster busMaster, BusData value)
 {
     BusMaster = busMaster;
     Value     = value;
 }