public int ReadInput() { short value = 0; _ulStatErrorInfo = _board.DIn(_channelType, out value); if (_ulStatErrorInfo.Value == ErrorInfo.ErrorCode.NoErrors) { if (value != 255) { if (_pulseIsCleared) { _pulseIsCleared = false; return(1); } } else { _pulseIsCleared = true; } } else { if (_ulStatErrorInfo.Value != ErrorInfo.ErrorCode.BadBoard) { _log.Warn("DAQ Input error: {0}", _ulStatErrorInfo.Message); } } return(0); }
public override IObservable <short> Process <TSource>(IObservable <TSource> source) { return(Observable.Defer(() => { ErrorInfo configError; var portType = PortType; var bitNumber = BitNumber; var board = new MccBoard(BoardNumber); if (bitNumber.HasValue) { configError = board.DConfigBit(portType, bitNumber.Value, DigitalPortDirection.DigitalIn); } else { configError = board.DConfigPort(portType, DigitalPortDirection.DigitalIn); } ThrowExceptionForErrorInfo(configError); if (bitNumber.HasValue) { return source.Select(input => { var error = board.DBitIn(portType, bitNumber.Value, out DigitalLogicState bitValue); ThrowExceptionForErrorInfo(error); return (short)bitValue; }); } else { return source.Select(input => { var error = board.DIn(portType, out short dataValue); ThrowExceptionForErrorInfo(error); return dataValue; }); } })); }