private void WriteInternal(BusData value) { Value = value; if (IsConnected) { _bus.OnMasterValueChanged(this); } }
private bool AreMultipleMastersActive(BusMaster currentMaster) { var floating = new BusData(BusWidth); return(_masters .Where(m => !m.Value.Equals(floating)) .Except(new[] { currentMaster }) .Any()); }
public void Write(BusData value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } ThrowIfNotEnabled(); WriteInternal(value); }
private void ApplyValue(BusData value) { int index = 0; foreach (var level in value.Signals) { _signals[index].Level = level; index++; } }
internal void OnMasterValueChanged(BusMaster busMaster) { ThrowIfMultipleMastersAreActive(busMaster); var value = busMaster.Value; if (!Value.Equals(value)) { _value = value; ApplyValue(value); NotifyChange(busMaster); } }
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(); }
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]; } }
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); }
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(); }
public BusChangedEventArgs(BusMaster busMaster, BusData value) { BusMaster = busMaster; Value = value; }