Esempio n. 1
0
        //研华输入卡PCI1750刷新输入
        /// <summary>
        /// 研华输入卡PCI1750刷新输入
        /// </summary>
        /// <returns>返回输入信号数组【数组长度64】:true - ON; false - OFF</returns>
        public bool[] GetInputStatus()
        {
            //initial the return value
            for (int a = 0; a < 16; a++)
            {
                ReadInStatus[a] = false;
            }

            if (SuccessBuiltNew == false)
            {
                ErrorMessage = "未成功建立类的新实例,无法开启线程进行输入信号扫描";
                return(ReadInStatus);
            }

            try
            {
                for (int Port = 0; Port <= 7; Port++)
                {
                    TargetDIOCard.DiRead(Port, out InPortData);

                    for (int Bit = 0; Bit <= 7; Bit++)
                    {
                        ReadInStatus[Port * 8 + Bit] = ((InPortData >> Bit) == 1) ? true : false;
                    }
                }

                return(ReadInStatus);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return(ReadInStatus);
            }
        }
Esempio n. 2
0
        public void GetAllIOStatus()
        {
            ErrorCode ret;

            lock (lockObj)
            {
                ret = m_dio.DiRead(0, 8, portData);
            }
            string strTest;

            for (int i = 0; i < 8; i++)
            {
                strTest = Convert.ToString(portData[i], 2);
                strTest = strTest.PadLeft(8, '0');
                for (int j = 0; j < 8; j++)
                {
                    if (strTest[7 - j] == '1')
                    {
                        bBitInputStatus[i * 8 + j] = true;
                    }
                    else
                    {
                        bBitInputStatus[i * 8 + j] = false;
                    }
                }
            }
        }
Esempio n. 3
0
        //研华输入卡PCI1754刷新输入
        /// <summary>
        /// 研华输入卡PCI1754刷新输入
        /// </summary>
        /// <returns>返回输入信号数组【数组长度64】:true - ON; false - OFF</returns>
        public bool[] GetInputStatus()
        {
            //initial the return value
            for (int a = 0; a < 64; a++)
            {
                ReadInStatus[a] = false;
            }

            if (SuccessBuiltNew == false)
            {
                //MessageBox.Show("未成功建立类的新实例,无法开启线程进行输入信号扫描");
                ErrorMessage = "未成功建立类的新实例,无法开启线程进行输入信号扫描";
                return(ReadInStatus);
            }

            try
            {
                for (int Port = 0; Port <= 7; Port++)
                {
                    if (NeedFormControlFlag == true)
                    {
                        TargetPCI1754Card.Read(Port, out PortData);
                    }
                    else
                    {
                        TargetDICard.DiRead(Port, out PortData);
                    }
                    for (int Bit = 0; Bit <= 7; Bit++)
                    {
                        ReadInStatus[Port * 8 + Bit] = ((PortData >> Bit) == 1) ? true : false;
                    }
                }

                return(ReadInStatus);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return(ReadInStatus);
            }
        }