Пример #1
0
 private void ThrowIfNotOurs(DigitalSignalProvider provider)
 {
     if (!_providers.Contains(provider))
     {
         throw new ArgumentException("Specified Provider is not connected to this DigitalSignal.", nameof(provider));
     }
 }
Пример #2
0
 private bool AreMultipleProvidersActive(DigitalSignalProvider changeProvider)
 {
     return(_providers
            .Where(p => p.Level != DigitalLevel.Floating)
            .Except(new[] { changeProvider })
            .Any());
 }
Пример #3
0
 private void ThrowIfMultipleProvidersActive(DigitalSignalProvider changeProvider)
 {
     if (AreMultipleProvidersActive(changeProvider))
     {
         throw new DigitalSignalConflictException("Multiple DigitalSignalProviders are active on: " + Name);
     }
 }
Пример #4
0
        internal void Attach(DigitalSignalProvider provider)
        {
            if (_providers.Contains(provider))
            {
                throw new ArgumentException(
                          "Specified Provider is already connected.", nameof(provider));
            }

            _providers.Add(provider);
        }
Пример #5
0
        internal void OnNewProviderValue(DigitalSignalProvider provider)
        {
            ThrowIfNotOurs(provider);
            ThrowIfMultipleProvidersActive(provider);

            if (Level != provider.Level)
            {
                _level = provider.Level;
                NotifyOnChanged(provider);
            }
        }
Пример #6
0
        internal void OnNewProviderValue(DigitalSignalProvider provider)
        {
            if (!_providers.Contains(provider))
            {
                throw new ArgumentException("Specified Provider is not connected to this DigitalSignal.", nameof(provider));
            }

            ThrowIfMultipleProvidersActive(provider);
            if (Level != provider.Level)
            {
                _level = provider.Level;
                NotifyOnChanged(provider);
            }
        }
Пример #7
0
 private void NotifyOnChanged(DigitalSignalProvider provider)
 {
     OnChanged?.Invoke(this, new DigitalLevelChangedEventArgs(provider, Level));
 }
Пример #8
0
 public DigitalLevelChangedEventArgs(DigitalSignalProvider provider, DigitalLevel level)
 {
     Provider = provider;
     Level    = level;
 }