GageStream2Disk第4次尝试 本篇内容:GageStream2Disk的函数和API详解(超长预警)

本文详细介绍了GageStream2Disk中涉及的CompuScope API,包括初始化系统、查询系统信息、配置系统参数等功能。通过对函数的逐个解析,揭示了如何与CompuScope硬件交互,以及在驱动和硬件配置过程中的关键步骤和注意事项。
摘要由CSDN通过智能技术生成

从GageStream2Disk的第一个函数开始按顺序讲解,函数之间用水平线分割 :

i32Status = CsInitialize();

初始化接口,返回参数=>1则为初始化成功,其他为失败。i32Status为检查状态的变量。


i32Status = CsGetSystem(&g_hSystem, 0, 0, 0, 0);

锁定并初始化 指定参数 找到的  CompuScope 系统。

此方法查找指定的 CompuScope 系统。如果存在,API 将检索 CompuScope 系统句柄,并为调用此 API 的进程保留对该句柄的唯一访问。必须在所有后续 CompuScope API 调用中使用返回的句柄来控制此系统。该方法搜索满足指定参数指定条件的 CompuScope 系统。任何指定参数都可以为零,在这种情况下,它们将被忽略为搜索条件。返回尚未与任何进程关联且满足指定条件的第一个 CompuScope 系统。在多个检索到的 CompuScope 系统满足搜索条件的情况下,选择具有指定 i16Index 参数的系统。 i16Index 值分配给与方法参数(如果有)指定的标准相匹配的 CompuScope 系统。 i16Index 标识的顺序在会话之间保留。但是,如果 CompuScope 卡在不同会话中插入不同的 PCI 插槽,则顺序可能会发生变化。找不到 CompuScope 系统的情况可能是因为该系统正被另一个进程使用或因为不正确的选择标准。 CompuScope Manager 可用于查看所有可用的 CompuScope 系统。

Parameters

hSystem : Handle of CompuScope system found by the method. A NULL value indicates that no system was found.
u32BoardType : CompuScope model
u32Channels : Number of channels in the CompuScope system
u32SampleBits : Resolution of the CompuScope system
i16Index : Index of CompuScope system to search for.

Returns

  • Positive value (>0) for success.
  • Negative value (<0) for error. Call CsGetErrorString with the error code to obtain a descriptive error string.

咱们继续顺着代码往下看函数:

if (CS_FAILED(i32Status))
	{
		DisplayErrorString(i32Status);
		return (-1);
	}

CS_FAILED是宏:

#define  CS_FAILED(x)   ((x)<0?TRUE:FALSE)
Macro for verifying an unsuccessful operation.

i32Status = CsGetSystemInfo(g_hSystem, &CsSysInfo);

Retrieves the static information about the CompuScope system

This method queries static or unchangeable information about the CompuScope system, such as sample resolution and memory size. To query for dynamic parameters settings the CsGet method should be used.

Parameters

hSystem : Handle of the CompuScope system to be addressed. Obtained from CsGetSystem
pSystemInfo : Pointer to the structure that will be filled with the CompuScope system information.

Returns

  • Positive value (>0) for success.
  • Negative value (<0) for error. Call CsGetErrorString with the error code to obtain a descriptive error string.

CsAs_ConfigureSystem(g_hSystem, (int)CsSysInfo.u32ChannelCount,
		(int)CalculateTriggerCountFromConfig(&CsSysInfo,(LPCTSTR)szIniFile),
		(LPCTSTR)szIniFile, &u32Mode);

功能:Configures the system by reading the ini file

目的:We are analysing the ini file to find the number of triggers

以下三个函数为完整运行上面这个函数而做的解释。 

CalculateTriggerCountFromConfig(CSSYSTEMINFO* pCsSysInfo, const LPCTSTR szIniFile)

下面两个函数是上面这个函数里面的。该函数最后的返回值是trigger count。

GetFullPathName(szIniFile, MAX_PATH, szFilePath, NULL);

功能:从一指定文件得到文件的路径。

LPCTSTR lpFileName, 指定文件的名字
DWORD nBufferLength,缓存区的大小
LPTSTR lpBuffer, 用于存放路径的缓存区
LPTSTR *lpFilePart 文件名的起始地址
返回值:
  如果调用成功 返回实际路径的长度
  如果缓冲区太小,不能装下文件完整路径的话 返回值就是缓冲区的值 所以我们一般都将缓存区大小设置得足够大
  调用失败 返回0 用GetLastError获得错误信息。


GetPrivateProfileSection(szTrigger, szString, 100, szFilePath);

功能:从指定的文件中取得全部的关键字的值。

参数类型及说明:
  lpAppName String,欲获取的小节。注意这个字串不区分大小写
  lpReturnedString String,项和值字串的列表。每个字串都由一个NULL字符分隔,最后一个字串后面用两个NULL字符中止
  nSize Long,lpReturnedString缓冲区的大小。在windows系统中最大值为32767
  lpFileName String,初始化文件的名字。如没有指定完整路径名,windows就在Windows目录中查找文件。


LoadStmConfiguration(szIniFile, &g_StreamConfig);

在该函数下,分为一下6个函数,按顺序执行:

GetFullPathName(szIniFile, MAX_PATH, szFilePath, NULL);

为一个指定的文件或目录返回文件系统的属性。如果函数成功,返回值包含文件或目录的属性。如果函数失败,返回值是INVALID_FILE_ATTRIBUTES。

GetPrivateProfileSection(STM_SECTION, szString, 100, szFilePath)

检索初始化文件指定节的所有键和值。

GetPrivateProfileInt(STM_SECTION, _T("SaveToFile"), nDummy, szFilePath)

检索与初始化文件的指定节中的键关联的整数。

UINT GetPrivateProfileInt(
  [in] LPCTSTR lpAppName,
  [in] LPCTSTR lpKeyName,
  [in] INT     nDefault,
  [in] LPCTSTR lpFileName
);

参数:

[in] lpAppName:

初始化文件中节的名称。

[in] lpKeyName:

要检索其值的键

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
01-13 2667
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值