コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="channel"></param>
        /// <returns></returns>
        public double Read(int channel)
        {
            double value;

            if (!IsInit)
            {
                // Модуль не инициализирован
                throw new Exception <Pci1747UExceptionArgs>(new Pci1747UExceptionArgs(0),
                                                            "The object of card PCI1747U is not initialized");
            }
            if (channel < 0 || channel >= ChannelCountMax)
            {
                // Номер канала задан неверно
                throw new Exception <Pci1747UExceptionArgs>(new Pci1747UExceptionArgs(0),
                                                            "The channel of card PCI1747U is not valid");
            }
            InstantAiContrl.Channels[channel].ValueRange = DefaultValueRange;
            var error_code = InstantAiContrl.Read(channel, out value);

            if (ErrorCode.Success != error_code)
            {
                // Возникла ошибка
                throw new Exception <Pci1747UExceptionArgs>(new Pci1747UExceptionArgs(0),
                                                            $"Ошибка чтения данных из канала {channel:D} интерфейсной платы PCI-1747U - {error_code}");
            }
            return(value);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="channel"></param>
        /// <returns></returns>
        public double Read(int channel)
        {
            double value;

            if (!IsInit)
            {
                throw new Exception <Pci1716ExceptionArgs>(new Pci1716ExceptionArgs(0),
                                                           "The object of card Pci1716 is not initialized");
            }
            if (channel < 0 || channel >= ChannelCountMax)
            {
                throw new Exception <Pci1716ExceptionArgs>(new Pci1716ExceptionArgs(0),
                                                           $"The channel {channel} of card Pci1716 is not valid");
            }
            InstantAiContrl.Channels[channel].ValueRange = DefaultValueRange;
            var error_code = InstantAiContrl.Read(channel, out value);

            if (error_code != ErrorCode.Success)
            {
                // Возникла ошибка
                throw new Exception <Pci1716ExceptionArgs>(new Pci1716ExceptionArgs(0),
                                                           $"Ошибка чтения данных из канала {channel} интерфейсной платы PCI-1716 - {error_code}");
            }
            return(value);
        }