예제 #1
0
        /// <summary>
        /// 按位输出信号
        /// </summary>
        /// <param name="nIndex"></param>
        /// <param name="bBit"></param>
        /// <returns></returns>
        public override bool WriteIoBit(int nIndex, bool bBit)
        {
            if (!m_bOpen)
            {
                return(false);
            }
            short ret;
            uint  int_value;
            int   num = DASK.DO_ReadPort((ushort)m_dev, 0, out int_value);

            if (num != 0)
            {
                return(false);
            }
            uint result = 0;

            if (bBit)
            {
                result = int_value | (uint)(1 << nIndex);
            }
            else
            {
                result = int_value &= ~(uint)(1 << nIndex);
            }
            ret = DASK.DO_WritePort((ushort)m_dev, 0, result);
            if (ret < 0)
            {
                return(false);//获取失败
            }
            return(true);
        }
예제 #2
0
        /// <summary>
        ///释放IO卡
        /// </summary>
        public override void DeInit()
        {
            short ret;

            if (m_dev >= 0)
            {
                ret = DASK.Release_Card((ushort)m_dev);
            }
        }
예제 #3
0
 public override bool Init()
 {
     m_bOpen = false;
     m_dev   = DASK.Register_Card(DASK.PCI_7230, (ushort)m_nCardNo);
     if (m_dev == 0)
     {
         m_bOpen = true;
     }
     return(m_bOpen);
 }
예제 #4
0
        /// <summary>
        ///按位获取输入信号
        /// </summary>
        /// <param name="nIndex"></param>
        /// <returns></returns>
        public override bool ReadIoInBit(int nIndex)
        {
            if (!m_bOpen)
            {
                return(false);
            }
            short ret;
            uint  int_value;

            ret = DASK.DI_ReadPort((ushort)m_dev, 0, out int_value);
            if (ret < 0)
            {
                return(false);//获取失败
            }
            if ((int_value & (1 << nIndex)) == 0L)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }