• 大小: 4KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-11
  • 语言: C#
  • 标签: PCI1716  接口  c$  

资源简介

c#访问研华PCI1716 代码程序,通过线程读取PCI板卡 A/D数据转换结果

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace BogieTest
{
    public  partial class Ads1716
    {
        private Int32 _DriverHandle;

        public unsafe static string DRV_GetErrorMessage(Int32 ErrorCode)
        {
            byte[] buff = new byte[200];
            string f;
            fixed (byte* p = buff)
            {
                DRV_GetErrorMessage(ErrorCode ref  buff[0]);
                f = Marshal.PtrToStringAnsi((IntPtr)(p));
            }
            return f;
        }
       
        unsafe static public int DRV_SelectDevice(IntPtr hCaller bool GetModule ref   Int32 DeviceNum out string Description)
        {
            byte[] dec = new byte[200];
            int r;
            fixed (byte* p = dec)
            {
                r = DRV_SelectDevice(hCaller false ref DeviceNum ref dec[0]);
                if (r == 0)
                    Description = Marshal.PtrToStringAnsi((IntPtr)(p));
                else
                    Description = null;
            }
            return r;
        }

        unsafe public string DRV_DeviceOpen()
        {
            int dwErrCdei;

            PT_AIConfig ptAIConfig = new PT_AIConfig();
            try
            {
                dwErrCde = Ads1716.DRV_DeviceOpen(0 ref _DriverHandle);
                if (dwErrCde != 0)
                {
                    return ““;
                }
                else
                {
                    DRV_MAIConfig();
                }
                //配置增益

                return ““;
            }
            catch (System.Exception ex)
            {
                return ex.Message.ToString();
            }
            return ““;
        }
        unsafe public string DRV_DeviceClose()
        {
            try
            {
                int result = Ads1716.DRV_DeviceClose(ref _DriverHandle);
                if (result == 0)
                {
                    return ““;
                }
                return DRV_GetErrorMessage(result);
            }
            catch (System.Exception ex)
            {
                return ex.Message.ToString();
            }
            return ““;
        }

        unsafe public string DRV_AIVoltageIn(ushort chanref float data)
        {
            PT_AIVoltageIn ptAIVoltageIn = new PT_AIVoltageIn();
            IntPtr pVoltage= Marshal.AllocHGlobal(sizeof(float));//为输入模拟电压指针分配内存,其大小为一个float型变量的大小。;
            float[] fVoltage = new float[1];  
            try
            {
                ptAIVoltageIn.chan = chan;
                ptAIVoltageIn.gain = 16;
                ptAIVoltageIn.TrigMode = 0;
                ptAIVoltageIn.voltage = pVoltage;

                PT_AIConfig ptAIConfig = new PT_AIConfig();
                ptAIConfig.DasChan = chan;                                //设置通道
                ptAIConf

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       7036  2011-12-20 07:41  Ads1716Sample.cs

     文件       7219  2011-12-16 14:26  Ads1716Api.cs

     文件       2689  2011-12-16 10:39  Ads1716H.cs

----------- ---------  ---------- -----  ----

                16944                    3


评论

共有 条评论