/// <summary> /// Closes the given pin /// </summary> /// <param name="pin">The pin to close</param> public virtual void ClosePin(AnalogInputPin pin) { if (_openPins.Remove(pin)) { // This may fire back, therefore the test above pin.Dispose(); } }
/// <summary> /// Opens a pin in order for it to be ready to use. /// </summary> /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param> public AnalogInputPin OpenPin(int pinNumber) { // This does the number conversion itself, therefore done first if (!SupportsAnalogInput(pinNumber)) { throw new NotSupportedException($"Pin {pinNumber} is not supporting analog input."); } int logicalPinNumber = ConvertPinNumberToLogicalNumberingScheme(pinNumber); if (_openPins.Any(x => x.PinNumber == pinNumber)) { throw new InvalidOperationException("The selected pin is already open."); } AnalogInputPin openPin = OpenPinCore(logicalPinNumber); _openPins.Add(openPin); return(openPin); }