public MccDeviceReader(Settings _settings)
        {
            settings = _settings;
            ISet<MccDaq.DigitalPortType> portsUsed = settings.getPortsUsed();
            tempBoard = new MccBoard(settings.TempBoardNumber);

            if (settings.TemperatureFormat == TemperatureFormatEnum.Farenheit)
            {
                tempScale = TempScale.Fahrenheit;
            }
            else
            {
                tempScale = TempScale.Celsius;
            }
            dioBoard = new MccBoard(settings.DIOBoardNumber);
            foreach (MccDaq.DigitalPortType portType in settings.getPortsUsed())
            {
                MccDaq.ErrorInfo ulStat = dioBoard.DConfigPort(portType, MccDaq.DigitalPortDirection.DigitalIn);
                if (ulStat.Value != ErrorInfo.ErrorCode.NoErrors)
                {
                    logger.Error("Error while configuring DIO Board : " + ulStat.Message);
                    throw new DeviceException("Error while configuring DIO Board : " + ulStat.Message);
                }
            }

            //    MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);
        }
예제 #2
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;
                    });
                }
            }));
        }
예제 #3
0
        public override IObservable <short> Process(IObservable <short> 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.DigitalOut);
                }
                else
                {
                    configError = board.DConfigPort(portType, DigitalPortDirection.DigitalOut);
                }
                ThrowExceptionForErrorInfo(configError);

                if (bitNumber.HasValue)
                {
                    return source.Do(input =>
                    {
                        var bitValue = input != 0 ? DigitalLogicState.High : DigitalLogicState.Low;
                        var error = board.DBitOut(portType, bitNumber.Value, bitValue);
                        ThrowExceptionForErrorInfo(error);
                    });
                }
                else
                {
                    return source.Do(dataValue =>
                    {
                        var error = board.DOut(portType, dataValue);
                        ThrowExceptionForErrorInfo(error);
                    });
                }
            }));
        }
예제 #4
0
 public void Initialize(IExecutable executableObject, SetupData setupData, XmlNode setupNode)
 {
     MccBoard board;
     int num = 0;
     this.m_boards = new MccBoard[GlobalConfig.NumBoards];
     this.m_boardPortType = new DigitalPortType[GlobalConfig.NumBoards];
     int index = 0;
     while (index < GlobalConfig.NumBoards)
     {
         board = new MccBoard(index);
         board.BoardConfig.GetBoardType(out num);
         if (num == 0)
         {
             break;
         }
         this.m_boards[index] = board;
         this.m_boardPortType[index] = (DigitalPortType)1;
         index++;
     }
     Array.Resize<MccBoard>(ref this.m_boards, index);
     Array.Resize<DigitalPortType>(ref this.m_boardPortType, index);
     this.m_hardwareMap = new VixenPlus.HardwareMap[index];
     int num3 = 0;
     int num6 = 0;
     Dictionary<string, int> dictionary = new Dictionary<string, int>();
     this.m_pinBoardIndex = new int[0];
     this.m_pinBoardOffset = new int[0];
     for (index = 0; index < this.m_boards.Length; index++)
     {
         Dictionary<string, int> dictionary2;
         string str;
         board = this.m_boards[index];
         if (!dictionary.ContainsKey(board.BoardName))
         {
             dictionary[board.BoardName] = 0;
         }
         this.m_hardwareMap[index] = new VixenPlus.HardwareMap(board.BoardName, dictionary[board.BoardName]);
         (dictionary2 = dictionary)[str = board.BoardName] = dictionary2[str] + 1;
         int pinCount = this.m_pinCount;
         board.BoardConfig.GetDiNumDevs(out num3);
         for (int i = 0; i < num3; i++)
         {
             int num5;
             board.DioConfig.GetDevType(i, out num5);
             if (num5 == 10)
             {
                 this.m_boardPortType[index] = (DigitalPortType)10;
             }
             board.DConfigPort((DigitalPortType) num5, DigitalPortDirection.DigitalOut);
             board.DioConfig.GetNumBits(i, out num6);
             Array.Resize<int>(ref this.m_pinBoardIndex, this.m_pinBoardIndex.Length + num6);
             Array.Resize<int>(ref this.m_pinBoardOffset, this.m_pinBoardOffset.Length + num6);
             for (int j = 0; j < num6; j++)
             {
                 this.m_pinBoardIndex[j + this.m_pinCount] = index;
                 this.m_pinBoardOffset[j + this.m_pinCount] = (this.m_pinCount + j) - pinCount;
             }
             this.m_pinCount += num6;
         }
     }
 }
예제 #5
0
        public void Initialize(IExecutable executableObject, SetupData setupData, XmlNode setupNode)
        {
            MccBoard board;
            int      num = 0;

            this.m_boards        = new MccBoard[GlobalConfig.NumBoards];
            this.m_boardPortType = new DigitalPortType[GlobalConfig.NumBoards];
            int index = 0;

            while (index < GlobalConfig.NumBoards)
            {
                board = new MccBoard(index);
                board.BoardConfig.GetBoardType(out num);
                if (num == 0)
                {
                    break;
                }
                this.m_boards[index]        = board;
                this.m_boardPortType[index] = (DigitalPortType)1;
                index++;
            }
            Array.Resize <MccBoard>(ref this.m_boards, index);
            Array.Resize <DigitalPortType>(ref this.m_boardPortType, index);
            this.m_hardwareMap = new VixenPlus.HardwareMap[index];
            int num3 = 0;
            int num6 = 0;
            Dictionary <string, int> dictionary = new Dictionary <string, int>();

            this.m_pinBoardIndex  = new int[0];
            this.m_pinBoardOffset = new int[0];
            for (index = 0; index < this.m_boards.Length; index++)
            {
                Dictionary <string, int> dictionary2;
                string str;
                board = this.m_boards[index];
                if (!dictionary.ContainsKey(board.BoardName))
                {
                    dictionary[board.BoardName] = 0;
                }
                this.m_hardwareMap[index] = new VixenPlus.HardwareMap(board.BoardName, dictionary[board.BoardName]);
                (dictionary2 = dictionary)[str = board.BoardName] = dictionary2[str] + 1;
                int pinCount = this.m_pinCount;
                board.BoardConfig.GetDiNumDevs(out num3);
                for (int i = 0; i < num3; i++)
                {
                    int num5;
                    board.DioConfig.GetDevType(i, out num5);
                    if (num5 == 10)
                    {
                        this.m_boardPortType[index] = (DigitalPortType)10;
                    }
                    board.DConfigPort((DigitalPortType)num5, DigitalPortDirection.DigitalOut);
                    board.DioConfig.GetNumBits(i, out num6);
                    Array.Resize <int>(ref this.m_pinBoardIndex, this.m_pinBoardIndex.Length + num6);
                    Array.Resize <int>(ref this.m_pinBoardOffset, this.m_pinBoardOffset.Length + num6);
                    for (int j = 0; j < num6; j++)
                    {
                        this.m_pinBoardIndex[j + this.m_pinCount]  = index;
                        this.m_pinBoardOffset[j + this.m_pinCount] = (this.m_pinCount + j) - pinCount;
                    }
                    this.m_pinCount += num6;
                }
            }
        }