Exemplo n.º 1
0
        private void WriteInternal(BusData value)
        {
            Value = value;

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

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

            WriteInternal(value);
        }
Exemplo n.º 4
0
        private void ApplyValue(BusData value)
        {
            int index = 0;

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

            if (!Value.Equals(value))
            {
                _value = value;
                ApplyValue(value);
                NotifyChange(busMaster);
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 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];
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 10
0
 public BusChangedEventArgs(BusMaster busMaster, BusData value)
 {
     BusMaster = busMaster;
     Value     = value;
 }