commit cf7036731357bea2e099627469b194fe9cd5be03 Author: zhengsl Date: Tue Jun 30 12:10:29 2026 +0800 Initial commit: SSPC Dynamic Test System diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..43304b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# ===== .NET ===== +**/bin/ +**/obj/ +*.user +*.suo +*.userosscache +*.sln.docstates +*.userprefs + +# ===== Visual Studio ===== +.vs/ +*.rsuser +[Dd]ebug/ +[Rr]elease/ +x64/ +x86/ + +# ===== Publish & Build Output ===== +publish/ + +# ===== NuGet ===== +*.nupkg +**/packages/* +!**/packages/build/ +*.nuget.props +*.nuget.targets + +# ===== IDE & Editors ===== +.idea/ +*.swp +*~ +.vscode/ +*.code-workspace + +# ===== Environment & Secrets ===== +.env +.env.* +*.local.json +settings.local.json + +# ===== OS ===== +.DS_Store +Thumbs.db +Desktop.ini + +# ===== Logs ===== +logs/ +*.log +serilog/ + +# ===== Test Results ===== +TestResults/ +*.trx +*.coverage +*.coveragexml + +# ===== Runtime Data (user config stored in %LOCALAPPDATA%) ===== +SSPCTester.UI/settings.json + +# ===== Driver DLLs (厂商提供,不纳入版本) ===== +**/ACTS1000_64.dll +**/ACTS1000*.dll +**/ACTS1000*.lib +**/ACTS1000*.h diff --git a/Docs/Modbus接口规范/Modbus接口规范.md b/Docs/Modbus接口规范/Modbus接口规范.md new file mode 100644 index 0000000..08e4a77 --- /dev/null +++ b/Docs/Modbus接口规范/Modbus接口规范.md @@ -0,0 +1,251 @@ +# Modbus 接口规范 + +## 1. 文档用途 + +本文档用于指导主项目接入已完成现场实测的 24 路继电器、电压采集和电流采集设备。 + +配套文件: + +- `device-profile.json`:设备协议与通道映射的唯一权威配置。 +- `appsettings.Modbus.example.json`:主项目默认配置字段示例。 +- `接入验收清单.md`:开发完成后的测试和验收要求。 + +主项目实现时必须读取配置,不得在业务代码中硬编码从站地址、线圈、寄存器、量程、公式或通道映射。 + +## 2. 实测资料与结论 + +本规范依据以下现场结果整理: + +- `结果_Modbus-接口-电流-电压对应表.txt`:逐个物理插位手动测量得到的采集页通道对应关系。 +- `结果_modbus-tuner-20260618-131814.json`:调试程序于 2026-06-18 导出的已调通通讯参数。 + +编号含义必须严格区分: + +| 名称 | 含义 | +|---|---| +| `physicalSlot` | 机器上的物理接口位置,也是主项目业务层唯一使用的通道号,范围 1~24 | +| `relayChannel` | 调试程序继电器控制页按钮号;实测与物理插位一致 | +| `sourceDisplayChannel` | 调试程序采集页面上出现读数的通道号,仅保留作实测追溯 | +| `registerOffset` | 在本次 24 寄存器回包数据区中的零基位置,主项目实际解析使用 | + +主项目不得把 `sourceDisplayChannel` 当作物理插位,也不得直接用它计算字节偏移。 + +## 3. 总线与串口参数 + +所有模块共用一条 RS485 总线。 + +| 参数 | 实测值 | +|---|---| +| 协议 | Modbus RTU | +| 波特率 | 9600 | +| 数据位 | 8 | +| 校验 | None | +| 停止位 | 1 | +| 读取超时 | 500 ms | +| 失败重试 | 2 次 | +| CRC | CRC16-Modbus | +| CRC 字节序 | 低字节在前 | +| 地址、数量和寄存器数据 | 高字节在前 | + +现场调试使用过 `COM9`,但 COM 号属于计算机本地设置。主项目应允许用户选择和保存,不得把 `COM9` 固定为设备协议的一部分。 + +同一串口的请求必须串行执行。不得让继电器写入、电压读取和电流读取同时向串口写帧。 + +## 4. 模块地址 + +| 模块 | 从站地址 | +|---|---:| +| 继电器板 1,负责物理插位 1~8 | 1 | +| 继电器板 2,负责物理插位 9~16 | 2 | +| 继电器板 3,负责物理插位 17~24 | 3 | +| 24 路电压采集模块 | 4 | +| 24 路电流采集模块 | 5 | + +## 5. 继电器控制 + +使用功能码 `0x05` 写单个线圈。 + +- 开:`0xFF00` +- 关:`0x0000` +- 正常响应应回显请求中的从站、功能码、线圈地址和值。 +- 响应必须检查长度、从站、功能码、回显内容和 CRC。 + +主项目业务接口建议: + +```text +SetRelayAsync(int physicalSlot, bool isOn) +``` + +处理流程: + +1. 校验 `physicalSlot` 为 1~24。 +2. 从 `device-profile.json` 的 `channels` 查找该物理插位。 +3. 取得 `relay.slave` 和 `relay.coil`。 +4. 构造并发送 `0x05` 帧。 +5. 验证回显后才更新业务状态。 + +不要在未确认当前硬件是否允许的情况下自动全开 24 路。 + +## 6. 电压采集 + +实测配置: + +| 参数 | 值 | +|---|---| +| 从站 | 4 | +| 功能码 | `0x03` | +| 起始寄存器 | 0 | +| 寄存器数量 | 24 | +| 量程 | 100 V | +| 解析公式 | B | +| 公式 | `实际电压 = DATA / 100` | +| DATA 类型 | `UInt16` | +| 每通道字节数 | 2 | +| 数据字节序 | Big-Endian | + +请求主体: + +```text +04 03 00 00 00 18 +``` + +追加 CRC16-Modbus 后发送。正常响应共 53 字节: + +```text +[从站1][功能码1][字节数0x30][48字节数据][CRC2] +``` + +## 7. 电流采集 + +实测配置: + +| 参数 | 值 | +|---|---| +| 从站 | 5 | +| 功能码 | `0x03` | +| 起始寄存器 | 0 | +| 寄存器数量 | 24 | +| 量程 | 60 A | +| 解析公式 | A | +| 公式 | `实际电流 = DATA / 10000 × 60` | +| DATA 类型 | `Int16` | +| 每通道字节数 | 2 | +| 数据字节序 | Big-Endian | + +请求主体: + +```text +05 03 00 00 00 18 +``` + +这里的“带符号”按现场导出配置解释为:读取寄存器 0~23,并将每个 16 位原始值按二进制补码转换为 `Int16`。主项目不得自行把起始寄存器改成 24,也不得在映射地址上额外加 24。如后续更换硬件或重新标定,应修改配置版本并重新验收。 + +## 8. 采集回包解析 + +电压和电流共用以下流程: + +1. 检查响应最小长度。 +2. 检查响应从站等于配置从站。 +3. 检查功能码。若最高位为 1,按 Modbus 异常响应处理。 +4. 检查字节数为 `registerCount × registerBytes`,当前应为 48。 +5. 验证 CRC16-Modbus。 +6. 对每个物理插位读取对应的 `registerOffset`。 +7. 字节位置为: + +```text +position = dataStartOffset + registerOffset × channelBytes +``` + +当前 `dataStartOffset=3`,`channelBytes=2`。 + +8. 按 Big-Endian 合成原始 16 位值。 +9. 根据 `signed` 转换为 `UInt16` 或 `Int16`。 +10. 根据 `formula` 和 `range` 换算工程值。 + +公式定义: + +```text +A: value = DATA / 10000.0 × range +B: value = DATA / range +``` + +## 9. 统一业务接口 + +主项目业务层只允许使用物理插位 1~24,建议公开以下抽象: + +```text +ConnectAsync() +DisconnectAsync() +SetRelayAsync(int physicalSlot, bool isOn) +ReadAllVoltagesAsync() +ReadAllCurrentsAsync() +ReadMeasurementsAsync() +``` + +一次测量结果建议包含: + +```text +PhysicalSlot +Voltage +Current +VoltageRaw +CurrentRaw +Timestamp +VoltageQuality +CurrentQuality +``` + +`ReadMeasurementsAsync()` 应分别完成一次电压整帧读取和一次电流整帧读取,再按 `physicalSlot` 合并。不要为每个物理插位单独读取一次寄存器;每种采集模块一次读取 24 个寄存器即可。 + +## 10. 配置加载与校验 + +程序启动时必须校验: + +- `schemaVersion` 是程序支持的版本。 +- 物理插位恰好覆盖 1~24,不重复、不缺失。 +- 继电器从站和线圈组合不重复。 +- 电压、电流的 `registerOffset` 均在 `0~registerCount-1`。 +- 每类采集映射不得出现重复的 `registerOffset`。 +- 从站地址范围为 1~247。 +- `registerBytes=2`、`channelBytes=2`。 +- 公式只能是 `A` 或 `B`。 +- 字节序和 CRC 类型为程序支持值。 + +配置错误时应阻止通讯并给出具体字段,不要静默使用代码默认值。 + +## 11. 超时、重试和线程规则 + +- 一次请求从发送到收到完整响应视为一个事务。 +- 失败后最多重试配置中的次数;当前为 2 次,即最多发送 3 次。 +- CRC 错误、响应超时、从站错误、功能码错误和响应长度错误都应记录原始 HEX。 +- 重试前应清理串口输入缓冲区,避免残帧与下一帧拼接。 +- 串口操作使用互斥锁或单消费者队列串行化。 +- 断开和应用退出时安全关闭串口。 + +## 12. 主项目配置建议 + +建议将机器本地参数放在主项目配置,将设备协议和映射放在独立配置: + +```text +主项目配置 +└─ Modbus + ├─ Enabled + ├─ PortName + ├─ DeviceProfilePath + └─ PollIntervalMs + +device-profile.json +├─ 串口通讯默认参数 +├─ Modbus 帧规则 +├─ 模块协议 +└─ 24 路权威映射 +``` + +`device-profile.json` 应随主程序发布并复制到输出目录。主项目可以提供配置界面修改 COM 口,但协议和通道映射只应由经过授权的维护流程更新。 + +## 13. AI 编程强制要求 + +将本目录交给主项目 AI 时,应附加以下要求: + +> 严格按《Modbus接口规范.md》和 `device-profile.json` 实现。业务层统一使用 `physicalSlot` 1~24。所有从站、线圈、寄存器、量程、公式及映射从配置读取,不得硬编码。`sourceDisplayChannel` 仅用于追溯现场实测,不参与解析寻址。实现配置启动校验、串口事务串行化、CRC及响应完整校验,并按《接入验收清单.md》完成测试。 + diff --git a/Docs/Modbus接口规范/appsettings.Modbus.example.json b/Docs/Modbus接口规范/appsettings.Modbus.example.json new file mode 100644 index 0000000..7dcbbca --- /dev/null +++ b/Docs/Modbus接口规范/appsettings.Modbus.example.json @@ -0,0 +1,11 @@ +{ + "Modbus": { + "Enabled": true, + "PortName": "", + "DeviceProfilePath": "Config/device-profile.json", + "PollIntervalMs": 1000, + "AutoConnect": false, + "CloseAllRelaysOnDisconnect": false, + "LogRawFrames": true + } +} diff --git a/Docs/Modbus接口规范/device-profile.json b/Docs/Modbus接口规范/device-profile.json new file mode 100644 index 0000000..a26ac14 --- /dev/null +++ b/Docs/Modbus接口规范/device-profile.json @@ -0,0 +1,85 @@ +{ + "schemaVersion": "1.0", + "profileId": "spc-dynatest-modbus-24ch", + "profileName": "SPC-DynaTest 24路实测设备配置", + "source": { + "type": "fieldMeasurement", + "measuredMappingFile": "结果_Modbus-接口-电流-电压对应表.txt", + "tunerExportFile": "结果_modbus-tuner-20260618-131814.json", + "tunerExportedAt": "2026-06-18T13:18:22.4296268+08:00" + }, + "serialDefaults": { + "baudRate": 9600, + "dataBits": 8, + "parity": "None", + "stopBits": 1, + "readTimeoutMs": 500, + "retry": 2, + "protocol": "ModbusRTU" + }, + "frame": { + "registerBytes": 2, + "dataByteOrder": "BigEndian", + "crc": "CRC16Modbus", + "crcByteOrder": "LittleEndian" + }, + "relay": { + "functionCodeWrite": 5, + "onValue": "0xFF00", + "offValue": "0x0000", + "verifyEchoResponse": true + }, + "voltage": { + "slave": 4, + "functionCodeRead": 3, + "startRegister": 0, + "registerCount": 24, + "range": 100.0, + "unit": "V", + "formula": "B", + "signed": false, + "dataStartOffset": 3, + "channelBytes": 2, + "dataByteOrder": "BigEndian" + }, + "current": { + "slave": 5, + "functionCodeRead": 3, + "startRegister": 0, + "registerCount": 24, + "range": 60.0, + "unit": "A", + "formula": "A", + "signed": true, + "dataStartOffset": 3, + "channelBytes": 2, + "dataByteOrder": "BigEndian", + "signedInterpretation": "Int16TwosComplement" + }, + "channels": [ + { "physicalSlot": 1, "relay": { "slave": 1, "coil": 7 }, "voltage": { "sourceDisplayChannel": 8, "registerOffset": 0 }, "current": { "sourceDisplayChannel": 8, "registerOffset": 4 } }, + { "physicalSlot": 2, "relay": { "slave": 1, "coil": 6 }, "voltage": { "sourceDisplayChannel": 7, "registerOffset": 1 }, "current": { "sourceDisplayChannel": 7, "registerOffset": 19 } }, + { "physicalSlot": 3, "relay": { "slave": 1, "coil": 5 }, "voltage": { "sourceDisplayChannel": 6, "registerOffset": 2 }, "current": { "sourceDisplayChannel": 6, "registerOffset": 5 } }, + { "physicalSlot": 4, "relay": { "slave": 1, "coil": 4 }, "voltage": { "sourceDisplayChannel": 5, "registerOffset": 3 }, "current": { "sourceDisplayChannel": 5, "registerOffset": 18 } }, + { "physicalSlot": 5, "relay": { "slave": 1, "coil": 3 }, "voltage": { "sourceDisplayChannel": 4, "registerOffset": 4 }, "current": { "sourceDisplayChannel": 4, "registerOffset": 6 } }, + { "physicalSlot": 6, "relay": { "slave": 1, "coil": 2 }, "voltage": { "sourceDisplayChannel": 3, "registerOffset": 5 }, "current": { "sourceDisplayChannel": 3, "registerOffset": 17 } }, + { "physicalSlot": 7, "relay": { "slave": 1, "coil": 1 }, "voltage": { "sourceDisplayChannel": 2, "registerOffset": 6 }, "current": { "sourceDisplayChannel": 2, "registerOffset": 7 } }, + { "physicalSlot": 8, "relay": { "slave": 1, "coil": 0 }, "voltage": { "sourceDisplayChannel": 1, "registerOffset": 7 }, "current": { "sourceDisplayChannel": 1, "registerOffset": 16 } }, + { "physicalSlot": 9, "relay": { "slave": 2, "coil": 7 }, "voltage": { "sourceDisplayChannel": 16, "registerOffset": 8 }, "current": { "sourceDisplayChannel": 16, "registerOffset": 0 } }, + { "physicalSlot": 10, "relay": { "slave": 2, "coil": 6 }, "voltage": { "sourceDisplayChannel": 15, "registerOffset": 9 }, "current": { "sourceDisplayChannel": 15, "registerOffset": 23 } }, + { "physicalSlot": 11, "relay": { "slave": 2, "coil": 5 }, "voltage": { "sourceDisplayChannel": 14, "registerOffset": 10 }, "current": { "sourceDisplayChannel": 14, "registerOffset": 1 } }, + { "physicalSlot": 12, "relay": { "slave": 2, "coil": 4 }, "voltage": { "sourceDisplayChannel": 13, "registerOffset": 11 }, "current": { "sourceDisplayChannel": 13, "registerOffset": 22 } }, + { "physicalSlot": 13, "relay": { "slave": 2, "coil": 3 }, "voltage": { "sourceDisplayChannel": 12, "registerOffset": 12 }, "current": { "sourceDisplayChannel": 12, "registerOffset": 2 } }, + { "physicalSlot": 14, "relay": { "slave": 2, "coil": 2 }, "voltage": { "sourceDisplayChannel": 11, "registerOffset": 13 }, "current": { "sourceDisplayChannel": 11, "registerOffset": 21 } }, + { "physicalSlot": 15, "relay": { "slave": 2, "coil": 1 }, "voltage": { "sourceDisplayChannel": 10, "registerOffset": 14 }, "current": { "sourceDisplayChannel": 10, "registerOffset": 3 } }, + { "physicalSlot": 16, "relay": { "slave": 2, "coil": 0 }, "voltage": { "sourceDisplayChannel": 9, "registerOffset": 15 }, "current": { "sourceDisplayChannel": 9, "registerOffset": 20 } }, + { "physicalSlot": 17, "relay": { "slave": 3, "coil": 7 }, "voltage": { "sourceDisplayChannel": 24, "registerOffset": 16 }, "current": { "sourceDisplayChannel": 24, "registerOffset": 8 } }, + { "physicalSlot": 18, "relay": { "slave": 3, "coil": 6 }, "voltage": { "sourceDisplayChannel": 23, "registerOffset": 17 }, "current": { "sourceDisplayChannel": 23, "registerOffset": 15 } }, + { "physicalSlot": 19, "relay": { "slave": 3, "coil": 5 }, "voltage": { "sourceDisplayChannel": 22, "registerOffset": 18 }, "current": { "sourceDisplayChannel": 22, "registerOffset": 9 } }, + { "physicalSlot": 20, "relay": { "slave": 3, "coil": 4 }, "voltage": { "sourceDisplayChannel": 21, "registerOffset": 19 }, "current": { "sourceDisplayChannel": 21, "registerOffset": 14 } }, + { "physicalSlot": 21, "relay": { "slave": 3, "coil": 3 }, "voltage": { "sourceDisplayChannel": 20, "registerOffset": 20 }, "current": { "sourceDisplayChannel": 20, "registerOffset": 10 } }, + { "physicalSlot": 22, "relay": { "slave": 3, "coil": 2 }, "voltage": { "sourceDisplayChannel": 19, "registerOffset": 21 }, "current": { "sourceDisplayChannel": 19, "registerOffset": 13 } }, + { "physicalSlot": 23, "relay": { "slave": 3, "coil": 1 }, "voltage": { "sourceDisplayChannel": 18, "registerOffset": 22 }, "current": { "sourceDisplayChannel": 18, "registerOffset": 11 } }, + { "physicalSlot": 24, "relay": { "slave": 3, "coil": 0 }, "voltage": { "sourceDisplayChannel": 17, "registerOffset": 23 }, "current": { "sourceDisplayChannel": 17, "registerOffset": 12 } } + ] +} diff --git a/Docs/Modbus接口规范/接入验收清单.md b/Docs/Modbus接口规范/接入验收清单.md new file mode 100644 index 0000000..fe4fdad --- /dev/null +++ b/Docs/Modbus接口规范/接入验收清单.md @@ -0,0 +1,81 @@ +# Modbus 主项目接入验收清单 + +## 1. 配置验收 + +- [ ] 主项目启动时成功加载 `device-profile.json`。 +- [ ] 配置文件随发布产物复制到预期目录。 +- [ ] COM 口可以在主项目中选择并保存,没有硬编码 `COM9`。 +- [ ] 配置缺少物理插位、出现重复寄存器或版本不支持时,程序阻止通讯并明确报错。 +- [ ] 业务代码中没有写死从站、线圈、寄存器、量程和通道映射。 + +## 2. 协议单元测试 + +- [ ] CRC16-Modbus 计算和校验正确,CRC 低字节在前。 +- [ ] 继电器写单线圈帧使用功能码 `0x05`。 +- [ ] ON 值为 `0xFF00`,OFF 值为 `0x0000`。 +- [ ] 电压请求为从站 4、功能码 `0x03`、起始寄存器 0、数量 24。 +- [ ] 电流请求为从站 5、功能码 `0x03`、起始寄存器 0、数量 24。 +- [ ] 电压原始值按 `UInt16` 解析。 +- [ ] 电流原始值按二进制补码 `Int16` 解析,负数测试通过。 +- [ ] 电压公式为 `DATA / 100`。 +- [ ] 电流公式为 `DATA / 10000 × 60`。 +- [ ] 解析器拒绝 CRC 错误、从站错误、功能码错误和长度不足的回包。 + +## 3. 映射自动测试 + +- [ ] 物理插位完整覆盖 1~24。 +- [ ] 24 个继电器从站/线圈组合不重复。 +- [ ] 电压 `registerOffset` 完整覆盖 0~23。 +- [ ] 电流 `registerOffset` 完整覆盖 0~23。 +- [ ] `sourceDisplayChannel` 仅用于记录和诊断,没有参与回包字节寻址。 + +重点抽查: + +| 物理插位 | 继电器 | 电压寄存器偏移 | 电流寄存器偏移 | +|---:|---|---:|---:| +| 1 | 从站1 / 线圈7 | 0 | 4 | +| 8 | 从站1 / 线圈0 | 7 | 16 | +| 9 | 从站2 / 线圈7 | 8 | 0 | +| 16 | 从站2 / 线圈0 | 15 | 20 | +| 17 | 从站3 / 线圈7 | 16 | 8 | +| 24 | 从站3 / 线圈0 | 23 | 12 | + +## 4. 实机逐路验收 + +对物理插位 1~24 逐路执行: + +1. 只闭合当前物理插位对应的继电器。 +2. 确认其他继电器没有误动作。 +3. 给当前接口施加已知电压和电流。 +4. 主项目读取一次完整电压帧和一次完整电流帧。 +5. 确认值出现在当前 `physicalSlot`,其他物理插位没有串位。 +6. 对比标准仪表,记录原始值、工程值和允许误差。 +7. 关闭继电器并确认硬件断开。 + +- [ ] 物理插位 1~8 通过。 +- [ ] 物理插位 9~16 通过。 +- [ ] 物理插位 17~24 通过。 +- [ ] 电流正值通过。 +- [ ] 电流负值或反向极性通过。 +- [ ] 连续轮询稳定性通过。 + +## 5. 异常与稳定性验收 + +- [ ] 拔掉串口后能超时退出,不永久卡住界面。 +- [ ] 恢复连接后可以重新打开串口。 +- [ ] CRC 错误帧不会被当作有效测量值。 +- [ ] Modbus 异常响应能够显示异常码。 +- [ ] 继电器操作与采集轮询不会同时写串口。 +- [ ] 重试不会把残留回包拼入下一次响应。 +- [ ] 应用退出时串口正确关闭。 +- [ ] 日志能够定位到时间、请求 HEX、响应 HEX、耗时和错误原因。 + +## 6. 完成标准 + +只有在以下条件全部满足后才视为接入完成: + +- 主项目所有业务页面统一使用 `physicalSlot`。 +- 24 路继电器、电压和电流均逐路实机通过。 +- 配置文件成为映射的唯一权威来源。 +- 主项目发布包在目标电脑上无需开发环境即可选择串口并运行。 + diff --git a/Docs/PCIe8586驱动接入资料/AI_INTEGRATION_GUIDE.md b/Docs/PCIe8586驱动接入资料/AI_INTEGRATION_GUIDE.md new file mode 100644 index 0000000..e10cb64 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/AI_INTEGRATION_GUIDE.md @@ -0,0 +1,131 @@ +# AI 开发指导:PCIe8586 主项目接入 + +## 目标 + +把 `src/Pcie8586.Driver` 作为主项目的硬件基础设施层接入,稳定获得按通道拆分、单位为伏特的采样块。不要复制调试工具的 WPF 界面代码,也不要绕过 `IDigitizer` 在业务层直接调用 P/Invoke。 + +## 已验证基线 + +- Windows x64、.NET 8。 +- 厂商运行库名:`ACTS1000_64.dll`。 +- 原生调用约定:`StdCall`。 +- 板卡最多 8 通道;当前公开配置允许 1、2、4、8 通道。 +- 基准采样率按 `100_000_000 / ClockDivider` 计算。 +- 输入量程:±5 V、±1 V。 +- 原始数据类型:16 位无符号码值。 +- DMA 数据布局:按采样点交错,即 `CH0[0], CH1[0], ..., CHn[0], CH0[1], ...`。 +- 输出 `SampleBlock.Channels` 布局:`[通道][该通道采样点]`,数值单位 V。 + +## 不可破坏的调用顺序 + +```text +EnumerateDevices + → Open + → Configure / ACTS1000_InitDeviceAD + → Start / ACTS1000_StartDeviceAD + → SoftwareTrigger / ACTS1000_SetDeviceTrigAD + → Read loop / ACTS1000_ReadDeviceAD + → Stop / ACTS1000_StopDeviceAD + → Release AD / ACTS1000_ReleaseDeviceAD + → Close / ACTS1000_ReleaseDevice +``` + +任何异常、取消、窗口关闭或应用退出路径都必须进入 `finally`,依次执行 `StopAsync()` 和 `CloseAsync()`。同一设备不能被两个进程同时占用。 + +## 推荐接入步骤 + +1. 给主项目添加 `Pcie8586.Driver.csproj` 项目引用,并把最终可执行项目固定为 x64。 +2. 在依赖注入容器中将 `IDigitizer` 注册为单例或应用级长生命周期对象: + + ```csharp + services.AddSingleton(); + ``` + +3. 应用启动或硬件页面进入时枚举设备;用户选择逻辑 ID 后再打开。 +4. 开始任务时创建 `AcquisitionConfig` 并调用 `ConfigureAsync`。正在采集时不要重配。 +5. 在后台任务消费 `StartAcquisitionAsync`,不要在 UI 线程运行 DMA 读取循环。 +6. 将每个 `SampleBlock` 立即交给主项目的数据管线。显示、算法、存盘应与采集解耦,慢消费者不能阻塞读卡。 +7. 停止时先取消采集令牌并等待消费任务退出,再调用 `StopAsync`。 +8. 应用退出时调用 `CloseAsync`/`Dispose`。 + +## 主项目应增加的适配层 + +建议新增一个业务服务,例如 `Pcie8586AcquisitionService`,负责: + +- 串行化打开、配置、启动、停止和关闭操作。 +- 维护 `Closed / Open / Running / Faulted` 状态。 +- 独占一个 `CancellationTokenSource` 和采集任务。 +- 将 `SampleBlock` 写入有界 `Channel`。 +- 通道满时采用符合业务要求的策略:等待、丢最旧显示帧,或停止并报警。测量原始数据不可静默丢弃。 +- 将底层异常转换为主项目统一的硬件故障事件。 + +不要让 ViewModel、窗口或算法模块持有原生设备句柄。 + +## 参数规则 + +- `ChannelCount`:只能为 1、2、4、8;启用的是从 CH0 开始的连续通道。 +- `ClockDivider`:正整数;实际采样率为 `100 MHz / ClockDivider`。接入后应使用设备 `GetMainInfo` 返回的能力做二次校验。 +- `InputRange`:±5 V 或 ±1 V,所有启用通道当前使用同一量程。 +- `Mode`:实时监控优先使用 `Continuous`。 +- `FiniteSamplesPerChannel`:仅有限点模式生效。厂商头文件要求后触发时“每通道点数 × 启用通道数 × 触发次数”为 512 的整数倍;主项目若启用有限点模式,应在上层对齐并做真卡专项测试。 + +当前硬件实现的固定参数: + +- DC 耦合、1 MΩ。 +- 板载参考时钟、内部采样时基。 +- 后触发、软件触发、触发一次。 +- 不输出时钟、不输出触发。 + +如果主项目需要外触发、多卡同步、单通道独立量程或非连续通道掩码,应扩展配置模型并对照 `vendor/include/ACTS1000.h`,不要直接修改常量碰运气。 + +## 数据处理规则 + +- `StartSampleIndex` 是每通道的相对采样序号,不是字节位置。 +- `SamplesPerChannel` 是单通道点数,总原始 word 数等于它乘以通道数。 +- `Timestamp` 是软件收到该块时的本机时间,不是硬件级精确首点时间戳。 +- ±5 V 换算:`V = ((10000 / 65536) × code - 5000) / 1000`。 +- ±1 V 换算:`V = ((2000 / 65536) × code - 1000) / 1000`。 +- `0x8000` 对应 0 V;最大码略低于正满量程。 + +若吞吐量较高,后续可把 `double[][]` 优化成池化缓冲或原始 `ushort` 管线,但必须先建立等价测试,确认交错顺序和电压换算没有改变。 + +## 并发与性能 + +- DMA 读取已经放入后台 `Task`;调用方仍应在独立采集任务中消费异步流。 +- 不要对每个采样块执行同步 UI 更新、日志逐点打印或数据库逐点写入。 +- 绘图只取最新帧并降采样,建议 10–20 Hz 刷新。 +- 连续存盘应使用专用写入任务和有界队列。 +- 8 通道 100 MS/s 的理论原始吞吐约 1.6 GB/s,常规 UI/托管内存流程不适合无约束全速长期保存。先按业务需要降低分频、通道数或录制时长。 + +## 错误处理验收 + +至少覆盖以下场景: + +- 未安装/找不到 `ACTS1000_64.dll`。 +- 主进程不是 x64,出现 `BadImageFormatException`。 +- 未发现板卡或逻辑 ID 打开失败。 +- 初始化、启动、触发或读取返回 false。 +- 用户取消、应用退出和采集任务异常时仍释放设备。 +- 设备被其他进程占用。 +- 消费速度低于采集速度时有明确背压或报警策略。 + +## 完成定义 + +- 主项目 x64 Release 编译通过。 +- 无真卡时可注入 `SimulatedDigitizer` 验证完整业务数据链。 +- 真卡可完成至少一次连续采集:枚举、打开、配置、触发、读取、停止、再次启动。 +- 1/2/4/8 通道的顺序和点数正确。 +- `0x8000 → 0 V` 等换算测试通过。 +- 停止、异常和退出后,调试工具或主项目可以再次打开设备,无句柄残留。 +- 主项目的数据消费速度和内存上限经过目标采样率压力测试。 + +## AI 修改约束 + +后续 AI 在改动驱动层时应遵守: + +1. 先阅读本文件、`docs/API_AND_DATA_FORMAT.md`、厂商头文件和现有实现。 +2. 保持 P/Invoke 集中在 `Pcie8586Digitizer.cs`。 +3. 不改变结构体字段顺序、数组长度、字符集和调用约定,除非有厂商文档依据。 +4. 不把原生句柄暴露给业务层。 +5. 每次改动都保留模拟卡路径,并补充纯逻辑测试。 +6. 涉及真卡行为的修改必须列出真卡复测项,不能仅以编译通过作为完成。 diff --git a/Docs/PCIe8586驱动接入资料/PCIe8586_采集调试程序_开发文档.md b/Docs/PCIe8586驱动接入资料/PCIe8586_采集调试程序_开发文档.md new file mode 100644 index 0000000..e016e39 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/PCIe8586_采集调试程序_开发文档.md @@ -0,0 +1,309 @@ +# PCIe8586M 采集调试程序 — 开发文档 + +> 给本机 Claude Code 的工作指令。本程序是「项目接入前测试探针」,目标是摸清阿尔泰 PCIe8586M 高速数字化仪的驱动行为,为主项目(.NET 8 + WPF + MVVM)提供经过验证的接入方案与精确配置。 + +--- + +## 0. 给 Claude Code 的首要约定 + +1. **函数名/结构体/常量的唯一权威是 `Samples/` 目录下的 VC 示例和 `Samples/VC/Include/*.h` 头文件。** 本文档刻意不写死任何 SDK 函数名。凡涉及具体 API,先 `grep`/阅读 `Samples/VC/Include` 与 `Samples/VC/Simple/AD/Continue`、`Finite`,以头文件为准。 +2. **Samples 是 VC(C/C++)的。** C# 接入靠 P/Invoke:把 `.h` 的 `extern "C"` 函数翻译成 `[DllImport]`,把 C 结构体翻译成 `[StructLayout(LayoutKind.Sequential)]`。翻译方法论见 §6。 +3. **分层不可破坏。** 只有 `Hardware/Pcie8586Digitizer.cs` 一个文件允许出现 `[DllImport]` 和 SDK 类型。其余所有代码只依赖 `IDigitizer` 接口。这样主项目可原样复用 `Hardware` + `Acquisition` 两层。 +4. **先用模拟卡跑通全链路,再接真卡。** 本机无硬件、无驱动,开发阶段用 `SimulatedDigitizer` 验证 UI/数据流/存盘;真卡实现 `Pcie8586Digitizer` 时只改这一层。 +5. **平台必须 x64。** SDK 是 64 位非托管 DLL,工程 `x64`,否则运行时 `BadImageFormatException`。 + +--- + +## 1. 硬件事实(已从手册固化,视为常量,不要再"识别") + +设备:`ACTS1000 PCIE8586 8CH 16Bit 100Msps High Speed Digitizer` +硬件 ID:`PCI\VEN_1E42&DEV_8586`(厂商号 0x1E42 = 阿尔泰,设备号 0x8586) +驱动版本:1.6.2.0(2025/7/20) + +| 项目 | 值 | 来源 | +|---|---|---| +| 通道数 | 8(单端) | 手册 2.3.2 | +| ADC 分辨率 | **16 bit**(8586M) | 手册 2.2 | +| 最高采样率 | 100 MS/s | 手册 2.1 | +| 输入量程 | ±5V 或 ±1V(软件可选) | 手册 2.3.2 | +| 板载内存 | 2 GB(八通道共享) | 手册 2.3.6 | +| 数据传输 | DMA | 手册 2.3.6 | +| 总线 | PCIe 2.0 x8 | 手册 2.3.1 | +| 支持系统 | XP/Win7/Win8/Win10 | 手册 2.3.1 | + +### 1.1 数据格式(关键,§4 解析的依据) + +- 每个采样点 = **16 bit 无符号原始码值 = 2 字节,小端**。 +- **码值→电压换算公式(仅 8586M,手册 4.3)**,单位 mV: + - ±5V 量程:`Volt = (10000.0 / 65536) * (code & 0xFFFF) - 5000.0` + - ±1V 量程:`Volt = (2000.0 / 65536) * (code & 0xFFFF) - 1000.0` + - 注意 8582M(12bit)、8584M(14bit) 公式不同(分母 4096/16384),**本卡是 16bit,分母固定 65536**。 +- 中间值(零点)码值 = 0x8000 = 32768,对应 0V。 + +### 1.2 多通道数据排列(解交错依据,手册 4.6) + +- 使能通道数只能是 **1 / 2 / 4 / 8**,且必须**从 CH0 起连续**(4 通道 = CH0~3;单通道只能是 CH0)。 +- 多通道时按**采样点交错**存放(每点 1 个字): + ``` + CH0[0] CH1[0] CH2[0] CH3[0] CH4[0] CH5[0] CH6[0] CH7[0] + CH0[1] CH1[1] CH2[1] CH3[1] CH4[1] CH5[1] CH6[1] CH7[1] + ... + ``` +- 解交错:`result[ch][s] = raw[s * channelCount + ch]`。 + +### 1.3 采样率是离散值(采集频率控制依据,手册 4.7) + +- `采样率 = 扫描时基频率 / ADC时钟分频器` +- 时基 = 100 MHz;分频器 = 1, 2, 3, ... (2³²−1) 的**正整数**。 +- 所以可设采样率 = `100MHz / N`:100M、50M、33.33M、25M ... 1M(N=100) ... 1k(N=100000)。 +- **UI 不能让用户自由填任意采样率。** 应让用户选分频器 N,或从预设档(100M/50M/10M/1M/100k...)选,并实时显示 `100e6/N` 的实际采样率。 + +### 1.4 采集模式与触发(手册 4.8 / 4.9) + +- 模式:**连续采样**、**有限点采样**。无硬件级"暂停/继续"。 +- 触发源:软件触发、ATR(模拟)、DTR(数字 PFI)、同步信号。**调试程序默认软件触发**。 +- 有限点支持:中间触发、后触发、预触发、硬件延时触发、重复触发。 +- **定时录制(本程序核心功能)映射**:见 §3.2。 + +--- + +## 2. 架构 + +三层,自底向上: + +``` +Hardware 层 IDigitizer 接口 + Pcie8586Digitizer(真卡, 唯一含 DllImport) + + SimulatedDigitizer(模拟卡) + ↓ +Acquisition 层 后台采集线程 / 环形历史缓冲 / 解交错 / 码值换算 / 定时录制 / 存盘 + ↓ +UI 层 (WPF+MVVM) 设备识别 / 实时曲线(ScottPlot) / 实时表格 / 录制控制 / 剪辑 +``` + +**复用边界**:`Hardware` + `Acquisition` 两层将原样进主项目;UI 层主项目重写。因此这两层**不得引用任何 WPF 类型**(无 `Dispatcher`、无 `ObservableCollection`),保持纯 .NET。 + +### 2.1 建议目录结构 + +``` +Pcie8586Probe/ +├─ Pcie8586Probe.csproj # net8.0-windows, UseWPF, x64 +├─ Samples/ # ← 你放上位机参考的地方(VC 示例 + Include 头文件) +├─ Hardware/ +│ ├─ IDigitizer.cs # 抽象接口(见 §5.1 职责) +│ ├─ SimulatedDigitizer.cs # 模拟实现(生成交错原始码值) +│ └─ Pcie8586Digitizer.cs # 真卡实现(P/Invoke,照 Samples 填) +├─ Acquisition/ +│ ├─ CodeConverter.cs # 码值→电压 + 解交错(§1.1/§1.2) +│ ├─ RingHistoryBuffer.cs # 录制/剪辑用的最近 N 秒环形缓冲 +│ ├─ Recorder.cs # 定时定长录制状态机(§3.2) +│ └─ WaveformWriter.cs # 落盘(二进制 + JSON 头) +├─ Models/ +│ ├─ AcquisitionConfig.cs # 通道数/量程/分频器/模式 等配置 +│ ├─ DeviceInfo.cs +│ └─ SampleBlock.cs # 一块已解交错的电压数据 +├─ ViewModels/ +│ ├─ MainViewModel.cs +│ └─ ChannelRow.cs # 表格一行(通道实时统计) +├─ Views/ +│ └─ MainWindow.xaml(.cs) +└─ Converters/ # XAML 值转换器(如枚举→显示文本) +``` + +### 2.2 NuGet 依赖 + +- `CommunityToolkit.Mvvm`(`[ObservableProperty]` / `[RelayCommand]` 源生成器,减样板)。 +- `ScottPlot.WPF`(高刷新实时曲线,远优于 WPF 原生绘图)。 + +--- + +## 3. 功能需求与验收点 + +### 3.1 设备识别(自动 + 手动) + +- **自动**:调用 SDK 枚举接口列出所有同型号板卡,填充下拉框(显示逻辑号 + 描述)。 + - 多数阿尔泰 SDK 有 `GetDeviceCount` 之类;若没有,可循环 `CreateDevice(i)` 试探,成功记录后 `ReleaseDevice`。**具体函数看 Samples/VC/Simple/AD/PhysicalID 或 Include。** +- **手动**:用户直接填逻辑号(0/1/2...)打开。 +- 验收:模拟卡返回 1 张虚拟卡可被选中打开;真卡能枚举到 `VEN_1E42&DEV_8586`。 + +### 3.2 定时定长录制 +剪辑(替代"暂停/继续") + +这是本程序与普通示波器软件的核心差异点。语义: + +- **连续采集常驻**:打开设备并 Start 后,DMA 持续流入,曲线实时滚动显示。这一路**不落盘**,只进 `RingHistoryBuffer`(保留最近 N 秒,N 可配,受内存约束见 §7)。 +- **定时录制按钮**:1ms / 10ms / 100ms / 1s / 10s 五个预设。点击后: + - 计算目标点数 `target = round(采样率 × 时长)`。 + - 进入"录制中"状态:从下一个数据块起,把块追加进录制缓冲,累计每通道点数 ≥ target 时**自动停止录制**,截断到精确 target 点,落盘。 + - 录制中曲线继续显示、不影响连续监控。 +- **采集后剪辑**:录制完(或从历史缓冲)得到一段数据后,提供"起点/终点"两个游标(UI 上拖动或填采样序号),裁出子区间另存。 +- 验收:选 1MS/s、录 10ms → 落盘文件每通道恰好 10000 点(±0,因软件截断);裁剪 [2000,5000) → 3000 点。 + +> **两种实现取舍(文档建议默认前者)**: +> 1. **连续采集 + 软件截取**(默认):录制只是从连续流里数够点数。能边显示边录,长度精确(软件截断),两段录制无硬件重启间隙。 +> 2. **有限点 + 软件触发**(备选):每次录制重新 init→start,硬件采满 target 点自停。最干净,但与实时显示互斥、两段间有重配置延时。 +> 真卡阶段若连续采集 DMA 吞吐顶不住(§7),再退到方案 2。 + +### 3.3 实时显示 + +- **曲线**:ScottPlot,每通道一条线,X 轴时间(ms 或样本序号),Y 轴电压(V),量程决定 Y 范围(±5 或 ±1)。只画最近一屏的点(降采样显示,见 §7)。 +- **表格**:每通道一行,列 = 通道名 / 最新值 / Min / Max / RMS,随采集刷新(节流到 ~10–20 Hz)。 + +### 3.4 采集参数控制 + +- 通道数下拉:1/2/4/8。 +- 量程下拉:±5V / ±1V。 +- 采样率:选分频器 N 或预设档,旁显实际 `100e6/N`。 +- 模式:连续 / 有限点(有限点需填点数)。 + +### 3.5 存盘格式(见 §8,与未来 Python 分析对齐) + +--- + +## 4. 数据解析(Acquisition/CodeConverter.cs) + +实现两个纯函数(无副作用、无 SDK 依赖、可单测): + +1. `CodeToVolts(ushort code, InputRange range)` → 按 §1.1 公式返回 V。 +2. `Deinterleave(ReadOnlySpan raw, int channelCount, InputRange range)` → `double[][]`([通道][点]),按 §1.2 排列解交错并换算。 + +单元测试验收:`code=0x8000` → 0V;`code=0xFFFF` → +5V 量程下约 +4.99985V;`code=0` → −5V。 + +--- + +## 5. 各层职责(不写函数名,描述 API 类别) + +### 5.1 IDigitizer 接口应暴露的能力 + +- 枚举设备 → 返回 `IReadOnlyList`。 +- 按逻辑号打开 / 关闭。 +- 用 `AcquisitionConfig` 初始化采集(设量程、通道掩码、时钟分频、模式、软件触发)。 +- 启动采集:以**回调或 IAsyncEnumerable** 的方式持续吐出 `SampleBlock`(已解交错、已换算),直到取消或有限点采满。 +- 实现 `IDisposable` 释放 SDK 资源。 + +### 5.2 Pcie8586Digitizer(真卡,唯一含 P/Invoke) + +照 `Samples/VC/Simple/AD/Continue` 的调用顺序翻译。**典型**连续采集流程(具体函数名看 Samples): + +1. **创建设备**:`CreateDevice(逻辑号)` → 返回设备句柄(HANDLE/IntPtr)。判断无效值(通常 0 或 -1/INVALID_HANDLE_VALUE)。 +2. **配置参数**:填充 SDK 的"AD 参数结构体"(量程枚举、通道数/掩码、`ADC时钟分频器 = config.ClockDivider`、采集模式、触发源=软件触发、是否主卡等),调用初始化函数(`InitDeviceAD` / `SetADParam` 一类)。 +3. **启动**:`StartDeviceAD(句柄)`。 +4. **读 DMA**:循环调用读取函数(`GetDeviceAD` / `ReadDeviceAD`,参数通常是 `句柄, 缓冲区指针, 期望点数, 超时ms`),返回实际读到的点数。把读到的 `ushort[]` 原始码值交给 `CodeConverter.Deinterleave` → `SampleBlock` → 回调。 +5. **软件触发**:若初始化为软件触发,需在 Start 后调用一次软件触发函数(手册 4.8.2)。 +6. **停止/释放**:`StopDeviceAD(句柄)` → `ReleaseDevice(句柄)`。 + +读取循环必须在**后台线程/Task**,不可阻塞 UI 线程。缓冲区用 `GCHandle.Alloc(buf, GCHandleType.Pinned)` 固定后传 `AddrOfPinnedObject()`,用完 `Free()`;或用 `Marshal.AllocHGlobal` + `Marshal.Copy`。 + +### 5.3 SimulatedDigitizer(模拟卡) + +- 不碰 SDK。内部按 §1.2 布局生成**交错的 ushort 原始码值**(每通道不同频率正弦 + 1% 噪声),再走与真卡**完全相同**的 `Deinterleave` 路径,确保两条路径解析逻辑一致。 +- 按配置的采样率节流出块(建议每秒约 30 块,每块点数 = 采样率/30 上限封顶几千点),`await Task.Delay` 模拟 DMA 节奏。 +- 支持连续与有限点(有限点采满点数后结束)。 + +### 5.4 MainViewModel(UI 线程安全是重点) + +- 用 `CommunityToolkit.Mvvm` 的 `[ObservableProperty]`/`[RelayCommand]`。 +- **高速数据进 UI 的关键**:采集回调在后台线程触发,**不要**每块都 `Dispatcher.Invoke` 更新绑定属性(会卡死 UI)。正确做法: + - 后台把最新数据写入一个**无锁/带锁的"最新帧"缓冲**; + - 用一个 `DispatcherTimer`(~50ms,即 20Hz)在 UI 线程定时把最新帧刷到 ScottPlot 和表格。 + - 即"采集高频、渲染定频",解耦两者速率。 +- 命令:`Open/Close/StartMonitor/StopMonitor/Record(时长)/ClearScreen/SaveClip(起,止)`。 + +--- + +## 6. P/Invoke 翻译方法论(VC 头文件 → C#) + +Claude Code 对着 `Include/*.h` 按下表翻译。**逐个核对头文件的真实类型,不要套用记忆。** + +| C / VC 头文件 | C# P/Invoke | 备注 | +|---|---|---| +| `HANDLE` / `void*` / `DEVICE_HANDLE` | `IntPtr` | 设备句柄一律 IntPtr | +| `int` / `LONG` | `int` | 4 字节 | +| `unsigned int` / `DWORD` / `ULONG` | `uint` | 时钟分频器常是 DWORD | +| `unsigned short` / `WORD` / `USHORT` | `ushort` | 原始码值类型 | +| `unsigned char` / `BYTE` | `byte` | | +| `BOOL` | `[return: MarshalAs(UnmanagedType.Bool)] ... bool` 或直接 `int` | BOOL 是 4 字节 int,别用 1 字节 bool | +| `char*`(入参字符串) | `string` + `CharSet` / 或 `byte[]` | 看是 ANSI 还是宽字符 | +| `WORD* pData` / `void* pBuffer`(缓冲区) | `IntPtr` + pinning,或 `ushort[]` | 大缓冲建议 IntPtr + Marshal.Copy | +| `struct { ... }`(参数结构体) | `[StructLayout(LayoutKind.Sequential)] struct` | **字段顺序、类型、对齐必须 1:1** | +| `enum` | C# `enum : int` 或直接用 int 常量 | | + +`[DllImport]` 模板: +```csharp +[DllImport("PCIe8586M.dll", // ← DLL 名以实际为准(看驱动安装目录/Samples 链接的 .lib) + CallingConvention = CallingConvention.StdCall, // ← VC 常是 __stdcall;若 .h 里是 __cdecl 则改 Cdecl + CharSet = CharSet.Ansi, + SetLastError = true)] +private static extern IntPtr 函数名(参数); +``` + +### 6.1 已知坑 + +1. **调用约定**:阿尔泰 DLL 多为 `__stdcall`(=`StdCall`)。若崩溃在调用后栈不平衡(`PInvokeStackImbalance` 调试警告),改 `CallingConvention`。看 `.h` 里是否有 `WINAPI`/`__stdcall`/`__cdecl` 宏。 +2. **结构体对齐**:若 `.h` 里有 `#pragma pack(1)`,C# struct 要 `[StructLayout(LayoutKind.Sequential, Pack = 1)]`。错了会导致字段错位、参数乱掉。 +3. **BOOL ≠ bool**:C 的 `BOOL` 是 4 字节。直接用 C# `bool`(1字节) 编组会错位,用 `UnmanagedType.Bool` 或声明成 `int`。 +4. **缓冲区生命周期**:读 DMA 的缓冲必须 pinned 或非托管堆分配,传指针期间不能被 GC 移动。循环里复用同一块缓冲,别每块 new。 +5. **句柄无效判断**:`CreateDevice` 失败可能返回 `0`、`-1` 或 `0xFFFFFFFF`,看 Samples 里怎么判断的,照抄。 +6. **x86/x64**:DLL 是 64 位 → 工程必须 x64,否则 `BadImageFormatException`。 +7. **DLL 找不到**:运行时把 SDK 的 DLL 放 exe 同目录(或加 PATH)。开发期 DLL 不在本机属正常,模拟卡不需要它。 + +--- + +## 7. 性能与内存约束 + +- 8 通道 @ 100MS/s = 1600 MB/s 原始数据(手册 4.9)。**调试程序不要全速 8 通道连续显示**,会爆。测试时用降速(如 1MS/s)或少通道。 +- **显示降采样**:ScottPlot 一屏最多画几千个点。来一块几万点的数据,画之前做 min/max 抽稀(每像素列取最值),否则渲染卡。ScottPlot 的 `Signal` 类型对密集点有内建优化,优先用。 +- **录制/剪辑缓冲上限**:`RingHistoryBuffer` 按"最近 N 秒 × 采样率 × 通道数 × 4字节(float)"预估,设硬上限(如 ≤ 500MB),超出丢最旧。UI 标明可剪辑的历史长度。 +- **采集频率 vs 渲染频率解耦**:见 §5.4,渲染固定 ~20Hz。 + +--- + +## 8. 存盘格式(与未来 Python 分析对齐) + +每次录制/剪辑输出两个文件: + +- `{name}.bin`:`float32` 小端,按通道**交错**:`CH0[0]CH1[0]..CHn[0]CH0[1]..`(电压,单位 V)。 +- `{name}.json`:元数据头: + ```json + { + "channel_count": 8, + "sample_rate_hz": 1000000.0, + "input_range": "5V", + "samples_per_channel": 10000, + "dtype": "float32", + "layout": "interleaved", + "unit": "volt", + "recorded_at": "ISO8601", + "duration_ms": 10.0 + } + ``` + +> Python 读法(未来):`np.fromfile(bin, dtype=' + ``` + +3. 主项目和最终进程必须为 `x64`,运行环境为 Windows。 +4. 在目标机安装厂商 PCIe8586 驱动,并确保进程能加载 `ACTS1000_64.dll`。 +5. 按 `examples/ConsoleIntegration/Program.cs` 的生命周期调用。 + +类库源码沿用已验证调试工具的命名空间 `Pcie8586Probe.*`,以保持代码与测试版本一致。主项目可以先原样接入,确认真卡采集后再统一重命名。 + +## 边界 + +- `ACTS1000_64.lib` 只供原生 C/C++ 链接,C# 项目不需要引用它。 +- 仓库中没有厂商运行时 `ACTS1000_64.dll`,也没有 `.sys/.inf/.cat` 驱动安装文件,不能用本目录代替厂商驱动安装包。 +- UI、ScottPlot 和 CommunityToolkit.Mvvm 没有进入接入包。 +- 当前真卡配置使用板载时钟、内部时基、软件触发、DC 耦合和 1 MΩ 输入。 + +实施接入前请先阅读 [AI_INTEGRATION_GUIDE.md](AI_INTEGRATION_GUIDE.md)。 diff --git a/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/1.bat b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/1.bat new file mode 100644 index 0000000..25f3f9a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/1.bat @@ -0,0 +1 @@ +Rename sys.exe sys_32.exe \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/ReadMe.txt b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/ReadMe.txt new file mode 100644 index 0000000..d7779df --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/ReadMe.txt @@ -0,0 +1 @@ +2014/6/19 32 64 λʾ JRL \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/Sys.c b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/Sys.c new file mode 100644 index 0000000..919f15e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/AD/Continue/Sys.c @@ -0,0 +1,253 @@ + +//#include +#include "windows.h" +#include +#include + +static int (__stdcall *getch)(void); +static int (__stdcall *kbhit)(void); + + + + +int InputRange; + +#define AD_DATA_LEN 256*1024 // ҪȡʹADݳȣ֣ +USHORT ADBuffer[AD_DATA_LEN]; // 仺(洢ԭʼ) +int main (int argc, char *argv[]) + +{ + + HANDLE hDevice; + int DeviceLgcID; + ULONG ulDDR2Length = 0; + ULONGLONG ulDDR2LengthByte = 0; + + ACTS1000_PARA_AD ADPara; // Ӳ + ACTS1000_STATUS_AD ADStatus; + ULONG nRetSizeWords; + ULONG nAvailSampsPoints; + ULONG nRead; + + int nCurrentChannel = 0,nADChannel = 0; + WORD ADData; + float fVolt; + ACTS1000_AD_MAIN_INFO ADMainInfo; + WORD wMaxLSB = 0x3FFF; + float fLsbCount = 16384.0; + int nCH=0; + + int ChannelCount = 0; + + LONG ulTime = GetTickCount(); + double dResult; + __int64 i64Cnt=0; + LONG ulTmp=0; + LONG ulSecCnt=0; + + ULONGLONG ulReadCount = 0; + ULONG nTChannel = 0; + int Index=0; + + + HINSTANCE hInst = LoadLibrary("MSVCRT.DLL"); + getch = GetProcAddress(hInst, "_getch"); + kbhit = GetProcAddress(hInst, "_kbhit"); + + + DeviceLgcID = 0; + printf("߼ID:"); + scanf("%d", &DeviceLgcID); + hDevice = ACTS1000_CreateDevice(DeviceLgcID); // 豸 + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("CreateDevice error...\n"); + getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetMainInfo(hDevice,&ADMainInfo); // DDR2ij(λMB) + + switch (ADMainInfo.nDeviceType>>16) + { + case 0x2012: + printf("PXIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + case 0x2111: + printf("PCIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + default: + printf("ACTS1000-%04X\n",ADMainInfo.nDeviceType); + } + + ulDDR2LengthByte = ADMainInfo.nDepthOfMemory; + + wMaxLSB = (WORD)(ADMainInfo.nSampCodeCount - 1); + fLsbCount = (float)ADMainInfo.nSampCodeCount; + + InputRange = ACTS1000_INPUT_N1000_P1000mV; // ҪûӼѡ + + memset(&ADPara, 0x00, sizeof(ADPara)); // λȷֵ0(ǿҽ) + + // ԤӲ + ADPara.SampleMode = ACTS1000_SAMPMODE_CONTINUOUS; // ޵ + ADPara.FreqDivision = 1; + for (nCH=0; nCHulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = ADStatus.lSavePoints*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + } + } + } + else + { + + while ( !kbhit() ) + { + if(!ACTS1000_ReadDeviceAD(hDevice, ADBuffer, nRead, &nRetSizeWords, &nAvailSampsPoints,5.0)) + { + printf("ReadDeviceDmaAD error...\n"); + getch(); + goto ExitRead; + } + if (nRetSizeWords<=0) + { + continue; + } + ulReadCount+=nRetSizeWords; +#if 1 + ulTmp = GetTickCount()-ulTime; + if (ulTmp/1000>ulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = ulReadCount*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + nTChannel = 0; + for(Index=0; Index<8; Index++) + { + for(nADChannel=nTChannel; nADChannel +#include "windows.h" +#include +#include + +static int (__stdcall *getch)(void); +static int (__stdcall *kbhit)(void); + + + + +#define AD_DATA_LEN 256*1024 // ҪȡʹADݳȣ֣ +USHORT ADBuffer[AD_DATA_LEN]; // 仺(洢ԭʼ) +int main (int argc, char *argv[]) + +{ + HANDLE hDevice; + int DeviceLgcID; + ULONG ulDDR2Length = 0; + + ACTS1000_PARA_AD ADPara; // Ӳ + ACTS1000_STATUS_AD ADStatus; + ULONG nRetSizeWords; + ULONG nAvailSampsPoints; + ULONGLONG nReadSizeRemain; + ULONGLONG nReadSizeWords; + ULONG nRead; + ULONG InputRange = ACTS1000_INPUT_N1000_P1000mV; + + int nADChannel = 0; + WORD ADData; + float fVolt; + ACTS1000_AD_MAIN_INFO ADMainInfo; + WORD wMaxLSB = 0x3FFF; + float fLsbCount = 16384.0; + + int nCH=0; + + int ChannelCount = 0; + + LONG ulTime = GetTickCount(); + double dResult; + __int64 i64Cnt=0; + LONG ulTmp=0; + LONG ulSecCnt=0; + + ULONGLONG ulReadCount = 0; + ULONG nTChannel = 0; + int Index=0; + + + HINSTANCE hInst = LoadLibrary("MSVCRT.DLL"); + getch = GetProcAddress(hInst, "_getch"); + kbhit = GetProcAddress(hInst, "_kbhit"); + + + DeviceLgcID = 0; + printf("߼ID:"); + scanf("%d", &DeviceLgcID); + hDevice = ACTS1000_CreateDevice(DeviceLgcID); // 豸 + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("CreateDevice error...\n"); + getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetMainInfo(hDevice,&ADMainInfo); // DDR2ij(λMB) + + switch (ADMainInfo.nDeviceType>>16) + { + case 0x2012: + printf("PXIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + case 0x2111: + printf("PCIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + default: + printf("ACTS1000-%04X\n",ADMainInfo.nDeviceType); + } + + wMaxLSB = (WORD)(ADMainInfo.nSampCodeCount - 1); + fLsbCount = (float)ADMainInfo.nSampCodeCount; + + memset(&ADPara, 0x00, sizeof(ADPara)); // λȷֵ0(ǿҽ) + + // ԤӲ + ADPara.SampleMode = ACTS1000_SAMPMODE_FINITE; // ޵ + ADPara.FreqDivision = 1; + for ( nCH=0; nCHulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = ADStatus.lSavePoints*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + } + } + } + } + else + { + nReadSizeRemain = nReadSizeWords; + while (nReadSizeRemain>0) + { + if (nReadSizeRemain>=AD_DATA_LEN) + { + nRead = AD_DATA_LEN; + } + else + { + nRead = nReadSizeRemain; + } +NextRead: + + if(kbhit()) goto ExitRead; + if(!ACTS1000_ReadDeviceAD(hDevice, ADBuffer, nRead, &nRetSizeWords, &nAvailSampsPoints,1.0)) + { + printf("ReadDeviceAD error...\n"); + getch(); + goto ExitRead; + } + if (nRetSizeWords<=0) + { + goto NextRead; + } + nReadSizeRemain = nReadSizeRemain-nRetSizeWords; + +#if 1 + ulTmp = GetTickCount()-ulTime; + if (ulTmp/1000>ulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = (nReadSizeWords-nReadSizeRemain)*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + nTChannel = 0; + for(Index=0; Index<8; Index++) + { + for(nADChannel=nTChannel; nADChannel +#include "windows.h" +#include +#include + +static int (__stdcall *getch)(void); +static int (__stdcall *kbhit)(void); + + + + +int main (int argc, char *argv[]) + +{ + + HANDLE hDevice; + LONG DevID, LinkType; + LONG DeviceLgcID, DevicePhysID; + + + + HINSTANCE hInst = LoadLibrary("MSVCRT.DLL"); + getch = GetProcAddress(hInst, "_getch"); + kbhit = GetProcAddress(hInst, "_kbhit"); + + + + + DeviceLgcID = 0; +SlectLT: + printf("ѡ豸ʽ:0:߼ 1: "); + scanf("%d", &LinkType); + if (LinkType<0 || LinkType>1) + { + goto SlectLT; + } + +SlectID: + printf("ID:"); + scanf("%d", &DevID); + if (DevID <0) + { + goto SlectID; + } + switch (LinkType) + { + case 0: + hDevice = ACTS1000_CreateDevice(DevID); // 豸 + break; + case 1: + hDevice = ACTS1000_CreateDeviceEx(DevID); // 豸 + break; + } + + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("ACTS1000_CreateDevice fail"); + getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetDeviceCurrentID(hDevice, &DeviceLgcID, &DevicePhysID); + printf("ǰ豸߼ID:%d ID:%d\n", DeviceLgcID, DevicePhysID); + + printf("ID:"); + scanf("%d", &DevicePhysID); + ACTS1000_SetDevicePhysID(hDevice, DevicePhysID); + ACTS1000_ReleaseDevice(hDevice); // ͷ豸 + + return 0; +} + diff --git a/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.cws b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.cws new file mode 100644 index 0000000..28d1b28 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.cws @@ -0,0 +1,166 @@ +[Workspace Header] +Version = 1001 +Pathname = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/PhysicalID/Sys.cws" +CVI Dir = "/c/program files (x86)/national instruments/cvi2010" +CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI" +CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2010" +CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI" +IVI Standard Root Dir = "/C/Program Files (x86)/IVI Foundation/IVI" +IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI" +VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt" +VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64" +Number of Projects = 1 +Active Project = 1 +Project 0001 = "Sys.prj" +Drag Bar Left = 160 +Window Top = 78 +Window Left = 31 +Window Bottom = 580 +Window Right = 821 +Maximized = True +Maximized Children = True +Max32 Number Of Errors = 20 +Track Include File Dependencies = True +Prompt For Missing Includes = True +Stop On First Error File = False +Bring Up Err Win For Warnings = True +Show Build Dialog = False +Save Changes Before Running = "Always" +Save Changes Before Compiling = "Always" +Hide Windows = False +Break At First Statement = False +Sort Type = "File Name" +Number of Opened Files = 2 +Window Confinement Region Enabled = True +MainColumnWidth = 143 +FileDateColumnWidth = 70 +FileSizeColumnWidth = 70 +StatusColumnWidth = 70 + +[Project Header 0001] +Version = 1001 +Don't Update DistKit = False +Platform Code = 4 +Build Configuration = "Release" +Warn User If Debugging Release = 1 +Batch Build Release = False +Batch Build Debug = False +Force Rebuild = False + +[File 0001] +Path = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/PhysicalID/Sys.c" +File Type = "CSource" +Disk Date = 3708407608 +In Projects = "1," +Window Top = 38 +Window Z-Order = 1 +Source Window State = "1,25,27,27,44,44,44,0,0,288,0,0,0,0,0,73,0,0,26,150,400,600,1,0," + +[File 0002] +Path = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/PhysicalID/ACTS1000.h" +File Type = "Include" +Disk Date = 3708388578 +In Projects = "1," +Window Top = 192 +Window Left = 91 +Window Z-Order = 2 +Source Window State = "1,327,337,337,0,15,15,0,0,122,0,0,0,0,0,25,317,0,327,0,323,769,1,0," + +[File 0003] +Path = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/PhysicalID/CONIO.H" +File Type = "Include" +Disk Date = 0 +In Projects = "1," +Window Top = 32 +Window Left = 6 +Source Window State = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," + +[File 0004] +Path = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/PhysicalID/ACTS1000_32.lib" +File Type = "Library" +Disk Date = 3704698817 +In Projects = "1," + +[Default Build Config 0001 Debug] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Batch Build = False +Profile = "Disabled" +Debugging Level = "Standard" +Execution Trace = "Disabled" +Command Line Args = "" +Working Directory = "" +External Process Path = "" + +[Default Build Config 0001 Release] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Batch Build = False +Profile = "Disabled" +Debugging Level = "Standard" +Execution Trace = "Disabled" +Command Line Args = "" +Working Directory = "" +External Process Path = "" + +[Default Build Config 0001 Debug64] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Batch Build = False +Profile = "Disabled" +Debugging Level = "Standard" +Execution Trace = "Disabled" +Command Line Args = "" +Working Directory = "" +External Process Path = "" + +[Default Build Config 0001 Release64] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Batch Build = False +Profile = "Disabled" +Debugging Level = "Standard" +Execution Trace = "Disabled" +Command Line Args = "" +Working Directory = "" +External Process Path = "" + +[Build Options 0001] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Execution Trace = "Disabled" +Profile = "Disabled" +Debugging Level = "Standard" +Break On Library Errors = True +Break On First Chance Exceptions = False + +[Execution Target 0001] +Execution Target Address = "Local desktop computer" +Execution Target Port = 0 +Execution Target Type = 0 + +[SCC Options 0001] +Use global settings = True +SCC Provider = "" +SCC Project = "" +Local Path = "" +Auxiliary Path = "" +Perform Same Action For .h File As For .uir File = "Ask" +Perform Same Action For .cds File As For .prj File = "Ask" +Username = "" +Comment = "" +Use Default Username = False +Use Default Comment = True +Suppress CVI Error Messages = False +Always show confirmation dialog = True + +[DLL Debugging Support 0001] +External Process Path = "" + +[DLLs Used By Executable 0001] +DLL 0001 = "/C/Windows/SYSTEM32/ACTS1000_32.dll" + +[Command Line Args 0001] +Command Line Args = "" +Working Directory = "" + diff --git a/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.exe b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.exe new file mode 100644 index 0000000..24e653e Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.prj b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.prj new file mode 100644 index 0000000..0352a6b --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/LabWindows/PhysicalID/Sys.prj @@ -0,0 +1,368 @@ +[Project Header] +Version = 1001 +Pathname = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/Sys.prj" +CVI Dir = "/c/program files (x86)/national instruments/cvi2010" +CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI" +CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2010" +CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI" +IVI Standard Root Dir = "/C/Program Files (x86)/IVI Foundation/IVI" +VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt" +IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI" +VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64" +Number of Files = 4 +Target Type = "Executable" +Flags = 1040 +Copied From Locked InstrDrv Directory = False +Copied from VXIPNP Directory = False +Locked InstrDrv Name = "" +Don't Display Deploy InstrDrv Dialog = False + +[File 0001] +File Type = "Include" +Res Id = 1 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "ACTS1000.h" +Path = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/ACTS1000.h" +Exclude = False +Project Flags = 0 +Folder = "Include Files" + +[File 0002] +File Type = "Include" +Res Id = 2 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "CONIO.H" +Path = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/CONIO.H" +Exclude = False +Project Flags = 0 +Folder = "Include Files" + +[File 0003] +File Type = "CSource" +Res Id = 3 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "Sys.c" +Path = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/Sys.c" +Exclude = False +Compile Into Object File = False +Project Flags = 0 +Folder = "Source Files" + +[File 0004] +File Type = "Library" +Res Id = 4 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "ACTS1000_32.lib" +Path = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/ACTS1000_32.lib" +Exclude = False +Project Flags = 0 +Folder = "Not In A Folder" + +[Folders] +User Interface Files Folder Not Added Yet = True +Instrument Files Folder Not Added Yet = True +Folder 0 = "Include Files" +Folder 1 = "Source Files" + +[Custom Build Configs] +Num Custom Build Configs = 0 + +[Default Build Config Debug] +Config Name = "Debug" +Is 64-Bit = False +Is Release = False +Default Calling Convention = "cdecl" +Uninitialized Locals Compile Warning = "Conservative" +Require Prototypes = True +Require Return Values = True +Enable Pointer Mismatch Warning = False +Enable Unreachable Code Warning = False +Enable Unreferenced Identifiers Warning = False +Enable Assignment In Conditional Warning = False +Enable C99 Extensions = False +Stack Size = 250000 +Image Base Address = 4194304 +Image Base Address x64 = 4194304 +Compiler Defines = "/DWIN32_LEAN_AND_MEAN" +Sign = False +Sign Store = "" +Sign Certificate = "" +Sign Timestamp URL = "" +Sign URL = "" +Manifest Embed = False +Icon File Is Rel = False +Icon File = "" +Application Title = "" +DLL Import Library Choice = "Gen Lib For Current Mode" +Use IVI Subdirectories for Import Libraries = False +Use VXIPNP Subdirectories for Import Libraries = False +Use Dflt Import Lib Base Name = True +Where to Copy DLL = "Do not copy" +Custom Directory to Copy DLL Is Rel = False +Custom Directory to Copy DLL = "" +Generate Source Documentation = "None" +Runtime Support = "Full Runtime Support" +Embed Project .UIRs = False +Generate Map File = False +Create Console Application = True +Using LoadExternalModule = False +DLL Exports = "Include File Symbols" +Register ActiveX Server = False +Add Type Lib To DLL = False +Include Type Lib Help Links = False +TLB Help Style = "HLP" +Type Lib FP File Is Rel = False +Type Lib FP File = "" + +[Default Build Config Release] +Config Name = "Release" +Is 64-Bit = False +Is Release = True +Default Calling Convention = "cdecl" +Uninitialized Locals Compile Warning = "Conservative" +Require Prototypes = True +Require Return Values = True +Enable Pointer Mismatch Warning = False +Enable Unreachable Code Warning = False +Enable Unreferenced Identifiers Warning = False +Enable Assignment In Conditional Warning = False +Enable C99 Extensions = False +Stack Size = 250000 +Image Base Address = 4194304 +Image Base Address x64 = 4194304 +Compiler Defines = "/DWIN32_LEAN_AND_MEAN" +Sign = False +Sign Store = "" +Sign Certificate = "" +Sign Timestamp URL = "" +Sign URL = "" +Manifest Embed = False +Icon File Is Rel = False +Icon File = "" +Application Title = "" +DLL Import Library Choice = "Gen Lib For Current Mode" +Use IVI Subdirectories for Import Libraries = False +Use VXIPNP Subdirectories for Import Libraries = False +Use Dflt Import Lib Base Name = True +Where to Copy DLL = "Do not copy" +Custom Directory to Copy DLL Is Rel = False +Custom Directory to Copy DLL = "" +Generate Source Documentation = "None" +Runtime Support = "Full Runtime Support" +Embed Project .UIRs = False +Generate Map File = False +Create Console Application = True +Using LoadExternalModule = False +DLL Exports = "Include File Symbols" +Register ActiveX Server = False +Add Type Lib To DLL = False +Include Type Lib Help Links = False +TLB Help Style = "HLP" +Type Lib FP File Is Rel = False +Type Lib FP File = "" + +[Default Build Config Debug64] +Config Name = "Debug64" +Is 64-Bit = True +Is Release = False +Default Calling Convention = "cdecl" +Uninitialized Locals Compile Warning = "Conservative" +Require Prototypes = True +Require Return Values = True +Enable Pointer Mismatch Warning = False +Enable Unreachable Code Warning = False +Enable Unreferenced Identifiers Warning = False +Enable Assignment In Conditional Warning = False +Enable C99 Extensions = False +Stack Size = 250000 +Image Base Address = 4194304 +Image Base Address x64 = 4194304 +Compiler Defines = "/DWIN32_LEAN_AND_MEAN" +Sign = False +Sign Store = "" +Sign Certificate = "" +Sign Timestamp URL = "" +Sign URL = "" +Manifest Embed = False +Icon File Is Rel = False +Icon File = "" +Application Title = "" +DLL Import Library Choice = "Gen Lib For Current Mode" +Use IVI Subdirectories for Import Libraries = False +Use VXIPNP Subdirectories for Import Libraries = False +Use Dflt Import Lib Base Name = True +Where to Copy DLL = "Do not copy" +Custom Directory to Copy DLL Is Rel = False +Custom Directory to Copy DLL = "" +Generate Source Documentation = "None" +Runtime Support = "Full Runtime Support" +Embed Project .UIRs = False +Generate Map File = False +Create Console Application = True +Using LoadExternalModule = False +DLL Exports = "Include File Symbols" +Register ActiveX Server = False +Add Type Lib To DLL = False +Include Type Lib Help Links = False +TLB Help Style = "HLP" +Type Lib FP File Is Rel = False +Type Lib FP File = "" + +[Default Build Config Release64] +Config Name = "Release64" +Is 64-Bit = True +Is Release = True +Default Calling Convention = "cdecl" +Uninitialized Locals Compile Warning = "Conservative" +Require Prototypes = True +Require Return Values = True +Enable Pointer Mismatch Warning = False +Enable Unreachable Code Warning = False +Enable Unreferenced Identifiers Warning = False +Enable Assignment In Conditional Warning = False +Enable C99 Extensions = False +Stack Size = 250000 +Image Base Address = 4194304 +Image Base Address x64 = 4194304 +Compiler Defines = "/DWIN32_LEAN_AND_MEAN" +Sign = False +Sign Store = "" +Sign Certificate = "" +Sign Timestamp URL = "" +Sign URL = "" +Manifest Embed = False +Icon File Is Rel = False +Icon File = "" +Application Title = "" +DLL Import Library Choice = "Gen Lib For Current Mode" +Use IVI Subdirectories for Import Libraries = False +Use VXIPNP Subdirectories for Import Libraries = False +Use Dflt Import Lib Base Name = True +Where to Copy DLL = "Do not copy" +Custom Directory to Copy DLL Is Rel = False +Custom Directory to Copy DLL = "" +Generate Source Documentation = "None" +Runtime Support = "Full Runtime Support" +Embed Project .UIRs = False +Generate Map File = False +Create Console Application = True +Using LoadExternalModule = False +DLL Exports = "Include File Symbols" +Register ActiveX Server = False +Add Type Lib To DLL = False +Include Type Lib Help Links = False +TLB Help Style = "HLP" +Type Lib FP File Is Rel = False +Type Lib FP File = "" + +[Compiler Options] +Default Calling Convention = "cdecl" +Require Prototypes = True +Require Return Values = True +Enable Pointer Mismatch Warning = False +Enable Unreachable Code Warning = False +Enable Unreferenced Identifiers Warning = False +Enable Assignment In Conditional Warning = False +O Option Compatible With 5.0 = False +Enable C99 Extensions = False +Uninitialized Locals Compile Warning = "Conservative" +Precompile Prefix Header = False +Prefix Header File = "" + +[Run Options] +Stack Size = 250000 +Image Base Address = 4194304 +Image Base Address x64 = 4194304 + +[Compiler Defines] +Compiler Defines = "/DWIN32_LEAN_AND_MEAN" + +[Include Paths] +Include Path 1 Is Rel = True +Include Path 1 Rel To = "Project" +Include Path 1 Rel Path = "" +Include Path 1 = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue" + +[Create Executable] +Executable File_Debug Is Rel = True +Executable File_Debug Rel To = "Project" +Executable File_Debug Rel Path = "Sys_dbg.exe" +Executable File_Debug = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/Sys_dbg.exe" +Executable File_Release Is Rel = True +Executable File_Release Rel To = "Project" +Executable File_Release Rel Path = "Sys.exe" +Executable File_Release = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/Sys.exe" +Executable File_Debug64 Is Rel = True +Executable File_Debug64 Rel To = "Project" +Executable File_Debug64 Rel Path = "Sys.exe" +Executable File_Debug64 = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/Sys.exe" +Executable File_Release64 Is Rel = True +Executable File_Release64 Rel To = "Project" +Executable File_Release64 Rel Path = "Sys.exe" +Executable File_Release64 = "/f/Driver/MyDrv-X64/ACTS/ACTS1000/LabWindows/AD/Continue/Sys.exe" +Icon File Is Rel = False +Icon File = "" +Application Title = "" +DLL Exports = "Include File Symbols" +DLL Import Library Choice = "Gen Lib For Current Mode" +Use IVI Subdirectories for Import Libraries = False +Use VXIPNP Subdirectories for Import Libraries = False +Use Dflt Import Lib Base Name = True +Where to Copy DLL = "Do not copy" +Custom Directory to Copy DLL Is Rel = False +Custom Directory to Copy DLL = "" +Generate Source Documentation = "None" +Add Type Lib To DLL = False +Include Type Lib Help Links = False +TLB Help Style = "HLP" +Type Lib FP File Is Rel = False +Type Lib FP File = "" +Type Lib Guid = "" +Runtime Support = "Full Runtime Support" +Instrument Driver Support Only = False +Embed Project .UIRs = False +Generate Map File = False + +[External Compiler Support] +UIR Callbacks File Option = 0 +Using LoadExternalModule = False +Create Project Symbols File = True +UIR Callbacks Obj File Is Rel = False +UIR Callbacks Obj File = "" +Project Symbols H File Is Rel = False +Project Symbols H File = "" +Project Symbols Obj File Is Rel = False +Project Symbols Obj File = "" + +[ActiveX Server Options] +Specification File Is Rel = False +Specification File = "" +Source File Is Rel = False +Source File = "" +Include File Is Rel = False +Include File = "" +IDL File Is Rel = False +IDL File = "" +Register ActiveX Server = False + +[Signing Info] +Sign = False +Sign Debug Build = False +Store = "" +Certificate = "" +Timestamp URL = "" +URL = "" + +[Manifest Info] +Embed = False + +[tpcSection] +tpcEnabled = 0 +tpcOverrideEnvironment = 0 +tpcEnabled x64 = 0 +tpcOverrideEnvironment x64 = 0 + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADCalibration.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADCalibration.cpp new file mode 100644 index 0000000..8bdac82 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADCalibration.cpp @@ -0,0 +1,123 @@ +// DlgCalibration.cpp : implementation file +// + +#include "stdafx.h" +#include "sys.h" +#include "ADCalibration.h" +#include "ACTS1000.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CADCalibration dialog + + + +CADCalibration::CADCalibration(CWnd* pParent /*=NULL*/) + : CDialog(CADCalibration::IDD, pParent) +{ + //{{AFX_DATA_INIT(CADCalibration) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void CADCalibration::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CADCalibration) + DDX_Control(pDX, IDC_PROGRESS_Calibration, m_ProgressCalibration); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CADCalibration, CDialog) + //{{AFX_MSG_MAP(CADCalibration) + ON_BN_CLICKED(IDC_BUTTON_Calibration, OnBUTTONCalibration) + ON_WM_TIMER() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CADCalibration message handlers +extern CSysApp theApp; +BOOL gl__bCalibration = FALSE; + +BOOL CADCalibration::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: Add extra initialization here + + m_ProgressCalibration.SetRange(0, 100); + + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CADCalibration::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: Add your message handler code here and/or call default + + m_lProgress++; + if (m_lProgress>100) + m_lProgress = 0; + m_ProgressCalibration.SetPos(m_lProgress); + + if (!gl__bCalibration) + StopCalibration(); + + + CDialog::OnTimer(nIDEvent); +} + +void CADCalibration::OnBUTTONCalibration() +{ + // TODO: Add your control notification handler code here + + if (theApp.m_hDevice != INVALID_HANDLE_VALUE) + { + int iRet = AfxMessageBox(_T("ȷûⲿź(ע:֧迹Ϊ1MŷУ׼)!"),MB_OKCANCEL); + if (iRet == 2) + { + return; + } + CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_Calibration); + m_lProgress =0; + gl__bCalibration = TRUE; + SetTimer(1, 100, NULL); + pStatic->SetWindowText(_T("Calibration over a long time, please be patient")); + GetDlgItem(IDC_BUTTON_Calibration)->EnableWindow(FALSE); + + AfxBeginThread(ReadDataThread, &m_hWnd, THREAD_PRIORITY_HIGHEST); + } + else + { + AfxMessageBox(_T("The device does not exist"),MB_OK, MB_ICONWARNING); + } +} + +UINT CADCalibration::ReadDataThread(PVOID hWnd) +{ + ACTS1000_ADCalibration(theApp.m_hDevice); + gl__bCalibration = FALSE; + + TRACE("END ADCalibrationThread"); + return 1; +} + +void CADCalibration::StopCalibration() +{ + GetDlgItem(IDC_BUTTON_Calibration)->EnableWindow(TRUE); + KillTimer(1); + m_ProgressCalibration.SetPos(100); + CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_Calibration); + pStatic->SetWindowText(_T("Complete the calibration")); + AfxMessageBox(_T("Complete the calibration")); + +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADCalibration.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADCalibration.h new file mode 100644 index 0000000..4750837 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADCalibration.h @@ -0,0 +1,53 @@ +#if !defined(AFX_DLGCALIBRATION_H__3DBE5577_6559_45CA_A620_0C3AA9A92AAC__INCLUDED_) +#define AFX_DLGCALIBRATION_H__3DBE5577_6559_45CA_A620_0C3AA9A92AAC__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// DlgCalibration.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CADCalibration dialog + +class CADCalibration : public CDialog +{ +// Construction +public: + LONG m_lProgress; + CADCalibration(CWnd* pParent = NULL); // standard constructor + void StopCalibration(); + + +// Dialog Data + //{{AFX_DATA(CADCalibration) + enum { IDD = IDD_DIALOG_Calibration }; + CProgressCtrl m_ProgressCalibration; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADCalibration) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + static UINT ReadDataThread(PVOID hWnd); +// static UINT ADCalibrationThread(PVOID hWnd); + + // Generated message map functions + //{{AFX_MSG(CADCalibration) + afx_msg void OnBUTTONCalibration(); + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DLGCALIBRATION_H__3DBE5577_6559_45CA_A620_0C3AA9A92AAC__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDigitView.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDigitView.cpp new file mode 100644 index 0000000..a97c28a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDigitView.cpp @@ -0,0 +1,483 @@ +// ADDigitView.cpp : implementation of the CADDigitView class +// +#include "stdafx.h" +#include "Sys.h" +#include "ADDoc.h" +#include "ADDigitView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern int gl_InputRange[MAX_CHANNEL_COUNT]; +///////////////////////////////////////////////////////////////////////////// +// CADDigitView + +IMPLEMENT_DYNCREATE(CADDigitView, CScrollView) + +BEGIN_MESSAGE_MAP(CADDigitView, CScrollView) +//{{AFX_MSG_MAP(CADDigitView) +ON_WM_CONTEXTMENU() +ON_WM_CANCELMODE() +ON_COMMAND(IDM_SixteenShow, OnSixteenShow) +ON_UPDATE_COMMAND_UI(IDM_SixteenShow, OnUpdateSixteenShow) +ON_COMMAND(IDM_TenShow, OnTenShow) +ON_UPDATE_COMMAND_UI(IDM_TenShow, OnUpdateTenShow) +ON_COMMAND(IDM_DigitalVoltShowMode, OnDigitalVoltShowMode) +ON_UPDATE_COMMAND_UI(IDM_DigitalVoltShowMode, OnUpdateDigitalVoltShowMode) +ON_WM_VSCROLL() +ON_WM_CREATE() +ON_WM_SIZE() +ON_WM_ERASEBKGND() + ON_WM_HSCROLL() + ON_WM_KEYDOWN() + ON_WM_MOUSEWHEEL() +ON_MESSAGE(WM_SHOWDIGIT, ShowDigit) + //}}AFX_MSG_MAP +// Standard printing commands +ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint) +ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint) +ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CADDigitView construction/destruction + +CADDigitView::CADDigitView() +{ + // TODO: add construction code here + m_DigitalDataShowMode = VOLT_DATAMODE; // ѹֵʾģʽ + CurrentProgress = 0; // òɼֵΪ0 + m_nDigDrawIdx = 0; + m_nDigDrawLen = 1024; +} + +CADDigitView::~CADDigitView() +{ + + +} + +BOOL CADDigitView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + return CScrollView::PreCreateWindow(cs); +} + +///////////////////////////////////////////////////////////////////////////// +// CADDigitView drawing +void CADDigitView::OnDraw(CDC* pDC) +{ + ADDigit(pDC); + if(m_bProgress) // ˢADDigitViewͼʱ½״̬ + { + CADFrame* pShow=((CSysApp*)AfxGetApp())->m_ADFrame ; // ȡ֡ھ + pProgress=(CProgressCtrl*)(pShow->m_wndShowStatus.GetDlgItem(IDC_PROGRESS)); + pProgress->SetPos(CurrentProgress); + CurrentProgress++; + if(CurrentProgress>50) CurrentProgress=0; + m_bProgress=FALSE; + } +} + +void CADDigitView::OnInitialUpdate() +{ + CScrollView::OnInitialUpdate(); + CSize sizeTotal; + // TODO: calculate the total size of this view + const SIZE conPSize = {200,1}; + const SIZE conLSize = {20,1}; + sizeTotal.cx = 500; + sizeTotal.cy = 1026*16; + SetScrollSizes(MM_TEXT, sizeTotal, CSize(sizeDefault.cx, 36*16), CSize(sizeDefault.cx, 16)); + CADDoc* pDoc = GetDocument(); + pDoc->m_hWndDigit = m_hWnd; +} + +///////////////////////////////////////////////////////////////////////////// +// CADDigitView printing + +BOOL CADDigitView::OnPreparePrinting(CPrintInfo* pInfo) +{ + // default preparation + return DoPreparePrinting(pInfo); +} + +///////////////////////////////////////////////////////////////////////////// +// CADDigitView diagnostics +#ifdef _DEBUG +void CADDigitView::AssertValid() const +{ + CScrollView::AssertValid(); +} + +void CADDigitView::Dump(CDumpContext& dc) const +{ + CScrollView::Dump(dc); +} + +CADDoc* CADDigitView::GetDocument() // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CADDoc))); + return (CADDoc*)m_pDocument; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CADDigitView message handlers +void CADDigitView::ADDigit(CDC *pDC)//ʾchֵ +{ + + bDrawing = TRUE; // ֪ͨݴ̣߳ڻ֣벻ҪDrawBuffer + CRect rect; + int i; + TCHAR strIndex[512], str[512]; + int ChannelIndex = 0; + int nChannelCount=0; + GetClientRect(&rect); + OnPrepareDC(pDC); + pDC->DPtoLP(&rect); + CBrush brush; + brush.CreateSolidBrush(RGB(0, 0, 0)); + pDC->FillRect(rect, &brush); + pDC->SetTextColor(RGB(0, 255, 0)); + pDC->SetBkMode(TRANSPARENT); + int Channel = 0; + int nTextHeight = 0; + + ULONG ulBuffID = m_nDigDrawIdx; + pDC->SetTextColor(RGB(0, 255, 0)); + nChannelCount = 0; + _stprintf(strIndex, _T("%s "), _T("Index")); + pDC->TextOut(-rect.left, rect.top +20, strIndex); // first line text out "Index CHX..." + switch(m_DigitalDataShowMode) + { + case DEC_DATAMODE: // ʮʾ + _stprintf(str, _T("%s"), _T(" ʮʾ")); + pDC->SetTextColor(RGB(255, 0, 0)); + pDC->TextOut(-rect.left, rect.top, str); + pDC->SetTextColor(RGB(0, 255, 0)); + for (Channel=0; ChannelTextOut(-rect.left+(nChannelCount+1)*70, rect.top +20, str); // first line text out "Index CHX..." + nChannelCount++; + } + } + break; + case HEX_DATAMODE: // ʮʾ + _stprintf(str, _T("%s"),_T(" ʮԭʾ")); + pDC->SetTextColor(RGB(0, 255, 255)); + pDC->TextOut(-rect.left, rect.top, str); + pDC->SetTextColor(RGB(0, 255, 0)); + _stprintf(strIndex, _T("%s "), _T("Index")); + for (Channel=0; ChannelTextOut(-rect.left+(nChannelCount+1)*70, rect.top +20, str); // first line text out "Index CHX..." + nChannelCount++; + } + } + + break; + case VOLT_DATAMODE: // ѹֵʾ + _stprintf(str, _T("%s"), _T(" ѹֵʾ")); + pDC->SetTextColor(RGB(255, 255, 0)); + pDC->TextOut(-rect.left, rect.top, str); + pDC->SetTextColor(RGB(0, 255, 0)); + _stprintf(strIndex, _T("%s "), _T("Index")); + for (Channel=0; ChannelTextOut(-rect.left+(nChannelCount+1)*70, rect.top +20, str); // first line text out "Index CHX..." + nChannelCount++; + } + } + break; + } + nTextHeight = 20; + //pDC->TextOut(-rect.left, rect.top +20, strIndex); // first line text out "Index CHX..." + + ULONG nDataLength = MAX_RAM_SIZE/gl_nChannelCount-glOffset; + if (gl_bSmlThenSize && ADPara.SampleMode==ACTS1000_SAMPMODE_FINITE) + { + nDataLength = (gl_ReadSizeWords%8192)/gl_nChannelCount-glOffset; + if (nDataLength == 0) + nDataLength = 8192/gl_nChannelCount; + } + + nDataLength = m_nDigDrawLen; + +// if (nDataLength>m_nPlotWidth) +// { +// nDataLength = m_nPlotWidth; +// } + + int Index = 0; + for(i=rect.top; i= MAX_RAM_SIZE/MAX_CHANNEL_COUNT) break; +// if(Index >= MAX_RAM_SIZE/gl_nChannelCount) break; + if(Index >= nDataLength) break; + _stprintf(strIndex, _T("%8d"), Index); + pDC->TextOut(-rect.left, rect.top+nTextHeight+16, strIndex); // text out Index of data + nChannelCount = 0; + switch(m_DigitalDataShowMode) + { + case DEC_DATAMODE: // ʮƫ + for(Channel=0; ChannelTextOut(-rect.left-30+(nChannelCount+1)*70, rect.top+nTextHeight+16, str); // text out decimal value every channel + nChannelCount++; + } + } + break; + case HEX_DATAMODE: // ʮԭ + for(Channel=0; ChannelTextOut(-rect.left-30+(nChannelCount+1)*70, rect.top+nTextHeight+16, str); // text out hex value every channel + nChannelCount++; + } + } + break; + case VOLT_DATAMODE: // ѹֵ + for(Channel=0; ChannelTextOut(-rect.left-30+(nChannelCount+1)*70, rect.top+nTextHeight+16, str); // text out volt value + nChannelCount++; + } + } + break; + default: + break; + } + + nTextHeight += 16; // next line + } + } + bDrawing = FALSE; // ֪ͨݴֻ̣߳ɣDrawBuffer +} + + +void CADDigitView::OnContextMenu(CWnd* pWnd, CPoint point) +{ + // TODO: Add your message handler code here + { + if (point.x == -1 && point.y == -1) + { + //keystroke invocation + CRect rect; + GetClientRect(rect); + ClientToScreen(rect); + + point = rect.TopLeft(); + point.Offset(5, 5); + } + + CMenu menu; + VERIFY(menu.LoadMenu(IDR_ChooseMode)); + + CMenu* pPopup = menu.GetSubMenu(0); + ASSERT(pPopup != NULL); + CWnd* pWndPopupOwner = this; + + while (pWndPopupOwner->GetStyle() & WS_CHILD) + pWndPopupOwner = pWndPopupOwner->GetParent(); + + pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); + } +} + +void CADDigitView::OnCancelMode() +{ + CScrollView::OnCancelMode(); + // TODO: Add your message handler code here +} + +void CADDigitView::OnSixteenShow() //ʮʾ +{ + // TODO: Add your command handler code here + m_DigitalDataShowMode = HEX_DATAMODE; + CSysApp *pApp=(CSysApp *)AfxGetApp(); + CADDoc* pDoc=pApp->m_pADDoc; + pDoc->UpdateAllViews(NULL, 1, NULL); // 1Ҫػͼ +} + +void CADDigitView::OnTenShow()//ʮʾ +{ + // TODO: Add your command handler code here + m_DigitalDataShowMode = DEC_DATAMODE; + CSysApp *pApp=(CSysApp *)AfxGetApp(); + CADDoc* pDoc=pApp->m_pADDoc; + pDoc->UpdateAllViews(NULL, 1, NULL); // 1Ҫػͼ +} + +void CADDigitView::OnDigitalVoltShowMode() +{//ѹʾ + // TODO: Add your command handler code here + m_DigitalDataShowMode = VOLT_DATAMODE; + CSysApp *pApp=(CSysApp *)AfxGetApp(); + CADDoc* pDoc=pApp->m_pADDoc; + pDoc->UpdateAllViews(NULL, 1, NULL); // 1Ҫػͼ +} + +void CADDigitView::OnUpdateSixteenShow(CCmdUI* pCmdUI) +{//ʮ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck (m_DigitalDataShowMode == HEX_DATAMODE); +} + +void CADDigitView::OnUpdateTenShow(CCmdUI* pCmdUI) +{//ʮʾ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck (m_DigitalDataShowMode == DEC_DATAMODE); +} + +void CADDigitView::OnUpdateDigitalVoltShowMode(CCmdUI* pCmdUI) +{//ѹʾ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(m_DigitalDataShowMode == VOLT_DATAMODE); +} + +void CADDigitView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default +// RedrawWindow(); // û϶ʱҪͼػ + Invalidate(); + CScrollView::OnVScroll(nSBCode, nPos, pScrollBar); + +} + + +int CADDigitView::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CScrollView::OnCreate(lpCreateStruct) == -1) + return -1; + + return 0; +} + +void CADDigitView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) +{ + // TODO: Add your specialized code here and/or call the base class + if(lHint==1) // ַʽִиOnUpdateOnDraw + { + CScrollView::OnUpdate(pSender, lHint, pHint); + } +} + +void CADDigitView::OnSize(UINT nType, int cx, int cy) +{ + CScrollView::OnSize(nType, cx, cy); + CADDoc* pDoc=GetDocument(); + CRect rect; + GetWindowRect(&rect); + pDoc->m_nADDigitWidth=rect.Width()+7; +} + +BOOL CADDigitView::OnEraseBkgnd(CDC* pDC) +{ + // TODO: Add your message handler code here and/or call default + CBrush brush; + CRect rect; + GetClientRect(rect); + brush.CreateSolidBrush(RGB(0, 0, 0)); + pDC->FillRect(rect, &brush); + return TRUE; + // return CScrollView::OnEraseBkgnd(pDC); +} + + + +LRESULT CADDigitView::ShowDigit(WPARAM wParam, LPARAM lParam) +{ + + m_nDigDrawLen = wParam; + m_nDigDrawIdx = lParam; + this->Invalidate(); // ˢͼ + return 1; +} + +void CADDigitView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + Invalidate(); + CScrollView::OnHScroll(nSBCode, nPos, pScrollBar); +} + +void CADDigitView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: Add your message handler code here and/or call default + switch(nChar) + { + case VK_HOME: + SendMessage(WM_VSCROLL, SB_TOP, NULL); + break; + case VK_END: + SendMessage(WM_VSCROLL, SB_BOTTOM, NULL); + break; + case VK_PRIOR: + SendMessage(WM_VSCROLL, SB_PAGEUP, NULL); + break; + case VK_NEXT: + SendMessage(WM_VSCROLL, SB_PAGEDOWN, NULL); + break; + case VK_UP: + SendMessage(WM_VSCROLL, SB_LINEUP, NULL); + break; + case VK_DOWN: + SendMessage(WM_VSCROLL, SB_LINEDOWN, NULL); + break; + case VK_LEFT: + SendMessage(WM_HSCROLL, SB_LINELEFT, NULL); + break; + case VK_RIGHT: + SendMessage(WM_HSCROLL, SB_LINERIGHT, NULL); + break; + default: + break; + } + CScrollView::OnKeyDown(nChar, nRepCnt, nFlags); +} + +BOOL CADDigitView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) +{ + // TODO: Add your message handler code here and/or call default + if(zDelta > 0) + { + SendMessage(WM_VSCROLL, SB_LINEUP, NULL); + } + else + { + SendMessage(WM_VSCROLL, SB_LINEDOWN, NULL); + } + return CScrollView::OnMouseWheel(nFlags, zDelta, pt); +} + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDigitView.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDigitView.h new file mode 100644 index 0000000..27a2c2a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDigitView.h @@ -0,0 +1,88 @@ +// ADDigitView.h : interface of the CADDigitView class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_ADDIGITVIEW_H__D485DF07_85AB_11D1_B878_A68EB300DD63__INCLUDED_) +#define AFX_ADDIGITVIEW_H__D485DF07_85AB_11D1_B878_A68EB300DD63__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +class CADDigitView : public CScrollView +{ +protected: // create from serialization only + CADDigitView(); + DECLARE_DYNCREATE(CADDigitView) + +// Attributes +public: + CProgressCtrl* pProgress; + int CurrentProgress; +// Operations +public: + ULONG m_nDigDrawIdx; + ULONG m_nDigDrawLen; + void ADDigit(CDC *pDC); + CADDoc *GetDocument(); + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADDigitView) + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + protected: + virtual void OnInitialUpdate(); // called first time after construct + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); + //}}AFX_VIRTUAL + +// Implementation +public: + LRESULT ShowDigit(WPARAM wParam, LPARAM lParam); + CDC memDC; + CBitmap m_Bitmap; + virtual ~CADDigitView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CADDigitView) + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnCancelMode(); + afx_msg void OnSixteenShow(); + afx_msg void OnUpdateSixteenShow(CCmdUI* pCmdUI); + afx_msg void OnTenShow(); + afx_msg void OnUpdateTenShow(CCmdUI* pCmdUI); + afx_msg void OnDigitalVoltShowMode(); + afx_msg void OnUpdateDigitalVoltShowMode(CCmdUI* pCmdUI); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; +CADDoc *GetDocument(); +#ifndef _DEBUG // debug version in ADDigitView.cpp +inline CADDoc* CADDigitView::GetDocument() + { return (CADDoc*)m_pDocument; } +#endif + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ADDigitVIEW_H__D485DF07_85AB_11D1_B878_A68EB300DD63__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDoc.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDoc.cpp new file mode 100644 index 0000000..e7fb664 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDoc.cpp @@ -0,0 +1,654 @@ +// ADDoc.cpp : implementation of the CADDoc class +// + +#include "stdafx.h" +#include "Sys.h" +#include "ADDoc.h" +#include "ADDigitView.h" +#include "ADWaveView.h" +#include "ADStatusView.h" +#include "ParaCfgView.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif +#ifdef ACTS1000_CreateSystemEvent +#define ACTS1000_CreateSystemEvent ACTS1000_TCreateSystemEvent +#endif +//////////////////////////////////////////////////////////////////////// +WORD* ADBuffer[MAX_SEGMENT]; // +WORD* ADDrawBuffer; // ˢ» + +BOOL m_bDrawComp= FALSE; +BOOL gl_bAutoCollect = FALSE; +int CurrentIndex; // ADݴ̵߳ǰ +int ReadIndex; // ADݲɼ̵߳ǰ +BOOL gl_bDeviceADRun=FALSE; +BOOL gl_bAutoTrig=TRUE; +ACTS1000_PARA_AD ADPara; +ACTS1000_PARA_AD OldADPara; +ACTS1000_STATUS_AD gl_ADStatus; +ACTS1000_AD_MAIN_INFO gl_ADMainInfo; +WORD gl_wMaxLSB = 0x3FFF; +float gl_fLsbCount = 16384.0; +WORD gl_lLsbHalf = 8192; +//BOOL bCheckOverflow=FALSE; // ǷFIFO־ +int gl_nSampleMode = PRO_MODE; // ɼģʽ(1,ѯ 2, жϣ 3 DMA) +UINT ReadDataThread(PVOID hWnd);//߳ +UINT ProccessDataThread(PVOID hWnd); // ߳ + +BOOL m_bFirstCreateDeviceFile; +int m_ProcessGraphicMode;//Ϊ1,ʾ +BOOL m_AnalyzeCheck;//ƾȷ +int gl_ScreenVolume;//Ļʾ +int m_TriggerVolt;//ѹ +int gl_MiddleLsb[MAX_CHANNEL_COUNT]; +float m_AnalyzeAllCount; +UINT m_OverLimitCount; +int m_ProcessMoveVolt;//Ϊ1ʱ,ƽƵѹ +BOOL bCreateDevice; +BOOL m_bProgress; // Ƿ½ +int nProcessMode; // ݴʽ 1ʾ 2ʾ 3ݴ +CEdit* pCountEdit; +CEdit* pRangeEdit; +CEdit* pRatioEdit; +CADDigitView* m_pDigitView; +CADWaveView* m_pWaveView; +CADStatusView* pADStatusView = NULL; +CParaCfgView* pParaCfgView = NULL; +HANDLE hEvent; // ɼ̵߳߳ͬź +int m_DigitalDataShowMode; // ִʾģʽ +int DeviceID; // óʹõ豸ID +HANDLE g_ArrFileOut; + +int gl_nChannelCount = MAX_CHANNEL_COUNT; +int gl_nSaveFileCount = MAX_CHANNEL_COUNT; + +BOOL m_bCloseFile; +HANDLE hExitEvent; +float Center, PerY; +CRect ClientRect; +float middle1; +BOOL bDrawing=FALSE; + +ULONGLONG FileLenghtWords; +int nChannelArrayClient[MAX_CHANNEL_COUNT];// ͨ +int gl_CurrentbufNum = 0; // ǰĻ +int DisplayChannel[MAX_CHANNEL_COUNT];// ڱ־ͨǷʾ +float OutAnalogValve; // ʾģⴥȫֱ +ULONG gl_nSampleLenth = MAX_RAM_SIZE; // +int gl_InputRange[MAX_CHANNEL_COUNT]; // ͨõĵѹ̷Χ +float gl_PerLsbVoltM[MAX_CHANNEL_COUNT]; // λLSBĵѹֵ +CString g_strFileFullName; +ULONG gl_StartAddr; + +TCHAR g_strChannelEn[2][64] = { L"ֹ", L"" }; +TCHAR g_strGain[4][64] = { L"1Ŵ", L"2Ŵ", L"4Ŵ", L"8Ŵ" }; +TCHAR g_strRefGround[3][64] = { L"ֱ", L""}; +TCHAR g_strAIRange[3][64] = {L"5V", L"1V", L"10V"}; +TCHAR g_strInputImped[2][64] = {L"1M", L"50"}; + +ULONG m_nSampRangeCount; +ULONG m_nSampRangeVal[8]; + +ULONG gl_CHIdx[MAX_CHANNEL_COUNT] = +{ + 0,1,2,3,4,5,6,7 +}; +CCriticalSection gl_Section; +ULONG gl_nDrawLen = 1024; + +ULONG gl_nDocDrawLen = 1024; + +ULONG gl_nDrawIdx = 0; +ULONG gl_nDocDrawIdx = 0; +//############################################## +//ʹöý嶨ʱÿ50֡µٶˢĻ +#include "stdio.h" +#include "MmSystem.h" + +void PASCAL DrawWindowProc(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2); +#define ONE_MILLI_SECOND 1 +#define TWO_SECOND 2000 +// ʱ ʣ Ϊ λ ---- +#define TIMER_ACCURACY 1 +UINT wAccuracy; // +UINT TimerID; // ʱ + +//////////////////////////////////////////////////////////////////////////// +// CADDoc + +IMPLEMENT_DYNCREATE(CADDoc, CDocument) + +BEGIN_MESSAGE_MAP(CADDoc, CDocument) +//{{AFX_MSG_MAP(CADDoc) +ON_COMMAND(IDM_TileWave, OnTileWave) +ON_COMMAND(IDM_SuperPoseWave, OnSuperPoseWave) +ON_UPDATE_COMMAND_UI(IDM_SuperPoseWave, OnUpdateSuperPoseWave) +ON_UPDATE_COMMAND_UI(IDM_TileWave, OnUpdateTileWave) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() +/////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// CADDoc construction/destruction + +extern CSysApp theApp; +CADDoc::CADDoc() +{ + // TODO: add one-time construction code here + m_bProgress=FALSE; // һʼ½ + nProcessMode = DATA_MODE; // ĬϷʽʾ + m_TriggerVolt=(int)VOLT_RANGE; // ôƽijֵΪ + m_bFirstCreateDeviceFile=TRUE; // һʼΪһδļ + m_bCloseFile=TRUE; // ûдļʱΪļر + gl_nChannelCount=0; + ACTS1000_LoadParaAD(theApp.m_hDevice, &ADPara); // ϵͳ + + for (int i=gl_ADMainInfo.nChannelCount; im_hDevice==INVALID_HANDLE_VALUE) + { + AfxMessageBox(_T("Բ豸..."),MB_ICONERROR); + return; + } + if(!gl_bTerminateDrawThr) + { + AfxMessageBox(_T(" ߳ûֹ")); + return; + } + FileLenghtWords = 0; // ļȳʼ + m_DrawWindowThread = AfxBeginThread(ProccessDataThread,NULL, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); + m_DrawWindowThread->m_bAutoDelete = TRUE; // Զɾ + + // ݲɼ봰ڻͬ¼ + hEvent = ACTS1000_CreateSystemEvent(); + hExitEvent = ACTS1000_CreateSystemEvent(); + bCollectData=TRUE; // 豸󣬿Խݲɼ +// for(int i=0;i>16; // 豸 + header.DeviceNum = DEFAULT_DEVICE_NUM; + header.DeviceType = gl_ADMainInfo.nDeviceType&0xFFFF; // 豸ID + header.ChannelCount = gl_nChannelCount; // ÿͨǶģΪ1 + header.DataWidth = gl_ADMainInfo.nSampResolution; // 12λ + header.bXorHighBit = 0; // λ + header.nRevisionID = theApp.m_nRevisionID; + + ULONG nSampRangeCount; + ULONG nSampRangeVal[8]; + if (!ACTS1000_GetSupportRangeInfo(theApp.m_hDevice, &nSampRangeCount,nSampRangeVal)) + { + AfxMessageBox(L"ȥ֧Ϣʧ",MB_ICONWARNING,0); + + return; + } + + // û + switch(ADPara.InputRange[0]) // ѹ + { + case ACTS1000_INPUT_N1000_P1000mV: // 1000 + header.VoltTopRange = 1000; + header.VoltBottomRange = -1000; + break; + case ACTS1000_INPUT_N10000_P10000mV: // 5000 + + header.VoltTopRange = 10000; + header.VoltBottomRange = -10000; + break; + case ACTS1000_INPUT_N5000_P5000mV: + header.VoltTopRange = 5000; + header.VoltBottomRange = -5000; + break; + } + header.ADPara = ADPara; + header.CrystalFreq = gl_ADMainInfo.nBaseRate; // Ƶ + header.HeadEndFlag = HEAD_END_FLAG; + header.ADStatus = gl_ADStatus; + + time_t nowtime; + time(&nowtime); + header.CreateFTime = (ULONGLONG)nowtime; + memcpy(&header.ADMainInfo, &gl_ADMainInfo, sizeof(gl_ADMainInfo)); + + // дļͷ + // g_ArrFileOut[Index].Write((WORD*)&header, header.HeadSizeBytes); + DWORD dTmp; + if (!WriteFile(g_ArrFileOut, (WORD*)&header, header.HeadSizeBytes, + &dTmp, NULL)) + { + AfxMessageBox(L"error"); + } + } + + // ͨͼΧ + CADDigitView* pDigitView=(CADDigitView*)(CWnd::FromHandle(m_hWndDigit)); + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(m_hWndWave)); + CADFrame* pShow=((CSysApp*)AfxGetApp())->m_ADFrame ; // ȡ֡ھ + + CProgressCtrl* pProgress=(CProgressCtrl*)(pShow->m_wndShowStatus.GetDlgItem(IDC_PROGRESS)); + pProgress->SetPos(0); // ͷ豸ʱýΪֵ + + + // 豸 + if(!MyStartDeviceAD(pApp->m_hDevice)) // 豸,ʼɼ + { + AfxMessageBox(_T("豸ʧ")); + return; + } + + gl_bDeviceADRun = TRUE; + if(pParaCfgView != NULL) + { + pParaCfgView->EnableWindows(FALSE); // 豸ʼʱֹӲ + pParaCfgView->StartAD(); + } + m_DrawWindowThread->ResumeThread(); // ƴ߳ +} + +BOOL gl_Event = FALSE; +//################### ߳ ################################################3### +UINT ProccessDataThread(PVOID hWnd) +{ + CSysApp *pApp=(CSysApp *)AfxGetApp(); + CADFrame *pFrm=pApp->m_ADFrame ; + CADDoc* pDoc=pApp->m_pADDoc; + // ߳ȡͼָ + CADDigitView* pDigitView=(CADDigitView*)(CWnd::FromHandle(pDoc->m_hWndDigit)); + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + CString str; + BOOL bFirst=TRUE; + ULONG WroteMB=0; + + pDoc->m_Wrote8KWCounter=0; + pDoc->m_WroteMB=0; + CurrentIndex=0; + int ShowCount=0,i; + ULONG ulTime = 0; + ULONG nDrawL = 0; + ULONG nDrawI = 0; + while(gl_bDeviceADRun) // ѭAD + { + do{ + if(!gl_bDeviceADRun) goto ExitProcDataThread; + } while(WaitForSingleObject(hEvent, 100) != WAIT_OBJECT_0); + gl_bTerminateDrawThr = FALSE; + gl_Event = TRUE; + switch(nProcessMode) // ݴ + { + case DATA_MODE: // ִ + if ((GetTickCount()-ulTime)>100) + { + + gl_Section.Lock(); + nDrawL =gl_nDrawLen; + nDrawI =gl_nDrawIdx; + gl_nDocDrawLen = gl_nDrawLen; + gl_nDocDrawIdx =gl_nDrawIdx; + gl_Section.Unlock(); + ::SendMessage(pDoc->m_hWndDigit, WM_SHOWDIGIT, nDrawL, nDrawI); + m_bProgress=TRUE; // ʹOnDrawܸ½ + ulTime = GetTickCount(); + } + /*else + { + if (gl_bSmlThenSize) + { + gl_bSmlThenSize = FALSE; + } + }*/ + break; + case WAVE_MODE: // δ + if ((GetTickCount()-ulTime)>120) + { + + + gl_Section.Lock(); + nDrawL =gl_nDrawLen; + nDrawI =gl_nDrawIdx; + gl_nDocDrawLen = gl_nDrawLen; + gl_nDocDrawIdx =gl_nDrawIdx; + gl_Section.Unlock(); + ::SendMessage(pDoc->m_hWndWave,WM_SHOWWAVE, nDrawL, nDrawI); + m_bProgress=TRUE; // ʹOnDrawܸ½ + ulTime = GetTickCount(); + //Sleep(1); + } + break; + case SAVE_MODE: // ݴ̴ + WroteMB=(WroteMB+32)%1024; + pFrm->m_Progress()->SetPos((int)WroteMB); + str.Format(_T("%d"), (FileLenghtWords/512)); + i=str.GetLength()-3; + while(i>0) + { + str.Insert(i, ','); + i-=3; + } + str+=" Kb"; + pFrm->m_FileLenght()->SetWindowText(str); + ShowCount++; + break; + }//end switch + + }//end while +ExitProcDataThread: + gl_bTerminateDrawThr = TRUE; // ֹ߳ + + return TRUE; +} +//########################################################################################## + +void CADDoc::Public_ReleaseDevice(void) // MDIڵ +{ + StopDeviceAD(); +} + +void CADDoc::StopDeviceAD() +{ + CSysApp *pApp=(CSysApp *)AfxGetApp(); +// gl_bDeviceADRun = FALSE; // ֹͣ߳̽ݲɼ + + CADFrame* pShow=((CSysApp*)AfxGetApp())->m_ADFrame ; // ȡ֡ھ + + + +// bCreateDevice = FALSE; +// SetEvent(hExitEvent); +// WaitForSingleObject(hExitEvent, 100); // ȴɼ߳˳ + // ֹɼ߳ + CProgressCtrl* pProgress=(CProgressCtrl*)(pShow->m_wndShowStatus.GetDlgItem(IDC_PROGRESS)); + pProgress->SetPos(0); // ͷ豸ʱýΪֵ + + // 豸ͷźӲ + if(pParaCfgView != NULL) + { + pParaCfgView->EnableWindows(TRUE); + } + bCreateDevice = FALSE; // ͷ豸豸δ + + +// ::SendMessage(m_hWndDigit, WM_SHOWDIGIT, gl_nDocDrawLen, NULL); +// ::SendMessage(m_hWndWave,WM_SHOWWAVE, gl_nDocDrawLen, NULL); + if(!MyStopDeviceAD(pApp->m_hDevice)) // رAD豸 + { + AfxMessageBox(_T("رAD豸ʧ!")); + return; + } + if(nProcessMode == SAVE_MODE) // ݴʽΪ + { + + OnCloseFile();//ͷļ + nProcessMode = DATA_MODE; // óַʽ + if(pADStatusView != NULL) + { + CButton* pDataSave=(CButton*)(pADStatusView->GetDlgItem(IDM_DataSave)); + pDataSave->EnableWindow(FALSE); // ʹ̷ʽѡЧ + + } + } + ACTS1000_ReleaseSystemEvent(hEvent); // ͷϢ + ACTS1000_ReleaseSystemEvent(hExitEvent); // ͷϢ + + gl_Section.Lock(); + gl_nDocDrawLen = gl_nDrawLen; + gl_nDocDrawIdx =gl_nDrawIdx; + gl_Section.Unlock(); + ::SendMessage(m_hWndDigit, WM_SHOWDIGIT, gl_nDrawLen, gl_nDrawIdx); + ::SendMessage(m_hWndWave,WM_SHOWWAVE, gl_nDrawLen, gl_nDrawIdx); + +} + + +void CADDoc::OnDataFileNew() +{ + // TODO: Add your command handler code here + CString strNewFileName; + CString TempFileName; + CSysApp* pApp=(CSysApp*)AfxGetApp(); + if (!(pApp->DoPromptFileName(strNewFileName, IDS_NEW_FILE, + OFN_HIDEREADONLY | OFN_CREATEPROMPT, TRUE, NULL))) + return; + if(!m_bFirstCreateDeviceFile) + { // ǵһδļ,ͷļ + if ( ! CloseHandle( g_ArrFileOut ) ) + { + AfxMessageBox(L"ͷļʧ...",MB_ICONSTOP,0); + } + } + + // ļ + + int FileNameLength=strNewFileName.GetLength(); + //TempFileName=strNewFileName.Left(FileNameLength-4); + + + g_ArrFileOut =CreateFile(strNewFileName, GENERIC_READ|GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); + if (g_ArrFileOut == INVALID_HANDLE_VALUE ) + + { + AfxMessageBox(_T("ʼļʧ..."),MB_ICONSTOP,0); + return; + } + // 򿪵ļ + g_strFileFullName = strNewFileName; + + gl_nSaveFileCount = gl_nChannelCount; + + + + CADFrame* pShow=((CSysApp*)AfxGetApp())->m_ADFrame ; // ȡ֡ھ + pShow->ShowHideDlgSave (); //ʾ + pShow->ShowHideStatus(FALSE);//״̬ + if(pADStatusView != NULL) + { + CButton* pDataSave=(CButton*)(pADStatusView->GetDlgItem(IDM_DataSave)); + pDataSave->EnableWindow(TRUE); // ʹ̷ʽѡЧ + } + + _ULARGE_INTEGER dlFreeSpace, dlTotalSpace, dlUserSpace; + + GetDiskFreeSpaceEx(strNewFileName.Left(3), &dlUserSpace, &dlUserSpace, &dlFreeSpace); + (void)dlTotalSpace; + (void)dlUserSpace; + + ULONGLONG DiskFreeBytes = dlFreeSpace.QuadPart; + + // ȡļڴ̿ÿռ */ + m_RemainMB=(ULONG)(DiskFreeBytes/(1024*1024)); // жM + CString str; + + if(m_RemainMB<2) + { + AfxMessageBox(_T("Ӳʣռ䲻2M̲ܽ..."),MB_ICONSTOP,0); + return; + } + str.Format(_T("%d Mb"),m_RemainMB); + pShow->m_DiskFree()->SetWindowText (str);// õǰӲ̿ÿռMB + + pShow->m_Progress()->SetRange32(0,1024);// ý̷Χ + pShow->m_Progress()->SetPos(0); + + ///////////// + pShow->m_FileName()->SetWindowText(strNewFileName);//ʾļ + m_bFirstCreateDeviceFile=FALSE; // ɹļñ־ + + m_bCloseFile=FALSE; // ļûйر,Բرյǰļ˵ + if(pADStatusView != NULL) + pADStatusView->SetDlgCheck(); + nProcessMode = SAVE_MODE; // ļʱζҪд̴ + + pADStatusView->SetDlgCheck(); +} + +void CADDoc::OnCloseFile() +{ + // TODO: Add your command handler code here + DWORD dTmp; + + header.HeadSizeBytes = sizeof(FILE_HEADER); + header.ADStatus = gl_ADStatus; // gl_ADStatus.bTrigFlag; +// g_ArrFileOut.SeekToBegin(); +// g_ArrFileOut.Write(&header, sizeof(FILE_HEADER)); +// g_ArrFileOut.Close(); + SetFilePointer(g_ArrFileOut, 0, 0, FILE_BEGIN); + //ACTS1000_WriteFile(hFileObject[nChannel], &header, sizeof(FILE_HEADER)); + if (!WriteFile(g_ArrFileOut, &header, sizeof(FILE_HEADER), &dTmp, NULL)) + { + AfxMessageBox(L"error"); + } + CloseHandle( g_ArrFileOut); + + CString strTitle; + strTitle = GetTitle(); // ΪֹSetPathNameıĵTitleǰ + // ӵ 򿪵ļб + + + + + + m_bCloseFile=TRUE; // ļر + nProcessMode = DATA_MODE; // رļʱζҪٽд̴óַʽ + m_bFirstCreateDeviceFile=TRUE; // ļرպζԺļǵһα + /////// + CADFrame* pADFrm = ((CSysApp*)AfxGetApp())->m_ADFrame ; // ȡ֡ھ + CButton* pDataSave=(CButton*)(pADStatusView->GetDlgItem(IDM_DataSave)); + pDataSave->EnableWindow(TRUE); // ʹ̷ʽѡЧ + + CString str; + str.Format(_T("%d"), 0); + pADFrm->m_DiskFree()->SetWindowText(str); + + if (gl_bAutoCollect) + { +// SetPathName(g_strFileFullName[1]); + SetPathName(g_strFileFullName); + SetTitle(strTitle); // ָĵTitle + pADFrm->ShowHideDlgSave (FALSE); // ش + pADFrm->ShowHideStatus();//ʾ״̬ + } + + + pADFrm->m_Progress()->SetRange32(0,1024); // ý̷Χ + pADFrm->m_Progress()->SetPos(0); + // һ׽ + pADStatusView->SetDlgCheck(); +} + + +void CADDoc::OnTileWave() +{ + // TODO: Add your command handler code here + gl_bTileWave = TRUE; + CButton* pButtonTile = (CButton*)pADStatusView->GetDlgItem(IDM_TileWave); + pButtonTile->SetCheck(1); + CButton* pButtonPose = (CButton*)pADStatusView->GetDlgItem(IDM_SuperPoseWave); + pButtonPose->SetCheck(0); + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(m_hWndWave)); + pWaveView->m_ADScopeCtrl.InvalidateCtrl(); + pWaveView->OnDrawPolyLine(gl_nDocDrawLen,gl_nDocDrawIdx); +} + +void CADDoc::OnSuperPoseWave() +{ + // TODO: Add your command handler code here + gl_bTileWave = FALSE; + CButton* pButtonTile = (CButton*)pADStatusView->GetDlgItem(IDM_TileWave); + pButtonTile->SetCheck(0); + CButton* pButtonPose = (CButton*)pADStatusView->GetDlgItem(IDM_SuperPoseWave); + pButtonPose->SetCheck(1); + CADWaveView* pWaveView = (CADWaveView*)(CWnd::FromHandle(m_hWndWave)); + pWaveView->m_ADScopeCtrl.InvalidateCtrl(); + pWaveView->OnDrawPolyLine(gl_nDocDrawLen,gl_nDocDrawIdx); + +} + +void CADDoc::OnUpdateSuperPoseWave(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(gl_bTileWave==TRUE ? 0:1); +} + +void CADDoc::OnUpdateTileWave(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(gl_bTileWave==TRUE ? 1:0); + +} + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDoc.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDoc.h new file mode 100644 index 0000000..7d382ad --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADDoc.h @@ -0,0 +1,85 @@ + + +// ADDoc.h : interface of the CADDoc class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_SHOWDATADOC_H__D485DF05_85AB_11D1_B878_A68EB300DD63__INCLUDED_) +#define AFX_SHOWDATADOC_H__D485DF05_85AB_11D1_B878_A68EB300DD63__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +//#include "sys.h" +//#include "ADFrm.h" +//class CSysApp :public WinApp{}; +//class CADFrame :public CMDIChildWnd{}; +class CADDoc : public CDocument +{ +protected: // create from serialization only + CADDoc(); + DECLARE_DYNCREATE(CADDoc) + +// Attributes +public: + HWND m_hWndDigit; // ִھ + HWND m_hWndWave; // δھ + HWND m_hWndADSave; // δھ + HWND m_hWndADCfg; //ұߵ + FILE_HEADER header; // ļͷϢ + + ULONG m_RemainMB; + ULONG m_WroteMB; + ULONG m_Wrote8KWCounter; // ¼8KWĽ +public: + void OnDataFileNew(); + void OnCloseFile(); + void Public_ReleaseDevice(void); +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADDoc) + public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); + //}}AFX_VIRTUAL + +// Implementation +public: + CWinThread* m_ReadThread; // ߳̾ + CWinThread* m_DrawWindowThread; // ߳̾ + int m_nADDigitWidth; + BOOL bCollectData; + virtual ~CADDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +public: + void StartDeviceAD(); + void StopDeviceAD(); +// Generated message map functions +public: +// CStatic* m_FrmFileName() +// {return ((CStatic*)(((CSysApp*)AfxGetApp())->m_ADFrame->m_wndDlgSave.GetDlgItem(IDC_FileName)));} + //{{AFX_MSG(CADDoc) + afx_msg void OnTileWave(); + afx_msg void OnSuperPoseWave(); + afx_msg void OnUpdateSuperPoseWave(CCmdUI* pCmdUI); + afx_msg void OnUpdateTileWave(CCmdUI* pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SHOWDATADOC_H__D485DF05_85AB_11D1_B878_A68EB300DD63__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADFrm.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADFrm.cpp new file mode 100644 index 0000000..916db59 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADFrm.cpp @@ -0,0 +1,489 @@ +// ADFrm.cpp : implementation of the CADFrame class +// + +#include "stdafx.h" +#include "Sys.h" + +#include "MainFrm.h" +#include "ADFrm.h" +#include "ADDoc.h" +#include "ADDigitView.h" +#include "ADWaveView.h" +#include "QSortData.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif +///////////////////////////////////////////////////////////// +#include "ADStatusView.h" +#include "ParaCfgView.h" +extern CADStatusView* pADStatusView; +extern CParaCfgView* pParaCfgView; +//////////////////////////////////////////////////////////////////////////// +// CADFrame + +IMPLEMENT_DYNCREATE(CADFrame, CMDIChildWnd) + +BEGIN_MESSAGE_MAP(CADFrame, CMDIChildWnd) +ON_COMMAND_EX(CG_ID_VIEW_DLGBAR, OnBarCheck) +ON_UPDATE_COMMAND_UI(CG_ID_VIEW_DLGBAR, OnUpdateControlBarMenu) +ON_COMMAND_EX(CG_ID_VIEW_SHOWSTATUS1, OnBarCheck) +ON_UPDATE_COMMAND_UI(CG_ID_VIEW_SHOWSTATUS1, OnUpdateControlBarMenu) +ON_COMMAND_EX(CG_ID_VIEW_SHOWSTATUS, OnBarCheck) +ON_UPDATE_COMMAND_UI(CG_ID_VIEW_SHOWSTATUS, OnUpdateControlBarMenu) +ON_WM_CREATE() +ON_COMMAND_EX(CG_ID_VIEW_SETUPDLG, OnBarCheck) +ON_UPDATE_COMMAND_UI(CG_ID_VIEW_SETUPDLG, OnUpdateControlBarMenu) +//{{AFX_MSG_MAP(CADFrame) +ON_WM_CLOSE() +ON_WM_CANCELMODE() +ON_WM_LBUTTONUP() +//ON_COMMAND(IDM_History_Digit, OnHistoryDigit) +ON_COMMAND(IDM_History_Wave, OnHistoryWave) +//ON_UPDATE_COMMAND_UI(IDM_History_Digit, OnUpdateHistoryDigit) +ON_UPDATE_COMMAND_UI(IDM_History_Wave, OnUpdateHistoryWave) +ON_COMMAND(IDM_MoveVolt, OnMoveVolt) +ON_WM_DESTROY() +ON_WM_CREATE() +ON_UPDATE_COMMAND_UI(IDM_MoveVolt, OnUpdateMoveVolt) +ON_BN_CLICKED(IDC_CHECK_CheckOverflow, OnCHECKCheckOverflow) +ON_COMMAND(IDM_ShowCfgAnalBar, OnShowCfgAnalBar) +ON_UPDATE_COMMAND_UI(IDM_ShowCfgAnalBar, OnUpdateShowCfgAnalBar) +ON_COMMAND(IDM_ShowStatusBar, OnShowStatusBar) +ON_UPDATE_COMMAND_UI(IDM_ShowStatusBar, OnUpdateShowStatusBar) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CADFrame construction/destruction + +CADFrame::CADFrame() +{ + // TODO: add member initialization code here + // m_ProcessDigitalMode=1; + m_ProcessGraphicMode = 1; + m_AnalyzeCheck = false; + m_bShowCfgAnalBar = true; + m_bShowStatusBar = true; + m_ProcessMoveVolt = 1; + gl_ReadSizeWords = 0; + gl_ScreenVolume = (int)VOLT_RANGE; + +} + +CADFrame::~CADFrame() +{ + if(m_pWndSTCBar != NULL) + { + delete m_pWndSTCBar; + m_pWndSTCBar = NULL; + } + pParaCfgView = NULL; + pADStatusView = NULL; + +} + + + +///////////////////////////////////////////////////////////////////////////// +// CADFrame diagnostics + +#ifdef _DEBUG +void CADFrame::AssertValid() const +{ + CMDIChildWnd::AssertValid(); +} + +void CADFrame::Dump(CDumpContext& dc) const +{ + CMDIChildWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CADFrame message handlers + +BOOL CADFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) +{ + + // TODO: Add your specialized code here and/or call the base class + if (!m_wndSplitter.CreateStatic(this, 1, 2)) // 12зָ + { + TRACE0("Failed to CreateStaticSplitter\n"); + return FALSE; + } + + // add the first splitter pane - the default view in column 0 + // һӣ0ʹĬϵͼĵģ + + if (!m_wndSplitter.CreateView(0, 0, + RUNTIME_CLASS(CADDigitView), CSize(360, 50), pContext))//CADDigitView + { + TRACE0("Failed to create first pane\n"); + return FALSE; + } + + if (!m_wndSplitter.CreateView(0, 1, + RUNTIME_CLASS(CADWaveView), CSize(0, 470), pContext))// + { + TRACE0("Failed to create second pane\n"); + return FALSE; + } + return TRUE; +} + + +void CADFrame::ActivateFrame(int nCmdShow) +{ + nCmdShow = SW_SHOWMAXIMIZED; // ʹ֡ + CMDIChildWnd::ActivateFrame(nCmdShow); +} + +int CADFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + + if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) + return -1; + // ҲCControlBar + m_pWndSTCBar = new CCfgTabCtrlBar; + m_pWndSTCBar->Create(this, CSize(235, 100), IDW_PROP_BAR); + m_pWndSTCBar->SetBarStyle(CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);//CBRS_SIZE_DYNAMIC); + + m_pWndSTCBar->EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(m_pWndSTCBar, AFX_IDW_DOCKBAR_RIGHT); + { // ͼû + pParaCfgView=(CParaCfgView*)m_pWndSTCBar->AddView(_T(""), RUNTIME_CLASS(CParaCfgView/*CParaCfgView*/));//CParaCfgView + pParaCfgView->m_pADFrm = this; + } + {// ͼ + pADStatusView=(CADStatusView*)m_pWndSTCBar->AddView(_T("ܷ"), RUNTIME_CLASS(CADStatusView));//CADStatusView + } + + OldADPara = ADPara; + // TODO: Add a menu item that will toggle the visibility of the + { + // Initialize dialog bar m_wndShowStatus + if (!m_wndShowStatus.Create(this, CG_IDD_Status, + CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE, + CG_IDD_Status)) + { + TRACE0("Failed to create dialog bar m_wndShowStatus\n"); + return -1; // fail to create + } + + m_wndShowStatus.EnableDocking(CBRS_ALIGN_BOTTOM | CBRS_ALIGN_TOP); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndShowStatus); + + CProgressCtrl* pT=(CProgressCtrl*)m_wndShowStatus.GetDlgItem(IDC_PROGRESS); + pT->SetRange(0, 50); + + if (!m_wndDlgSave.Create(this, CG_IDD_DIALOG_Save, + CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE, + CG_IDD_DIALOG_Save)) + { + TRACE0("Failed to create dialog bar m_wndShowStatus\n"); + return -1; // fail to create + } + m_wndDlgSave.ShowWindow(SW_HIDE); + m_wndDlgSave.EnableDocking(CBRS_ALIGN_BOTTOM | CBRS_ALIGN_TOP); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndDlgSave); + } + CEdit* pFreqEdit=(CEdit*)(this->m_wndShowStatus).GetDlgItem(IDC_EDIT_MeasureFreq); + pFreqEdit->SetWindowText(_T("Ƶ")); + + //m_ToolTip.Create(this,TTS_ALWAYSTIP|WS_CHILD|WS_VISIBLE); + if(pParaCfgView != NULL) + { + CComboBox * pTriggerSource =(CComboBox *)pParaCfgView->GetDlgItem(IDC_COMBO_TriggerSource); + CComboBox * pTriggerDir =(CComboBox *)pParaCfgView->GetDlgItem(IDC_COMBO_OutTriggerDir); + + CEdit * pBufferID =(CEdit *)pParaCfgView->GetDlgItem(IDC_EDIT_BufferID); + CSliderCtrl* pSLIDER_Offset =(CSliderCtrl*)pParaCfgView->GetDlgItem(IDC_SLIDER_Offset); + /*m_ToolTip.AddTool(pFrequency,_T("趨Ƶ")); + m_ToolTip.AddTool(pTriggerSource,_T("ڲⲿ")); + m_ToolTip.AddTool(pTriggerDir,_T("")); + m_ToolTip.AddTool(pBufferID,_T("2ѡ񻺳")); + m_ToolTip.AddTool(pSLIDER_Offset,_T("ڻѡƫ"));*/ + } + return 0; +} + +void CADFrame::OnClose() +{ + // TODO: Add your message handler code here and/or call default + CMDIChildWnd::OnClose(); +} + +void CADFrame::OnCancelMode() +{ + CMDIChildWnd::OnCancelMode(); + + // TODO: Add your message handler code here + +} + +void CADFrame::OnLButtonUp(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + CMDIChildWnd::OnLButtonUp(nFlags, point); +} + + +//void CADFrame::OnHistoryDigit() +//{ +// // TODO: Add your command handler code here +// STARTUPINFO StartupInfo; +// memset(&StartupInfo,0,sizeof(STARTUPINFO)); +// StartupInfo.cb=sizeof(STARTUPINFO); +// +// PROCESS_INFORMATION ProcessInfo; +// +// ::CreateProcess +// (_T("\\User\\SysTest\\Release\\SysTest.exe"), +// _T(" Digit"), // ע⣺һַΪո +// NULL, +// NULL, +// FALSE, +// 0, +// NULL, +// NULL, +// &StartupInfo, +// &ProcessInfo); +//} + +void CADFrame::OnHistoryWave() +{ + // TODO: Add your command handler code here + STARTUPINFO StartupInfo; + memset(&StartupInfo,0,sizeof(STARTUPINFO)); + StartupInfo.cb=sizeof(STARTUPINFO); + + PROCESS_INFORMATION ProcessInfo; + + ::CreateProcess + (_T("\\User\\SysTest\\Release\\SysTest.exe"), + _T(" Wave"), // ע⣺һַΪո + NULL, + NULL, + FALSE, + 0, + NULL, + NULL, + &StartupInfo, + &ProcessInfo); + +} + +//void CADFrame::OnUpdateHistoryDigit(CCmdUI* pCmdUI) +//{ +// // TODO: Add your command update UI handler code here +// pCmdUI->Enable(FALSE); +//} + +void CADFrame::OnUpdateHistoryWave(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(FALSE); +} + +void CADFrame::OnMoveVolt() //ƽƵѹĺ +{ + LONG m_DataMiddle; // мԭ + ULONG nArrayCount=-1; + ULONG m=0; + TCHAR str[100]; + + //m_ProcessMoveVolt=m_ProcessMoveVolt==0?1:0; + CSysApp *pApp=(CSysApp *)AfxGetApp(); + CADDoc* pDoc=pApp->m_pADDoc; + CString strn; + CADDigitView* pDigitView=(CADDigitView*)(CWnd::FromHandle(pDoc->m_hWndDigit)); + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + if(m_ProcessMoveVolt == 1) // ʼмֵ + { + m_ProcessMoveVolt = 0; + if(gl_ReadSizeWords == 0) + { +// AfxMessageBox(_T("ûпʼɼ!"); +// return; + } + + ULONG lCount = (gl_ReadSizeWords%4096)/gl_nChannelCount; + if (lCount == 0) + { + if (gl_ReadSizeWords < MAX_RAM_SIZE) + { + lCount = gl_ReadSizeWords/gl_nChannelCount; + } + else + { + lCount = (gl_ReadSizeWords%MAX_RAM_SIZE)/gl_nChannelCount; + } + if (lCount == 0) + { + lCount = MAX_RAM_SIZE/gl_nChannelCount; + } + } + + + //pADStatusView->m_nMoveVolt.ResetContent(); + + if (lCount>8192) // 8192ΪSHORT DataAnalyze[MAX_CHANNEL_COUNT][8192]; + { + lCount = 8192; + } + + for(int nChannel=0; nChannelm_nMoveVolt.SetWindowText(StrMoveVolt); + if(pADStatusView != NULL) + pADStatusView->m_nMoveVolt.AddString (str); + } + m_AnalyzeAllCount=0; + m_OverLimitCount=0; + } + if(pADStatusView != NULL) + pADStatusView->m_nMoveVolt.SetCurSel(0); + } + else + { + m_ProcessMoveVolt = 1; + for(int i=0;im_nMoveVolt.GetCount()>0) + pADStatusView->m_nMoveVolt.DeleteString(0); + CString StrMoveVolt; + StrMoveVolt=" "; + pADStatusView->m_nMoveVolt.AddString (StrMoveVolt); + } + } + + if(gl_bDeviceADRun==FALSE) // 豸ûУ̬ + { + pDigitView->RedrawWindow(); + pWaveView->OnDrawPolyLine(gl_nDocDrawLen,gl_nDocDrawIdx); + return; + } + if(nProcessMode == DATA_MODE) // Dzηʽַֻʽ + { + pDigitView->RedrawWindow(); + } + if(nProcessMode == WAVE_MODE) // ֮Ȼ + { + pWaveView->OnDrawPolyLine(gl_nDocDrawLen,gl_nDocDrawIdx); + } +} +void CADFrame::OnUpdateMoveVolt(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(!m_ProcessMoveVolt); +} + +void CADFrame::OnDestroy() +{ + + // TODO: Add your message handler code here + ACTS1000_SaveParaAD(NULL, &ADPara); + if(gl_bDeviceADRun)//Ƿ豸 + { + CADDoc* pDoc=(CADDoc*)GetActiveDocument(); + pDoc->Public_ReleaseDevice(); + } + ; + CSysApp* pApp = (CSysApp*)AfxGetApp(); +// ACTS1000_ReleaseDevice(pApp->m_hDevice); + pApp->m_bCreateADFrm = FALSE; + pApp->m_ADFrame = NULL; + + CMDIChildWnd::OnDestroy(); +} + +void CADFrame::OnCHECKCheckOverflow() +{ + // TODO: Add your control notification handler code here + MessageBox(_T("OnCHECKCheckOverflow")); +} + +void CADFrame::OnShowCfgAnalBar() +{ + // TODO: Add your command handler code here + m_bShowCfgAnalBar = !m_bShowCfgAnalBar; + ShowControlBar(m_pWndSTCBar, m_bShowCfgAnalBar, false); + +} + +void CADFrame::OnUpdateShowCfgAnalBar(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(m_bShowCfgAnalBar); + +} + +void CADFrame::OnShowStatusBar() +{ + // TODO: Add your command handler code here + m_bShowStatusBar = !m_bShowStatusBar; + ShowControlBar(&m_wndShowStatus, m_bShowStatusBar, false); +} + +void CADFrame::OnUpdateShowStatusBar(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(m_bShowStatusBar); +} + +BOOL CADFrame::PreTranslateMessage(MSG* pMsg) +{ + //m_ToolTip.RelayEvent(pMsg); + return CMDIChildWnd::PreTranslateMessage(pMsg); +} + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADFrm.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADFrm.h new file mode 100644 index 0000000..865e004 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADFrm.h @@ -0,0 +1,106 @@ +// ADFrm.h : interface of the CADFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#include "MTabWnd.h" +#if !defined(AFX_ADFRM_H__D485DF03_85AB_11D1_B878_A68EB300DD63__INCLUDED_) +#define AFX_ADFRM_H__D485DF03_85AB_11D1_B878_A68EB300DD63__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include "Resource.h" +#include "CfgTabCtrlBar.h" + +#include "QSortData.h" // Added by ClassView +class CADFrame : public CMDIChildWnd +{ + DECLARE_DYNCREATE(CADFrame) +public: + inline void ShowHideDlgSave(BOOL Flag=TRUE) + { ShowControlBar(&m_wndDlgSave, Flag, FALSE); } + inline void ShowHideStatus(BOOL Flag=TRUE) + { ShowControlBar(&m_wndShowStatus, Flag,FALSE); } + inline CStatic* m_FileName() + { return ((CStatic*)m_wndDlgSave.GetDlgItem(IDC_FileName));} + inline CStatic* m_DiskFree() + { return ((CStatic*)m_wndDlgSave.GetDlgItem(IDC_DiskFree));} + inline CStatic* m_FileLenght() + { return ((CStatic*)m_wndDlgSave.GetDlgItem(IDC_FileLenght));} + inline CProgressCtrl* m_Progress() + { return ((CProgressCtrl*)m_wndDlgSave.GetDlgItem(IDC_PROGRESS));} + inline CStatic *m_TimeDiv() + { return ((CStatic*)m_wndShowStatus.GetDlgItem(IDC_STATIC_TimeOfDiv));} + CADFrame(); + +// Attributes +public: + LONG DataAnalyze[MAX_CHANNEL_COUNT][8192]; + CDialogBar m_wndDlgBar; + CDialogBar m_wndDlgSave; + +public: +// CCfgTabCtrlBar m_wndSTCBar; // ҲVCĿؼ + CCfgTabCtrlBar* m_pWndSTCBar; // ҲVCĿؼ + + CSplitterWnd m_wndSplitter; + CDialogBar m_wndShowStatus; + CDialogBar m_wndSetupDlg; + CDialogBar m_wndSave; + + BOOL m_bShowCfgAnalBar; + BOOL m_bShowStatusBar; + //CToolTipCtrl m_ToolTip; +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADFrame) + public: + virtual void ActivateFrame(int nCmdShow = -1); + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); + //}}AFX_VIRTUAL + +// Implementation +public: + CQSortData m_QSortData; + virtual ~CADFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +// Generated message map functions +protected: + CDialogBar m_DevDlgBar; + //{{AFX_MSG(CADFrame) + afx_msg void OnClose(); + afx_msg void OnCancelMode(); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + //afx_msg void OnHistoryDigit(); + afx_msg void OnHistoryWave(); + //afx_msg void OnUpdateHistoryDigit(CCmdUI* pCmdUI); + afx_msg void OnUpdateHistoryWave(CCmdUI* pCmdUI); + afx_msg void OnMoveVolt(); + afx_msg void OnDestroy(); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnUpdateMoveVolt(CCmdUI* pCmdUI); + afx_msg void OnCHECKCheckOverflow(); + afx_msg void OnShowCfgAnalBar(); + afx_msg void OnUpdateShowCfgAnalBar(CCmdUI* pCmdUI); + afx_msg void OnShowStatusBar(); + afx_msg void OnUpdateShowStatusBar(CCmdUI* pCmdUI); + afx_msg void OnUpdateHalfMode(CCmdUI* pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ADFRM_H__D485DF03_85AB_11D1_B878_A68EB300DD63__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDigitView.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDigitView.cpp new file mode 100644 index 0000000..6dd322d --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDigitView.cpp @@ -0,0 +1,456 @@ +// HistDigitView.cpp:implementation file +// + +#include "stdafx.h" +#include "Sys.h" +#include "ADHistDoc.h" +#include "ADHistDigitView.h" +#include +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CADHistDigitView + +IMPLEMENT_DYNCREATE(CADHistDigitView, CListView) + +CADHistDigitView::CADHistDigitView() +{ + nChooseMode = 3; +} + +CADHistDigitView::~CADHistDigitView() +{ + +} + + +BEGIN_MESSAGE_MAP(CADHistDigitView, CListView) + ON_WM_CONTEXTMENU() + //{{AFX_MSG_MAP(CADHistDigitView) + ON_COMMAND(IDM_SixteenShow, OnSixteenShow) + ON_UPDATE_COMMAND_UI(IDM_SixteenShow, OnUpdateSixteenShow) + ON_COMMAND(IDM_DigitalVoltShowMode, OnDigitalVoltShowMode) + ON_UPDATE_COMMAND_UI(IDM_DigitalVoltShowMode, OnUpdateDigitalVoltShowMode) + ON_COMMAND(IDM_TenShow, OnTenShow) + ON_UPDATE_COMMAND_UI(IDM_TenShow, OnUpdateTenShow) + ON_COMMAND(IDM_REFURBISH, OnRefurbish) + ON_WM_SIZE() + ON_WM_KEYDOWN() + ON_WM_VSCROLL() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CADHistDigitView drawing + +void CADHistDigitView::OnDraw(CDC* ) +{ +} +///////////////////////////////////////////////////////////////////////////// +// CADHistDigitView diagnostics + +#ifdef _DEBUG +void CADHistDigitView::AssertValid() const +{ + CListView::AssertValid(); +} + +void CADHistDigitView::Dump(CDumpContext& dc) const +{ + CListView::Dump(dc); +} +CADHistDoc* CADHistDigitView::GetDocument()// non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CADHistDoc))); + return (CADHistDoc*)m_pDocument; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CADHistDigitView message handlers + +void CADHistDigitView::OnInitialUpdate() +{ + CListView::OnInitialUpdate(); + DWORD type; + type= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES; + + // ıбͼķΪʾ + GetListCtrl().SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LPARAM(type)); + + CADHistDoc* pDoc = (CADHistDoc*)GetDocument(); + pDoc->m_hWndDigit = m_hWnd; + + CString str; + CListCtrl& List = GetListCtrl(); + + int mChannelCount = pDoc->m_ChannelCount; + + long VoltTopRange, VoltBottomRange; + VoltTopRange = pDoc->m_Header.VoltTopRange; // ѹֵ + VoltBottomRange = pDoc->m_Header.VoltBottomRange; // ѹСֵ + if (abs(VoltBottomRange) <= 5) m_jixing = 1; + else + m_jixing = 0; + + int nCnt =0; + for (int nCH=0; nCHm_Header.ADMainInfo.nChannelCount; nCH++) + { + if (pDoc->m_Header.ADPara.bChannelArray[nCH] == 1) + { + + //m_PerLsbVolt[nCnt] = (float)((pDoc->m_Header.VoltTopRange-pDoc->m_Header.VoltBottomRange)*1.0 / pDoc->m_fLsbCount); + + + switch (pDoc->m_Header.ADPara.InputRange[nCH]) + { + case ACTS1000_INPUT_N5000_P5000mV: + + m_PerLsbVolt[nCnt] = (float)(10000.0 / pDoc->m_fLsbCount); + +// pDoc->m_VoltBottomRange[nCnt] = -5000; +// pDoc->m_VoltTopRange[nCnt] = 5000; + break; + case ACTS1000_INPUT_N1000_P1000mV: + m_PerLsbVolt[nCnt] = (float)(2000.0 / pDoc->m_fLsbCount); +// pDoc->m_VoltBottomRange[nCnt] = -1000; +// pDoc->m_VoltTopRange[nCnt] = 1000; + break; + default: + m_PerLsbVolt[nCnt] = (float)(20000.0 / pDoc->m_fLsbCount); +// pDoc->m_VoltBottomRange[nCnt] = -5000; +// pDoc->m_VoltTopRange[nCnt] = 5000; + } + nCnt++; + } + + } + + CADHistFrm* pFrame = (CADHistFrm*)GetParentFrame(); + CListBox* pList = (CListBox*)(pFrame->m_wndSetupBar.GetDlgItem(IDC_FILESINFO)); + switch(pDoc->m_Header.BusType) + {//1:PCI, 2:USB, 3:ISA, 4:PC104 + case PCI_BUS: + str="BusType:PCI"; + break; + case USB_BUS: + str="BusType:USB"; + break; + case ISA_BUS: + str="BusType:ISA"; + break; + case PC104_BUS: + str="BusType:PC104"; + break; + case PXI_BUS: + str="BusType:PXI"; + break; + case PCIE_BUS: + str="BusType:PCIE"; + break; + }//忨 + + pList->AddString (str); + str.Format(L"DeviceNum:%x",pDoc->m_Header.DeviceType ); + pList->AddString (str); + str.Format(L"HeadSizeBytes:%d",pDoc->m_Header.HeadSizeBytes ); + pList->AddString(str); + + str.Format(L"ֱ:%dλ", pDoc->m_Header.DataWidth); + pList->AddString(str); +// str.Format(L"ѹ:%d%dmV",pDoc->m_Header.VoltBottomRange,pDoc->m_Header.VoltTopRange); +// pList->AddString (str);//ѹ + str.Format(L"Դ:%d",pDoc->m_Header.ADPara.TriggerSource); + pList->AddString (str);//Դ + str.Format(L":%d",pDoc->m_Header.ADPara.TriggerDir); + pList->AddString (str); + + + CEdit* pEditOffset = (CEdit*)(pFrame->m_wndSetupBar.GetDlgItem(IDC_EDIT_Offset)); + str.Format(L"%I64d", pDoc->m_Offset); + pEditOffset->SetWindowText(str); // ʾļƫ + + CEdit* pLength = (CEdit*)(pFrame->m_wndSetupBar.GetDlgItem(IDC_EDIT_FileLength)); + str.Format(L"%I64d", pDoc->m_FileLength); + pLength->SetWindowText(str); // ʾļȣ֣ + + CSliderCtrl* pSliderOffset = (CSliderCtrl*)(pFrame->m_wndSetupBar.GetDlgItem(IDC_SLIDER_Offset)); + + // ֮Գͨÿͨ + pSliderOffset->SetRange(0, ((pDoc->m_FileLength-sizeof(::_FILE_HEADER))/(sizeof(WORD) * mChannelCount)-pDoc->m_ReadDataSize/mChannelCount)/pDoc->m_SliderRatio); // ûΧ֣ + pSliderOffset->SetPageSize(1000*pDoc->m_SliderRatio); + + CEdit* pEditPerChannel = (CEdit*)(pFrame->m_wndSetupBar.GetDlgItem(IDC_EDIT_PerChannel)); + + str.Format(_T("%I64d/ͨ"), (pDoc->m_FileLength-sizeof(::_FILE_HEADER)) / (sizeof(WORD) * mChannelCount)); + pEditPerChannel->SetWindowText(str); // ʾÿͨ + CComboBox* pRate = (CComboBox*)(pFrame->m_wndSetupBar.GetDlgItem(IDC_COMBO_Rate)); + pRate->SetCurSel(0); + + CStatic* pLabel = (CStatic*)pFrame->m_wndSetupBar.GetDlgItem(IDC_STATIC_CardType); + pLabel->SetWindowText(pDoc->m_File.GetFilePath()); + + List.InsertColumn(0, L"Index" ,LVCFMT_LEFT,42,-1); // һ + + int Row = 0; + for (Row=0; Row<(int)(pDoc->m_ReadDataSize/mChannelCount); Row++) + { + str.Format(L"%d", Row); + List.InsertItem(Row, str); // к,Ӧһһ + } + //str.Format(L"ݻط:%s",pDoc->m_File.GetFileName()); + str.Format(L"%s",pDoc->m_File.GetFileName()); + pDoc->SetTitle(str); + SetListView(); // б + GetListCtrl().SetHotItem(0); +} + +void CADHistDigitView::SetListView(void) +{ + CADHistDoc* pDoc = (CADHistDoc*)GetDocument(); + CListCtrl& List = GetListCtrl(); + int Col = 0, Row = 0; + List.ShowWindow(SW_HIDE); + List.SetRedraw(FALSE); + int index(0); + int nEndRow = 0; + int nChannel = 0; + INT ChannelCount = pDoc->m_ChannelCount; + + pDoc->ReadData(); + int ch=0; +// for (nChannel=0; nChannelm_Header.ADPara.bChannelArray[nChannel] == TRUE) + { + CString strChannel; + List.DeleteColumn(nChannel + 1); + strChannel.Format(_T("CH%d"), nChannel + 0); + List.InsertColumn(nChannel + 1, strChannel, LVCFMT_LEFT, 70, -1); + } + } + break; + case 2: + for (nChannel=0; nChannelm_Header.ADPara.bChannelArray[nChannel] == TRUE) + { + CString strChannel; + List.DeleteColumn(nChannel + 1); + strChannel.Format(_T("CH%d"), nChannel + 0); + List.InsertColumn(nChannel + 1, strChannel, LVCFMT_LEFT, 85, -1); + + } + } + break; + case 3: + for (nChannel=0; nChannelm_Header.ADPara.bChannelArray[nChannel] == TRUE) + { + CString strChannel; + List.DeleteColumn(nChannel + 1); + strChannel.Format(_T("CH%d"), nChannel + 0); + List.InsertColumn(nChannel + 1, strChannel, LVCFMT_LEFT, 70, -1); + } + } + break; + default: + ASSERT(FALSE); + break; + } + + __int64 start = pDoc->m_Offset - pDoc->m_Offset % ChannelCount; + for (Row=0; Row<(INT)(pDoc->m_ReadDataSize/ChannelCount); Row++) + { + if((pDoc->m_Offset + Row) < (pDoc->m_FileLength-sizeof(::_FILE_HEADER))/(sizeof(WORD) * ChannelCount)) + { + swprintf_s(str, _T("%I64d"), pDoc->m_Offset + Row); + List.SetItemText(Row, 0, str); // Index + for (Col=0; Col<(INT)ChannelCount; Col++) + { + switch (nChooseMode) + { + case 1: // ʮʾ + swprintf_s(str, _T("%d"), (pDoc->m_ADBuffer[index]) & pDoc->m_wMaxLSB); + break; + + case 2: // ʮʾ + swprintf_s(str, _T("%x"), (pDoc->m_ADBuffer[index]) & pDoc->m_wMaxLSB); + break; + + case 3: + { + + _stprintf(str,_T("%.2f"), (float)((((pDoc->m_ADBuffer[Row*ChannelCount+Col])&pDoc->m_wMaxLSB)-pDoc->m_lLsbHalf)*m_PerLsbVolt[Col])); +// float tempResult; +// tempResult = (float)((pDoc->m_ADBuffer[index]) & pDoc->m_wMaxLSB); +// tempResult = ((float)(tempResult/LSB_COUNT)) * 2 * voltMid[ADPara.InputRange[gl_Channel[Col]]]; +// if (m_jixing == 0) +// swprintf_s(str, _T("%.2f"), (tempResult - voltMid[ADPara.InputRange[gl_Channel[Col]]])); +// else +// swprintf_s(str, _T("%.2f"), (tempResult)); + + break; + } + default: + ASSERT(FALSE); + break; + } + if (index > (INT)(pDoc->m_nCount * ChannelCount)) return; + List.SetItemText(Row, (start % ChannelCount) + 1, str);// Ӹ + start++; + index++; + } + nEndRow = Row; + } + else + List.DeleteItem(nEndRow+1); + } + List.SetRedraw(TRUE); + List.ShowWindow(SW_SHOW); +} + +BOOL CADHistDigitView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Add your specialized code here and/or call the base class + cs.style &= ~(LVS_LIST | LVS_ICON | LVS_SMALLICON); + cs.style |= LVS_REPORT; + cs.style |= LVS_SINGLESEL; + cs.style |= LVS_SHOWSELALWAYS; + return CListView::PreCreateWindow(cs); +} + +void CADHistDigitView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) +{ + // TODO: Add your specialized code here and/or call the base class + CListView::OnUpdate(pSender, lHint, pHint); + +} + +#include "resource.h" +void CADHistDigitView::OnContextMenu(CWnd*, CPoint point) +{ + + // CG: This block was added by the Pop-up Menu component + { + if (point.x == -1 && point.y == -1){ + //keystroke invocation + CRect rect; + GetClientRect(rect); + ClientToScreen(rect); + + point = rect.TopLeft(); + point.Offset(5, 5); + } + + CMenu menu; + VERIFY(menu.LoadMenu(IDR_HisMouseR)); + + CMenu* pPopup = menu.GetSubMenu(0); + ASSERT(pPopup != NULL); + CWnd* pWndPopupOwner = this; + + while (pWndPopupOwner->GetStyle() & WS_CHILD) + pWndPopupOwner = pWndPopupOwner->GetParent(); + + pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, + pWndPopupOwner); + } +} + +void CADHistDigitView::OnSixteenShow() +{ + // TODO: Add your command handler code here + //AfxMessageBox(L"ʮ"); + nChooseMode=2; + SetListView();//ˢб +} + +void CADHistDigitView::OnUpdateSixteenShow(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(nChooseMode==2); +} + +void CADHistDigitView::OnDigitalVoltShowMode() +{ + // TODO: Add your command handler code here + //AfxMessageBox(L"ѹʾ"); + nChooseMode=3; + SetListView();//ˢб +} + +void CADHistDigitView::OnUpdateDigitalVoltShowMode(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(nChooseMode==3); +} + +void CADHistDigitView::OnTenShow() +{ + // TODO: Add your command handler code here + //AfxMessageBox(L"ʮʾ"); + nChooseMode=1;//ˢб + SetListView();//ˢб +} + +void CADHistDigitView::OnUpdateTenShow(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(nChooseMode==1); +} + +void CADHistDigitView::OnRefurbish() //ˢб +{ + // TODO: Add your command handler code here + SetListView();//ˢб + +} + +void CADHistDigitView::OnSize(UINT nType, int cx, int cy) +{ + CListView::OnSize(nType, cx, cy); + CADHistDoc* pDoc=(CADHistDoc*)GetDocument(); + CRect rect; + GetWindowRect(&rect); + pDoc->m_nDigitWidth=rect.right+7; +} + + +void CADHistDigitView::SetHotItem(int Index) +{ + GetListCtrl().SetHotItem(Index); +} + +void CADHistDigitView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: Add your message handler code here and/or call default + + + CListView::OnKeyDown(nChar, nRepCnt, nFlags); +} + +void CADHistDigitView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + + CListView::OnVScroll(nSBCode, nPos, pScrollBar); +} + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDigitView.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDigitView.h new file mode 100644 index 0000000..181dfb6 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDigitView.h @@ -0,0 +1,77 @@ +#if !defined(AFX_HistDigitView_H__D442B983_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_) +#define AFX_HistDigitView_H__D442B983_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// HistDigitView.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CADHistDigitView view + +class CADHistDigitView : public CListView +{ +protected: + CADHistDigitView(); // protected constructor used by dynamic creation + DECLARE_DYNCREATE(CADHistDigitView) + +// Attributes +public: + CADHistDoc* GetDocument(); + void SetListView(void); +// Operations +public: + void SetHotItem(int Index); + float m_PerLsbVolt[MAX_CHANNEL_COUNT]; + WCHAR str[100]; + int m_jixing; + int nChooseMode; // 1ʮʾ 2ʮʾ 3ѹʾ + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADHistDigitView) + public: + virtual void OnInitialUpdate(); + protected: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); + //}}AFX_VIRTUAL + +// Implementation +protected: + virtual ~CADHistDigitView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + // Generated message map functions +protected: + afx_msg void OnContextMenu(CWnd*, CPoint point); + //{{AFX_MSG(CADHistDigitView) + afx_msg void OnSixteenShow(); + afx_msg void OnUpdateSixteenShow(CCmdUI* pCmdUI); + afx_msg void OnDigitalVoltShowMode(); + afx_msg void OnUpdateDigitalVoltShowMode(CCmdUI* pCmdUI); + afx_msg void OnTenShow(); + afx_msg void OnUpdateTenShow(CCmdUI* pCmdUI); + afx_msg void OnRefurbish(); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in ShowDigitView.cpp +inline CADHistDoc* CADHistDigitView::GetDocument() + { return (CADHistDoc*)m_pDocument; } +#endif +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_HistDigitView_H__D442B983_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDoc.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDoc.cpp new file mode 100644 index 0000000..af3865f --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDoc.cpp @@ -0,0 +1,244 @@ +// HistDataDoc.cpp : implementation file +// + +#include "stdafx.h" +#include "ADHistDoc.h" +#include "ADHistDigitView.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CADHistDoc + +IMPLEMENT_DYNCREATE(CADHistDoc, CDocument) + +CADHistDoc::CADHistDoc() +{ + m_Offset = 0; + m_SliderOffset = 0; + m_Rate = 1; + m_nFileNum = 0; + m_ReadDataSize = 4096; + m_bAsynMode = FALSE; + m_HistScreenWith = GetSystemMetrics(SM_CXSCREEN); // ȡĻ + for (int index=0; indexm_strFilePath = ""; + for (int index=0; indexm_strFilePath.GetBuffer(sizeof(pApp->m_strFilePath)); // ת + + if (m_File.Open(lpszPathName, CFile::modeRead)) // ļ + { + m_File.Seek(0, CFile::begin); + m_File.Read((WORD*)&m_Header, sizeof(m_Header)); + + m_ChannelCount = m_Header.ChannelCount; + m_ReadDataSize = m_ReadDataSize-m_ReadDataSize%(m_ChannelCount); + } + m_FileLength = ((m_File.GetLength() /*- sizeof(::_FILE_HEADER)*/)); // ļ() + + if (m_FileLength<0x7FFFFFFF) + { + m_SliderRatio = 1; + } + else + { + m_SliderRatio = (m_FileLength/0x7FFFFFFF)+1; +// if (m_SliderRatio<100) +// { +// m_SliderRatio = 100; +// } + } + + + m_fLsbCount = (float)m_Header.ADMainInfo.nSampCodeCount; + m_wMaxLSB = (WORD)(m_Header.ADMainInfo.nSampCodeCount-1); + m_lLsbHalf = (WORD)(m_Header.ADMainInfo.nSampCodeCount/2); + + int nSampChanCount = 0; + for (int nChannel=0; nChannel256) m_nCount = 256; + + LONGLONG loffset = (m_Offset * sizeof(WORD))*m_ChannelCount + m_Header.HeadSizeBytes; + m_File.Seek(loffset, CFile::begin); + try + { + m_nCount = m_File.Read((ULONG*)&m_ADBuffer, sizeof(m_ADBuffer)); + } + catch(...) + { + AfxMessageBox(_T("ļʹ̳쳣")); + return; + } + + m_nCount = m_nCount/sizeof(WORD)/m_ChannelCount; +} + +void CADHistDoc::OnHistoryData() +{ + // TODO: Add your command handler code here + ((CSysApp*)AfxGetApp())->OnHistoryData(); +} + +PWORD CADHistDoc::GetBuffer(LONGLONG* pDataSizeWords) // +{ + ASSERT(pDataSizeWords != NULL); + m_File.Seek(0, CFile::begin); + + LONGLONG loffset = sizeof(::_FILE_HEADER)+(m_Offset*sizeof(WORD))*m_ChannelCount; + + *pDataSizeWords = (m_FileLength /*- m_Header.HeadSizeBytes*/-loffset)/(sizeof(WORD)*m_ChannelCount); + + if (*pDataSizeWords == -1) + { + int a= 0; + } + m_File.Seek(loffset, CFile::begin); + try + { + m_File.Read((ULONG*)&m_ADBuffer, sizeof(m_ADBuffer)); + } + catch(...) + { + AfxMessageBox(_T("ļʹ̳쳣")); + return 0; + } + + return m_ADBuffer; +} + + +PWORD CADHistDoc::GetBuffer(int iChannel, LONGLONG iOffset, LONGLONG* pDataSizeWords) +{ + ASSERT(iOffset >= 0); + if ((iChannel>=0) && (iChannel=0) && (iChannelGetBuffer(&iDataLength); + + //iDataLength = iDataLength/m_ChannelCount; // תΪͨij + // ͨݵ + + int iDataPos = 0; // ڴ󻺳еλ + int iPos=0; + for ( iPos=0; iPos iDataLength) + { + break; + } + // ڴ󻺳еλ + iDataPos = iPos * m_ChannelCount + (iChannel - 0); + m_HistDataBuffer[iChannel][iPos] = (SHORT)(pDataBuff[iDataPos] & m_wMaxLSB); + + if ((iOffset+iPos) > (LONGLONG)((m_FileLength-sizeof(::_FILE_HEADER))/(sizeof(WORD) * m_ChannelCount))) + { + m_HistDataBuffer[iChannel][iPos] = NULL; + } + } + + if (pDataSizeWords != NULL) + { + // ݵ + *pDataSizeWords = iPos-1; + } + + return m_HistDataBuffer[iChannel]; + } + else + { + ASSERT(FALSE); // ûжԸͨɼ + return NULL; + } + + } + else + { + ASSERT(FALSE); // ͨ + return NULL; + } + + return NULL; +} \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDoc.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDoc.h new file mode 100644 index 0000000..70ce05e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistDoc.h @@ -0,0 +1,88 @@ +#if !defined(AFX_HistDataDoc_H__D442B985_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_) +#define AFX_HistDataDoc_H__D442B985_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// HistDataDoc.h : header file +// +#include "Sys.h" +#include "ADHistFrm.h" + +///////////////////////////////////////////////////////////////////////////// +// CADHistDoc document + +class CADHistDoc : public CDocument +{ +protected: + CADHistDoc(); // protected constructor used by dynamic creation + DECLARE_DYNCREATE(CADHistDoc) + PWORD m_HistDataBuffer[MAX_CHANNEL_COUNT]; + INT m_HistScreenWith; + +public: + HWND m_hWndDigit; // ִھ + HWND m_hWndWave; // δھ + +// Attributes +public: + int m_nDigitWidth; + CFile m_File; + CString m_FileName; + __int64 m_FileLength; + __int64 m_SliderRatio; // Sliderѹ + FILE_HEADER m_Header; // ļͷϢ + +// LONG m_VoltBottomRange[8]; // (mV) +// LONG m_VoltTopRange[8]; // (mV) + int m_ChannelCount; + LONGLONG m_SliderOffset; // Sliderƫ() + LONGLONG m_Offset; // ļƫ() + WORD m_ADBuffer[8192]; + int m_Rate; // طٶ + ULONG m_ScreenOffset; // Ļλ + int m_nFileNum; // ļ + LONG m_nCount; // ͨݸ + WORD m_wMaxLSB; + float m_fLsbCount; + WORD m_lLsbHalf; + ULONG m_ChCfg[MAX_CHANNEL_COUNT]; +public: + void ReadData(void); + PWORD GetBuffer(LONGLONG* pDataSizeWords); + PWORD GetBuffer(int iChannel = 0, LONGLONG iOffSet = 0, LONGLONG* pDataSizeWords = NULL); +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADHistDoc) + public: + virtual void Serialize(CArchive& ar); // overridden for document i/o + virtual BOOL OnNewDocument(); + virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); + //}}AFX_VIRTUAL + +// Implementation +public: + UINT m_ReadDataSize; + int m_nDigitLine; + virtual ~CADHistDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + // Generated message map functions +protected: + BOOL m_bAsynMode; + //{{AFX_MSG(CADHistDoc) + afx_msg void OnHistoryData(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_HistDataDoc_H__D442B985_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistFrm.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistFrm.cpp new file mode 100644 index 0000000..8b5e4cd --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistFrm.cpp @@ -0,0 +1,423 @@ +// HistDataFrm.cpp : implementation file +// + +#include "stdafx.h" +#include "Sys.h" +#include "ADHistFrm.h" + +#include "ADHistDigitView.h" +#include "ADHistWaveView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CADHistFrm + +IMPLEMENT_DYNCREATE(CADHistFrm, CMDIChildWnd) + +CADHistFrm::CADHistFrm() +{ + m_bStart = FALSE; + m_ShowMode = 2; // λطţ1Ϊֻطţ + m_PositionAoffset = 0; +} + +CADHistFrm::~CADHistFrm() +{ +} + +BEGIN_MESSAGE_MAP(CADHistFrm, CMDIChildWnd) + ON_WM_CREATE() + ON_COMMAND_EX(CG_ID_VIEW_DIALOGBAR, OnBarCheck) + ON_UPDATE_COMMAND_UI(CG_ID_VIEW_DIALOGBAR, OnUpdateControlBarMenu) + //{{AFX_MSG_MAP(CADHistFrm) + ON_WM_LBUTTONUP() + ON_WM_TIMER() + ON_WM_SIZE() + ON_COMMAND(IDM_History_Start, OnHistoryStart) + ON_UPDATE_COMMAND_UI(IDM_History_Start, OnUpdateHistoryStart) + ON_COMMAND(IDM_History_Stop, OnHistoryStop) + ON_UPDATE_COMMAND_UI(IDM_History_Stop, OnUpdateHistoryStop) + ON_WM_HSCROLL() + ON_WM_VSCROLL() + ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_Offset, OnCustomdrawSLIDEROffset) + ON_CBN_SELCHANGE(IDC_COMBO_Rate, OnSelchangeCOMBORate) + ON_EN_CHANGE(IDC_EDIT_Offset, OnChangeEDITOffset) + ON_WM_CLOSE() + ON_BN_CLICKED(IDC_BUTTON_RefrushData, OnBUTTONRefrushData) + ON_BN_CLICKED(IDC_BUTTON_PositionA, OnBUTTONPositionA) + ON_BN_CLICKED(IDC_BUTTON_PositionB, OnBUTTONPositionB) + + //}}AFX_MSG_MAP + ON_BN_CLICKED(IDC_Goto, &CADHistFrm::OnBnClickedGoto) + ON_EN_KILLFOCUS(IDC_EDIT_Offset, &CADHistFrm::OnEnKillfocusEditOffset) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CADHistFrm message handlers + +BOOL CADHistFrm::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) +{ + // TODO: Add your specialized code here and/or call the base class + if (!m_wndSplitter.CreateStatic(this, 1, 2)) // 12зָ + { + TRACE0("Failed to CreateStaticSplitter\n"); + return FALSE; + } + + // add the first splitter pane - the default view in column 0 + // һӣ0ʹĬϵͼĵģ + if (!m_wndSplitter.CreateView(0, 0, + pContext->m_pNewViewClass, CSize(250, 50), pContext)) + { + TRACE0("Failed to create first pane\n"); + return FALSE; + } + + if (!m_wndSplitter.CreateView(0, 1, + RUNTIME_CLASS(CADHistWaveView), CSize(350, 50), pContext)) + { + TRACE0("Failed to create first pane\n"); + return FALSE; + } + + return TRUE; + + //return CMDIChildWnd::OnCreateClient(lpcs, pContext); +} + +int CADHistFrm::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + { + // Initialize dialog bar m_wndSetupBar + if (!m_wndSetupBar.Create(this, CG_IDD_HistoryDlg, + CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE, + CG_ID_VIEW_DIALOGBAR)) + { + TRACE0("Failed to create dialog bar m_wndSetupBar\n"); + return -1; // fail to create + } + + m_wndSetupBar.EnableDocking(CBRS_ALIGN_BOTTOM | CBRS_ALIGN_TOP); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndSetupBar); + + CButton* pRadioA = (CButton*)m_wndSetupBar.GetDlgItem(IDC_RADIO_PositionA); + CButton* pRadioB = (CButton*)m_wndSetupBar.GetDlgItem(IDC_RADIO_PositionB); + pRadioA->EnableWindow(FALSE); + pRadioB->EnableWindow(FALSE); + pRadioA->SetCheck(1); + pRadioB->SetCheck(0); + + } + return 0; +} + + +void CADHistFrm::OnLButtonUp(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + CMDIChildWnd::OnLButtonUp(nFlags, point); +} + +void CADHistFrm::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: Add your message handler code here and/or call default + CADHistDoc* pDoc = (CADHistDoc*)GetActiveDocument(); // Frameȡõǰĵָ + CADHistWaveView* pWaveView = (CADHistWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + //pDoc->m_Offset += (pDoc->m_Rate*pDoc->m_SliderRatio); + +// pDoc->m_SliderOffset += pDoc->m_Rate; +// pDoc->m_Offset = pDoc->m_SliderOffset*pDoc->m_SliderRatio; + + pDoc->m_Offset += pDoc->m_Rate; + pDoc->m_SliderOffset = pDoc->m_Offset/pDoc->m_SliderRatio; + + LONG nChannelCount = pDoc->m_ChannelCount; + LONGLONG lPointCount = (pDoc->m_FileLength-sizeof(::_FILE_HEADER)) / (sizeof(WORD) * nChannelCount); + if (pDoc->m_Offset >= (lPointCount-pDoc->m_ReadDataSize/nChannelCount)) + { + pDoc->m_Offset = lPointCount-pDoc->m_ReadDataSize/nChannelCount; + pDoc->m_SliderOffset = pDoc->m_Offset/pDoc->m_SliderRatio; + KillTimer(1); + } + RedrawDataWindow(); + CMDIChildWnd::OnTimer(nIDEvent); +} + +void CADHistFrm::OnSize(UINT nType, int cx, int cy) +{ + CMDIChildWnd::OnSize(nType, cx, cy); + + // TODO: Add your message handler code here + + +} + +void CADHistFrm::OnHistoryStart() +{ + // TODO: Add your command handler code here + m_bStart=TRUE; + SetTimer(1, 200, NULL); +} + +void CADHistFrm::OnUpdateHistoryStart(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(m_bStart==FALSE?1:0); +} + +void CADHistFrm::OnHistoryStop() +{ + // TODO: Add your command handler code here + m_bStart=FALSE; + KillTimer(1); +} + +void CADHistFrm::OnUpdateHistoryStop(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(m_bStart==TRUE?1:0); +} + + +void CADHistFrm::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + CMDIChildWnd::OnHScroll(nSBCode, nPos, pScrollBar); +} + +void CADHistFrm::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + + + CMDIChildWnd::OnVScroll(nSBCode, nPos, pScrollBar); +} + +void CADHistFrm::OnCustomdrawSLIDEROffset(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + CADHistDoc* pDoc = (CADHistDoc*)GetActiveDocument(); // Frameȡõǰĵָ + + CSliderCtrl* pSliderOffset = (CSliderCtrl*)(m_wndSetupBar.GetDlgItem(IDC_SLIDER_Offset)); + int Pos = pSliderOffset->GetPos(); // ȡûλãļƫƣ֣ + pSliderOffset->SetPos(Pos); + pDoc->m_SliderOffset = Pos; + pDoc->m_Offset = Pos*pDoc->m_SliderRatio; // ĵеļƫƵڻߵƫλ + int ChannelCount; + ChannelCount = pDoc->m_ChannelCount; + CString str; + CEdit* pEditOffset = (CEdit*)(m_wndSetupBar.GetDlgItem(IDC_EDIT_Offset)); + CEdit* pEditScreenPos = (CEdit*)(m_wndSetupBar.GetDlgItem(IDC_EDIT_ScreenPos)); + str.Format(L"%I64d", pDoc->m_Offset); + pEditOffset->SetWindowText(str); // ʾļƫ + str.Format(L"%I64d", pDoc->m_Offset); + pEditScreenPos->SetWindowText(str); + RedrawDataWindow(); // ػͼ + Invalidate(); + + *pResult = 0; +} + +void CADHistFrm::RedrawDataWindow(void) +{ + CString strScreenPos; + CADHistDoc* pDoc = (CADHistDoc*)GetActiveDocument(); // Frameȡõǰĵָ + CADHistDigitView* pDigitView = (CADHistDigitView*)(CWnd::FromHandle(pDoc->m_hWndDigit)); + CADHistWaveView* pWaveView = (CADHistWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + int ScreenPositon = (int)pWaveView->m_ADHistScope.m_ScreenPosition; + int ChannelCount = pDoc->m_ChannelCount; + CEdit* pEditScreenPos = (CEdit*)(m_wndSetupBar.GetDlgItem(IDC_EDIT_ScreenPos)); + strScreenPos.Format(_T("%I64d"), pDoc->m_Offset/*/ChannelCount*/); + pEditScreenPos->SetWindowText(strScreenPos); + + CString strOffset; + CEdit* pEditOffset = (CEdit*)(m_wndSetupBar.GetDlgItem(IDC_EDIT_Offset)); + //strOffset.Format(_T("%d"), Pos); + pEditOffset->SetWindowText(strScreenPos); // ʾļƫ + + CSliderCtrl* pSliderOffset = (CSliderCtrl*)(m_wndSetupBar.GetDlgItem(IDC_SLIDER_Offset)); + + //pSliderOffset->SetPos(pDoc->m_Offset/pDoc->m_SliderRatio); + pSliderOffset->SetPos((int)pDoc->m_SliderOffset); + + pWaveView->RedrawWindow(); + LONGLONG iDataLenth = 0; + PWORD pBuff = NULL; + for (int iChannel=0; iChannelm_ChannelCount; iChannel++) + { + pBuff = pDoc->GetBuffer(iChannel, pDoc->m_Offset, &iDataLenth); + + if (pBuff != NULL) + { + pWaveView->m_ADHistScope.AppendPoly(pBuff, iChannel, iDataLenth, pDoc->m_Offset, FALSE); + } + } +} + +void CADHistFrm::OnSelchangeCOMBORate() +{ + // TODO: Add your control notification handler code here + CADHistDoc* pDoc = (CADHistDoc*)GetActiveDocument(); // Frameȡõǰĵָ + CComboBox* pRate=(CComboBox*)(m_wndSetupBar.GetDlgItem(IDC_COMBO_Rate)); + CString str; + int Index=pRate->GetCurSel(); // ȡõǰѡ + pRate->GetLBText(Index,str); // ѡȡѡı + pDoc->m_Rate=wcstol(str,NULL, 10); // ַת +} + +void CADHistFrm::OnChangeEDITOffset() +{ + // TODO: If this is a RICHEDIT control, the control will not + // send this notification unless you override the CMDIChildWnd::OnInitDialog() + // function and call CRichEditCtrl().SetEventMask() + // with the ENM_CHANGE flag ORed into the mask. + + // TODO: Add your control notification handler code here +} + +void CADHistFrm::OnClose() +{ + // TODO: Add your message handler code here and/or call default + CMDIChildWnd::OnClose(); +} + +void CADHistFrm::OnBUTTONRefrushData() +{ + CADHistDoc* pDoc = (CADHistDoc*)GetActiveDocument(); // Frameȡõǰĵָ + CADHistDigitView* pDigitView = (CADHistDigitView*)(CWnd::FromHandle(pDoc->m_hWndDigit)); + pDigitView->SetListView(); +} + +void CADHistFrm::ActivateFrame(int nCmdShow) +{ + CListBox* pList = (CListBox*)(m_wndSetupBar.GetDlgItem(IDC_FILESINFO)); + pList->RedrawWindow(); + pList->SendMessage(WS_VSCROLL, SB_LINEDOWN, NULL); + CMDIChildWnd::ActivateFrame(nCmdShow); +} + +CDocument* CADHistFrm::GetActiveDocument() +{ + return CMDIChildWnd::GetActiveDocument(); +} + +BOOL CADHistFrm::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext) +{ + return CMDIChildWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext); +} + +void CADHistFrm::OnBUTTONPositionA() +{ + CADHistDoc* pDoc = (CADHistDoc*)GetActiveDocument(); // Frameȡõǰĵָ + CADHistWaveView* pWaveView = (CADHistWaveView*)CWnd::FromHandle(pDoc->m_hWndWave); + CADHistDigitView* pView = (CADHistDigitView*)CWnd::FromHandle(pDoc->m_hWndDigit); + + CString strPositionA; + CStatic* pStaticA = (CStatic*)m_wndSetupBar.GetDlgItem(IDC_STATIC_PositionA); + pStaticA->GetWindowText(strPositionA); + pView->SetListView(); + + CListCtrl& List = pView->GetListCtrl(); + + LPCTSTR lpszmyString = strPositionA; + LVFINDINFO info; + int nIndex; + info.flags = LVFI_STRING; + info.psz = lpszmyString; + while ((nIndex = List.FindItem(&info)) != -1) + { + if (nIndex >= 0) + { + List.EnsureVisible(nIndex, FALSE); // ʹlistctrlһɼ + List.SetItemState(nIndex, 2, LVIS_SELECTED|LVIS_FOCUSED); // ѡһ(0,Ϊȡ) + List.SetFocus(); + break; + } + } + + Invalidate(); + +} + +void CADHistFrm::OnBUTTONPositionB() +{ + CADHistDoc* pDoc = (CADHistDoc*)GetActiveDocument(); // Frameȡõǰĵָ + CADHistWaveView* pWaveView = (CADHistWaveView*)CWnd::FromHandle(pDoc->m_hWndWave); + CADHistDigitView* pView = (CADHistDigitView*)CWnd::FromHandle(pDoc->m_hWndDigit); + + CString strPositionB;; + CStatic* pStaticB = (CStatic*)m_wndSetupBar.GetDlgItem(IDC_STATIC_PositionB); + pStaticB->GetWindowText(strPositionB); + pView->SetListView(); + + CListCtrl& List = pView->GetListCtrl(); + + LPCTSTR lpszmyString = strPositionB; + LVFINDINFO info; + int nIndex; + info.flags = LVFI_STRING; + info.psz = lpszmyString; + while ((nIndex = List.FindItem(&info)) != -1) + { + if (nIndex >= 0) + { + List.EnsureVisible(nIndex, FALSE); // ʹlistctrlһɼ + List.SetItemState(nIndex, 2, LVIS_SELECTED|LVIS_FOCUSED); // ѡѡһ(0,Ϊȡ) + List.SetFocus(); + break; + } + } + + Invalidate(); + +} + +void CADHistFrm::OnBUTTONTriggerPos() +{ + +} + +void CADHistFrm::OnBnClickedGoto() +{ + // TODO: ڴӿؼ֪ͨ + + CADHistDoc* pDoc = (CADHistDoc*)GetActiveDocument(); // Frameȡõǰĵָ + CEdit* pEditOffset = (CEdit*)(m_wndSetupBar.GetDlgItem(IDC_EDIT_Offset)); + CString str; + pEditOffset->GetWindowText(str); // ʾļƫ + ULONG ul = _tcstol(str, NULL, 10); + CSliderCtrl* pSliderOffset = (CSliderCtrl*)(m_wndSetupBar.GetDlgItem(IDC_SLIDER_Offset)); + + pSliderOffset->SetPos(ul/pDoc->m_SliderRatio); + + + pDoc->m_Offset = ul/pDoc->m_SliderRatio*pDoc->m_SliderRatio; // ĵеļƫƵڻߵƫλ +// int ChannelCount; +// ChannelCount = pDoc->m_ChannelCount; +// CString str; +// CEdit* pEditOffset = (CEdit*)(m_wndSetupBar.GetDlgItem(IDC_EDIT_Offset)); +// CEdit* pEditScreenPos = (CEdit*)(m_wndSetupBar.GetDlgItem(IDC_EDIT_ScreenPos)); +// str.Format(L"%I64d", pDoc->m_Offset); +// pEditOffset->SetWindowText(str); // ʾļƫ +// str.Format(L"%I64d", pDoc->m_Offset); +// pEditScreenPos->SetWindowText(str); + RedrawDataWindow(); // ػͼ + Invalidate(); + + +} + +void CADHistFrm::OnEnKillfocusEditOffset() +{ + // TODO: ڴӿؼ֪ͨ + +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistFrm.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistFrm.h new file mode 100644 index 0000000..3aa7d4a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistFrm.h @@ -0,0 +1,80 @@ +#if !defined(AFX_HistDataFrm_H__D442B980_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_) +#define AFX_HistDataFrm_H__D442B980_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// HistDataFrm.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CADHistFrm frame + +class CADHistFrm : public CMDIChildWnd +{ + DECLARE_DYNCREATE(CADHistFrm) +protected: + CADHistFrm(); // protected constructor used by dynamic creation + +// Attributes +public: + CSplitterWnd m_wndSplitter; + CDialogBar m_wndSetupBar; +public: + BOOL m_bStart; + int m_ShowMode; + LONG m_PositionAoffset; +public: + void RedrawDataWindow(void); +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADHistFrm) + public: + virtual void ActivateFrame(int nCmdShow = -1); + virtual CDocument* GetActiveDocument(); + virtual BOOL LoadFrame(UINT nIDResource, DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL); + protected: + virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); + //}}AFX_VIRTUAL + +// Implementation +protected: + + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + virtual ~CADHistFrm(); + + // Generated message map functions + //{{AFX_MSG(CADHistFrm) + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnHistoryStart(); + afx_msg void OnUpdateHistoryStart(CCmdUI* pCmdUI); + afx_msg void OnHistoryStop(); + afx_msg void OnUpdateHistoryStop(CCmdUI* pCmdUI); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnCustomdrawSLIDEROffset(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnSelchangeCOMBORate(); + afx_msg void OnChangeEDITOffset(); + afx_msg void OnClose(); + afx_msg void OnBUTTONRefrushData(); + afx_msg void OnBUTTONPositionA(); + afx_msg void OnBUTTONPositionB(); + afx_msg void OnBUTTONTriggerPos(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedGoto(); + afx_msg void OnEnKillfocusEditOffset(); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_HistDataFrm_H__D442B980_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistScope.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistScope.cpp new file mode 100644 index 0000000..517ab2a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistScope.cpp @@ -0,0 +1,1108 @@ +// ADHistScope.cpp : implementation file// + +#include "stdafx.h" +#include "math.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif +////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// CADHistScope +CADHistScope::CADHistScope() +{ + INT iScreenWidth = GetSystemMetrics(SM_CXSCREEN); // ȡĻ + for (INT iChannel=0; iChannelLoadStandardCursor(IDC_SIZEWE); + m_hCursorVSize = (HCURSOR)AfxGetApp()->LoadStandardCursor(IDC_SIZENS); + m_hCursorArrow = (HCURSOR)AfxGetApp()->LoadStandardCursor(IDC_ARROW); + m_hCursorAllSize = (HCURSOR)AfxGetApp()->LoadStandardCursor(IDC_SIZEALL); + m_nShowCursor = 0; // ʾ + m_iActivexChannel = 0; + + m_clPen[0] = RGB(255, 0, 0); + m_clPen[1] = RGB(255, 255, 0); + m_clPen[2] = RGB(0, 255, 0); + m_clPen[3] = RGB(255, 0, 255); + m_clPen[4] = RGB(255, 0, 0); + m_clPen[5] = RGB(255, 255, 0); + m_clPen[6] = RGB(0, 255, 0); + m_clPen[7] = RGB(255, 0, 255); +} + +///////////////////////////////////////////////////////////////////////////// + +CADHistScope::~CADHistScope() +{ + if (m_pOldBmp != NULL) + m_dcMem.SelectObject(m_pOldBmp); + m_pOldBmp = NULL; + + for (INT iChannel=0; iChannelGetSafeHwnd(), (HMENU)nID); + + return result; + +} // Create + +///////////////////////////////////////////////////////////////////////////// +void CADHistScope::SetRange(float fLower, float fUpper, INT nChannel) +{ + // ô̵ֱĴС + ASSERT(fUpper > fLower); + + m_fLowerLimit[nChannel] = fLower; + m_fUpperLimit[nChannel] = fUpper; + + // ʾ + this->ProssDataToPT(nChannel); + this->Invalidate(); + +} + +void CADHistScope::SetVisableRange(float fLower, float fUpper, INT nChannel) +{ + ASSERT(fUpper > fLower); + m_fVisableLower[nChannel] = fLower; + m_fVisableUpper[nChannel] = fUpper; + + // ʾ + this->ProssDataToPT(nChannel); + this->Invalidate(); +} + +void CADHistScope::SetXUnits(CString string) +{ + m_strXUnitsString = string; + this->Invalidate(); +} + +void CADHistScope::SetYUnits(CString string) +{ + m_strYUnitsString = string; + + this->Invalidate(); +} + +void CADHistScope::SetGridColor(COLORREF color) +{ + m_crGridColor = color; + this->Invalidate(); +} + +void CADHistScope::SetPlotColor(COLORREF color) +{ + m_crPlotColor = color; +} + +void CADHistScope::SetBackgroundColor(COLORREF color) +{ + m_crBackColor = color; + + m_brushBack.DeleteObject(); + m_brushBack.CreateSolidBrush(m_crBackColor); + + this->Invalidate(); +} + +void CADHistScope::OnPaint() +{ + CPaintDC dc(this); + CADHistWaveView* pView = (CADHistWaveView*)GetParent(); + CADHistDoc* pDoc = (CADHistDoc*)pView->GetDocument(); + m_nChannelCount = pDoc->m_ChannelCount; + memcpy(m_ChCfg, pDoc->m_ChCfg, sizeof(m_ChCfg)); + m_wMaxLSB = pDoc->m_wMaxLSB; + m_fLsbCount = pDoc->m_fLsbCount; + m_lLsbHalf = pDoc->m_lLsbHalf; + + if (NULL == m_dcMem.m_hDC) + { + m_dcMem.CreateCompatibleDC(&dc); + } + + if (NULL == m_bmpMem.m_hObject) + { + m_bmpMem.CreateCompatibleBitmap(&dc, m_rectClient.Width(), m_rectClient.Height()); + m_pOldBmp = m_dcMem.SelectObject(&m_bmpMem); + } + + this->DrawBkGnd(); // ƱС仯ʱֻͨƱ + + this->DrawPoly(); // Сݱ仯ʱ + + m_dcMem.SetBkMode(TRANSPARENT); // ñΪ͸ + INT nOldDrawMode = m_dcMem.SetROP2(R2_XORPEN); // ûģʽ + + m_dcMem.SelectObject(&m_PenLineA); // ѡAĻ + m_dcMem.MoveTo(m_OldMoveX1, m_rectPlot.top); + m_dcMem.LineTo(m_OldMoveX1, m_rectPlot.bottom); // A + + TCHAR str[100]; + swprintf_s(str, _T("%s"), _T("A")); + m_dcMem.SetTextColor(RGB(255, 0, 0)); + m_dcMem.TextOut(m_OldMoveX1+20, m_rectPlot.top+30, str); + + m_dcMem.SelectObject(&m_PenLineB); // ѡBĻ + m_dcMem.MoveTo(m_OldMoveX2, m_rectPlot.top); + m_dcMem.LineTo(m_OldMoveX2, m_rectPlot.bottom); // B + + swprintf_s(str, _T("%s"), _T("B")); + m_dcMem.SetTextColor(RGB(255, 0, 0)); + m_dcMem.TextOut(m_OldMoveX2+20, m_rectPlot.top+30, str); + + if (FALSE == m_bAllChannel) + { + m_dcMem.SelectObject(&m_PenLineV); // ѡVĻ + m_dcMem.MoveTo(m_rectPlot.left, m_OldVoltageY); + m_dcMem.LineTo(m_rectPlot.right, m_OldVoltageY); // V + } + m_dcMem.SetROP2(nOldDrawMode); + + dc.BitBlt(m_rectClient.left, + m_rectClient.top, + m_rectClient.Width(), + m_rectClient.Height(), + &m_dcMem, + 0, 0, SRCCOPY); //SRCCOPY); + UpdataChannelRect(); +} + +///////////////////////////////////////////////////////////////////////////// +void CADHistScope::OnSize(UINT nType, INT cx, INT cy) +{ + CWnd::OnSize(nType, cx, cy); + + GetClientRect(m_rectClient); // ȡǰĿͻС + + m_rectPlot.left = 60; + m_rectPlot.top = 10; + m_rectPlot.right = m_rectClient.right-10; + m_rectPlot.bottom = m_rectClient.bottom - 10; + m_nPlotHeight = m_rectPlot.Height(); + m_nPlotWidth = m_rectPlot.Width(); + + m_OldVoltageY = m_CurVoltageY = m_rectPlot.top + 20; + m_OldMoveX1 = m_CurMoveX1 = m_rectPlot.left + 20; + m_OldMoveX2 = m_CurMoveX2 = m_rectPlot.right - 20; + m_OldVoltageY = m_CurVoltageY = m_rectPlot.top + 20; + + if (NULL != m_pOldBmp) + { + m_dcMem.SelectObject(m_pOldBmp); + m_bmpMem.DeleteObject(); + m_pOldBmp = NULL; + } + + this->UpdataChannelRect(); +} + +void CADHistScope::Reset() +{ + +} + +INT CADHistScope::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CWnd::OnCreate(lpCreateStruct) == -1) + return -1; + m_rectClient = CRect(0, 0, 1024, 1000); + + m_rectPlot.left = 20; + m_rectPlot.top = 10; + m_rectPlot.right = m_rectClient.right - 10; + m_rectPlot.bottom = m_rectClient.bottom - 25; + + m_nPlotHeight = m_rectPlot.Height(); + m_nPlotWidth = m_rectPlot.Width(); + + + m_PenLineA.CreatePen(PS_DOT, 1, m_crLineAColor); + m_PenLineB.CreatePen(PS_DOT, 1, m_crLineBColor); + m_PenLineV.CreatePen(PS_DOT, 1, m_crLineVColor); + + for (INT Channel=0; ChannelGetDocument(); + CClientDC dc(this); + if (m_rectPlot.PtInRect(point)) + { + if (!m_bRBtnDown) m_nShowCursor = 0; + // ͨλжһ߻ý + if (abs(point.x - m_OldMoveX1) < 5) + { + m_nShowCursor = 1; + } + if (abs(point.x - m_OldMoveX2) < 5) + { + m_nShowCursor = 2; + } + if (!m_bAllChannel && abs(point.y - m_OldVoltageY) < 5) + { + m_nShowCursor = 3; + } + + if (m_bLBtnDown || m_bRBtnDown) + { + DrawMoveLine(&dc, point); + } + } + + if (point.x >= 60) + { + m_MouseOffset = point.x - 60; + } + else + m_MouseOffset = 0; + + CString str; + CADHistFrm* pADHistFrm = (CADHistFrm*)GetParentFrame(); + CEdit* pOffsetEdit = (CEdit*)(pADHistFrm->m_wndSetupBar.GetDlgItem(IDC_EDIT_ScreenPos)); + + CEdit* pEditOffset = (CEdit*)(pADHistFrm->m_wndSetupBar.GetDlgItem(IDC_EDIT_Offset)); + + pEditOffset->GetWindowText(str); + LONGLONG lOffset = _tcstoi64(str, NULL, 10); + +// str.Format(_T("%d"), m_MouseOffset + pDoc->m_Offset); + str.Format(_T("%I64d"), lOffset + m_MouseOffset); + pOffsetEdit->SetWindowText(str); // ʾļƫ + + CWnd::OnMouseMove(nFlags, point); +} + +void CADHistScope::OnLButtonDown(UINT nFlags, CPoint point) +{ + m_bLBtnDown = TRUE; + if (m_rectPlot.PtInRect(point)) + { + // ͨλжһ߻ý + if (abs(point.x - m_OldMoveX1) < 5) + { + m_nLineIndex = 1; + m_bOnlyLine = TRUE; + } + + if (abs(point.x - m_OldMoveX2) < 5) + { + m_nLineIndex = 2; + m_bOnlyLine = TRUE; + } + + if (!m_bAllChannel && abs(point.y - m_OldVoltageY) < 5) + { + m_nLineIndex = 3; + m_bOnlyLine = TRUE; + } + } + SetCapture(); + CWnd::OnLButtonDown(nFlags, point); +} + +// ԭֵ(bufferԭ), ٴɿʾĵ +void CADHistScope::AppendPoly(PWORD pBuff, const INT iChannel, LONGLONG iDataSize, LONGLONG iOffset, BOOL bUpdata) +{ + ASSERT(iChannel >= 0 && iChannel < MAX_CHANNEL_COUNT); + ASSERT(iDataSize >=0 && iOffset >= 0); + ASSERT(NULL != pBuff); + if (iDataSize > 8192/m_nChannelCount) + iDataSize = 8192/m_nChannelCount; + if (iChannel >= 0 && iChannel < MAX_CHANNEL_COUNT) + { + m_iDataLength[iChannel] = (INT)iDataSize; + m_iOffset[iChannel] = iOffset; // ƫ + m_pDataBuff[iChannel] = pBuff; + if (FALSE == m_bAllChannel && m_iActivexChannel == iChannel) + { + this->ProssDataToPT(iChannel); + } + else + { + this->ProssDataToPT(iChannel); + } + + if (TRUE == bUpdata) + { + this->Invalidate(); + } + } +} + +// ĵ +void CADHistScope::DrawPoly() +{ + CPen* pOldPen; + CADHistWaveView* pView = (CADHistWaveView*)GetParent(); + CADHistDoc* pDoc = (CADHistDoc*)pView->GetDocument(); + LONG DataCount = (LONG)((pDoc->m_FileLength-sizeof(::_FILE_HEADER)) / (sizeof(WORD) * pDoc->m_ChannelCount)); + if (m_bAllChannel) // ͨʾʾʱ + { + int iChannel = 0; + for (INT index=0; index= m_rectPlot.Width()) + { + m_dcMem.Polyline(m_pPtCHannel[iChannel], m_rectPlot.Width()); + } + else + { + m_dcMem.Polyline(m_pPtCHannel[iChannel], m_iDataLength[iChannel]-1); + } + + m_dcMem.SelectObject(pOldPen); + m_dcMem.RestoreDC(-1); + } + } + } + else // ͨʾ + { + if (NULL != m_pDataBuff[m_iActivexChannel]) + { + m_dcMem.SaveDC(); + m_dcMem.IntersectClipRect(m_rectPlot); + pOldPen = m_dcMem.SelectObject(&m_penChannel[m_iActivexChannel % 4]); + m_dcMem.MoveTo(m_pPtCHannel[m_iActivexChannel][0]); // ƶһ + + if (m_iDataLength[m_iActivexChannel] >= m_rectPlot.Width()) + { + m_dcMem.Polyline(m_pPtCHannel[m_iActivexChannel], m_rectPlot.Width()); + } + else + { + m_dcMem.Polyline(m_pPtCHannel[m_iActivexChannel], m_iDataLength[m_iActivexChannel]); + } + + m_dcMem.SelectObject(pOldPen); + m_dcMem.RestoreDC(-1); + + } + } +} + +void CADHistScope::OnLButtonUp(UINT nFlags, CPoint point) +{ + m_bOnlyLine = FALSE; + m_bLBtnDown = FALSE; + ::ReleaseCapture(); + + static BOOL bFirstPosition = TRUE; // ʼı־ + CADHistFrm* pFrame = (CADHistFrm*)GetParentFrame(); + CADHistWaveView* pView = (CADHistWaveView*)GetParent(); + CADHistDoc* pDoc = (CADHistDoc*)pView->GetDocument(); + CButton* pRadioA = (CButton*)pFrame->m_wndSetupBar.GetDlgItem(IDC_RADIO_PositionA); + CButton* pRadioB = (CButton*)pFrame->m_wndSetupBar.GetDlgItem(IDC_RADIO_PositionB); + CStatic* pStaticA = (CStatic*)pFrame->m_wndSetupBar.GetDlgItem(IDC_STATIC_PositionA); + CStatic* pStaticB = (CStatic*)pFrame->m_wndSetupBar.GetDlgItem(IDC_STATIC_PositionB); + CStatic* pDistanceAB = (CStatic*)pFrame->m_wndSetupBar.GetDlgItem(IDC_STATIC_DistanceAB); + CString str; + + if (abs(point.x - m_OldMoveX1)<5 || abs(point.x - m_OldMoveX2)<5) + { + m_CurPosition = pDoc->m_Offset + point.x - m_rectPlot.left; + m_ScreenPosition = point.x - m_rectPlot.left; + } + + str.Format(_T("%I64d"), m_CurPosition); + pRadioA->SetCheck(m_nLineIndex == 1 ? 1:0); + pRadioB->SetCheck(m_nLineIndex == 2 ? 1:0); + + if (pRadioA->GetCheck()) + { + pStaticA->SetWindowText(str); + } + + if (pRadioB->GetCheck()) + { + pStaticB->SetWindowText(str); + } + + int nDistanceAB = 0; + pStaticA->GetWindowText(str); + m_nPositionA = _tcstol(str, NULL, 10); + pStaticB->GetWindowText(str); + m_nPositionB = _tcstol(str, NULL, 10); + nDistanceAB = abs(m_nPositionA - m_nPositionB); + str.Format(_T("%d"), nDistanceAB); + pDistanceAB->SetWindowText(str); + + SetStatusBar(); + bFirstPosition = !bFirstPosition; + Invalidate(); + CWnd::OnLButtonUp(nFlags, point); +} + +void CADHistScope::SetStatusBar() +{ + + float fFrequency; + CString strTimeDiv; + CString strCountTimer; + CString strFrequency; + CString strVol; + int SubstValue = abs(m_nPositionA - m_nPositionB); + CSysApp *pApp = (CSysApp *)AfxGetApp(); + CADHistWaveView* pView = (CADHistWaveView*)GetParent(); + CADHistDoc* pDoc = (CADHistDoc*)pView->GetDocument(); + CADHistFrm* pFrame = (CADHistFrm*)GetParentFrame(); + + int ChannelCount = m_nChannelCount; + LONG nHistFrequency = pDoc->m_Header.ADMainInfo.nBaseRate/pDoc->m_Header.ADPara.FreqDivision; // ļͷȡòƵ + + + if(SubstValue) + { + //fCalFrequency = (float)((80000000/nHistFrequency)/nDistanceAB); + fFrequency = (float)(nHistFrequency/SubstValue); + if(fFrequency < 1000) + strFrequency.Format(_T("%7.2f Hz"), fFrequency); + if(fFrequency > 1000 && fFrequency < 1000000) + strFrequency.Format(_T("%7.2f KHz"), fFrequency / 1000); + if(fFrequency > 1000000) + strFrequency.Format(_T("%7.2f MHz"), fFrequency / 1000000); + + CStatic* pStaticFre = (CStatic*)pFrame->m_wndSetupBar.GetDlgItem(IDC_STATIC_Frequency); + pStaticFre->SetWindowText(strFrequency); + } + +} + +// ͨ +void CADHistScope::DrawAllChannelGrid(CDC *pDC) +{ + INT Point, ChannelCount; + INT nGridPix = 0; // YߵĿ̶ + float hight = (float)(m_rectPlot.Height() / float(m_nChannelCount)); // ÿͨY + + for (ChannelCount=1; ChannelCountSetPixel(Point, nGridPix, m_crGridColor); + } + } + + for (ChannelCount=0; ChannelCountSetPixel(Point, (INT)(m_rectPlot.top + (hight * ChannelCount) + hight/2.0), RGB(255, 255, 255)); + } + } +} + +void CADHistScope::DrawSingleCHGrid(CDC *pDC) +{ + for (INT Point=m_rectPlot.left; PointSetPixel(Point, m_rectPlot.top+(INT)(m_rectPlot.Height()/2), RGB(255, 255, 255)); +} + +void CADHistScope::DrawAllChannelText(CDC *pDC) +{ + CString str; + int iChannel = 0; + + for (INT index=0; indexSetTextColor(m_clPen[m_ChCfg[iChannel]]); // ֵɫ + + str.Format (_T("%.*lf V"), m_nYDecimals, m_fVisableUpper[m_ChCfg[iChannel]] / 1000.0); // ѹֵ + pDC->TextOut (m_rectPlot.left-4, (INT)(m_rcChannel[iChannel].top + 8), str); + + pDC->SetTextAlign (TA_RIGHT | TA_BASELINE); + str.Format (_T("%.*lf V"), m_nYDecimals, m_fVisableLower[m_ChCfg[iChannel]] / 1000.0); // ѹֵ + pDC->TextOut (m_rectPlot.left-4, (INT)(m_rcChannel[iChannel].bottom - 5), str); + + + str.Format(_T("CH %d"), m_ChCfg[iChannel]); + pDC->TextOut(m_rectPlot.left - 4, (INT)(m_rcChannel[iChannel].CenterPoint().y), str); + } +} + +void CADHistScope::DrawSingleCHText(CDC *pDC, INT nChannelNum) +{ + CString str; + if (nChannelNum != 0xFFFF) + pDC->SetTextColor(m_clPen[nChannelNum % COLR_COUNT]); + else + pDC->SetTextColor(m_crGridColor); + + if (nChannelNum != 0xFFFF) + { + str.Format(_T("%.*lf mV"), 0, m_fVisableUpper[nChannelNum]); // ѹֵ + pDC->TextOut (m_rectPlot.left - 4, m_rectPlot.top, str); + pDC->SetTextAlign(TA_RIGHT|TA_BASELINE); + + str.Format (_T("%.*lf mV"), 0, m_fVisableLower[nChannelNum]); // ѹֵ + pDC->TextOut (m_rectPlot.left - 4, m_rectPlot.top + m_nPlotHeight, str); + } + + if (nChannelNum == 0xFFFF) // ǵʾʱ + str = "CH"; + else + str.Format(_T("CH %d"), nChannelNum); + // дͨ + pDC->TextOut(m_rectPlot.left - 4, m_rectPlot.top + m_nPlotHeight / 2 + 5, str); + +} + +void CADHistScope::OnRButtonDown(UINT nFlags, CPoint point) +{ + HCURSOR hCursor; + m_bRBtnDown = TRUE; + INT DistanceSub = abs(point.x - m_OldMoveX1) + abs(point.x - m_OldMoveX2); + INT DistanceAB = abs(m_OldMoveX1 - m_OldMoveX2); + if (DistanceSub == DistanceAB) // ʱм + { + m_nLineIndex = 0; // ͬʱѡʱı־ֵ + m_nShowCursor = 4; + hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEALL); + ::SetCursor(hCursor); + + m_RBtnDownPosX = point.x; + m_StartOldMoveX1 = m_OldMoveX1; // ƶʱ1ʼλ + m_StartOldMoveX2 = m_OldMoveX2; // ƶʱ2ʼλ + + CRect ClipRect = m_rectPlot; + ClientToScreen(&ClipRect); + if (m_OldMoveX1 < m_OldMoveX2) // 12 + { + ClipRect.left += point.x - m_OldMoveX1; + ClipRect.right -= m_OldMoveX2 - point.x; + } + else // 12ұ + { + ClipRect.left += point.x - m_OldMoveX2; + ClipRect.right -= m_OldMoveX1 - point.x; + } + + ::ClipCursor(&ClipRect); + } + CWnd::OnRButtonDown(nFlags, point); +} + +void CADHistScope::OnRButtonUp(UINT nFlags, CPoint point) +{ + HCURSOR hCursor; + hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); + ::SetCursor(hCursor); + + m_bRBtnDown = FALSE; + m_nLineIndex = 0xFFFF; + ClipCursor(NULL); + CWnd::OnRButtonUp(nFlags, point); +} + +void CADHistScope::DrawMoveLine(CDC *pDC, CPoint point) +{ + CPen* pOldPen; + int nOldPositionX = point.x; + int nOldPositionY = point.y; + int nMode; + pDC->SetBkMode(TRANSPARENT); // ͸ + nMode = pDC->SetROP2(R2_XORPEN); // ģʽ + switch(m_nLineIndex) + { + case 0: // ͬʱѡ12 + pOldPen = pDC->SelectObject(&m_PenLineA); + pDC->MoveTo(m_OldMoveX1, m_rectPlot.top); // һλA + pDC->LineTo(m_OldMoveX1, m_rectPlot.Height()+10); + TCHAR str[100]; + swprintf_s(str, _T("%s"), _T("A")); + m_dcMem.SetTextColor(RGB(0, 0, 0)); + m_dcMem.TextOut(m_OldMoveX1, m_rectPlot.top+20, str); + + pDC->SelectObject(&m_PenLineB); + pDC->MoveTo(m_OldMoveX2, m_rectPlot.top); // һλB + pDC->LineTo(m_OldMoveX2, m_rectPlot.Height()+10); + + swprintf_s(str, _T("%s"), _T("B")); + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->TextOut(m_OldMoveX1, m_rectPlot.top+20, str); + + m_OldMoveX1 = m_StartOldMoveX1 + (point.x - m_RBtnDownPosX); + m_OldMoveX2 = m_StartOldMoveX2 + (point.x - m_RBtnDownPosX); + pDC->SelectObject(&m_PenLineA); + pDC->MoveTo(m_OldMoveX1, m_rectPlot.top); // A + pDC->LineTo(m_OldMoveX1, m_rectPlot.Height()+10); + swprintf_s(str, _T("%s"), _T("A")); + m_dcMem.SetTextColor(RGB(255, 0, 0)); + m_dcMem.TextOut(m_OldMoveX1, m_rectPlot.top+20, str); + pDC->SelectObject(&m_PenLineB); + pDC->MoveTo(m_OldMoveX2, m_rectPlot.top); // B + pDC->LineTo(m_OldMoveX2, m_rectPlot.Height()+10); + swprintf_s(str, _T("%s"), _T("B")); + pDC->SetTextColor(RGB(255, 0, 0)); + pDC->TextOut(m_OldMoveX1, m_rectPlot.top+20, str); + pDC->SelectObject(pOldPen); // ָɵĻ + break; + + case 1: // ѡ1 + pOldPen = pDC->SelectObject(&m_PenLineA); + pDC->MoveTo(m_OldMoveX1, m_rectPlot.top); // һλA + pDC->LineTo(m_OldMoveX1, m_rectPlot.Height()+10); + swprintf_s(str, _T("%s"), _T("A")); + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->TextOut(m_OldMoveX1, m_rectPlot.top+20, str); + + m_OldMoveX1 = point.x; + pDC->MoveTo(point.x, m_rectPlot.top); // A + pDC->LineTo(point.x, m_rectPlot.Height()+10); + swprintf_s(str, _T("%s"), _T("A")); + pDC->SetTextColor(RGB(255, 0, 0)); + pDC->TextOut(point.x, m_rectPlot.top+20, str); + pDC->SelectObject(pOldPen); // ָɵĻ + break; + + case 2: // ѡ2 + pOldPen = pDC->SelectObject(&m_PenLineB); + pDC->MoveTo(m_OldMoveX2, m_rectPlot.top); // һλB + pDC->LineTo(m_OldMoveX2, m_rectPlot.Height()+10); // B + swprintf_s(str, _T("%s"), _T("B")); + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->TextOut(m_OldMoveX2, m_rectPlot.top+20, str); + + m_OldMoveX2 = point.x; + pDC->MoveTo(point.x, m_rectPlot.top); + pDC->LineTo(point.x, m_rectPlot.Height()+10); + swprintf_s(str, _T("%s"), _T("B")); + pDC->SetTextColor(RGB(255, 0, 0)); + pDC->TextOut(m_OldMoveX2, m_rectPlot.top+20, str); + pDC->SelectObject(pOldPen); // ָɵĻ + break; + case 3: // ѡ3 + pOldPen = pDC->SelectObject(&m_PenLineV); + pDC->MoveTo(m_rectPlot.left, m_OldVoltageY); // һλV + pDC->LineTo(m_rectPlot.right, m_OldVoltageY); // V + m_OldVoltageY = point.y; + pDC->MoveTo(m_rectPlot.left, point.y); + pDC->LineTo(m_rectPlot.right, point.y); + pDC->SelectObject(pOldPen); // ָɵĻ + break; + + default: + break; + } + Invalidate(); + pDC->SetROP2(nMode); +} + +BOOL CADHistScope::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) +{ + // TODO: Add your message handler code here and/or call default + switch (m_nShowCursor) + { + case 1: + case 2: + ::SetCursor(m_hCursorHSize); + break; + + case 3: + ::SetCursor(m_hCursorVSize); + break; + + case 4: + ::SetCursor(m_hCursorAllSize); + break; + + default: + ::SetCursor(m_hCursorArrow); + break; + } + + return CWnd::OnSetCursor(pWnd, nHitTest, message); +} + +BOOL CADHistScope::IsShowAllChannle() +{ + return m_bAllChannel; +} + +BOOL CADHistScope::ShowChannel(INT iFirstChannel, INT iLastChannel, BOOL bUpata) +{ + int index=0; + for ( index=0; indexUpdateVisableChannleArray(); + this->UpdataChannelRect(); + if (TRUE == bUpata) + { + this->Invalidate(); + } + + return TRUE; +} + +VOID CADHistScope::ProssDataToPT(INT iChannel) +{ + if (NULL != m_pDataBuff[iChannel]) + { + float fLsbOfPixel; + if (m_bAllChannel) + { + if (gl_bTileWave) // ͨƽʾ + { + float fRang = m_fUpperLimit[iChannel] - m_fLowerLimit[iChannel]; // ̷Χ + fLsbOfPixel = (float) m_fLsbCount / (m_rcChannel[iChannel].Height() * fRang / (m_fVisableUpper[iChannel] - + m_fVisableLower[iChannel])); + + // 0 ֵλ + long yBase = long(m_rcChannel[iChannel].bottom + + m_rcChannel[iChannel].Height() * (m_fVisableLower[iChannel] - + m_fLowerLimit[iChannel])/(m_fVisableUpper[iChannel] - + m_fVisableLower[iChannel])); + + for (INT Index=0; Index<(m_iDataLength[iChannel]); Index++) + { + if (Index >= m_rectPlot.Width()) + { + break; + } + + m_pPtCHannel[iChannel][Index].x = m_rectPlot.left + 1 + Index; // Xʼλ; + m_pPtCHannel[iChannel][Index].y = long(yBase - ((m_pDataBuff[iChannel][Index])& m_wMaxLSB) / fLsbOfPixel); + } + + } + else // ͨʾ + { + float fRang = m_fUpperLimit[iChannel] - m_fLowerLimit[iChannel]; // ̷Χ + fLsbOfPixel = (float)m_fLsbCount / (m_rectPlot.Height() * fRang / + (m_fVisableUpper[iChannel] - m_fVisableLower[iChannel])); + + // 0 ֵλ + long yBase = long(m_rectPlot.bottom + + m_rectPlot.Height() * (m_fVisableLower[iChannel] - + m_fLowerLimit[iChannel])/ (m_fVisableUpper[iChannel] - + m_fVisableLower[iChannel])); + + for (INT Index=0; Index<=m_nPlotWidth; Index++) + { + if (Index >= m_rectPlot.Width()) + { + break; + } + + m_pPtCHannel[iChannel][Index].x = m_rectPlot.left + 1 + Index; // Xʼλ; + m_pPtCHannel[iChannel][Index].y = long(yBase - ((m_pDataBuff[iChannel][Index])& m_wMaxLSB) / fLsbOfPixel); + } + } + } + else + { + float fRang = m_fUpperLimit[iChannel] - m_fLowerLimit[iChannel]; // ̷Χ + fLsbOfPixel = (float)m_fLsbCount / (m_rectPlot.Height() * fRang / (m_fVisableUpper[iChannel] - + m_fVisableLower[iChannel])); + + // 0 ֵλ + long yBase = long(m_rectPlot.bottom + + m_rectPlot.Height() * (m_fVisableLower[iChannel] - + m_fLowerLimit[iChannel]) / (m_fVisableUpper[iChannel] - + m_fVisableLower[iChannel])); + + for (INT Index=0; Index<=m_nPlotWidth; Index++) + { + if (Index >= m_rectPlot.Width()) + { + break; + } + + m_pPtCHannel[iChannel][Index].x = m_rectPlot.left + 1 + Index; // Xʼλ; + m_pPtCHannel[iChannel][Index].y = long(yBase - ((m_pDataBuff[iChannel][Index])& m_wMaxLSB) / fLsbOfPixel); + } + } + } +} + +void CADHistScope::SetTileMode() +{ + gl_bTileWave = TRUE; + for (INT iChannel=0; iChannelProssDataToPT(iChannel); // + } + + this->Invalidate(); +} + +BOOL CADHistScope::IsTileMode() +{ + return gl_bTileWave; +} + +void CADHistScope::SetSuperMode() +{ + gl_bTileWave = FALSE; + for (INT iChannel=0; iChannelProssDataToPT(iChannel); + } + + this->Invalidate(); +} + +void CADHistScope::UpdateVisableChannleArray() // ʾͨ +{ + m_arrayVisableChannel.RemoveAll(); + for (int index=0; indexGetDocument(); +// m_nChannelCount = pDoc->m_ChannelCount; + + // ͨľ + CRect rcChanle(m_rectPlot); + rcChanle.top = m_rectPlot.top; + rcChanle.bottom = m_rectPlot.top + m_rectPlot.Height() / m_nChannelCount; + + int iChannel; + + for (INT index=0; indexm_arrayVisableChannel; // ɼͨ + void UpdateVisableChannleArray(); // ʾͨ + void UpdataChannelRect(); + + INT m_nRBtnMoveX; + INT m_MouseOffset; // ڻͼƫλ + INT m_OldMoveX1; // ƶߵλ + INT m_OldMoveX2; + LONGLONG m_CurPosition; + INT m_CurMoveX1; + INT m_CurMoveX2; + + INT m_RBtnDownPosX; + INT m_StartOldMoveX1; + INT m_StartOldMoveX2; + + COLORREF m_crLineAColor; // Aߵɫ + COLORREF m_crLineBColor; // Bߵɫ + COLORREF m_crLineVColor; // Cߵɫ + + CPen m_PenLineA; // AߵĻ + CPen m_PenLineB; // BߵĻ + CPen m_PenLineV; // VߵĻ + + int m_nPositionA; + int m_nPositionB; + + HCURSOR m_hCursorHSize; + HCURSOR m_hCursorVSize; + HCURSOR m_hCursorArrow; + HCURSOR m_hCursorAllSize; + INT m_nShowCursor; + INT m_CurVoltageY; + INT m_OldVoltageY; + + INT m_nLineIndex; + BOOL m_bAllChannel; + + INT m_nShiftPixels; + INT m_nYDecimals; + + CString m_strXUnitsString; + CString m_strYUnitsString; + + COLORREF m_crBackColor; + COLORREF m_crGridColor; + COLORREF m_crPlotColor; + + double m_dCurrentPosition; + +public: + double m_ScreenPosition; + +private: + VOID ProssDataToPT(INT iChannel); + void DrawBkGnd(); // + void DrawPoly(); + +protected: + CPen m_penChannel[MAX_CHANNEL_COUNT]; + COLORREF m_clPen[MAX_CHANNEL_COUNT]; + + void DrawMoveLine(CDC *pDC, CPoint poINT); + BOOL m_bRBtnDown; + + BOOL m_bOnlyLine; + BOOL m_bLBtnDown; + + //{{AFX_MSG(CADHistScope) + afx_msg void OnPaint(); + afx_msg void OnSize(UINT nType, INT cx, INT cy); + afx_msg INT OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnMouseMove(UINT nFlags, CPoint poINT); + afx_msg void OnLButtonDown(UINT nFlags, CPoint poINT); + afx_msg void OnLButtonUp(UINT nFlags, CPoint poINT); + afx_msg void OnRButtonDown(UINT nFlags, CPoint poINT); + afx_msg void OnRButtonUp(UINT nFlags, CPoint poINT); + afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + INT m_nHalfShiftPixels; + INT m_nPlotShiftPixels; + + INT m_nPlotHeight; + INT m_nPlotWidth; // + CRect m_rectClient; + CRect m_rectPlot; + CBrush m_brushBack; + +protected: + // ڴص + CDC m_dcMem; + CBitmap m_bmpMem; + CBitmap* m_pOldBmp; +}; + +///////////////////////////////////////////////////////////////////////////// +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistWaveView.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistWaveView.cpp new file mode 100644 index 0000000..56154c8 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistWaveView.cpp @@ -0,0 +1,243 @@ +// HistWaveView.cpp : implementation file +// + +#include "stdafx.h" +#include "Sys.h" +#include "ADHistFrm.h" +#include "ADHistWaveView.h" +#include "ADHistDigitView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CADHistWaveView +IMPLEMENT_DYNCREATE(CADHistWaveView, CScrollView) + +CADHistWaveView::CADHistWaveView() +{ + m_ScreenVolume = (int)VOLT_RANGE; // Ϊ10V + m_ChannelCount = 0; +} + +CADHistWaveView::~CADHistWaveView() +{ +} + +BEGIN_MESSAGE_MAP(CADHistWaveView, CScrollView) + //{{AFX_MSG_MAP(CADHistWaveView) + ON_WM_SIZE() + ON_WM_DESTROY() + ON_WM_HSCROLL() + ON_WM_ERASEBKGND() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CADHistWaveView drawing + +void CADHistWaveView::OnInitialUpdate() +{ + CScrollView::OnInitialUpdate(); + // TODO: calculate the total size of this view + CADHistDoc* pDoc = (CADHistDoc*)GetDocument(); + CADHistFrm* pHistFrm = (CADHistFrm*)GetParentFrame(); + m_ChannelCount = pDoc->m_ChannelCount; + CSize sizeTotal; + sizeTotal.cx = 0; + sizeTotal.cy = 0; + SetScrollSizes(MM_TEXT, sizeTotal); + pDoc->m_hWndWave = m_hWnd; + CSliderCtrl* pSliderOffset = (CSliderCtrl*)(pHistFrm->m_wndSetupBar.GetDlgItem(IDC_SLIDER_Offset)); + pSliderOffset->SetPos(0); // Ļʾڿʼ + + // ͼ + CRect rect; + GetClientRect(rect); + m_ADHistScope.Create(WS_CHILD | WS_VISIBLE, rect, this); + m_ADHistScope.SetXUnits(_T("X")); + m_ADHistScope.SetYUnits(_T("Y")); + m_ADHistScope.ShowChannel(0, MAX_CHANNEL_COUNT-1); + + for (int Channel=0; Channelm_Header.VoltBottomRange, pDoc->m_Header.VoltTopRange, Channel); +// m_ADHistScope.SetVisableRange(pDoc->m_Header.VoltBottomRange, pDoc->m_Header.VoltTopRange, Channel); + switch (pDoc->m_Header.ADPara.InputRange[Channel]) + { + case ACTS1000_INPUT_N10000_P10000mV: + + + m_ADHistScope.SetRange(-10000.0, 10000.0, Channel); + m_ADHistScope.SetVisableRange(-10000.0, 10000.0, Channel); + break; + case ACTS1000_INPUT_N5000_P5000mV: + m_ADHistScope.SetRange(-5000.0, 5000.0, Channel); + m_ADHistScope.SetVisableRange(-5000.0, 5000.0, Channel); + + break; + case ACTS1000_INPUT_N1000_P1000mV: + m_ADHistScope.SetRange(-1000.0, 1000.0, Channel); + m_ADHistScope.SetVisableRange(-1000.0, 1000.0, Channel); + break; + } + } + + m_ADHistScope.ShowWindow(SW_SHOWNA); + + m_ScrollBar.Create(SBS_HORZ | WS_CHILD | WS_VISIBLE, CRect(rect.left, rect.bottom+20, rect.right, rect.bottom), this, IDC_SCROLLBAR_ScreenCur); + m_ScrollBar.SetScrollRange(0, (8192/m_ChannelCount)); // ûΧ֣ + +} + +void CADHistWaveView::OnDraw(CDC *pDC) +{ + +} + +void CADHistWaveView::OnDrawPolyLine() +{ + CADHistDoc* pDoc = (CADHistDoc*)GetDocument(); + + if (NULL != pDoc) + { + LONGLONG iDataLenth = 0; + PWORD pBuff = NULL; + for (int iChannel=0; iChannelm_ChannelCount; iChannel++) + { + pBuff = pDoc->GetBuffer(iChannel, pDoc->m_Offset, &iDataLenth); + + if (pBuff != NULL) + { + m_ADHistScope.AppendPoly(pBuff, iChannel, iDataLenth, pDoc->m_Offset, FALSE); + } + } + } +} + +///////////////////////////////////////////////////////////////////////////// +// CADHistWaveView diagnostics + +#ifdef _DEBUG +void CADHistWaveView::AssertValid() const +{ + CScrollView::AssertValid(); +} + +void CADHistWaveView::Dump(CDumpContext& dc) const +{ + CScrollView::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CADHistWaveView message handlers + +void CADHistWaveView::OnSize(UINT nType, int cx, int cy) +{ + CScrollView::OnSize(nType, cx, cy); + + if (m_ADHistScope.m_hWnd != NULL) + { + m_ADHistScope.SetWindowPos(NULL, 0, 0, cx, cy-20, SWP_DRAWFRAME); + m_ScrollBar.SetWindowPos(NULL, 0, cy-20, cx, 20, SWP_NOOWNERZORDER); + this->OnDrawPolyLine(); + } +} + +void CADHistWaveView::OnDestroy() +{ + CScrollView::OnDestroy(); +} + + +void CADHistWaveView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + CADHistDoc* pDoc = (CADHistDoc*)GetDocument(); + CADHistFrm* pHistFrm = (CADHistFrm*)GetParentFrame(); + int ChannelCount = pDoc->m_ChannelCount; + int Pos = m_ScrollBar.GetScrollPos(); // ȡûλãļƫƣ֣ + int nPageSize = 8192/m_ChannelCount/20; + switch(nSBCode) + { + case SB_LINERIGHT: + Pos += 1; + break; + + case SB_LINELEFT: + Pos -= 1; + break; + + case SB_PAGEDOWN: + Pos += nPageSize; + break; + + case SB_PAGEUP: + Pos -= nPageSize; + break; + + case SB_THUMBPOSITION: + Pos = nPos; + break; + case SB_THUMBTRACK: + Pos = nPos; + break; + + default : + break; + + } + + if (Pos<0) + Pos = 0; + m_ScrollBar.SetScrollPos(Pos); + + pDoc->m_ScreenOffset = Pos - Pos%ChannelCount; // ĵеĻƫƵڻߵĻλƫ + + LONGLONG i64Pos = Pos; + i64Pos+= pDoc->m_Offset; + LONGLONG ulOld = pDoc->m_Offset; + + + pDoc->m_Offset = i64Pos; + + CString str; + CEdit* pEditOffset = (CEdit*)(pHistFrm->m_wndSetupBar.GetDlgItem(IDC_EDIT_Offset)); + CEdit* pEditScreenPos = (CEdit*)(pHistFrm->m_wndSetupBar.GetDlgItem(IDC_EDIT_ScreenPos)); + str.Format(_T("%I64d"), i64Pos); + pEditOffset->SetWindowText(str); // ʾļƫ + str.Format(_T("%I64d"), i64Pos); + pEditScreenPos->SetWindowText(str); + + RedrawWindow(); // ػͼ + + LONGLONG iDataLenth = 0; + PWORD pBuff = NULL; + for (int iChannel=0; iChannelm_ChannelCount; iChannel++) + { + pBuff = pDoc->GetBuffer(iChannel, pDoc->m_Offset, &iDataLenth); + if (iDataLenth == -1) + { + iDataLenth= 0; + } + + if (pBuff != NULL) + { + m_ADHistScope.AppendPoly(pBuff, iChannel, iDataLenth, pDoc->m_Offset, FALSE); + } + } + + pDoc->m_Offset = ulOld; + + CScrollView::OnHScroll(nSBCode, nPos, pScrollBar); +} + +BOOL CADHistWaveView::OnEraseBkgnd(CDC* pDC) +{ + // TODO: Add your message handler code here and/or call default + return TRUE; +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistWaveView.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistWaveView.h new file mode 100644 index 0000000..3704e61 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADHistWaveView.h @@ -0,0 +1,61 @@ +#if !defined(AFX_HistWaveView_H__D442B984_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_) +#define AFX_HistWaveView_H__D442B984_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// HistWaveView.h : header file +// +#include "ADHistScope.h" + +///////////////////////////////////////////////////////////////////////////// +// CADHistWaveView view + +class CADHistWaveView : public CScrollView +{ +protected: + CADHistWaveView(); // protected constructor used by dynamic creation + DECLARE_DYNCREATE(CADHistWaveView) + +// Attributes +public: + CScrollBar m_ScrollBar; + int m_ScreenVolume; // Ļʾ + CADHistScope m_ADHistScope; + int m_ChannelCount; + // Operations +public: +// int m_nWidth; + void OnDrawPolyLine(); +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADHistWaveView) + protected: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual void OnInitialUpdate(); // first time after construct + //}}AFX_VIRTUAL + +// Implementation +protected: + virtual ~CADHistWaveView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + // Generated message map functions + //{{AFX_MSG(CADHistWaveView) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnDestroy(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_HistWaveView_H__D442B984_8439_11D1_B87A_A3845A0CA5FE__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADScopeCtrl.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADScopeCtrl.cpp new file mode 100644 index 0000000..312515c --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADScopeCtrl.cpp @@ -0,0 +1,1136 @@ +// OScopeCtrl.cpp : implementation file// + +#include "stdafx.h" +#include "math.h" +#include "sys.h" +#include "ParaCfgView.h" +#include "ADScopeCtrl.h" +#include "ADFrm.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__ ; +#endif +////////////////////////////////////////////////// +#define MAX_OFFSET 8192 +int gl_moveY = 0; +extern int gl_MLength; +extern int gl_NLength; +extern CParaCfgView* pParaCfgView; +extern ACTS1000_PARA_AD ADPara; +extern int gl_InputRange[MAX_CHANNEL_COUNT]; +extern CSysApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CADScopeCtrl +CADScopeCtrl::CADScopeCtrl() +{ + m_dPreviousPosition = 0.0 ; + m_nYDecimals = 3 ; + for(int j=0; jGetSafeHwnd(), (HMENU)nID) ; + // if (result != 0) + // InvalidateCtrl() ; + + return result ; + +} // Create + +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::SetRange(double dLower, double dUpper, int nChannel) +{ // ô̵ֱĴС + ASSERT(dUpper > dLower) ; + + m_dLowerLimit[nChannel] = dLower ; + m_dUpperLimit[nChannel] = dUpper ; + m_nYDecimals = 2 ; + m_dRange = m_dUpperLimit[nChannel] - m_dLowerLimit[nChannel] ; + m_dVerticalFactor = (double)m_nPlotHeight / m_dRange ; + + InvalidateCtrl() ; + +} // SetRange + + +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::SetXUnits(CString string) +{ + m_strXUnitsString = string ; + + InvalidateCtrl() ; + +} // SetXUnits + +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::SetYUnits(CString string) +{ + m_strYUnitsString = string ; + + InvalidateCtrl() ; + +} // SetYUnits + +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::SetGridColor(COLORREF color) +{ + m_crGridColor = color ; + + InvalidateCtrl() ; + +} // SetGridColor + + +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::SetPlotColor(COLORREF color) +{ + m_crPlotColor = color ; + + m_penPlot.DeleteObject() ; + m_penPlot.CreatePen(PS_SOLID, 0, m_crPlotColor) ; + + InvalidateCtrl() ; + +} // SetPlotColor + + +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::SetBackgroundColor(COLORREF color) +{ + m_crBackColor = color ; + + m_brushBack.DeleteObject() ; + m_brushBack.CreateSolidBrush(m_crBackColor) ; + + InvalidateCtrl() ; + +} // SetBackgroundColor + +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::InvalidateCtrl() +{ + +// if (gl_bDeviceADRun) +// { +// return; +// } + + CClientDC dc(this); + if (m_dcGrid.GetSafeHdc() == NULL) + { + m_dcGrid.CreateCompatibleDC(&dc) ; + m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight) ; + m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid) ; + } + if(m_dcPlot.GetSafeHdc() == NULL) + { + m_dcPlot.CreateCompatibleDC(&dc) ; + m_bitmapPlot.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight) ; + m_pbitmapOldPlot = m_dcPlot.SelectObject(&m_bitmapPlot) ; + } + if(m_PenLineA.m_hObject == NULL) + m_PenLineA.CreatePen(PS_DASHDOT, 1, m_crLineAColor); // AߵĻ + if(m_PenLineB.m_hObject == NULL) + m_PenLineB.CreatePen(PS_DASHDOT, 1, m_crLineBColor); // BߵĻ + if(m_PenLineV.m_hObject == NULL) + m_PenLineV.CreatePen(PS_DASHDOT, 1, m_crLineVColor); // VߵĻ + for(int i=0; im_nChannelCount = 1; + DrawBkGnd(); // + ProcessData(gl_nDocDrawLen,gl_nDocDrawIdx); + DrawPoly(gl_nDocDrawLen,gl_nDocDrawIdx); + m_bInitialed = TRUE; +} // InvalidateCtrl + +///////////////////////////////////////////////////////////////////////////// +double CADScopeCtrl::AppendPoint(double dNewPoint) +{ + + double dPrevious ; + + dPrevious = m_dCurrentPosition ; + m_dCurrentPosition = dNewPoint ; + DrawPoint() ; + + Invalidate() ; + + return dPrevious ; + +} // AppendPoint + +//////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::OnPaint() +{ // m_nClientWidth, m_ClientHeightҲȡm_rectClientĴС + CPaintDC dc(this) ; // device context for painting + CDC memDC ; + CBitmap memBitmap ; + CBitmap* oldBitmap ; // bitmap originally found in CMemDC + memDC.CreateCompatibleDC(&dc) ; + memBitmap.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight) ; + oldBitmap = (CBitmap *)memDC.SelectObject(&memBitmap) ; + CString str; + + if (memDC.GetSafeHdc() != NULL) + { + memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, + &m_dcGrid, 0, 0, SRCCOPY) ; + memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, + &m_dcPlot, 0, 0, SRCPAINT) ; //SRCPAINT + memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, + &m_dcMove, 0, 0, SRCPAINT) ; //SRCPAINT + dc.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, + &memDC, 0, 0, SRCCOPY); //SRCCOPY) ; + + } + memDC.SelectObject(oldBitmap) ; + + int nDrawMode; + dc.SetBkMode(TRANSPARENT); // ñΪ͸ + nDrawMode = dc.SetROP2(R2_XORPEN); // ûģʽ + + dc.SelectObject(&m_PenLineA); // ѡAĻ + dc.MoveTo(m_OldMoveX1/*+100*/, m_rectPlot.top); + dc.LineTo(m_OldMoveX1, m_rectPlot.Height()+10); // A + dc.SetTextColor(RGB(255, 255, 0)); + dc.TextOut(m_OldMoveX1, m_rectPlot.Height()+13, _T("")); + + dc.SelectObject(&m_PenLineB); // ѡBĻ + dc.MoveTo(m_OldMoveX2, m_rectPlot.top); + dc.LineTo(m_OldMoveX2, m_rectPlot.Height()+10); // B + if(!m_bAllChannel) + { + dc.SelectObject(&m_PenLineV); // ѡVĻ + dc.MoveTo(m_rectPlot.left, m_OldVoltageY); + dc.LineTo(m_rectPlot.right, m_OldVoltageY); // V + } + dc.SetROP2(nDrawMode); +} // OnPaint + +//##################################################################### +// ĵ(λͼƶ̬) +void CADScopeCtrl::DrawPoint() +{ + int currX, prevX, currY, prevY ; + + CPen *oldPen ; + CRect rectCleanUp ; + + if (m_dcPlot.GetSafeHdc() != NULL) + { + m_dcPlot.BitBlt(m_rectPlot.left, m_rectPlot.top+1, + m_nPlotWidth, m_nPlotHeight, &m_dcPlot, + m_rectPlot.left+1/*2/*m_nShiftPixels*/, m_rectPlot.top+1, + SRCCOPY) ; + + + rectCleanUp = m_rectPlot ; + rectCleanUp.left = rectCleanUp.right - 1; + + m_dcPlot.FillRect(rectCleanUp, &m_brushBack) ; + + oldPen = m_dcPlot.SelectObject(&m_penPlot) ; + + prevX = m_rectPlot.right-2;//m_nPlotShiftPixels ; + prevY = m_rectPlot.bottom - (long)m_dPreviousPosition-10; + m_dcPlot.MoveTo (prevX, prevY) ; + + currX = m_rectPlot.right-1;//m_nHalfShiftPixels ; + currY = m_rectPlot.bottom -(long)m_dCurrentPosition-10; + m_dcPlot.LineTo (currX, currY); + + m_dcPlot.SelectObject(oldPen) ; + + m_dPreviousPosition = m_dCurrentPosition ; + + } + +} // end DrawPoint +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy) ; + if(m_bInitialed) + { + GetClientRect(m_rectClient) ; // ȡǰĿͻС + + m_nClientHeight = m_rectClient.Height() ; + m_nClientWidth = m_rectClient.Width() ; + + m_rectPlot.left = 60 ; + m_rectPlot.top = 10 ; + m_rectPlot.right = m_rectClient.right-10 ; + m_rectPlot.bottom = m_rectClient.bottom-25 ; + + m_nPlotHeight = m_rectPlot.Height() ; + m_nPlotWidth = m_rectPlot.Width() ; + + m_dVerticalFactor = (double)m_nPlotHeight / m_dRange ; + gl_moveY = m_rectPlot.top-5; + InvalidateCtrl(); // » + + m_OldVoltageY = m_CurVoltageY = m_rectPlot.top + 20; +// m_OldMoveX1 = m_CurMoveX1 = m_rectPlot.left + ADPara.M_Length; // 20; + m_OldMoveX1 = m_CurMoveX1 = m_rectPlot.left; // 20; + m_OldMoveX2 = m_CurMoveX2 = m_rectPlot.right - 20; + m_OldVoltageY = m_CurVoltageY = m_rectPlot.top + 20; + + } +} // OnSize + + +///////////////////////////////////////////////////////////////////////////// +void CADScopeCtrl::Reset() +{ +} +//////////////////////////////////////////////// +// InvalidateCtrl() ;///////////////////////////// +int CADScopeCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CWnd::OnCreate(lpCreateStruct) == -1) + return -1; + m_rectClient = CRect(0, 0, 1024+60, 1000); // 768 + m_nClientHeight = m_rectClient.Height(); + m_nClientWidth = m_rectClient.Width(); + + m_rectPlot.left = 20 ; + m_rectPlot.top = 10 ; + m_rectPlot.right = m_rectClient.right-10 ; + m_rectPlot.bottom = m_rectClient.bottom-25 ; + + m_nPlotHeight = m_rectPlot.Height() ; + m_nPlotWidth = m_rectPlot.Width() ; + + m_dVerticalFactor = (double)m_nPlotHeight / m_dRange ; + + return 0; +} + +//######################################################################## +// +void CADScopeCtrl::DrawBkGnd() +{ + int nCharacters=0 ; + CPen *oldPen ; + CPen solidPen(PS_SOLID, 0, m_crGridColor) ; + CFont axisFont, yUnitFont, *oldFont ; + CString strTemp ; + //--------------------------------------------------------------------------- + m_dcGrid.SetBkColor (m_crBackColor) ; + // fill the grid background + m_dcGrid.FillRect(m_rectClient, &m_brushBack) ; + // ִռõַ + nCharacters = abs((int)log10(fabs(m_dUpperLimit[0]))) ; + nCharacters = max(nCharacters, abs((int)log10(fabs(m_dLowerLimit[0])))); + + nCharacters = nCharacters + 4 + m_nYDecimals ; + // m_rectPlot.left = m_rectClient.left + 6*(nCharacters) ; + m_nPlotWidth = m_rectPlot.Width() ; + //---------------------------------------------------------------------------------- + // ܵĿ + oldPen = m_dcGrid.SelectObject (&solidPen) ; // ܵķ + m_dcGrid.MoveTo (m_rectPlot.left, m_rectPlot.top) ; + m_dcGrid.LineTo (m_rectPlot.right+1, m_rectPlot.top) ; + m_dcGrid.LineTo (m_rectPlot.right+1, m_rectPlot.bottom+1) ; + m_dcGrid.LineTo (m_rectPlot.left, m_rectPlot.bottom+1) ; + m_dcGrid.LineTo (m_rectPlot.left, m_rectPlot.top) ; + m_dcGrid.SelectObject (oldPen) ; + COLORREF m_Grid = RGB(200, 200, 200); + int k; + for(k=50; kLoadStandardCursor(IDC_ARROW); + ::SetCursor(m_hCurSor); + int nOldPositionX, nOldPositionY; + CString str; + CEdit* pEditM_Length=(CEdit*)(pParaCfgView->GetDlgItem(IDC_EDIT_M_Length)); // ȡIDC_EDIT_M_Length + CEdit* pEditN_Length=(CEdit*)(pParaCfgView->GetDlgItem(IDC_EDIT_N_Length)); // ȡIDC_EDIT_N_Length + + /////////////////////////////////////////////////////////////////////////////// + CClientDC dc(this); + int nMode; + dc.SetBkMode(TRANSPARENT); // ͸ + nMode = dc.SetROP2(R2_XORPEN); // ģʽ + if(m_rectPlot.PtInRect(point)) + { + // ͨλжһ߻ý + if(abs(point.x - m_OldMoveX1) < 5) + { + m_hCurSor = (HCURSOR)AfxGetApp()->LoadStandardCursor(IDC_SIZEWE); + ::SetCursor(m_hCurSor); + if(gl_LBtnDown && !gl_bOnly) + { + m_nLineIndex = 1; + gl_bOnly = TRUE; + } + + } + if(abs(point.x - m_OldMoveX2) < 5) + { + m_hCurSor = (HCURSOR)AfxGetApp()->LoadStandardCursor(IDC_SIZEWE); + ::SetCursor(m_hCurSor); + if(gl_LBtnDown && !gl_bOnly) + { + m_nLineIndex = 2; + gl_bOnly = TRUE; + } + + } + if (!m_bAllChannel && abs(point.y - m_OldVoltageY) < 5) + { + m_hCurSor = (HCURSOR)AfxGetApp()->LoadStandardCursor(IDC_SIZENS); + ::SetCursor(m_hCurSor); + if(gl_LBtnDown && !gl_bOnly) + { + m_nLineIndex = 3; + gl_bOnly = TRUE; + } + } + + if(gl_LBtnDown) + { + if(point.x < m_rectPlot.left) nOldPositionX = m_rectPlot.left; + if(point.x > m_rectPlot.right) nOldPositionX = m_rectPlot.right; + if(point.x >= m_rectPlot.left && point.x <= m_rectPlot.right) + { + nOldPositionX = point.x; + } + + if(point.y > m_rectPlot.bottom) nOldPositionY = m_rectPlot.bottom; + if(point.y < m_rectPlot.top) nOldPositionY = m_rectPlot.top; + if(point.y >= m_rectPlot.top && point.y <= m_rectPlot.bottom) + { + nOldPositionY = point.y; + } + + switch(m_nLineIndex) + { + case 1: // ѡ1 + dc.SelectObject(&m_PenLineA); + dc.MoveTo(m_OldMoveX1 /*+ 100*/, m_rectPlot.top);//һλA + dc.LineTo(m_OldMoveX1, m_rectPlot.Height()+10); // A + dc.SetTextColor(RGB(0, 0, 0)); + dc.TextOut(m_OldMoveX1, m_rectPlot.Height()+13, _T("")); + m_OldMoveX1 = point.x; + dc.MoveTo(point.x, m_rectPlot.top); + dc.LineTo(point.x, m_rectPlot.Height()+10); + dc.SetTextColor(RGB(255, 255, 0)); + dc.TextOut(point.x, m_rectPlot.Height()+13, _T("")); + +// gl_MLength = (MouseOffset - m_rectPlot.left + glOffset); +// //gl_NLength = gl_nSampleLenth - gl_MLength; // ־MλС +// gl_nSampleLenth = gl_NLength - gl_MLength; // ־MλС +// +// str.Format(_T("%d"), gl_MLength); +// pEditM_Length->SetWindowText(str); +// str.Format(_T("%d"), gl_NLength); +// pEditN_Length->SetWindowText(str); +// ADPara.M_Length = gl_MLength; +// ADPara.N_Length = gl_NLength; + break; + case 2: // ѡ2 + dc.SelectObject(&m_PenLineB); + dc.MoveTo(m_OldMoveX2, m_rectPlot.top);//һλB + dc.LineTo(m_OldMoveX2, m_rectPlot.Height()+10); // B + m_OldMoveX2 = point.x; + dc.MoveTo(point.x, m_rectPlot.top); + dc.LineTo(point.x, m_rectPlot.Height()+10); + break; + case 3: // ѡ3 + dc.SelectObject(&m_PenLineV); + dc.MoveTo(m_rectPlot.left, m_OldVoltageY);//һλV + dc.LineTo(m_rectPlot.right, m_OldVoltageY); // V + m_OldVoltageY = point.y; + dc.MoveTo(m_rectPlot.left, point.y); + dc.LineTo(m_rectPlot.right, point.y); + break; + } + } + } + dc.SetROP2(nMode); + MouseOffset = point.x; + SetStatusBar(); // ״̬Ƶʵ + + CWnd::OnMouseMove(nFlags, point); +} +void CADScopeCtrl::OnLButtonDblClk(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + if(m_bDrawPoly == TRUE && point.x > m_rectPlot.left && gl_bTileWave) // ڱ߿ʱ + { + // ͨж˫ʱλãʾһ·ͨ + if(m_bAllChannel) // ʾͨ + { + CString str; + tempCount = 1; + for(int i=0; iSetYUnits(_T("ͨ-")+str); + + pParaCfgView->m_lSingleCH = i; + + break; + } + } + } + + for(int j=0; jSetYUnits(str); + + pParaCfgView->m_lSingleCH = 0xFF; + } + m_bAllChannel = !m_bAllChannel; + this->InvalidateCtrl(); + pParaCfgView->EnableWindows(!gl_bDeviceADRun); + } + CWnd::OnLButtonDblClk(nFlags, point); +} + + +DWORD gl_nOldTicks = 0; +BOOL gl_LBtnDown = FALSE; +void CADScopeCtrl::OnLButtonDown(UINT nFlags, CPoint point) +{ + gl_LBtnDown = TRUE; + // TODO: Add your message handler code here and/or call default + // ˫¼ + DWORD nNewTick; + nNewTick = GetTickCount(); + if((nNewTick - gl_nOldTicks)<250) //Beep(3000, 1); + { + LPARAM CursorPos; + CursorPos = MAKELONG(point.x, point.y); + // ˫Ϣ, ĵǰ + ::SendMessage(this->m_hWnd, WM_LBUTTONDBLCLK, nFlags, CursorPos); + } + gl_nOldTicks = nNewTick; + this->SetCapture(); + CWnd::OnLButtonDown(nFlags, point); +} + +//##################################################################################### +// ԭֵ(bufferԭ), ٴɿʾĵ +BOOL gl_bInitBuf = FALSE; +void CADScopeCtrl::AppendPoly(int BufferID, int Offset, ULONG nDrawLen) +{ + m_nChannelCount = gl_nChannelCount; + m_BufferID = BufferID; // ID + m_Offset = Offset; // ƫ + if(!gl_bInitBuf) + { + DrawBkGnd(); // ڻ֮ǰȻ + gl_bInitBuf = TRUE; // ֻһ + } + // ָָתɶӦ + ProcessData(nDrawLen,BufferID); + // ʼ + DrawPoly(nDrawLen, BufferID); +} + +//############################################################################### +// , ѻеתɿʾĵ +BOOL gl_bTileWave = TRUE; +void CADScopeCtrl::ProcessData(ULONG nDrawLen,ULONG nDrawIdx) +{ + float m_ScreenVolume = VOLT_RANGE; // ͨʾʱĻǺѹֵһµ + float LsbOfPixel; + +// m_iDataLength = MAX_RAM_SIZE/gl_nChannelCount-glOffset; +// if (gl_bSmlThenSize && ADPara.SampleMode==ACTS1000_SAMPMODE_FINITE) +// { +// m_iDataLength = (gl_ReadSizeWords%8192)/gl_nChannelCount-glOffset; +// if (m_iDataLength == 0) +// m_iDataLength = 8192/gl_nChannelCount; +// } + + + if (nDrawLen>m_nPlotWidth) + { + nDrawLen = m_nPlotWidth; + } + m_iDataLength = nDrawLen; + + + + PerY = (float)(m_rectPlot.Height()*1.0 / m_nChannelCount); // ÿͨY + + LsbOfPixel=(float)(((m_ScreenVolume/VOLT_RANGE)*gl_fLsbCount)/(PerY));//ÿضӦֵ + + Center = (float)(PerY/2.0)+m_rectPlot.top; + + + int Channel, Index, StartX; + int nCount=0; + //-------------------------------------------------------- + + if (m_bDrawComp) + return; + + m_bDrawComp = TRUE; + + if(m_bAllChannel) + { + //if (!m_bDrawComp) + { + + ULONG ulBuffID = nDrawIdx; + if (nDrawLen>0) + { + memcpy(ADDrawBuffer, ADBuffer[ulBuffID], nDrawLen*2*MAX_CHANNEL_COUNT); + } + for(Channel=0; Channelm_nPlotWidth) + { + nDrawLen = m_nPlotWidth; + } + + + + //--------------------------------------------------------------------------------- + if(m_bAllChannel) // ͨʾ + { + + for(int i = 0; im_ADFrame; + CEdit *pEditDiv = (CEdit *)pFrame->m_wndShowStatus.GetDlgItem(IDC_STATIC_TimeOfDiv); + pEditDiv->GetWindowText(strTimeDiv); + fTimeDiv = (float)_tstof(strTimeDiv); + fTimePixel = fTimeDiv/ 50; // ÿ֮ʱ(nS) + + CString str = strTimeDiv.Mid(7,8); + str = str.Left(3); + strCountTimer.Format(_T("%7.2f"), fTimePixel * SubstValue); + + CEdit *pEditTime = (CEdit *)pFrame->m_wndShowStatus.GetDlgItem(IDC_EDIT_CountTime); + pEditTime->SetWindowText(strCountTimer+str); + // ƵʵĴС + if (SubstValue) + { + //fFrequency = (double)(1000000000.0 / (fTimePixel * SubstValue)); + fFrequency = (float)( gl_ADMainInfo.nBaseRate/ADPara.FreqDivision / SubstValue); + if(fFrequency < 1000.0) + { + strFrequency.Format(_T("%7.2f Hz"), fFrequency); + } + if(fFrequency >= 1000.0 && fFrequency < 1000000.0) + { + strFrequency.Format(_T("%7.2f KHz"), fFrequency/1000.0); + } + if(fFrequency >= 1000000.0) + { + strFrequency.Format(_T("%7.2f MHz"), fFrequency/1000000.0); + } + } + + + CEdit *pEditFre = (CEdit *)pFrame->m_wndShowStatus.GetDlgItem(IDC_EDIT_MeasureFreq); + pEditFre->SetWindowText(strFrequency); + // ѹֵѹֵ + float LsbOfPixel=(float)((gl_ScreenVolume*1.0)/(m_rectPlot.Height()));//ÿضӦֵ + + int Center = m_rectPlot.Height()/2 + m_rectPlot.top; + int nOffset = Center - m_OldVoltageY; + m_VolOffset = nOffset * LsbOfPixel; + strVol.Format(_T("%7.2f"), m_VolOffset); + CEdit *pEditVol = (CEdit *)pFrame->m_wndShowStatus.GetDlgItem(IDC_EDIT_Volt); + pEditVol->SetWindowText(strVol); + + CEdit *pEditOffset = (CEdit *)pFrame->m_wndShowStatus.GetDlgItem(IDC_EDIT_Offset); + CString strOffset; + strOffset.Format(_T("%d"), MouseOffset - m_rectPlot.left + glOffset); + if(MouseOffset >= m_rectPlot.left && MouseOffset <= m_rectPlot.right) + { + pEditOffset->SetWindowText(strOffset); + } + +} + +int CADScopeCtrl::FindTrigger(int nChannel, int nValue) // ֹζ +{ + int Offset=0; + for(int Index=100; Index<1024; Index++) // мĵ㣬ֹζ + { + int Temp = ADBuffer[m_BufferID][Index*gl_nChannelCount+gl_CHIdx[nChannel]]&gl_wMaxLSB; + if(Temp<(ADBuffer[m_BufferID][(Index+1)*gl_nChannelCount+gl_CHIdx[nChannel]]&gl_wMaxLSB)) + { + if(Temp>nValue && TempSetTextColor(m_clPen[i]); // ֵɫ + str.Format (_T("%.*lf V"), m_nYDecimals, m_dUpperLimit[i]/1000.0); // ѹֵ + pDC->TextOut (m_rectPlot.left-4, (int)(m_rectPlot.top+hight*nCount+8), str); + + pDC->SetTextAlign (TA_RIGHT|TA_BASELINE); + str.Format (_T("%.*lf V"), m_nYDecimals, m_dLowerLimit[i]/1000.0); // ѹֵ + pDC->TextOut (m_rectPlot.left-4, (int)(m_rectPlot.top+hight*(nCount+1)-5), str); + + str.Format(_T("CH %d"), i); + pDC->TextOut(m_rectPlot.left-4, (int)(m_rectPlot.top+hight*nCount+hight/2+5), str); + nCount++; + + } + } + +} + +void CADScopeCtrl::DrawSingleCHText(CDC *pDC, int nChannelNum) +{ + CString str; + if(nChannelNum != 0xFFFF) + { + pDC->SetTextColor(m_clPen[nChannelNum]); + str.Format (_T("%.*lf mV"), 0, m_dUpperLimit[nChannelNum]); // ѹֵ + pDC->TextOut (m_rectPlot.left-4, m_rectPlot.top, str); + pDC->SetTextAlign (TA_RIGHT|TA_BASELINE) ; + str.Format (_T("%.*lf mV"), 0, m_dLowerLimit[nChannelNum]); // ѹֵ + pDC->TextOut (m_rectPlot.left-4, m_rectPlot.top+m_nPlotHeight, str); + } + else + { + pDC->SetTextColor(m_crGridColor); + str.Format (_T("%.*lf mV"), 0, m_dUpperLimit[0]); // ѹֵ + //pDC->TextOut (m_rectPlot.left-4, m_rectPlot.top, str); + pDC->SetTextAlign (TA_RIGHT|TA_BASELINE) ; + str.Format (_T("%.*lf mV"), 0, m_dLowerLimit[0]); // ѹֵ + //pDC->TextOut (m_rectPlot.left-4, m_rectPlot.top+m_nPlotHeight, str); + } + + if(nChannelNum == 0xFFFF) // ǵʾʱ + str = _T("CH"); + else + str.Format(_T("CH %d"), nChannelNum); + // дͨ + pDC->TextOut(m_rectPlot.left-4, m_rectPlot.top+m_nPlotHeight/2+5, str); + +} \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADScopeCtrl.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADScopeCtrl.h new file mode 100644 index 0000000..ebf3c80 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADScopeCtrl.h @@ -0,0 +1,149 @@ +// OScopeCtrl.h : header file +// + +#ifndef __OScopeCtrl_H__ +#define __OScopeCtrl_H__ +///////////////////////////////////////////////////////////////////////////// +// CADScopeCtrl window + +class CADScopeCtrl : public CWnd +{ + // Construction +public: + CADScopeCtrl(); + + // Attributes +public: + double AppendPoint(double dNewPoint); + void SetRange(double dLower, double dUpper, int nDecimalPlaces=1); + void SetXUnits(CString string); + void SetYUnits(CString string); + void SetGridColor(COLORREF color); + void SetPlotColor(COLORREF color); + void SetBackgroundColor(COLORREF color); + void InvalidateCtrl(); + + void Reset(); + + // Operations +public: + + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADScopeCtrl) + public: + virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID=NULL); + protected: + virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + + // Implementation +public: + void DrawAllChannelText(CDC *pDC); + void DrawSingleCHText(CDC *pDC, int nChannelNum); + CPen m_polyPen[MAX_CHANNEL_COUNT]; + CPen m_ChannelPen[MAX_CHANNEL_COUNT]; + int FindTrigger(int nChannel, int nValue); + void SetStatusBar(); + void AppendPoly(int BufferID, int Offset, ULONG nDrawLen); + int m_nPtCount; + int tempCount; + int m_nChannelCount; + int m_nChannelNum; + float PerY; + int m_BufferID; + int m_Offset; + float PixelOfLsb; +// int m_nCenter[32]; + POINT pointxy[32][8192]; // ͨʾĵ + CPoint pointTemp[8192]; // ŵͨʾĵ + SHORT *m_pBuffer; + COLORREF m_clPen[MAX_CHANNEL_COUNT]; + int HeightMid[64] ; + int MouseOffset; // ڻͼƫλ + int m_OldMoveX1; // ƶߵλ + int m_OldMoveX2; + int m_OldMoveY; + int m_CurMoveX1; + int m_CurMoveX2; + int m_CurMoveY; + COLORREF m_crLineAColor; // Aߵɫ + COLORREF m_crLineBColor; // Bߵɫ + COLORREF m_crLineVColor; // Cߵɫ + + CPen m_PenLineA; // AߵĻ + CPen m_PenLineB; // BߵĻ + CPen m_PenLineV; // VߵĻ + + int m_CurVoltageY; + int m_OldVoltageY; + float m_VolOffset; + int m_nLineIndex; + BOOL m_bAllChannel; + + int m_nShiftPixels; + int m_nYDecimals; + + CString m_strXUnitsString; + CString m_strYUnitsString; + + COLORREF m_crBackColor; + COLORREF m_crGridColor; + COLORREF m_crPlotColor; + + double m_dCurrentPosition; + double m_dPreviousPosition; + + LONG m_iDataLength; + + virtual ~CADScopeCtrl(); +private: + UINT m_nLoop; + void DrawBkGnd(); // + void DrawPoint(); + void DrawPoly(ULONG nDrawLen,ULONG nDrawIdx); + void ProcessData(ULONG nDrawLen,ULONG nDrawIdx); + +protected: + //{{AFX_MSG(CADScopeCtrl) + afx_msg void OnPaint(); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + int m_nHalfShiftPixels; + int m_nPlotShiftPixels; + int m_nClientHeight; + int m_nClientWidth; + int m_nPlotHeight; + int m_nPlotWidth; // + BOOL m_bDrawPoly; + BOOL m_bInitialed; + double m_dLowerLimit[MAX_CHANNEL_COUNT]; // lower bounds + double m_dUpperLimit[MAX_CHANNEL_COUNT]; // upper bounds + double m_dRange; + double m_dVerticalFactor; + + CRect m_rectClient; + CRect m_rectPlot; + CPen m_penPlot; + CBrush m_brushBack; + + CDC m_dcGrid; + CDC m_dcPlot; + CDC m_dcMove; + CBitmap *m_pbitmapOldGrid; + CBitmap *m_pbitmapOldPlot; + CBitmap m_bitmapGrid; + CBitmap m_bitmapPlot; + + +}; + +///////////////////////////////////////////////////////////////////////////// +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADStatusView.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADStatusView.cpp new file mode 100644 index 0000000..373991a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADStatusView.cpp @@ -0,0 +1,193 @@ +// ADStatusView.cpp : implementation file +// + +#include "stdafx.h" +#include "Sys.h" + +#include "ADFrm.h" +#include "ADDoc.h" +#include "ADDigitView.h" +#include "ADWaveView.h" +#include "ADStatusView.h" +#include "ParaCfgView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CADStatusView + +IMPLEMENT_DYNCREATE(CADStatusView, CFormView) + +CADStatusView::CADStatusView() + : CFormView(CADStatusView::IDD) +{ + //{{AFX_DATA_INIT(CADStatusView) + //}}AFX_DATA_INIT +// bFirstChangeTrigge=TRUE; // ijЩû׼ʱܲCEdit +} + +CADStatusView::~CADStatusView() +{ +} + +void CADStatusView::DoDataExchange(CDataExchange* pDX) +{ + CFormView::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CADStatusView) + DDX_Control(pDX, IDC_Combo_ScreenVolume, m_nScreenVolume); + DDX_Control(pDX, IDC_Combo_MoveVolt, m_nMoveVolt); + DDX_Control(pDX, IDC_EDIT_AnalyzeCount, m_nAnalyzeCount); + DDX_Control(pDX, IDC_EDIT_OverRange, m_nOverRange); + DDX_Control(pDX, IDC_EDIT_OverRatio, m_nOverRatio); + DDX_Control(pDX, IDC_EDIT_TriggerVolt, m_nTringgerVolt); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CADStatusView, CFormView) + //{{AFX_MSG_MAP(CADStatusView) + ON_EN_CHANGE(IDC_EDIT_TriggerVolt, OnChangeEDITTriggerVolt) + ON_BN_CLICKED(IDM_GraphicShow, OnGraphicShow) + ON_BN_CLICKED(IDM_DigitalShow, OnDigitalShow) + ON_BN_CLICKED(IDM_DataSave, OnDataSave) + ON_CBN_SELCHANGE(IDC_Combo_ScreenVolume, OnSelchangeComboScreenVolume) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CADStatusView diagnostics + +#ifdef _DEBUG +void CADStatusView::AssertValid() const +{ + CFormView::AssertValid(); +} + +void CADStatusView::Dump(CDumpContext& dc) const +{ + CFormView::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CADStatusView message handlers + +void CADStatusView::OnInitialUpdate() +{ + CFormView::OnInitialUpdate(); + CString str; + // TODO: Add your specialized code here and/or call the base class + str.Format(_T("%d"), gl_ScreenVolume); + + str.Format(_T("%d"), m_TriggerVolt); + m_nTringgerVolt.SetWindowText(str); + + m_nScreenVolume.SetCurSel(12); +// gl_ScreenVolume = 10000; + + m_nMoveVolt.SetWindowText(_T("0")); + + m_nAnalyzeCount.SetWindowText(_T("0")); + + m_nOverRange.SetWindowText(_T("0"));//Ҫص + + m_nOverRatio.SetWindowText(_T("0"));//Ҫص + if(gl_bTileWave) + { + CButton* pButtonTile = (CButton*)GetDlgItem(IDM_TileWave); + pButtonTile->SetCheck(1); + } + else + { + CButton* pButtonPose = (CButton*)GetDlgItem(IDM_SuperPoseWave); + pButtonPose->SetCheck(1); + } + SetDlgCheck(); +} + + + + +void CADStatusView::OnChangeEDITTriggerVolt() //ı䴥ѹֵ +{ + // TODO: Add your control notification handler code here + CString str; + m_nTringgerVolt.GetWindowText(str); + m_TriggerVolt=_tcstol(str,NULL,10); + // ôƽʱóͳ + m_OverLimitCount=0; + m_AnalyzeAllCount=0; +} + +void CADStatusView::SetDlgCheck() +{ + CButton* pCheck = (CButton*)GetDlgItem(IDM_DigitalShow); + pCheck->SetCheck(nProcessMode == DATA_MODE ? BST_CHECKED:BST_UNCHECKED); + pCheck->EnableWindow(m_bFirstCreateDeviceFile); + + pCheck=(CButton*)GetDlgItem(IDM_GraphicShow); + pCheck->SetCheck(nProcessMode == WAVE_MODE ? BST_CHECKED:BST_UNCHECKED); + pCheck->EnableWindow(m_bFirstCreateDeviceFile); + + + pCheck=(CButton*)GetDlgItem(IDM_DataSave); + pCheck->SetCheck(nProcessMode == SAVE_MODE ? BST_CHECKED:BST_UNCHECKED); + pCheck->EnableWindow(!m_bFirstCreateDeviceFile); +} + + + +void CADStatusView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) +{ + // TODO: Add your specialized code here and/or call the base class +// if(lHint==1||lHint==2) return; + CView::OnUpdate(pSender, lHint, pHint); +} + +void CADStatusView::OnDigitalShow() +{//ַʽʾ + // TODO: Add your control notification handler code here + nProcessMode = DATA_MODE; + SetDlgCheck(); +} +void CADStatusView::OnGraphicShow() +{//ʾʽ + // TODO: Add your control notification handler code here + + nProcessMode = WAVE_MODE; + SetDlgCheck(); +} +void CADStatusView::OnDataSave() +{//̷ʽʾ + // TODO: Add your control notification handler code here + nProcessMode = SAVE_MODE; + SetDlgCheck(); + +} + + +void CADStatusView::OnSelchangeComboScreenVolume() +{ + // TODO: Add your control notification handler code here + CSysApp *pApp=(CSysApp *)AfxGetApp(); + CADDoc* pDoc=pApp->m_pADDoc; + + CString str; + m_nScreenVolume.GetWindowText(str); + gl_ScreenVolume=_tcstol(str,NULL,10); + + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + + if (!gl_bDeviceADRun) + { + pWaveView->OnDrawPolyLine(gl_nDocDrawLen,gl_nDocDrawIdx); + } + if(pWaveView->m_ADScopeCtrl.m_bAllChannel == FALSE) //ͨʾʱܲѹ + { + pWaveView->m_ADScopeCtrl.SetRange(-gl_ScreenVolume/2.0, gl_ScreenVolume/2.0, pWaveView->m_ADScopeCtrl.m_nChannelNum); + } +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADStatusView.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADStatusView.h new file mode 100644 index 0000000..ab4424c --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADStatusView.h @@ -0,0 +1,77 @@ +#if !defined(AFX_ADStatusView_H__E4B4B7A2_D13C_11D6_B1D2_AB386BFF0020__INCLUDED_) +#define AFX_ADStatusView_H__E4B4B7A2_D13C_11D6_B1D2_AB386BFF0020__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ADStatusView.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CADStatusView form view + +#ifndef __AFXEXT_H__ +#include +#endif + +class CADStatusView : public CFormView +{ +protected: + CADStatusView(); // protected constructor used by dynamic creation + DECLARE_DYNCREATE(CADStatusView) + +// Form Data +public: + //{{AFX_DATA(CADStatusView) + enum { IDD = CG_IDD_Capability }; + CComboBox m_nScreenVolume; + CComboBox m_nMoveVolt; + CEdit m_nAnalyzeCount; + CEdit m_nOverRange; + CEdit m_nOverRatio; + CEdit m_nTringgerVolt; + //}}AFX_DATA + +// Attributes +public: + void SetDlgCheck(); + + BOOL bFirstChangeTrigge; // ״θı䴥ƽ +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADStatusView) + public: + virtual void OnInitialUpdate(); + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); + //}}AFX_VIRTUAL + +// Implementation +protected: + virtual ~CADStatusView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + // Generated message map functions + //{{AFX_MSG(CADStatusView) + afx_msg void OnChangeEDITTriggerVolt(); + afx_msg void OnGraphicShow(); + afx_msg void OnDigitalShow(); + afx_msg void OnDataSave(); + afx_msg void OnSelchangeComboScreenVolume(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ADStatusView_H__E4B4B7A2_D13C_11D6_B1D2_AB386BFF0020__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADThread.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADThread.cpp new file mode 100644 index 0000000..08d9eee --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADThread.cpp @@ -0,0 +1,376 @@ +#include "stdAfx.h" +#include "Sys.h" +#include "ADThread.h" +#include "ADDigitView.h" +#include "math.h" + +CWinThread* m_ReadThread; // ߳̾ +BOOL gl_bTerminateThr = TRUE; // ߳Ƿɾ +BOOL gl_bSmlThenSize = FALSE; +////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------------------------------------------- +UINT ReadDataThread(PVOID hWnd); +//######################################################################## +// ݲɼ߳ +BOOL MyStartDeviceAD(HANDLE hDevice) +{ + if(!gl_bTerminateThr) // һ̻߳ûɾ + { + AfxMessageBox(_T("һε̻߳ûֹ")); + return FALSE; + } + + m_ReadThread = AfxBeginThread(ReadDataThread,NULL, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); + m_ReadThread->m_bAutoDelete = true; // Զɾ߳ + gl_bDeviceADRun = TRUE; // ֮ɼ߳̿Թ + m_ReadThread->ResumeThread(); // ɼ߳ReadDataThread_NotEmpty + return TRUE; +} + +BOOL bWriteCnt = 0; +//############################################################### +ACTS1000_PARA_AD gl_OldADPara = ADPara; +BOOL IsChangePara() +{ + BOOL bRet; + if(memcmp(&gl_OldADPara, &ADPara, sizeof(ADPara))==0) + bRet = FALSE; + else + bRet = TRUE; + gl_OldADPara = ADPara; + return bRet; +} +BOOL gl_bStoped = FALSE; + +// ȡ ̺߳ +UINT ReadDataThread(PVOID hWnd) +{ + CSysApp *pApp=(CSysApp *)AfxGetApp(); + CADDoc* pDoc=pApp->m_pADDoc; + ULONG ReadOffsetWords = 0; + LONG RetReadSizeWords; + int nADChannel = 0; + DWORD dTmp=0; + HANDLE hDevice = pApp->m_hDevice; + ULONG SampleCnt = 1; // ɼ + ULONG SampleIndex; + ULONG RemainSizeWords = 0; + ULONG nRetSizeWords; + ULONG nAvailSampsPoints; + ULONG nIndex = 0; + BOOL bSuccess = FALSE; + ULONGLONG nReadSize; + ULONG nRead; + ULONG lSaveTime; + + ULONG ulReadCount = MAX_RAM_SIZE; + if(gl_bAutoCollect) // ֶɼĻʾ˾ֹͣɼ + { + SampleCnt = 0xFFFFFFFF; + } + gl_bStoped = FALSE; + + + + + +// for(int i=0; i300) + { + if (gl_ADStatus.lSavePoints>FileLenghtWords) + { + FileLenghtWords=gl_ADStatus.lSavePoints; + SetEvent(hEvent); // ¼߻ƴ̣߳Ѳɼ + lSaveTime = GetTickCount(); + } + } + } + } + else // if (ADPara.bSaveFile) + { + + + nReadSize = gl_ReadSizeWords; + while (nReadSize>0) + { + if (nReadSize>=ulReadCount) + { + nRead = ulReadCount; + gl_bSmlThenSize = FALSE; + } + else + { + gl_bSmlThenSize = TRUE; + nRead = nReadSize; + } +NextRead: + if(!gl_bDeviceADRun) + goto ExitReadThread; + + RetReadSizeWords = ACTS1000_ReadDeviceAD(hDevice, ADBuffer[lBufferID], nRead, &nRetSizeWords, &nAvailSampsPoints,1.0); + if(RetReadSizeWords == 0) + { + AfxMessageBox(_T("ݳ!")); + goto ExitReadThread; + } + if (nRetSizeWords==0) + { + int a=0; + } + if (nRetSizeWords<=0) + { + goto NextRead; + } +// if (nRetSizeWords != 262144) +// { +// int a= 0; +// } + nReadSize -= nRetSizeWords; + bSuccess = TRUE; + if (nProcessMode == SAVE_MODE) + { + WriteFile(g_ArrFileOut,ADBuffer[lBufferID], nRetSizeWords*sizeof(WORD),&dTmp,NULL); + FileLenghtWords += nRead; // ļС + } + if (!m_bDrawComp) + { + glBufferID = lBufferID; + + gl_Section.Lock(); + //ADBuffer[lBufferID][10]= nTTT++; + gl_nDrawLen = nRetSizeWords/gl_nChannelCount; + gl_nDrawIdx = lBufferID; + gl_Section.Unlock(); + + if (nProcessMode != SAVE_MODE) + { + SetEvent(hEvent); // ¼߻ƴ̣߳Ѳɼ + } + } + + lBufferID++; + if (lBufferID >= MAX_SEGMENT) + lBufferID = 0; + if (nProcessMode == SAVE_MODE) + { + SetEvent(hEvent); // ¼߻ƴ̣߳Ѳɼ + } + + } + } + + +FinComplete: + ACTS1000_StopDeviceAD(hDevice); // ʼ豸 + + }// ߳ѭȡ + } + else + { + lBufferID = 0; + if (!ACTS1000_StartDeviceAD(hDevice))// ʼ豸 + { + MsgBox(_T("ʧ!")); + goto ExitReadThread; + } + + //ACTS1000_SetDeviceTrigAD(hDevice); + if (ADPara.bSaveFile) + { + while(TRUE) + { + if(!ACTS1000_GetDevStatusAD(hDevice, &gl_ADStatus)) + { + MsgBox(_T("GetDevStatusAD Error")); + goto ExitReadThread; + } + if(!gl_bDeviceADRun) + goto ExitReadThread; + Sleep(1); + if (GetTickCount()-lSaveTime>300) + { + if (gl_ADStatus.lSavePoints>FileLenghtWords) + { + FileLenghtWords=gl_ADStatus.lSavePoints; + SetEvent(hEvent); // ¼߻ƴ̣߳Ѳɼ + lSaveTime = GetTickCount(); + } + } + } + } + else + { + nRead = ulReadCount; + while(gl_bDeviceADRun) + { + RetReadSizeWords = ACTS1000_ReadDeviceAD(hDevice, ADBuffer[lBufferID], nRead, &nRetSizeWords, &nAvailSampsPoints,1.0); + if(RetReadSizeWords == 0) + { + AfxMessageBox(_T("ݳ!")); + goto ExitReadThread; + } + if (nRetSizeWords<=0) + { + Sleep(1); + continue; + } + bSuccess = TRUE; + if (nProcessMode == SAVE_MODE) + { + WriteFile(g_ArrFileOut,ADBuffer[lBufferID], nRetSizeWords*sizeof(WORD),&dTmp,NULL); + + FileLenghtWords += nRetSizeWords; // ļС + } + + if (!m_bDrawComp) + { + glBufferID = lBufferID; + + gl_Section.Lock(); + gl_nDrawLen = nRetSizeWords/gl_nChannelCount; + gl_nDrawIdx = lBufferID; + gl_Section.Unlock(); + if (nProcessMode != SAVE_MODE) + { + SetEvent(hEvent); // ¼߻ƴ̣߳Ѳɼ + } + + + } + lBufferID++; + if (lBufferID >= MAX_SEGMENT) + lBufferID = 0; + + if (nProcessMode == SAVE_MODE) + { + SetEvent(hEvent); // ¼߻ƴ̣߳Ѳɼ + } + nConstReadCnt++; + if (nConstReadCnt%4000==0) + { + if (ACTS1000_GetDevStatusAD(hDevice,&ADStatus)) + { + if (ADStatus.bAheadTrig) + { + AfxMessageBox(_T("Ӳ,1:뽵Ͳ 2:߳Ч 3:ʹSimple\AD\ContinueµexeԴٶ!")); + goto ExitReadThread; + } + } + } + } + } + } +ExitReadThread: + SetEvent(hExitEvent); // 豸ɹ˳Ϣùر豸̵߳ôϢ + gl_bTerminateThr = TRUE; + gl_bCollected = TRUE; // һβɼ + + ACTS1000_StopDeviceAD(hDevice); + ACTS1000_ReleaseDeviceAD(hDevice); + + if (!gl_bAutoCollect && bSuccess && gl_bStoped==FALSE) + { + //pApp->m_pADDoc->StopDeviceAD(); + } + + + return TRUE; +} + +BOOL MyStopDeviceAD(HANDLE hDevice) +{ + CSysApp *pApp=(CSysApp *)AfxGetApp(); + + gl_bDeviceADRun = FALSE; + if (gl_bAutoTrig) + { + ACTS1000_SetDeviceTrigAD(pApp->m_hDevice); + } + if (gl_bAutoCollect == FALSE) + { + + gl_bStoped = TRUE; + WaitForSingleObject(m_ReadThread->m_hThread, 1000); + } + else + { + WaitForSingleObject(m_ReadThread->m_hThread, INFINITE); + } + bCreateDevice = FALSE; + return TRUE; +} + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADThread.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADThread.h new file mode 100644 index 0000000..053ac06 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADThread.h @@ -0,0 +1,2 @@ +BOOL MyStartDeviceAD(HANDLE hDevice);// ɼ߳ +BOOL MyStopDeviceAD(HANDLE hDevice); // ֹͣɼ߳ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADWaveView.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADWaveView.cpp new file mode 100644 index 0000000..03e1461 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADWaveView.cpp @@ -0,0 +1,224 @@ +// ADWaveView.cpp : implementation file +// + +#include "stdafx.h" +#include "Sys.h" +#include "ADWaveView.h" +#include "MainFrm.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +/////////////////////////////////////////////////////////// +#include "ADStatusView.h" +#include "ParaCfgView.h" +extern CADStatusView* pADStatusView; +extern CParaCfgView* pParaCfgView; +/////////////////////// +static CPoint pointxy[32][8192]; +int WavePointX; //¼Xλ +BOOL bMeasureFreq=FALSE; // ǷƵ +int StartX, EndX; // Ƶ +COLORREF pColor[]= +{ + + RGB(176,15,172), + RGB(170,21,33), + RGB(22,158,169), + RGB(4,187,109), + + RGB(176,15,172), + RGB(170,21,33), + RGB(22,158,169), + RGB(4,187,109), + + RGB(176,15,172), + RGB(170,21,33), + RGB(22,158,169), + RGB(4,187,109), + + RGB(176,15,172), + RGB(170,21,33), + RGB(22,158,169), + RGB(4,187,109), + +}; + +IMPLEMENT_DYNCREATE(CADWaveView, CScrollView) + +CADWaveView::CADWaveView() +{ + m_Draw=FALSE; + + Offset=0; + brush.CreateSolidBrush (RGB(255,255,255)); + CurrentProgress=0; // òɼֵΪ0 + m_ScaleH_Width = 40; + m_ScaleV_Width = 30; + m_oldPoint.x =m_oldPoint.y =-1; +} + +CADWaveView::~CADWaveView() +{ +} + + +BEGIN_MESSAGE_MAP(CADWaveView, CScrollView) +//{{AFX_MSG_MAP(CADWaveView) + ON_WM_SIZE() + ON_WM_ERASEBKGND() + ON_WM_MOUSEMOVE() + ON_WM_KEYDOWN() + ON_WM_LBUTTONUP() + ON_WM_NCCALCSIZE() + ON_WM_NCPAINT() + ON_WM_LBUTTONDOWN() + ON_WM_TIMER() + ON_WM_LBUTTONDBLCLK() + ON_MESSAGE(WM_SHOWWAVE, DrawPolyLine) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CADWaveView drawing +BOOL bCreate = FALSE; +void CADWaveView::OnInitialUpdate() +{ + CScrollView::OnInitialUpdate(); + + CADDoc* pDoc = (CADDoc*)GetDocument(); + pDoc->m_hWndWave=m_hWnd; // ȡͼԱDOCе߳ʹ + CSize sizeTotal; + // TODO: calculate the total size of this view + const SIZE conPSize={200,1}; + const SIZE conLSize={20,1}; + sizeTotal.cx = 0; + sizeTotal.cy = 0; + SetScrollSizes(MM_TEXT, sizeTotal); + SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS)); + for(int i=0;i<16;i++) + m_Pen[i].CreatePen(PS_SOLID,1,pColor[i]); + //////////////////////////////////////////////////////////////////////// + //ͼ + CRect rect; + GetClientRect(rect); + m_ADScopeCtrl.Create(WS_CHILD | WS_VISIBLE, CRect(10, 0, 400, 600), this); + m_ADScopeCtrl.SetXUnits(_T("X")); + m_ADScopeCtrl.SetYUnits(_T("Y")); + m_ADScopeCtrl.SetRange(-5, 5, 1); +} + +void CADWaveView::OnDraw(CDC* pDC) +{ +} + +///////////////////////////////////////////////////////////////////////////// +// CADWaveView diagnostics + +#ifdef _DEBUG +void CADWaveView::AssertValid() const +{ + CScrollView::AssertValid(); +} + +void CADWaveView::Dump(CDumpContext& dc) const +{ + CScrollView::Dump(dc); +} + +CADDoc* CADWaveView::GetDocument() // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CADDoc))); + return (CADDoc*)m_pDocument; +} +#endif //_DEBUG + +void CADWaveView::AnalyzeAccurate()//ȷ +{ + int m_TemporyVolt; + CString StrAllCount; + CString StrOverCount; + CString StrOverRatio; + int m_TriggerLsb; + m_TriggerLsb=(int)(m_TriggerVolt*(gl_fLsbCount/VOLT_RANGE)); + for(ULONG i=0;im_TriggerLsb) + { + m_OverLimitCount=m_OverLimitCount+1; + } + if(m_TemporyVolt<(-m_TriggerLsb)) + { + m_OverLimitCount=m_OverLimitCount+1; + } + } + m_AnalyzeAllCount=m_AnalyzeAllCount+gl_ReadSizeWords; + StrAllCount.Format(_T("%3.2e"),m_AnalyzeAllCount); + StrOverCount.Format(_T("%d"),m_OverLimitCount); + StrOverRatio.Format(_T("%4.4f"),m_OverLimitCount*100/m_AnalyzeAllCount); + StrOverRatio=StrOverRatio+"%"; + pADStatusView->m_nAnalyzeCount.SetWindowText(StrAllCount); + pADStatusView->m_nOverRange.SetWindowText(StrOverCount); + pADStatusView->m_nOverRatio.SetWindowText(StrOverRatio); +} + +void CADWaveView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) +{ + // TODO: Add your specialized code here and/or call the base class +} + +BOOL CADWaveView::OnEraseBkgnd(CDC* pDC) +{ + // TODO: Add your message handler code here and/or call default + CBrush brush; + CRect rect; + GetClientRect(rect); + brush.CreateSolidBrush(RGB(0, 0, 0)); + pDC->FillRect(rect, &brush); + return TRUE; +// return CScrollView::OnEraseBkgnd(pDC); +} + +void CADWaveView::OnSize(UINT nType, int cx, int cy) +{ + CScrollView::OnSize(nType, cx, cy); + // TODO: Add your message handler code here + GetClientRect(&ClientRect); + PerY=ClientRect.Height()*1.0/gl_nChannelCount; + middle1=(float)((((gl_ScreenVolume)/VOLT_RANGE)*gl_fLsbCount)/(PerY-5));//ÿضӦֵ + CRect rect; + GetClientRect(rect); + if(::IsWindow(m_ADScopeCtrl))//bCreate) + { + m_ADScopeCtrl.SetWindowPos(NULL, 0, 0, cx, cy, SWP_DRAWFRAME); + this->OnDrawPolyLine(gl_nDocDrawLen,gl_nDocDrawIdx); + } +} + +LRESULT CADWaveView::DrawPolyLine(WPARAM wParam, LPARAM lParam) +{ + if(m_bProgress && gl_bDeviceADRun) // ˢADDigitViewͼʱ½״̬ + { + CADFrame* pShow=((CSysApp*)AfxGetApp())->m_ADFrame ; // ȡ֡ھ + pProgress=(CProgressCtrl*)(pShow->m_wndShowStatus.GetDlgItem(IDC_PROGRESS)); + pProgress->SetPos(CurrentProgress); + CurrentProgress++; + if(CurrentProgress>50) CurrentProgress=0; + m_bProgress=FALSE; + } + OnDrawPolyLine((ULONG)wParam, (ULONG)lParam); // ʼʾͼ + return 1; +} + +void CADWaveView::OnDrawPolyLine(ULONG nDrawLen,ULONG nDrawIdx) +{ + m_ADScopeCtrl.AppendPoly(nDrawIdx, glOffset, nDrawLen); + +} + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADWaveView.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADWaveView.h new file mode 100644 index 0000000..938a498 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ADWaveView.h @@ -0,0 +1,87 @@ +#if !defined(AFX_ADWAVEVIEW_H__D485DF11_85AB_11D1_B878_A68EB300DD63__INCLUDED_) +#define AFX_ADWaveVIEW_H__D485DF11_85AB_11D1_B878_A68EB300DD63__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ADWaveView.h : header file +// +#include "ADScopeCtrl.h" +///////////////////////////////////////////////////////////////////////////// +// CADWaveView view + +class CADWaveView : public CScrollView +{ +protected: + CADWaveView(); // protected constructor used by dynamic creation + DECLARE_DYNCREATE(CADWaveView) +public: + int m_ScaleH_Width; + int m_ScaleV_Width; + +// Attributes +public: + //void ADWave(CDC *pDC); + CADScopeCtrl m_ADScopeCtrl; + CPen *OldPen; +// CPen Pen; + CBrush brush; + long Offset; // ¼8192еǰƫλ + + CProgressCtrl* pProgress; + int CurrentProgress; + int CurrentX, CurrentY; // ڿƵǰ + CPoint CurrentPoint; + CADDoc *GetDocument(); +// Operations +public: + void OnDrawPolyLine(ULONG nDrawLen,ULONG nDrawIdx); + + LRESULT DrawPolyLine(WPARAM wParam, LPARAM lParam); + + int * m_pBuffer; + CPen m_Pen[16]; + BOOL m_bCapture; + CPoint m_oldPoint; + BOOL m_Draw; + void AnalyzeAccurate(); + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CADWaveView) + protected: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual void OnInitialUpdate(); // first time after construct + virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); + //}}AFX_VIRTUAL + +// Implementation +protected: + CString m_ClassName; + CSize sizeTotal;//òʾͼĴС + virtual ~CADWaveView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + // Generated message map functions + //{{AFX_MSG(CADWaveView) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + //}}AFX_MSG + friend class CParaCfgView; + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in ADDigitView.cpp +inline CADDoc* CADWaveView::GetDocument() + { return (CADDoc*)m_pDocument; } +#endif +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ADWAVEVIEW_H__D485DF11_85AB_11D1_B878_A68EB300DD63__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/AIChanList.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/AIChanList.cpp new file mode 100644 index 0000000..d980f52 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/AIChanList.cpp @@ -0,0 +1,707 @@ +// AIChanList.cpp : implementation file +// + +#include "stdafx.h" +#include "Sys.h" + +#include "AIChanList.h" +#include "ParaCfgView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CAIChanList + +CAIChanList::CAIChanList() +{ + m_bEnableEx = TRUE; + m_nCurItem = 0; + m_nCurSubItem = 0; +} + +CAIChanList::~CAIChanList() +{ +} + +BEGIN_MESSAGE_MAP(CAIChanList, CListCtrl) + //{{AFX_MSG_MAP(CAIChanList) + ON_WM_LBUTTONDOWN() + ON_WM_VSCROLL() + ON_WM_HSCROLL() + ON_NOTIFY_REFLECT(NM_CLICK, OnClick) + ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick) + ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw) + ON_WM_CREATE() + ON_WM_MOUSEWHEEL() + ON_WM_SETFOCUS() + ON_WM_CONTEXTMENU() + ON_WM_DRAWITEM() + ON_COMMAND(IDM_SameParam, OnSameParam) + ON_MESSAGE(WM_SET_CTRL_FOCUS, OnSetCtrlFocus) + ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CAIChanList message handlers +void CAIChanList::OnClick(NMHDR* pNMHDR, LRESULT* pResult) +{ + if(m_bEnableEx == FALSE) return; + + *pResult = 0; + LPNMITEMACTIVATE lpItem = (LPNMITEMACTIVATE)pNMHDR; + m_nChanIdx = lpItem->iItem; + m_nType = lpItem->iSubItem; + + if(m_nChanIdx != -1) + { + CRect rcCtrl; + GetSubItemRect(m_nChanIdx, m_nType, LVIR_LABEL, rcCtrl); + RestoreCtrl(rcCtrl); + } +} + +extern CSysApp theApp; +BOOL CAIChanList::RestoreCtrl(CRect rcCtrl) +{ + CParaCfgView* pParent = (CParaCfgView*)GetParent(); + CADDoc* pDoc = (CADDoc*)pParent->GetDocument(); + CString strMsg, strTmp, strCur; + int nCurSel = 0, bChannelEn = 0, nSampleRange = 0, nSampleGain = 0, nCouplingType = 0; + switch(m_nType) + { +// case LIST_COL_CHANNEL: +// rcCtrl.bottom = rcCtrl.bottom + 200; +// m_wndCombo.MoveWindow(rcCtrl); +// m_wndCombo.ResetContent(); +// for(nChannel=0; nChannel2) + { + switch (m_nChanIdx) + { + case 0: + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 0; + ADPara.bChannelArray[2] = 0; + ADPara.bChannelArray[3] = 0; + ADPara.bChannelArray[4] = 0; + ADPara.bChannelArray[5] = 0; + ADPara.bChannelArray[6] = 0; + ADPara.bChannelArray[7] = 0; + break; + case 1: + if (nCurSel == 0) + { + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 0; + ADPara.bChannelArray[2] = 0; + ADPara.bChannelArray[3] = 0; + ADPara.bChannelArray[4] = 0; + ADPara.bChannelArray[5] = 0; + ADPara.bChannelArray[6] = 0; + ADPara.bChannelArray[7] = 0; + } + else + { + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 1; + ADPara.bChannelArray[2] = 0; + ADPara.bChannelArray[3] = 0; + ADPara.bChannelArray[4] = 0; + ADPara.bChannelArray[5] = 0; + ADPara.bChannelArray[6] = 0; + ADPara.bChannelArray[7] = 0; + } + break; + case 2: + if (nCurSel == 0) + { + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 1; + ADPara.bChannelArray[2] = 0; + ADPara.bChannelArray[3] = 0; + ADPara.bChannelArray[4] = 0; + ADPara.bChannelArray[5] = 0; + ADPara.bChannelArray[6] = 0; + ADPara.bChannelArray[7] = 0; + } + else + { + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 1; + ADPara.bChannelArray[2] = 1; + ADPara.bChannelArray[3] = 1; + ADPara.bChannelArray[4] = 0; + ADPara.bChannelArray[5] = 0; + ADPara.bChannelArray[6] = 0; + ADPara.bChannelArray[7] = 0; + } + break; + case 3: + if (nCurSel == 0) + { + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 1; + ADPara.bChannelArray[2] = 0; + ADPara.bChannelArray[3] = 0; + ADPara.bChannelArray[4] = 0; + ADPara.bChannelArray[5] = 0; + ADPara.bChannelArray[6] = 0; + ADPara.bChannelArray[7] = 0; + } + else + { + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 1; + ADPara.bChannelArray[2] = 1; + ADPara.bChannelArray[3] = 1; + ADPara.bChannelArray[4] = 0; + ADPara.bChannelArray[5] = 0; + ADPara.bChannelArray[6] = 0; + ADPara.bChannelArray[7] = 0; + } + break; + case 4: + case 5: + case 6: + case 7: + if (nCurSel == 0) + { + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 1; + ADPara.bChannelArray[2] = 1; + ADPara.bChannelArray[3] = 1; + ADPara.bChannelArray[4] = 0; + ADPara.bChannelArray[5] = 0; + ADPara.bChannelArray[6] = 0; + ADPara.bChannelArray[7] = 0; + } + else + { + ADPara.bChannelArray[0] = 1; + ADPara.bChannelArray[1] = 1; + ADPara.bChannelArray[2] = 1; + ADPara.bChannelArray[3] = 1; + ADPara.bChannelArray[4] = 1; + ADPara.bChannelArray[5] = 1; + ADPara.bChannelArray[6] = 1; + ADPara.bChannelArray[7] = 1; + } + break; + } + } + + + //SetItemText(m_nChanIdx, m_nType, strMsg); + //pParent->SetCurveRange(m_nChanIdx, nCurSel); + for(nChannel=0; nChannelOnSelchangeCOMBOnSampChanCount(); + + gl_nChannelCount = nSampChanCount; + } + pParent->EnableVootRange(); + break; + + case LIST_COL_SAMPRANGE: + nCurSel = m_wndCombo.GetCurSel(); + m_wndCombo.GetLBText(nCurSel, strMsg); + ADPara.InputRange[m_nChanIdx] = m_nSampRangeVal[nCurSel]; + SetItemText(m_nChanIdx, m_nType, strMsg); + //???pParent->SetCurveRange(m_nChanIdx, nCurSel); + + pParent->EnableVootRange(); + break; + + case LIST_COL_REFGND: + nCurSel = m_wndCombo.GetCurSel(); + m_wndCombo.GetLBText(nCurSel, strMsg); + ADPara.CouplingType[m_nChanIdx] = nCurSel; + SetItemText(m_nChanIdx, m_nType, strMsg); + break; + + case LIST_COL_IMPED: + nCurSel = m_wndCombo.GetCurSel(); + m_wndCombo.GetLBText(nCurSel, strMsg); + ADPara.InputImped[m_nChanIdx] = nCurSel; + SetItemText(m_nChanIdx, m_nType, strMsg); + break; + } + + return TRUE; +} + +void CAIChanList::OnLButtonDown(UINT nFlags, CPoint point) +{ + if(m_bEnableEx == FALSE) return; + + // TODO: Add your message handler code here and/or call default + SetFocus(); + CListCtrl::OnLButtonDown(nFlags, point); +} + +BOOL CAIChanList::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) +{ + m_wndCombo.ShowWindow(SW_HIDE); + m_wndCombo.EnableWindow(FALSE); + + m_wndEdit.ShowWindow(SW_HIDE); + m_wndEdit.EnableWindow(FALSE); + + return CListCtrl::OnMouseWheel(nFlags, zDelta, pt); +} + +void CAIChanList::PreSubclassWindow() +{ + // TODO: Add your specialized creation code here + CListCtrl::PreSubclassWindow(); + + // ﴴ + DWORD dwStyle; + CRect Rect(0, 0, 10, 10); + + dwStyle = WS_BORDER | WS_CHILD | ES_LEFT | ES_AUTOHSCROLL; + if( !m_wndEdit.Create(dwStyle, Rect, this, 0 ) ) + MessageBox(L"m_wndEdit.Create Error"); + + dwStyle = WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL; + if( !m_wndCombo.Create(dwStyle, Rect, this, 0 ) ) + MessageBox(L"m_wndCombo.Create Error"); + +} + +void CAIChanList::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + m_wndCombo.ShowWindow(SW_HIDE); + m_wndCombo.EnableWindow(FALSE); + + m_wndEdit.ShowWindow(SW_HIDE); + m_wndEdit.EnableWindow(FALSE); + + CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar); +} + +void CAIChanList::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + m_wndCombo.ShowWindow(SW_HIDE); + m_wndCombo.EnableWindow(FALSE); + + m_wndEdit.ShowWindow(SW_HIDE); + m_wndEdit.EnableWindow(FALSE); + + CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar); +} + +BOOL CAIChanList::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + NMHEADER* pNMHeader = (NMHEADER*)lParam; + if(pNMHeader->hdr.code == -12) // Headerϰʱ + { + m_wndCombo.ShowWindow(SW_HIDE); + m_wndCombo.EnableWindow(FALSE); + + m_wndEdit.ShowWindow(SW_HIDE); + m_wndEdit.EnableWindow(FALSE); + } + + return CListCtrl::OnNotify(wParam, lParam, pResult); +} + +void CAIChanList::SetSameParam(int nCurItem, int nSubItem) +{ + CString strNote; + int nID = 0, nItem = 0; + CParaCfgView* pParent = (CParaCfgView*)GetParent(); + int nChannel=0; + ULONG nSampChanCount = 0; + + //ACTS1000_PARA_AD CHParam = ADPara.CHParam[nCurItem]; + LONG bCHChannelArray = ADPara.bChannelArray[nCurItem]; + LONG lCHInputRange = ADPara.InputRange[nCurItem]; + LONG lCHCouplingType = ADPara.CouplingType[nCurItem]; + LONG lCHInputImped = ADPara.InputImped[nCurItem]; + + switch(nSubItem) + { +// case LIST_COL_CHANNEL: +// strNote.Format("ȷҪͨ趨%dŵһ", nCurItem); +// nID = AfxMessageBox(strNote, MB_YESNO); +// if(nID == IDNO) +// break; +// +// strNote.Format("AI%d", bCHChannelArray); +// for(nItem=0; nItemOnSelchangeCOMBOnSampChanCount(); + gl_nChannelCount = nSampChanCount; + pParent->EnableVootRange(); + break; + + case LIST_COL_SAMPRANGE: + strNote.Format(L"ȷҪвΧ趨%dŵһ", nCurItem); + nID = AfxMessageBox(strNote, MB_YESNO); + if(nID == IDNO) + break; + + strNote = GetItemText(nCurItem, nSubItem); + for(nItem=0; nItemSetCurveRange(nItem, lCHInputRange); + } + pParent->EnableVootRange(); + break; + + case LIST_COL_REFGND: + strNote.Format(L"ȷҪвο趨%dŵһ", nCurItem); + nID = AfxMessageBox(strNote, MB_YESNO); + if(nID == IDNO) + break; + + strNote = GetItemText(nCurItem, nSubItem); + for(nItem=0; nItemiSubItem; + if(nSubItem < 0) nSubItem = 0; + SetSameParam(nItem, nSubItem); + *pResult = 0; +} // OnColumnclick + +void CAIChanList::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) +{ + NMLVCUSTOMDRAW* pLVCD = (NMLVCUSTOMDRAW*)(pNMHDR); + // Take the default processing unless we set this to something else below. + *pResult = CDRF_NEWFONT; + // First thing - check the draw stage. If it's the control's prepaint + // stage, then tell Windows we want messages for every item. + if ( pLVCD->nmcd.dwDrawStage == CDDS_PREPAINT) + { + *pResult = CDRF_NOTIFYITEMDRAW; + } + // This is the notification message for an item. We'll request + // notifications before each subitem's prepaint stage. + else // if ( pLVCD->nmcd.dwDrawStage==CDDS_ITEMPREPAINT ) + { + *pResult = CDRF_DODEFAULT; + } +} + +int CAIChanList::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CListCtrl::OnCreate(lpCreateStruct) == -1) + return -1; + + CFont axisFont; + axisFont.CreateFont(54, 120, 11, 32, 400, + FALSE, FALSE, 10, ANSI_CHARSET, + OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, + DEFAULT_PITCH|FF_SWISS, L"MS Sans Serif"); + + SetFont(&axisFont); + + return 0; +} + +BOOL CAIChanList::EnableWindowEx(BOOL bEnable) +{ + BOOL bOldEnable = m_bEnableEx; + m_bEnableEx = bEnable; + return bOldEnable; +} + +void CAIChanList::OnSetFocus(CWnd* pOldWnd) +{ + // 򵱸ÿؼýʱ̴ڵסٻָǰʱListʾģ + // CListCtrl::OnSetFocus(pOldWnd); +} + +void CAIChanList::OnContextMenu(CWnd* pWnd, CPoint point) +{ + int nIndex = 0, nItemCount, nSeledCount = 0; + nItemCount = GetItemCount(); + for(nIndex=0; nIndexTrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); + +} // OnContextMenu + +void CAIChanList::OnSameParam() +{ + int nItem = GetSelectionMark(); + if(nItem != -1) + { + SetSameParam(m_nCurItem, m_nCurSubItem); + } +} + +void CAIChanList::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) +{ + NMLVCUSTOMDRAW* pLVCD = (NMLVCUSTOMDRAW*)(pNMHDR); + NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; + int nItem = 0, nSubItem = 0; + m_nCurItem = pNMListView->iItem; + m_nCurSubItem = pNMListView->iSubItem; + *pResult = 0; +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/AIChanList.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/AIChanList.h new file mode 100644 index 0000000..e359b07 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/AIChanList.h @@ -0,0 +1,85 @@ +#if !defined(AFX_AIAICHAN_LIST_H__162EB05F_779E_401B_83B8_2BCD82BC8A83__INCLUDED_) +#define AFX_AICHAN_LIST_H__162EB05F_779E_401B_83B8_2BCD82BC8A83__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// CHListCtrl.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CAIChanList window +#include "ChanCombo.h" +#include "ChanEdit.h" + +#define LIST_COL_CHANNEL 0 +#define LIST_COL_EN 1 +#define LIST_COL_SAMPRANGE 2 +//#define LIST_COL_GAIN 1 +#define LIST_COL_REFGND 3 +#define LIST_COL_IMPED 4 + +class CAIChanList : public CListCtrl +{ +// Construction +public: + CAIChanList(); + +// Attributes +public: + int m_nChanIdx; // ͨ鵥Ԫ± + int m_nType; + + CChanEdit m_wndEdit; // Build in Edit Control + CChanCombo m_wndCombo; // Build in ComboBox Control + BOOL RestoreCtrl(CRect rcCtrl); + BOOL SetCtrlFocus(CWnd* pWnd, BOOL bFocus); + BOOL m_bEnableEx; + BOOL EnableWindowEx(BOOL bEnable); + void SetSameParam(int nCurItem, int nSubItem); + int m_nCurItem; + int m_nCurSubItem; +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAIChanList) + protected: + virtual void PreSubclassWindow(); + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + //}}AFX_VIRTUAL + +// Implementation +public: + LRESULT OnSetCtrlFocus(WPARAM wParam, LPARAM lParam); + + virtual ~CAIChanList(); + + // Generated message map functions +protected: + //{{AFX_MSG(CAIChanList) + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); + afx_msg void OnDelNode(); + afx_msg void OnSameParam(); + afx_msg void OnRclick(NMHDR* pNMHDR, LRESULT* pResult); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHPARAMLIST_H__062EB05F_779E_401B_83B8_2BCD82BC8A83__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgCtrlBar.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgCtrlBar.cpp new file mode 100644 index 0000000..1097bb8 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgCtrlBar.cpp @@ -0,0 +1,423 @@ +// CfgCtrlBar.cpp : implementation file +// + +#include "stdafx.h" +#include "afxpriv.h" // for CDockContext +#include "CfgCtrlBar.h" +#include "resource.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CCfgCtrlBar + +CCfgCtrlBar::CCfgCtrlBar() +{ + m_sizeMin = CSize(32, 32); + m_sizeHorz = CSize(200, 400); + m_sizeVert = CSize(200, 400); + m_sizeFloat = CSize(200, 400); + m_bTracking = FALSE; + m_bInRecalcNC = FALSE; + m_cxEdge = 6; +} + +CCfgCtrlBar::~CCfgCtrlBar() +{ +} + +BEGIN_MESSAGE_MAP(CCfgCtrlBar, CControlBar) + //{{AFX_MSG_MAP(CCfgCtrlBar) + ON_WM_LBUTTONUP() + ON_WM_MOUSEMOVE() + ON_WM_SETCURSOR() + ON_WM_WINDOWPOSCHANGED() + ON_WM_NCPAINT() + ON_WM_NCLBUTTONDOWN() + ON_WM_NCHITTEST() + ON_WM_NCCALCSIZE() + ON_WM_LBUTTONDOWN() + ON_WM_CAPTURECHANGED() + ON_WM_LBUTTONDBLCLK() + ON_WM_SIZE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CCfgCtrlBar message handlers + +void CCfgCtrlBar::OnUpdateCmdUI(class CFrameWnd *pTarget, int bDisableIfNoHndler) +{ + UpdateDialogControls(pTarget, bDisableIfNoHndler); +} + +BOOL CCfgCtrlBar::Create(CWnd* pParentWnd, CSize sizeDefault, UINT nID, DWORD dwStyle) +{ + ASSERT_VALID(pParentWnd); // must have a parent + ASSERT (!((dwStyle & CBRS_SIZE_FIXED) && (dwStyle & CBRS_SIZE_DYNAMIC))); + + // save the style + m_dwStyle = CBRS_ALL; + + + dwStyle &= ~CBRS_ALL; + dwStyle |= CCS_NOPARENTALIGN|CCS_NOMOVEY|CCS_NODIVIDER|CCS_NORESIZE; + + m_sizeHorz = sizeDefault; + m_sizeVert = sizeDefault; + m_sizeFloat = sizeDefault; + + CString wndclass = AfxRegisterWndClass(CS_DBLCLKS, LoadCursor(NULL, IDC_ARROW), + CreateSolidBrush(GetSysColor(COLOR_BTNFACE)), 0); + + if (!CWnd::Create(wndclass, _T(""), dwStyle, CRect(0,0,0,0), + pParentWnd, nID)) + return FALSE; + + SetBarStyle(m_dwStyle|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC); + return TRUE; +} + +CSize CCfgCtrlBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) +{ + + CRect rc; + m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_TOP)->GetWindowRect(rc); + int nHorzDockBarWidth = bStretch ? 32767 : rc.Width() + 4; + m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_LEFT)->GetWindowRect(rc); + int nVertDockBarHeight = bStretch ? 32767 : rc.Height() + 4; + if (bHorz) + return CSize(nHorzDockBarWidth,m_sizeVert.cy); + else + return CSize(m_sizeVert.cx,nVertDockBarHeight); +} + +CSize CCfgCtrlBar::CalcDynamicLayout(int nLength, DWORD dwMode) +{ + if (dwMode & (LM_HORZDOCK | LM_VERTDOCK)) + { + if (nLength == -1) + { + GetDockingFrame()->DelayRecalcLayout(); + } + return CControlBar::CalcDynamicLayout(nLength,dwMode); + } + if (dwMode & LM_MRUWIDTH) + return m_sizeFloat; + + if (dwMode & LM_COMMIT) + { + m_sizeFloat.cx = nLength; + return m_sizeFloat; + } + + if (dwMode & LM_LENGTHY) + { + m_sizeFloat.cy = max(m_sizeMin.cy, nLength); + return CSize(m_sizeFloat.cx,m_sizeFloat.cy); + } + else + return CSize(max(m_sizeMin.cx, nLength), m_sizeFloat.cy); +} + +void CCfgCtrlBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) +{ + CControlBar::OnWindowPosChanged(lpwndpos); + + if (m_bInRecalcNC) return; + + // Find on which side are we docked + UINT nDockBarID = GetParent()->GetDlgCtrlID(); + + // Return if dropped at same location + if (nDockBarID == m_nDockBarID // no docking side change + && (lpwndpos->flags & SWP_NOSIZE) // no size change + && ((m_dwStyle & CBRS_BORDER_ANY) != CBRS_BORDER_ANY)) + return; + + m_nDockBarID = nDockBarID; + + // Force recalc the non-client area + m_bInRecalcNC = TRUE; + SetWindowPos(NULL, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | + SWP_NOACTIVATE | SWP_FRAMECHANGED); + m_bInRecalcNC = FALSE; + +} + +BOOL CCfgCtrlBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) +{ + if ((nHitTest != HTSIZE) || m_bTracking) + return CControlBar::OnSetCursor(pWnd, nHitTest, message); + + if (IsHorz()) + SetCursor(LoadCursor(NULL, IDC_SIZENS)); + else + SetCursor(LoadCursor(NULL, IDC_SIZEWE)); + return TRUE; +} + +///////////////////////////////////////////////////////////////////////// +// Mouse Handling +// +void CCfgCtrlBar::OnLButtonUp(UINT nFlags, CPoint point) +{ + if (!m_bTracking) + CControlBar::OnLButtonUp(nFlags, point); + else + { + ClientToWnd(point); + StopTracking(TRUE); + } +} + +void CCfgCtrlBar::OnMouseMove(UINT nFlags, CPoint point) +{ + if (IsFloating() || !m_bTracking) + { + CControlBar::OnMouseMove(nFlags, point); + return; + } + + CPoint cpt = m_rectTracker.CenterPoint(); + + ClientToWnd(point); + + if (IsHorz()) + { + if (cpt.y != point.y) + { + OnInvertTracker(m_rectTracker); + m_rectTracker.OffsetRect(0, point.y - cpt.y); + OnInvertTracker(m_rectTracker); + } + } + else + { + if (cpt.x != point.x) + { + OnInvertTracker(m_rectTracker); + m_rectTracker.OffsetRect(point.x - cpt.x, 0); + OnInvertTracker(m_rectTracker); + } + } +} + +void CCfgCtrlBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) +{ + // Compute the rectangle of the mobile edge + GetWindowRect(m_rectBorder); + m_rectBorder = CRect(0, 0, m_rectBorder.Width(), m_rectBorder.Height()); + + DWORD dwBorderStyle = m_dwStyle | CBRS_BORDER_ANY; + + switch(m_nDockBarID) + { + case AFX_IDW_DOCKBAR_TOP: + dwBorderStyle &= ~CBRS_BORDER_BOTTOM; + lpncsp->rgrc[0].bottom += -m_cxEdge; + m_rectBorder.top = m_rectBorder.bottom - m_cxEdge; + break; + case AFX_IDW_DOCKBAR_BOTTOM: + dwBorderStyle &= ~CBRS_BORDER_TOP; + lpncsp->rgrc[0].top += m_cxEdge; + m_rectBorder.bottom = m_rectBorder.top + m_cxEdge; + break; + case AFX_IDW_DOCKBAR_LEFT: + dwBorderStyle &= ~CBRS_BORDER_RIGHT; + lpncsp->rgrc[0].right += -m_cxEdge; + m_rectBorder.left = m_rectBorder.right - m_cxEdge; + break; + case AFX_IDW_DOCKBAR_RIGHT: + dwBorderStyle &= ~CBRS_BORDER_LEFT; + lpncsp->rgrc[0].left += m_cxEdge; + m_rectBorder.right = m_rectBorder.left + m_cxEdge; + break; + default: + m_rectBorder.SetRectEmpty(); + break; + } + + SetBarStyle(dwBorderStyle); +} + +void CCfgCtrlBar::OnNcPaint() +{ + EraseNonClient(); + + CDC *pDC = GetWindowDC(); + pDC->Draw3dRect(m_rectBorder, GetSysColor(COLOR_BTNHIGHLIGHT), + GetSysColor(COLOR_BTNSHADOW)); + + ReleaseDC(pDC); +} + +void CCfgCtrlBar::OnNcLButtonDown(UINT nHitTest, CPoint point) +{ + if (m_bTracking) return; + + if ((nHitTest == HTSIZE) && !IsFloating()) + StartTracking(); + else + CControlBar::OnNcLButtonDown(nHitTest, point); +} + +LRESULT CCfgCtrlBar::OnNcHitTest(CPoint point) +{ + + if (IsFloating()) + return CControlBar::OnNcHitTest(point); + + CRect rc; + GetWindowRect(rc); + point.Offset(-rc.left, -rc.top); + if (m_rectBorder.PtInRect(point)) + return HTSIZE; + else + return CControlBar::OnNcHitTest(point); +} + +void CCfgCtrlBar::OnLButtonDown(UINT nFlags, CPoint point) +{ + // only start dragging if clicked in "void" space + if (m_pDockBar != NULL) + { + // start the drag + ASSERT(m_pDockContext != NULL); + ClientToScreen(&point); + m_pDockContext->StartDrag(point); + } + else + { + CWnd::OnLButtonDown(nFlags, point); + } +} + +void CCfgCtrlBar::OnLButtonDblClk(UINT nFlags, CPoint point) +{ + // only toggle docking if clicked in "void" space + if (m_pDockBar != NULL) + { + // toggle docking + ASSERT(m_pDockContext != NULL); + m_pDockContext->ToggleDocking(); + } + else + { + CWnd::OnLButtonDblClk(nFlags, point); + } +} + +void CCfgCtrlBar::StartTracking() +{ + SetCapture(); + // make sure no updates are pending + RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); + m_pDockSite->LockWindowUpdate(); + + m_ptOld = m_rectBorder.CenterPoint(); + m_bTracking = TRUE; + + m_rectTracker = m_rectBorder; + if (!IsHorz()) m_rectTracker.bottom -= 4; + + OnInvertTracker(m_rectTracker); +} + +void CCfgCtrlBar::OnCaptureChanged(CWnd *pWnd) +{ + if (m_bTracking && pWnd != this) + StopTracking(FALSE); // cancel tracking + + CControlBar::OnCaptureChanged(pWnd); +} + +void CCfgCtrlBar::StopTracking(BOOL bAccept) +{ + OnInvertTracker(m_rectTracker); + m_pDockSite->UnlockWindowUpdate(); + m_bTracking = FALSE; + ReleaseCapture(); + + if (!bAccept) return; + + int maxsize, minsize, newsize; + CRect rcc; + m_pDockSite->GetClientRect(rcc); + + newsize = IsHorz() ? m_sizeHorz.cy : m_sizeVert.cx; + maxsize = newsize + (IsHorz() ? rcc.Height() : rcc.Width()); + minsize = IsHorz() ? m_sizeMin.cy : m_sizeMin.cx; + + CPoint point = m_rectTracker.CenterPoint(); + switch (m_nDockBarID) + { + case AFX_IDW_DOCKBAR_TOP: + newsize += point.y - m_ptOld.y; break; + case AFX_IDW_DOCKBAR_BOTTOM: + newsize += -point.y + m_ptOld.y; break; + case AFX_IDW_DOCKBAR_LEFT: + newsize += point.x - m_ptOld.x; break; + case AFX_IDW_DOCKBAR_RIGHT: + newsize += -point.x + m_ptOld.x; break; + } + + newsize = max(minsize, min(maxsize, newsize)); + + if (IsHorz()) + m_sizeHorz.cy = newsize; + else + m_sizeVert.cx = newsize; + + m_pDockSite->DelayRecalcLayout(); +} + +void CCfgCtrlBar::OnInvertTracker(const CRect& rect) +{ + ASSERT_VALID(this); + ASSERT(!rect.IsRectEmpty()); + ASSERT(m_bTracking); + + CRect rct = rect, rcc, rcf; + GetWindowRect(rcc); + m_pDockSite->GetWindowRect(rcf); + + rct.OffsetRect(rcc.left - rcf.left, rcc.top - rcf.top); + rct.DeflateRect(1, 1); + + CDC *pDC = m_pDockSite->GetDCEx(NULL, + DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE); + + CBrush* pBrush = CDC::GetHalftoneBrush(); + HBRUSH hOldBrush = NULL; + if (pBrush != NULL) + hOldBrush = (HBRUSH)SelectObject(pDC->m_hDC, pBrush->m_hObject); + + pDC->PatBlt(rct.left, rct.top, rct.Width(), rct.Height(), PATINVERT); + + if (hOldBrush != NULL) + SelectObject(pDC->m_hDC, hOldBrush); + + m_pDockSite->ReleaseDC(pDC); +} + +BOOL CCfgCtrlBar::IsHorz() const +{ + return (m_nDockBarID == AFX_IDW_DOCKBAR_TOP || + m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM); +} + +CPoint& CCfgCtrlBar::ClientToWnd(CPoint& point) +{ + if (m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM) + point.y += m_cxEdge; + else if (m_nDockBarID == AFX_IDW_DOCKBAR_RIGHT) + point.x += m_cxEdge; + + return point; +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgCtrlBar.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgCtrlBar.h new file mode 100644 index 0000000..ccaed75 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgCtrlBar.h @@ -0,0 +1,87 @@ +#if !defined(SIZECBAR_H_INCLUDED) +#define SIZECBAR_H_INCLUDED + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 +// sizecbar.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CCfgCtrlBar control bar + +class CCfgCtrlBar : public CControlBar +{ +// Construction / destruction +public: + CCfgCtrlBar(); + +// Attributes +public: + BOOL IsHorz() const; + +// Operations +public: + +// Overridables + virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); + +// Overrides +public: + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CCfgCtrlBar) + public: + virtual BOOL Create(CWnd* pParentWnd, CSize sizeDefault, UINT nID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP); + virtual CSize CalcFixedLayout( BOOL bStretch, BOOL bHorz ); + virtual CSize CalcDynamicLayout( int nLength, DWORD dwMode ); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CCfgCtrlBar(); + void StartTracking(); + void StopTracking(BOOL bAccept); + void OnInvertTracker(const CRect& rect); + + // implementation helpers + CPoint& ClientToWnd(CPoint& point); + +protected: + CSize m_sizeMin; + CSize m_sizeHorz; + CSize m_sizeVert; + CSize m_sizeFloat; + CRect m_rectBorder; + CRect m_rectTracker; + UINT m_nDockBarID; + CPoint m_ptOld; + BOOL m_bTracking; + BOOL m_bInRecalcNC; + int m_cxEdge; + +// Generated message map functions +protected: + //{{AFX_MSG(CCfgCtrlBar) + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); + afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos); + afx_msg void OnNcPaint(); + afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); + afx_msg LRESULT OnNcHitTest(CPoint point); + afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnCaptureChanged(CWnd *pWnd); + afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(SIZECBAR_H_INCLUDED) + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgTabCtrlBar.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgTabCtrlBar.cpp new file mode 100644 index 0000000..e0bf380 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgTabCtrlBar.cpp @@ -0,0 +1,292 @@ +// SizingTabCtrlBar.cpp: Implementierungsdatei +// + +#include "stdafx.h" +#include "Sys.h" + +#include "CfgTabCtrlBar.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CCfgTabCtrlBar + +CCfgTabCtrlBar::CCfgTabCtrlBar() +{ + m_nActiveTab = 0; +} + +CCfgTabCtrlBar::~CCfgTabCtrlBar() +{ + while(!m_views.IsEmpty()) + { + TCB_ITEM *pMember=m_views.RemoveHead(); + delete pMember; + } +} + +BEGIN_MESSAGE_MAP(CCfgTabCtrlBar, CCfgCtrlBar) + //{{AFX_MSG_MAP(CCfgTabCtrlBar) + ON_WM_CREATE() + ON_WM_SIZE() + ON_NOTIFY(TCN_SELCHANGE, IDI_TABCTRLBAR, OnTabSelChange) + ON_WM_KILLFOCUS() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// Behandlungsroutinen fr Nachrichten CCfgTabCtrlBar + +int CCfgTabCtrlBar::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CCfgCtrlBar::OnCreate(lpCreateStruct) == -1) + return -1; + + //Create the Tab Control + CRect rect; + m_tabctrl.Create(WS_VISIBLE|WS_CHILD,//|TCS_BOTTOM , + rect, this, IDI_TABCTRLBAR); + + m_images.Create(IDB_TABIMAGES, 16, 1, RGB(255,0,255)); // λͼ + m_tabctrl.SetImageList(&m_images); // λͼؼ + + // set "normal" GUI-font + CFont *font = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)); + m_tabctrl.SetFont(font); + CRect StartButtonRect(10, 6, 180, 36); + CRect StopButtonRect(10, 40, 180, 70); + //m_StartDeviceButton = new CButton(); + m_StartDeviceButton.Create(_T("ʼݲɼ"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_DEFPUSHBUTTON , StartButtonRect, this, IDM_StartDeviceAD); + //m_StopDeviceButton = new CButton(); + m_StopDeviceButton.Create(_T("ֹͣݲɼ"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , StopButtonRect, this, IDM_StopDeviceAD); + + + return 0; +} + +void CCfgTabCtrlBar::OnSize(UINT nType, int cx, int cy) +{ + CCfgCtrlBar::OnSize(nType, cx, cy); + int bottom = (IsHorz() || IsFloating()) ? cy - 82 : cy - 84; + m_tabctrl.MoveWindow( 7, 77, cx , bottom); // CControlBarƶTabؼλ + CWnd *pWnd; + for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos)) + { + pWnd=m_views.GetAt(pos)->pWnd; + pWnd->MoveWindow(9, 99, cx-18, bottom-25); // CControlBarƶͼĿؼλ + } +} + +CWnd* CCfgTabCtrlBar::AddView(LPCTSTR lpszLabel, CRuntimeClass *pViewClass, CCreateContext *pContext) +{ + +#ifdef _DEBUG + ASSERT_VALID(this); + ASSERT(pViewClass != NULL); + ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd))); + ASSERT(AfxIsValidAddress(pViewClass, sizeof(CRuntimeClass), FALSE)); +#endif + + CCreateContext context; + if (pContext == NULL) + { + // if no context specified, generate one from the currently selected + // client if possible + CView* pOldView = NULL; + if (pOldView != NULL && pOldView->IsKindOf(RUNTIME_CLASS(CView))) + { + // set info about last pane + ASSERT(context.m_pCurrentFrame == NULL); + context.m_pLastView = pOldView; + context.m_pCurrentDoc = pOldView->GetDocument(); + if (context.m_pCurrentDoc != NULL) + context.m_pNewDocTemplate = + context.m_pCurrentDoc->GetDocTemplate(); + } + pContext = &context; + } + + CWnd* pWnd; + + TRY + { + pWnd = (CWnd*)pViewClass->CreateObject(); + if (pWnd == NULL) + AfxThrowMemoryException(); + } + CATCH_ALL(e) + { + TRACE0("Out of memory creating a view.\n"); + // Note: DELETE_EXCEPTION(e) not required + return FALSE; + } + END_CATCH_ALL + + ASSERT_KINDOF(CWnd, pWnd); + ASSERT(pWnd->m_hWnd == NULL); // not yet created + DWORD dwStyle = AFX_WS_DEFAULT_VIEW; + CRect rect,rect1; + // Create with the right size and position + if (!pWnd->Create(NULL, NULL, dwStyle, rect, this, 0, pContext)) + { + TRACE0("Warning: couldn't create client pane for view.\n"); + // pWnd will be cleaned up by PostNcDestroy + return FALSE; + } + m_pActiveView = (CView*) pWnd; + + + TCB_ITEM *pMember=new TCB_ITEM; + pMember->pWnd=pWnd; + _tcscpy(pMember->szLabel, lpszLabel); + m_views.AddTail(pMember); + + int nViews = (int)m_views.GetCount(); + if (nViews!=1) + { + pWnd->EnableWindow(FALSE); + pWnd->ShowWindow(SW_HIDE); + } + else + { + ((CFrameWnd *)GetParent())->SetActiveView((CView *)m_pActiveView); + } + + TC_ITEM tci; + tci.mask = TCIF_TEXT | TCIF_IMAGE; + tci.pszText = (LPTSTR)(LPCTSTR)lpszLabel; + tci.iImage = nViews-1; + m_tabctrl.InsertItem(nViews, &tci); + + return pWnd; +} + +void CCfgTabCtrlBar::RemoveView(int nView) +{ + ASSERT_VALID(this); + ASSERT(nView >= 0); + + // remove the page from internal list + m_views.RemoveAt(m_views.FindIndex(nView)); +} + +void CCfgTabCtrlBar::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult) +{ + SetActiveView(m_tabctrl.GetCurSel()); +} + +void CCfgTabCtrlBar::SetActiveView(int nNewTab) +{ + ASSERT_VALID(this); + ASSERT(nNewTab >= 0); + + if (nNewTab!=-1 && nNewTab!=m_nActiveTab) + { + TCB_ITEM *newMember=m_views.GetAt(m_views.FindIndex(nNewTab)); + TCB_ITEM *oldMember=NULL; + + if (m_nActiveTab!=-1) + { + oldMember=m_views.GetAt(m_views.FindIndex(m_nActiveTab)); + oldMember->pWnd->EnableWindow(FALSE); + oldMember->pWnd->ShowWindow(SW_HIDE); + } + newMember->pWnd->EnableWindow(TRUE); + newMember->pWnd->ShowWindow(SW_SHOW); + newMember->pWnd->SetFocus(); + + m_pActiveView = (CView *)newMember->pWnd; + ((CFrameWnd *)GetParent())->SetActiveView(m_pActiveView); + + m_nActiveTab = nNewTab; + // select the tab (if tab programmatically changed) + m_tabctrl.SetCurSel(m_nActiveTab); + } +} + +void CCfgTabCtrlBar::SetActiveView(CRuntimeClass *pViewClass) +{ + ASSERT_VALID(this); + ASSERT(pViewClass != NULL); + ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd))); + ASSERT(AfxIsValidAddress(pViewClass, sizeof(CRuntimeClass), FALSE)); + + int nNewTab = 0; + for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos)) + { + TCB_ITEM *pMember=m_views.GetAt(pos); + if (pMember->pWnd->IsKindOf(pViewClass)) + { + //first hide old first view + m_pActiveView->EnableWindow(FALSE); + m_pActiveView->ShowWindow(SW_HIDE); + + // set new active view + m_pActiveView = (CView*)pMember->pWnd; + // enable, show, set focus to new view + m_pActiveView->EnableWindow(TRUE); + m_pActiveView->ShowWindow(SW_SHOW); + m_pActiveView->SetFocus(); + + ((CFrameWnd *)GetParent())->SetActiveView(m_pActiveView); + + m_nActiveTab = nNewTab; + // select the tab + m_tabctrl.SetCurSel(m_nActiveTab); + + break; + } + nNewTab++; + } +} + +CView* CCfgTabCtrlBar::GetActiveView() +{ + return m_pActiveView; +} + +CView* CCfgTabCtrlBar::GetView(int nView) +{ + ASSERT_VALID(this); + ASSERT(nView >= 0); + + if (nView!=-1) + { + TCB_ITEM *pMember=m_views.GetAt(m_views.FindIndex(nView)); + return (CView*)pMember->pWnd; + } + else + return NULL; +} + +CView* CCfgTabCtrlBar::GetView(CRuntimeClass *pViewClass) +{ + ASSERT_VALID(this); + ASSERT(pViewClass != NULL); + ASSERT(pViewClass->IsDerivedFrom(RUNTIME_CLASS(CWnd))); + ASSERT(AfxIsValidAddress(pViewClass, sizeof(CRuntimeClass), FALSE)); + + for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos)) + { + TCB_ITEM *pMember=m_views.GetAt(pos); + if (pMember->pWnd->IsKindOf(pViewClass)) + { + return (CView*)pMember->pWnd; + } + } + return NULL; +} + +/*void CCfgTabCtrlBar::OnKillFocus(CWnd* pNewWnd) +{ + + + CCfgCtrlBar::OnKillFocus(pNewWnd); + + // TODO: Add your message handler code here +}*/ + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgTabCtrlBar.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgTabCtrlBar.h new file mode 100644 index 0000000..20132db --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/CfgTabCtrlBar.h @@ -0,0 +1,72 @@ +#ifndef AFX_SIZINGTABCTRLBAR_H__3804CCE3_C325_11D1_91F5_B4375BB20A38__INCLUDED_ +#define AFX_SIZINGTABCTRLBAR_H__3804CCE3_C325_11D1_91F5_B4375BB20A38__INCLUDED_ + +// SizingTabCtrlBar.h : Header-Datei +// +#include +#include "CfgCtrlBar.h" + +typedef struct +{ + CWnd *pWnd; + TCHAR szLabel[32]; +}TCB_ITEM; + +///////////////////////////////////////////////////////////////////////////// +// Fenster CCfgTabCtrlBar + +class CCfgTabCtrlBar : public CCfgCtrlBar +{ +// Konstruktion +public: + CCfgTabCtrlBar(); + +// Attribute +public: + CButton m_StartDeviceButton; + CButton m_StopDeviceButton; + +// Operationen +public: + +// berschreibungen + void SetActiveView(int nNewTab); + void SetActiveView(CRuntimeClass *pViewClass); + // Vom Klassen-Assistenten generierte virtuelle Funktionsberschreibungen + //{{AFX_VIRTUAL(CCfgTabCtrlBar) + //}}AFX_VIRTUAL + +// Implementierung +public: + CView* GetActiveView(); + CView* GetView(int nView); + CView* GetView(CRuntimeClass *pViewClass); + CWnd* AddView(LPCTSTR lpszLabel, CRuntimeClass *pViewClass, CCreateContext *pContext = NULL); + void RemoveView(int nView); + CTabCtrl m_tabctrl; + CButton m_test; + virtual ~CCfgTabCtrlBar(); + + // Generierte Nachrichtenzuordnungsfunktionen +protected: + int m_nActiveTab; + CView* m_pActiveView; + + CList m_views; + CImageList m_images; + //{{AFX_MSG(CCfgTabCtrlBar) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult) ; +// afx_msg void OnKillFocus(CWnd* pNewWnd); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio fgt zustzliche Deklarationen unmittelbar vor der vorhergehenden Zeile ein. + +#endif // AFX_SIZINGTABCTRLBAR_H__3804CCE3_C325_11D1_91F5_B4375BB20A38__INCLUDED_ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanCombo.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanCombo.cpp new file mode 100644 index 0000000..336ff7d --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanCombo.cpp @@ -0,0 +1,63 @@ +// ChanCombo.cpp : implementation file +// + +#include "stdafx.h" +#include "Sys.h" +#include "ChanCombo.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CChanCombo + +CChanCombo::CChanCombo() +{ +} + +CChanCombo::~CChanCombo() +{ +} + + +BEGIN_MESSAGE_MAP(CChanCombo, CComboBox) + //{{AFX_MSG_MAP(CChanCombo) + ON_WM_KILLFOCUS() + ON_WM_CREATE() + ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CChanCombo message handlers + +void CChanCombo::OnKillFocus(CWnd* pNewWnd) +{ + CComboBox::OnKillFocus(pNewWnd); + + ShowWindow(SW_HIDE); + EnableWindow(FALSE); + + // CWnd* pParent = (CWnd* )GetParent(); + // ::SendMessage(pParent->m_hWnd, WM_SET_CTRL_FOCUS, NULL, NULL); +} + +int CChanCombo::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CComboBox::OnCreate(lpCreateStruct) == -1) + return -1; + + m_Font.CreatePointFont(90, L""); + SetFont(&m_Font); + + return 0; +} + +void CChanCombo::OnSelchange() +{ + CWnd* pParent = (CWnd* )GetParent(); + ::SendMessage(pParent->m_hWnd, WM_SET_CTRL_FOCUS, NULL, NULL); +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanCombo.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanCombo.h new file mode 100644 index 0000000..0f63a1a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanCombo.h @@ -0,0 +1,51 @@ +#if !defined(AFX_CHAN_COMBO_H__08E497EB_35AE_47F1_962E_DA7AB611098E__INCLUDED_) +#define AFX_CHAN_COMBO_H__08E497EB_35AE_47F1_962E_DA7AB611098E__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ChanCombo.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CChanCombo window + +class CChanCombo : public CComboBox +{ +// Construction +public: + CChanCombo(); + CFont m_Font; + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChanCombo) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CChanCombo(); + + // Generated message map functions +protected: + //{{AFX_MSG(CChanCombo) + afx_msg void OnKillFocus(CWnd* pNewWnd); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSelchange(); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHAN_COMBO_H__08E497EB_35AE_47F1_962E_DA7AB611098E__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanEdit.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanEdit.cpp new file mode 100644 index 0000000..78a999b --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanEdit.cpp @@ -0,0 +1,56 @@ +// ChanEdit.cpp : implementation file +// + +#include "stdafx.h" +#include "Sys.h" +#include "ChanEdit.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CChanEdit + +CChanEdit::CChanEdit() +{ +} + +CChanEdit::~CChanEdit() +{ +} + + +BEGIN_MESSAGE_MAP(CChanEdit, CEdit) + //{{AFX_MSG_MAP(CChanEdit) + ON_WM_CREATE() + ON_WM_KILLFOCUS() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CChanEdit message handlers + +int CChanEdit::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CEdit::OnCreate(lpCreateStruct) == -1) + return -1; + + m_Font.CreatePointFont(130, L""); + SetFont(&m_Font); + + return 0; +} + +void CChanEdit::OnKillFocus(CWnd* pNewWnd) +{ + CEdit::OnKillFocus(pNewWnd); + + ShowWindow(SW_HIDE); + EnableWindow(FALSE); + + CWnd* pParent = (CWnd* )GetParent(); + ::SendMessage(pParent->m_hWnd, WM_SET_CTRL_FOCUS, NULL, NULL); +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanEdit.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanEdit.h new file mode 100644 index 0000000..137e91f --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ChanEdit.h @@ -0,0 +1,52 @@ +#if !defined(AFX_CHAN_EDIT_H__C1AFC325_4FA3_421A_A85B_AAFE25FAD9F1__INCLUDED_) +#define AFX_CHAN_EDIT_H__C1AFC325_4FA3_421A_A85B_AAFE25FAD9F1__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// CChanEdit.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CChanEdit window + +class CChanEdit : public CEdit +{ +// Construction +public: + CChanEdit(); + +// Attributes +public: + +protected: + CFont m_Font; + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChanEdit) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CChanEdit(); + + // Generated message map functions +protected: + //{{AFX_MSG(CChanEdit) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnKillFocus(CWnd* pNewWnd); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHAN_EDIT_H__C1AFC325_4FA3_421A_A85B_AAFE25FAD9F1__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/DelTmp.bat b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/DelTmp.bat new file mode 100644 index 0000000..d7d17be --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/DelTmp.bat @@ -0,0 +1,59 @@ +@echo off +del /s *.~h +del /s *.~cpp +del /s *.~bpr +del /s *.dof +del /s *.ddp +del /s *.~dfm +del /s *.~ddp +del /s *.log +del /s *.~dpr +del /s *.dcu +del /s *.~pas +del /s *.exp +del /s *.obj +del /s *.sbr +del /s *.idb +del /s *.pch +del /s *.aps +del /s *.bsc +del /s *.obj +del /s *.pdb +del /s *.ncb +del /s *.opt +del /s *.sdf +del /s debug\*.exp +del /s debug\*.bsc +del /s debug\*.obj +del /s debug\*.sbr +del /s debug\*.idb +del /s debug\*.pch +del /s debug\*.ilk +del /s debug\*.pdb +del /s release\*.exp +del /s release\*.bsc +del /s release\*.obj +del /s release\*.sbr +del /s release\*.idb +del /s release\*.pch +del /s release\*.ilk +del /s release\*.pdb +del /s *.suo +del /s *.user +del debug\*.* /q + +del release\*.* /q + +del /s ipch\*.ipch + + +rd debug + +rd X86 /s /q +rd x64 /s /q + +rd ipch /s /q + +rd release + +rd ipch diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MTabWnd.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MTabWnd.cpp new file mode 100644 index 0000000..2c3e0e6 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MTabWnd.cpp @@ -0,0 +1,171 @@ + // MTabWnd.cpp : implementation file +// +///////////////////////////////////////////////////////////////////////////// +// Derive your mainframe window from this class to get support for the +// MDI tabs. Also adds support for next/previous MDI window selection. +///////////////////////////////////////////////////////////////////////////// +// +// Copyright ?1998 Written by Dieter Fauth +// mailto:fauthd@zvw.de +// +// This code may be used in compiled form in any way you desire. This +// file may be redistributed unmodified by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name and all copyright +// notices remains intact. If the source code in this file is used in +// any commercial application then a statement along the lines of +// "Portions Copyright ?1999 Dieter Fauth" must be included in +// the startup banner, "About" box or printed documentation. An email +// letting me know that you are using it would be nice as well. That's +// not much to ask considering the amount of work that went into this. +// +// This file is provided "as is" with no expressed or implied warranty. +// The author accepts no liability for any damage/loss of business that +// this product may cause. +// +// ========================================================================== +// HISTORY: +// ========================================================================== +// 1.00 08 May 1999 - Initial release. +// ========================================================================== +// +///////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include +#include "Sys.h" +#include "MTabWnd.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMDITabFrameWnd + +IMPLEMENT_DYNCREATE(CMDITabFrameWnd, CMDIFrameWnd) + +CMDITabFrameWnd::CMDITabFrameWnd() +{ +} + +CMDITabFrameWnd::~CMDITabFrameWnd() +{ +} + +BEGIN_MESSAGE_MAP(CMDITabFrameWnd, CMDIFrameWnd) + ON_WM_INITMENU() + //{{AFX_MSG_MAP(CMDITabFrameWnd) + ON_COMMAND(ID_WINDOW_NEXT_PANE, OnWindowNextPane) + ON_COMMAND(ID_WINDOW_PREV_PANE, OnWindowPrevPane) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +BOOL CMDITabFrameWnd::CreateTabs(void) +{ + // m_wndTabsCControlBar + if (!m_wndTabs.Create(this,WS_VISIBLE|WS_CHILD|CBRS_TOP|WS_EX_WINDOWEDGE, IDC_MDI_TAB_CTRL_BAR)) + { + TRACE("Failed to create test status bar\n"); + return -1; // fail to create + } + + m_wndMdiClient.m_pWndTabs = &m_wndTabs; + + ASSERT(m_hWndMDIClient != NULL); + + + // ͨעm_hWndMDIClient࣬ʹõӺȥTABؼϢ + if (!m_wndMdiClient.SubclassWindow(m_hWndMDIClient) ) + { + TRACE("Failed to subclass MDI client\n"); + return -1; // fail to create + } + return 0; +} + +///////////////////////////////////////////////////////////////////////////// +// CMDITabFrameWnd message handlers +// + +void CMDITabFrameWnd::OnWindowNextPane() +{ + MDINext(); +} + +void CMDITabFrameWnd::OnWindowPrevPane() +{ + ASSERT(::IsWindow(m_hWnd)); + ::SendMessage(m_hWndMDIClient, WM_MDINEXT, 0, 1); +} + + + +void CMDITabFrameWnd::OnInitMenu(CMenu* pMenu) +{ + CMDIFrameWnd::OnInitMenu(pMenu); + + // CG: This block added by 'Tip of the Day' component. + { + // TODO: This code adds the "Tip of the Day" menu item + // on the fly. It may be removed after adding the menu + // item to all applicable menu items using the resource + // editor. + + // Add Tip of the Day menu item on the fly! + static CMenu* pSubMenu = NULL; + + CString strHelp; strHelp.LoadString(CG_IDS_TIPOFTHEDAYHELP); + CString strMenu; + int nMenuCount = pMenu->GetMenuItemCount(); + BOOL bFound = FALSE; + for (int i=0; i < nMenuCount; i++) + { + pMenu->GetMenuString(i, strMenu, MF_BYPOSITION); + if (strMenu == strHelp) + { + pSubMenu = pMenu->GetSubMenu(i); + bFound = TRUE; + ASSERT(pSubMenu != NULL); + } + } + + CString strTipMenu; + strTipMenu.LoadString(CG_IDS_TIPOFTHEDAYMENU); + if (!bFound) + { + // Help menu is not available. Please add it! + if (pSubMenu == NULL) + { + // The same pop-up menu is shared between mainfrm and frame + // with the doc. + static CMenu popUpMenu; + pSubMenu = &popUpMenu; + pSubMenu->CreatePopupMenu(); + pSubMenu->InsertMenu(0, MF_STRING|MF_BYPOSITION, + CG_IDS_TIPOFTHEDAY, strTipMenu); + } + pMenu->AppendMenu(MF_STRING|MF_BYPOSITION|MF_ENABLED|MF_POPUP, + (UINT)pSubMenu->m_hMenu, strHelp); + DrawMenuBar(); + } + else + { + // Check to see if the Tip of the Day menu has already been added. + pSubMenu->GetMenuString(0, strMenu, MF_BYPOSITION); + + if (strMenu != strTipMenu) + { + // Tip of the Day submenu has not been added to the + // first position, so add it. + pSubMenu->InsertMenu(0, MF_BYPOSITION); // Separator + pSubMenu->InsertMenu(0, MF_STRING|MF_BYPOSITION, + CG_IDS_TIPOFTHEDAY, strTipMenu); + } + } + } + +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MTabWnd.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MTabWnd.h new file mode 100644 index 0000000..cb3a93c --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MTabWnd.h @@ -0,0 +1,56 @@ +#if !defined(AFX_MTABWND_H__E23B47A5_FE45_11D2_BC0D_006008CCD137__INCLUDED_) +#define AFX_MTABWND_H__E23B47A5_FE45_11D2_BC0D_006008CCD137__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 +// MTabWnd.h : header file +// + +#include "TabCtrlBarDoc.h" +#include "MdiClient.h" + +///////////////////////////////////////////////////////////////////////////// +// CMDITabFrameWnd frame + +class CMDITabFrameWnd : public CMDIFrameWnd +{ + DECLARE_DYNCREATE(CMDITabFrameWnd) +protected: + CMDITabFrameWnd(); // protected constructor used by dynamic creation + +// Attributes +public: + +// Operations +public: + BOOL CreateTabs(void) ; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMDITabFrameWnd) + protected: + //}}AFX_VIRTUAL +public: + +// Implementation +protected: + afx_msg void OnInitMenu(CMenu* pMenu); + virtual ~CMDITabFrameWnd(); + CTabCtrlBarDoc m_wndTabs; + CMdiClient m_wndMdiClient; + + // Generated message map functions + //{{AFX_MSG(CMDITabFrameWnd) + afx_msg void OnWindowNextPane(); + afx_msg void OnWindowPrevPane(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MTABWND_H__E23B47A5_FE45_11D2_BC0D_006008CCD137__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MainFrm.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MainFrm.cpp new file mode 100644 index 0000000..3ea6ede --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MainFrm.cpp @@ -0,0 +1,160 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "Sys.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +extern ACTS1000_PARA_AD Para; +extern BOOL bCreateDevice; +extern BOOL gl_bDeviceADRun; +///////////////////////////////////////////////////////////////////////////// +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) + //{{AFX_MSG_MAP(CMainFrame) + ON_WM_CREATE() + ON_WM_ACTIVATE() + ON_WM_ACTIVATEAPP() + ON_BN_CLICKED(IDC_ADDCHANNEL, ClickFunction) + ON_WM_DESTROY() + ON_WM_CLOSE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_SHOWMOUSEVOLT, //ʾָλ + ID_SHOWMOUSEVOLT, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here +} + +CMainFrame::~CMainFrame() +{ +} + + +void CMainFrame::ClickFunction(void) +{ + + +} +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + + if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + if(CreateTabs()==-1) + return -1; + + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + + if( !CMDIFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CMDIFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CMDIFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame message handlers + + + + +void CMainFrame::SetMouseVolt(CString strText)//ָλ״̬ +{ + int nIndex=m_wndStatusBar.CommandToIndex(ID_SHOWMOUSEVOLT); + CWindowDC dc(&m_wndStatusBar); + CSize sizeText=dc.GetTextExtent(strText); + m_wndStatusBar.SetPaneInfo(nIndex,ID_SHOWMOUSEVOLT,SBPS_NORMAL,sizeText.cx); + m_wndStatusBar.SetPaneText(2,strText); + +} + +void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) +{ + CMDIFrameWnd::OnActivate(nState, pWndOther, bMinimized); +} + +void CMainFrame::OnActivateApp(BOOL bActive, DWORD hTask) +{ + CMDIFrameWnd::OnActivateApp(bActive, hTask); + // TODO: Add your message handler code here +} + +BOOL CMainFrame::DestroyWindow() +{ + // TODO: Add your specialized code here and/or call the base class + return CMDIFrameWnd::DestroyWindow(); +} + +void CMainFrame::OnDestroy() +{ + CMDIFrameWnd::OnDestroy(); + // TODO: Add your message handler code here +} + + + +void CMainFrame::OnClose() +{ + // TODO: Add your message handler code here and/or call default +// if(MessageBox(_T("Ҫ˳ϵͳ..."), "..."), MB_YESNO|MB_ICONINFORMATION)==IDNO) +// return; + CMDIFrameWnd::OnClose(); +} + +BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) +{ + // TODO: Add your specialized code here and/or call the base class + return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); +} + +BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) +{ + // TODO: Add your specialized code here and/or call the base class + + return CMDIFrameWnd::OnCreateClient(lpcs, pContext); +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MainFrm.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MainFrm.h new file mode 100644 index 0000000..423c5cf --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MainFrm.h @@ -0,0 +1,70 @@ +// MainFrm.h : interface of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_MAINFRM_H__D485DF01_85AB_11D1_B878_A68EB300DD63__INCLUDED_) +#define AFX_MAINFRM_H__D485DF01_85AB_11D1_B878_A68EB300DD63__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CMainFrame : public CMDITabFrameWnd +{ + DECLARE_DYNAMIC(CMainFrame) +public: + CMainFrame(); + +public: + + // Attributes +public: + CStatusBar m_wndStatusBar; + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL DestroyWindow(); + virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); + protected: + virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); + //}}AFX_VIRTUAL + +// Implementation +public: + void SetMouseVolt(CString strText); + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + + CToolBar m_wndToolBar; + CReBar m_wndReBar; + +// Generated message map functions +protected: + //{{AFX_MSG(CMainFrame) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); + afx_msg void OnActivateApp(BOOL bActive, DWORD hTask); + afx_msg void ClickFunction(); + afx_msg void OnDestroy(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAINFRM_H__D485DF01_85AB_11D1_B878_A68EB300DD63__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MdiClient.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MdiClient.cpp new file mode 100644 index 0000000..3fcb7a6 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MdiClient.cpp @@ -0,0 +1,133 @@ + // MdiClient.cpp : implementation file +// +///////////////////////////////////////////////////////////////////////////// +// This class does subclass the MDI-CLIENT window. +// Subclassing means that all messages are first routed to this class, then +// to the original window (in this case the MDI-CLIENT). +// We need this to get notifications of the creation and deletion of the +// MDI child frames (contain views). +///////////////////////////////////////////////////////////////////////////// +// +// Copyright ?1998 Written by Dieter Fauth +// mailto:fauthd@zvw.de +// +// This code may be used in compiled form in any way you desire. This +// file may be redistributed unmodified by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name and all copyright +// notices remains intact. If the source code in this file is used in +// any commercial application then a statement along the lines of +// "Portions Copyright ?1999 Dieter Fauth" must be included in +// the startup banner, "About" box or printed documentation. An email +// letting me know that you are using it would be nice as well. That's +// not much to ask considering the amount of work that went into this. +// +// This file is provided "as is" with no expressed or implied warranty. +// The author accepts no liability for any damage/loss of business that +// this product may cause. +// +// ========================================================================== +// HISTORY: +// ========================================================================== +// 1.00 08 May 1999 - Initial release. +// ========================================================================== +// +///////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "TabCtrlBarDoc.h" +#include "MdiClient.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMdiClient + +CMdiClient::CMdiClient(): m_sizeClient(0, 0) +{ + m_crBkColor = GetSysColor(COLOR_DESKTOP); + m_pWndTabs = NULL; +} + + +CMdiClient::~CMdiClient() +{ +} + + +BEGIN_MESSAGE_MAP(CMdiClient, CWnd) + //{{AFX_MSG_MAP(CMdiClient) + ON_WM_ERASEBKGND() + ON_WM_SIZE() + ON_MESSAGE(WM_MDICREATE,OnMDICreate) + ON_MESSAGE(WM_MDIDESTROY,OnMDIDestroy) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +void CMdiClient::AddHandle(HWND hWnd) +{ + ASSERT(m_pWndTabs != NULL); + // б + m_pWndTabs->AddHandle(hWnd); +} + +void CMdiClient::RemoveHandle(HWND hWnd) +{ + ASSERT(m_pWndTabs != NULL); + m_pWndTabs->RemoveHandle(hWnd); +} + +///////////////////////////////////////////////////////////////////////////// +// CMdiClient message handlers + +LRESULT CMdiClient::OnMDICreate(WPARAM wParam, LPARAM lParam) +{ + HWND hWnd = (HWND) DefWindowProc(WM_MDICREATE, wParam, lParam); + AddHandle(hWnd); + return (LRESULT) hWnd; +} + +LRESULT CMdiClient::OnMDIDestroy(WPARAM wParam, LPARAM lParam) +{ + RemoveHandle((HWND) wParam); + return DefWindowProc(WM_MDIDESTROY, wParam, lParam); +} + + + +BOOL CMdiClient::OnEraseBkgnd(CDC* pDC) +{ + return CWnd::OnEraseBkgnd(pDC); +} +void CMdiClient::OnSize(UINT nType, int cx, int cy) +{ + // ͻ仯ʱá֡ڱʱҲϢ + CWnd::OnSize(nType, cx, cy); + + // Ӧó򱣴Сɷ + if ((m_sizeClient.cx == 0) && (m_sizeClient.cy == 0)) + { + m_sizeClient.cx = cx; + m_sizeClient.cy = cy; + + return ; + } + // ͻڴСδ仯򷵻 + if ((m_sizeClient.cx == cx) && ( m_sizeClient.cy == cy)) + { + return; + } + // ֵ + m_sizeClient.cx = cx; + m_sizeClient.cy = cy; + // ǿػ + RedrawWindow(NULL, NULL, + RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW | RDW_ALLCHILDREN); + + return; +} \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MdiClient.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MdiClient.h new file mode 100644 index 0000000..33eda40 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/MdiClient.h @@ -0,0 +1,61 @@ +#if !defined(AFX_MDICLIENT_H__07D11962_0399_11D3_BC0D_89BC9BB36074__INCLUDED_) +#define AFX_MDICLIENT_H__07D11962_0399_11D3_BC0D_89BC9BB36074__INCLUDED_ + + + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 +// MdiClient.h : header file +// +class CTabBar; + +///////////////////////////////////////////////////////////////////////////// +// CMdiClient window + +class CMdiClient : public CWnd +{ +// Construction +public: + CMdiClient(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMdiClient) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CMdiClient(); + CTabCtrlBarDoc *m_pWndTabs; + COLORREF m_crBkColor; + CSize m_sizeClient; // ͻС + +protected: + void RemoveHandle(HWND hWnd); + void AddHandle(HWND hWnd); + + // Generated message map functions +protected: + //{{AFX_MSG(CMdiClient) + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnSize(UINT nType, int cx, int cy); + + //}}AFX_MSG + afx_msg LRESULT OnMDICreate(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMDIDestroy(WPARAM wParam, LPARAM lParam); + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MDICLIENT_H__07D11962_0399_11D3_BC0D_89BC9BB36074__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ParaCfgView.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ParaCfgView.cpp new file mode 100644 index 0000000..2833918 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ParaCfgView.cpp @@ -0,0 +1,1676 @@ +// ParaCfgView.cpp : implementation file +// + +#include "stdafx.h" +#include "Sys.h" +#include "ParaCfgView.h" +#include "ADWaveView.h" +#include "ADDigitView.h" +#include "math.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + + +BOOL gl_bRt = FALSE; +///////////////////////////////////////////////////////////////////////////// +// CParaCfgView +/////////////////////////////// +int glOffset=0; +int glBufferID=0; +extern int gl_InputRange[MAX_CHANNEL_COUNT]; +int gl_MLength = 0; +int gl_NLength = 0; +LONG gl_lFrequency; + + + + +#define TIMER_TRIGER 3 + +extern CSysApp theApp; +/////////////////////////////// +IMPLEMENT_DYNCREATE(CParaCfgView, CFormView) +CParaCfgView::CParaCfgView() +: CFormView(CParaCfgView::IDD) +{ + CountItem = 4; + m_bInitial = FALSE; + //{{AFX_DATA_INIT(CParaCfgView) + m_TrigLevelVolt = 0; + m_nChannelDataBit = 0; + //}}AFX_DATA_INIT +} + +CParaCfgView::~CParaCfgView() +{ +} + +void CParaCfgView::DoDataExchange(CDataExchange* pDX) +{ + CFormView::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CParaCfgView) + DDX_Control(pDX, IDC_EDIT_TrigInterval, m_Edit_TrigInterva); + DDX_Control(pDX, IDC_CHECK_TimerTrig, m_Check_TimerTrig); + DDX_Control(pDX, IDC_BUTTON_SoftTirg, m_Button_SoftTirg); + DDX_Control(pDX, IDC_COMBO_SyncTrigSignal, m_Combo_SyncTrigSignal); + DDX_Control(pDX, IDC_CHECK_bMasterEn, m_Check_bMasterEn); + DDX_Control(pDX, IDC_CHECK_bClkOutEn, m_Check_bClkOutEn); + DDX_Control(pDX, IDC_CHECK_bTrigOutEn, m_Check_bTrigOutEn); + DDX_Control(pDX, IDC_EDIT_SampleLenth, m_Edit_nSampleLenth); + //DDX_Control(pDX, IDC_CHECK_bAvailableTrig, m_Check_bAvailableTrig); + DDX_Control(pDX, IDC_EDIT_TrigLevelVolt, m_Edit_TrigLevelVolt); + DDX_Control(pDX, IDC_EDIT_TrigCount, m_Edit_TrigCount); + DDX_Control(pDX, IDC_EDIT_TrigWindow, m_Edit_TrigWindow); + DDX_Control(pDX, IDC_EDIT_FreqDivision, m_Edit_FreqDivision); + DDX_Control(pDX, IDC_EDIT_Frequency, m_Edit_Frequency); + DDX_Control(pDX, IDC_EDIT_TrigOutWidth, m_Edit_TrigOutWidth); + DDX_Control(pDX, IDC_EDIT_N_Length, m_Edit_N_Length); + DDX_Control(pDX, IDC_EDIT_M_Length, m_Edit_M_Length); + DDX_Control(pDX, IDC_COMBO_ReferenceClock, m_Combo_ReferenceClock); + DDX_Control(pDX, IDC_COMBO_TrigOutPolarity, m_Combo_TrigOutPolarity); + DDX_Control(pDX, IDC_COMBO_ClkOutSel, m_Combo_ClkOutSel); + DDX_Control(pDX, IDC_COMBO_TriggerMode, m_ComBo_TriggerMode); + DDX_Control(pDX, IDC_COMBO_OutTriggerDir, m_Combo_TriggerDir); + DDX_Control(pDX, IDC_COMBO_TriggerSource, m_Combo_TriggerSource); + DDX_Control(pDX, IDC_STATIC_Offset, m_Static_Offset); + DDX_Control(pDX, IDC_SPIN_BufferID, m_Spin_BufferID); + DDX_Control(pDX, IDC_SLIDER_Offset, m_Slider_Offset); + DDX_Control(pDX, IDC_EDIT_BufferID, m_Edit_BufferID); + DDX_Control(pDX, IDC_CHECK_Auto, m_Check_Auto); + //}}AFX_DATA_MAP + DDX_Control(pDX, IDC_COMBO_TimeBaseClock, m_Combo_TimeBaseClock); + DDX_Control(pDX, IDC_COMBO_SampleMode, m_ComBo_SampleMode); + DDX_Control(pDX, IDC_LIST_CHParam, m_List_CHParam); + DDX_Control(pDX, IDC_COMBO_PFISel, m_Combo_PFISel); + DDX_Control(pDX, IDC_CHECK_bSaveFile, m_Check_bSaveFile); + DDX_Control(pDX, IDC_EDIT_FilePath, m_Edit_FilePath); +} + +BEGIN_MESSAGE_MAP(CParaCfgView, CFormView) +//{{AFX_MSG_MAP(CParaCfgView) + ON_CBN_SELCHANGE(IDC_COMBO_TriggerSource, OnSelchangeCOMBOTriggerSource) + ON_WM_KILLFOCUS() + ON_CBN_SELCHANGE(IDC_COMBO_OutTriggerDir, OnSelchangeCOMBOOutTriggerDir) + ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_Offset, OnCustomdrawSLIDEROffset) + ON_EN_CHANGE(IDC_EDIT_BufferID, OnChangeEDITBufferID) + ON_BN_CLICKED(IDC_CHECK_Auto, OnCHECKAuto) + ON_CBN_SELCHANGE(IDC_COMBO_TriggerMode, OnSelchangeCOMBOTriggerMode) +// ON_CBN_KILLFOCUS(IDC_COMBO_bAvailableTrig, OnKillfocusCOMBObAvailableTrig) + ON_CBN_SELCHANGE(IDC_COMBO_ReferenceClock, OnSelchangeCOMBOReferenceClock) +// ON_BN_CLICKED(IDC_CHECK_bAvailableTrig, OnCHECKbAvailableTrig) + ON_EN_CHANGE(IDC_EDIT_TrigLevelVolt, OnChangeEDITTrigLevelVolt) + ON_EN_CHANGE(IDC_EDIT_M_Length, OnChangeEDITMLength) + ON_EN_CHANGE(IDC_EDIT_N_Length, OnChangeEDITNLength) + ON_BN_CLICKED(IDC_CHECK_bMasterEn, OnCHECKbMasterEn) + ON_BN_CLICKED(IDC_CHECK_bClkOutEn, OnCHECKbClkOutEn) + ON_BN_CLICKED(IDC_CHECK_bTrigOutEn, OnCHECKbTrigOutEn) + ON_CBN_SELCHANGE(IDC_COMBO_SyncTrigSignal, OnSelchangeCOMBOSyncTrigSignal) + ON_BN_CLICKED(IDC_BUTTON_SoftTirg, OnBUTTONSoftTirg) + ON_EN_KILLFOCUS(IDC_EDIT_TrigInterval, OnKillfocusEDITTrigInterval) + ON_WM_TIMER() + //}}AFX_MSG_MAP + ON_EN_KILLFOCUS(IDC_EDIT_M_Length, &CParaCfgView::OnEnKillfocusEditMLength) + ON_EN_KILLFOCUS(IDC_EDIT_N_Length, &CParaCfgView::OnEnKillfocusEditNLength) + ON_EN_CHANGE(IDC_EDIT_TrigCount, &CParaCfgView::OnEnChangeEditTrigcount) + ON_EN_CHANGE(IDC_EDIT_TrigWindow, &CParaCfgView::OnEnChangeEditTrigWindow) + ON_CBN_SELCHANGE(IDC_COMBO_ClkOutSel, &CParaCfgView::OnCbnSelchangeComboClkoutsel) + ON_CBN_SELCHANGE(IDC_COMBO_TrigOutPolarity, &CParaCfgView::OnCbnSelchangeComboTrigoutpolarity) + ON_EN_CHANGE(IDC_EDIT_TrigOutWidth, &CParaCfgView::OnEnChangeEditTrigoutwidth) + ON_EN_KILLFOCUS(IDC_EDIT_TrigOutWidth, &CParaCfgView::OnEnKillfocusEditTrigoutwidth) + ON_EN_KILLFOCUS(IDC_EDIT_TrigWindow, &CParaCfgView::OnEnKillfocusEditTrigwindow) + ON_EN_KILLFOCUS(IDC_EDIT_FreqDivision, &CParaCfgView::OnEnKillfocusEditFreqdivision) + ON_EN_KILLFOCUS(IDC_EDIT_Frequency, &CParaCfgView::OnEnKillfocusEditFrequency) + ON_CBN_SELCHANGE(IDC_COMBO_TimeBaseClock, &CParaCfgView::OnCbnSelchangeComboTimebaseclock) + ON_CBN_SELCHANGE(IDC_COMBO_SampleMode, &CParaCfgView::OnCbnSelchangeComboSamplemode) + ON_CBN_SELCHANGE(IDC_COMBO_PFISel, &CParaCfgView::OnCbnSelchangeComboPfisel) + ON_BN_CLICKED(IDC_CHECK_bSaveFile, &CParaCfgView::OnBnClickedCheckbsavefile) + ON_EN_KILLFOCUS(IDC_EDIT_FilePath, &CParaCfgView::OnEnKillfocusEditFilepath) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CParaCfgView diagnostics + +#ifdef _DEBUG +void CParaCfgView::AssertValid() const +{ + CFormView::AssertValid(); +} + +void CParaCfgView::Dump(CDumpContext& dc) const +{ + CFormView::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CParaCfgView message handlers + +void CParaCfgView::OnInitialUpdate() +{ + CFormView::OnInitialUpdate(); + + CSysApp *pApp = (CSysApp *)AfxGetApp(); + CADDoc *pDoc = (CADDoc *)pApp->m_pADDoc; + CADWaveView* pWaveView = (CADWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + pDoc->m_hWndADCfg = this->m_hWnd; + pApp->m_hParaCfgView = this->m_hWnd; + m_lSingleCH = 0xFF; + + // ʼûӾ + CString str; + OutAnalogValve = 2000; + m_ComBo_TriggerMode.SetCurSel(ADPara.TriggerMode); + m_ComBo_SampleMode.SetCurSel(ADPara.SampleMode); + + m_Combo_TriggerDir.SetCurSel(ADPara.TriggerDir); + m_Static_Offset.SetWindowText(_T("0")); + m_Spin_BufferID.SetRange(0, MAX_SEGMENT-1); + m_Spin_BufferID.SetBuddy(&m_Edit_BufferID); + m_Spin_BufferID.SetPos(0); + + m_Slider_Offset.SetRange(0, MAX_RAM_SIZE/MAX_CHANNEL_COUNT-1); // ʼƫƷΧ + + OldADPara = ADPara; + + m_List_CHParam.InsertColumn(0, L"ͨ", LVCFMT_LEFT, 38, 70); + m_List_CHParam.InsertColumn(1, L"ʹ", LVCFMT_LEFT, 38, 70); + m_List_CHParam.InsertColumn(2, L"Χ", LVCFMT_LEFT, 45, 70); + m_List_CHParam.InsertColumn(3, L"", LVCFMT_LEFT, 38, 70); + if (gl_ADMainInfo.nSupportImped == 1) + { + m_List_CHParam.InsertColumn(4, L"迹", LVCFMT_LEFT, 38, 70); + } + DWORD type = LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP | LVS_EX_INFOTIP | + LVS_EX_ONECLICKACTIVATE | LVS_EX_SUBITEMIMAGES; + + m_List_CHParam.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LPARAM(type)); + + + //CString string; + + str.Format(_T("%d"), ADPara.FreqDivision); + m_Edit_FreqDivision.SetWindowText(str); + + gl_lFrequency = gl_ADMainInfo.nBaseRate/ADPara.FreqDivision; + str.Format(_T("%d"), gl_lFrequency); + m_Edit_Frequency.SetWindowText(str); + + + m_Edit_FilePath.SetWindowText(ADPara.chFileName); + m_Check_bSaveFile.SetCheck(ADPara.bSaveFile); + + m_Edit_FilePath.EnableWindow(ADPara.bSaveFile); + + + // ʼ + gl_nSampleLenth = ADPara.M_Length + ADPara.N_Length; + str.Format(_T("%u"), gl_nSampleLenth); + m_Edit_nSampleLenth.SetWindowText(str); + + + // ʼ״̬TimeDiv(ƵӦ) + float fFrequency, fTimePixel, fTimeDiv; + + fFrequency = gl_nSampleLenth/1000000.0; // ȡƵʴС(MHz) + fTimePixel = float(1000.0 / fFrequency); // ÿص֮ʱ(nS) + fTimeDiv = fTimePixel*50; + if(fTimeDiv < 1000.0) + str.Format(_T("%7.2f nS/Div"), fTimeDiv); + if(fTimeDiv>=1000.0 && fTimeDiv<1000000.0) + str.Format(_T("%7.2f uS/Div"), fTimeDiv/1000); + if(fTimeDiv>=1000000.0 && fTimeDiv<1000000000.0) + str.Format(_T("%7.2f mS/Div"), fTimeDiv/1000000); + if(fTimeDiv >= 1000000000.0) + str.Format(_T("%7.2f S/Div"), fTimeDiv/1000000000); + CStatic *pStatic = (CStatic *)m_pADFrm->m_wndShowStatus.GetDlgItem(IDC_STATIC_TimeOfDiv); + pStatic->SetWindowText(str); + + CString strMsg; + ULONG nChanIdx = 0; + + m_List_CHParam.DeleteAllItems(); + for(nChanIdx=0; nChanIdxShowWindow(SW_SHOW); + } + + if (gl_ADMainInfo.nSupportClkOut == 1) + { + m_Check_bClkOutEn.ShowWindow(SW_SHOW); + m_Combo_ClkOutSel.ShowWindow(SW_SHOW); + } + + + + if (ADPara.TriggerMode == ACTS1000_TRIGMODE_POST || ADPara.TriggerMode == ACTS1000_TRIGMODE_PRE) + { + m_Edit_M_Length.EnableWindow(FALSE); + ADPara.M_Length = 0; + } + + if (ADPara.TriggerMode == ACTS1000_TRIGMODE_POST || ADPara.TriggerMode == ACTS1000_TRIGMODE_DELAY) + { + if (ADPara.SampleMode == ACTS1000_SAMPMODE_CONTINUOUS) + { + m_Edit_TrigCount.EnableWindow(FALSE); + } + else + m_Edit_TrigCount.EnableWindow(TRUE); + } + else + { + m_Edit_TrigCount.EnableWindow(FALSE); + } + +// if (ADPara.M_Length > 645) // ʼMκNγ(645ΪʾĿ) +// { +// ADPara.M_Length = 0; +// ADPara.N_Length = gl_nSampleLenth - 1; +// } +// else + { + gl_MLength = ADPara.M_Length; + gl_NLength = ADPara.N_Length; + } + str.Format(_T("%u"), gl_MLength); + m_Edit_M_Length.SetWindowText(str); + str.Format(_T("%u"), gl_NLength); + m_Edit_N_Length.SetWindowText(str); + + for (int nChannel = 0; nChannelm_ADScopeCtrl.SetRange(-1000, 1000, nChannel); + break; + case ACTS1000_INPUT_N10000_P10000mV: + gl_InputRange[nChannel] = 20000; + gl_PerLsbVoltM[nChannel] = (float)(20000.0 / gl_fLsbCount); + pWaveView->m_ADScopeCtrl.SetRange(-10000, 10000, nChannel); + break; + + case ACTS1000_INPUT_N5000_P5000mV: + gl_InputRange[nChannel] = 10000; + gl_PerLsbVoltM[nChannel] = (float)(10000.0 / gl_fLsbCount); + pWaveView->m_ADScopeCtrl.SetRange(-5000, 5000, nChannel); + break; + default: + break; + } + } + + gl_ScreenVolume = gl_InputRange[0]; + str.Format(_T("%d"), ADPara.TrigLevelVolt); + m_Edit_TrigLevelVolt.SetWindowText(str); +// if (ADPara.TrigCount<1) +// ADPara.TrigCount= 1; + str.Format(_T("%d"), ADPara.TrigCount); + m_Edit_TrigCount.SetWindowText(str); + str.Format(_T("%d"), ADPara.TrigWindow); + m_Edit_TrigWindow.SetWindowText(str); + str.Format(_T("%d"), ADPara.TrigOutWidth); + m_Edit_TrigOutWidth.SetWindowText(str); + m_Check_Auto.SetCheck(TRUE); // Զɼ + m_Check_TimerTrig.SetCheck(1); + m_Edit_TrigInterva.SetWindowText(_T("100")); + OnSelchangeCOMBOTriggerSource(); + + + gl_bAutoCollect = TRUE; + m_bInitial = TRUE; + OnCHECKbClkOutEn(); + OnCHECKbTrigOutEn(); + OnSelchangeCOMBOReferenceClock(); + + ULONG nSampChanCount = 0; + for(ULONG nChannel=0; nChannelEnableWindow(FALSE); +// } +// } +// } +// } + + m_Edit_N_Length.EnableWindow(Flag); + m_Edit_TrigWindow.EnableWindow(Flag); + m_ComBo_TriggerMode.EnableWindow(Flag); + m_ComBo_SampleMode.EnableWindow(Flag); + m_Combo_TriggerSource.EnableWindow(Flag); + m_Combo_TriggerDir.EnableWindow(Flag); + + + m_Edit_FreqDivision.EnableWindow(Flag); + if (ADPara.TimeBaseClock == ACTS1000_TBCLK_IN) + { + m_Edit_Frequency.EnableWindow(Flag); + m_Combo_ReferenceClock.EnableWindow(Flag); + } + else + { + m_Edit_Frequency.EnableWindow(FALSE); + m_Combo_ReferenceClock.EnableWindow(FALSE); + } + +// m_Check_bAvailableTrig.EnableWindow(Flag); + m_Edit_TrigLevelVolt.EnableWindow(Flag); + m_Combo_ReferenceClock.EnableWindow(Flag); + m_Combo_TimeBaseClock.EnableWindow(Flag); + m_Combo_PFISel.EnableWindow(Flag); + if (ADPara.bClkOutEn) + { + m_Combo_ClkOutSel.EnableWindow(Flag); + } + else{ + m_Combo_ClkOutSel.EnableWindow(FALSE); + } + if (ADPara.bTrigOutEn) + { + m_Combo_TrigOutPolarity.EnableWindow(Flag); + m_Edit_TrigOutWidth.EnableWindow(Flag); + } + else{ + m_Combo_TrigOutPolarity.EnableWindow(FALSE); + m_Edit_TrigOutWidth.EnableWindow(FALSE); + } + m_Check_bMasterEn.EnableWindow(Flag); + m_Check_bClkOutEn.EnableWindow(Flag); + m_Check_bTrigOutEn.EnableWindow(Flag); + m_Combo_SyncTrigSignal.EnableWindow(Flag); + if(nProcessMode == SAVE_MODE) // Ǵ̲ + { + m_Edit_BufferID.EnableWindow(Flag); + m_Spin_BufferID.EnableWindow(Flag); + } + if (Flag) + { + OnCbnSelchangeComboPfisel(); + m_Edit_FilePath.EnableWindow(ADPara.bSaveFile); + } + else + { + m_Edit_FilePath.EnableWindow(FALSE); + + } + m_Check_bSaveFile.EnableWindow(Flag); +} + + +void CParaCfgView::OnKillFocus(CWnd* pNewWnd) +{ + CFormView::OnKillFocus(pNewWnd); + // TODO: Add your message handler code here +} + +void CParaCfgView::OnSelchangeCOMBOOutTriggerDir() +{ + // TODO: Add your control notification handler code here + ADPara.TriggerDir = m_Combo_TriggerDir.GetCurSel(); +} + + +void CParaCfgView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) +{ + // TODO: Add your specialized code here and/or call the base class + if(lHint==1 || lHint==2) return; + CView::OnUpdate(pSender, lHint, pHint); +} + +void CParaCfgView::OnCustomdrawSLIDEROffset(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + if(m_bInitial) + { + CSliderCtrl* pSliderOffset=(CSliderCtrl*)(GetDlgItem(IDC_SLIDER_Offset)); + int Pos = pSliderOffset->GetPos(); // ȡûλ + pSliderOffset->SetPos(Pos); + + glOffset = Pos; //gloffset ־ڻеƫ + CString str; + str.Format(_T("%d"), glOffset); + CStatic* pStatic = (CStatic*)(GetDlgItem(IDC_STATIC_Offset)); + pStatic->SetWindowText(str); + CSysApp* pApp = (CSysApp*)AfxGetApp(); + CADWaveView* pWaveView = (CADWaveView*)(CWnd::FromHandle(pApp->m_pADDoc->m_hWndWave)); + CADDigitView* pDigitView = (CADDigitView*)(CWnd::FromHandle(pApp->m_pADDoc->m_hWndDigit)); + + pWaveView->OnDrawPolyLine(gl_nDocDrawLen,gl_nDocDrawIdx); // ²ͼ + pDigitView->RedrawWindow(); // ͼ + +// CADFrame* pADFrame = (CADFrame*)pWaveView->GetParentFrame(); +// CEdit* pEditOffset=(CEdit*)(pADFrame->m_wndShowStatus).GetDlgItem(IDC_EDIT_Offset); +// int Count = glOffset + WavePointX; // ƫܵ +// str.Format(_T("%d"), Count); + + *pResult = 0; + } +} + +BOOL gl_bCollected = FALSE; // ǷѾйһβɼ +void CParaCfgView::OnChangeEDITBufferID() +{ + CString string; + CEdit* pEditBufferID = (CEdit*)(GetDlgItem(IDC_EDIT_BufferID)); + pEditBufferID->GetWindowText(string); + + glBufferID = _tcstol(string,NULL,10); // ıADBufferĻκ + if(glBufferID<0 || glBufferID>2) + { + glBufferID = 0; + pEditBufferID->SetWindowText(_T("0")); + } + CSysApp* pApp=(CSysApp*)AfxGetApp(); + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(pApp->m_pADDoc->m_hWndWave)); + CADDigitView* pDigitView=(CADDigitView*)(CWnd::FromHandle(pApp->m_pADDoc->m_hWndDigit)); + CADDoc *pADDoc = (CADDoc *)pApp->m_pADDoc; + + + pDigitView->RedrawWindow(); // ͼ + pWaveView->OnDrawPolyLine(gl_nDocDrawLen,gl_nDocDrawIdx); // ²ͼ +} + +void CParaCfgView::OnCHECKAuto() // Զɼ +{ + if(m_Check_Auto.GetCheck()) + gl_bAutoCollect = TRUE; + else + gl_bAutoCollect = FALSE; +} + + +// ͨ0ĵѹ +void CParaCfgView::OnSelchangeCOMBOVoltRange() +{ + // TODO: Add your control notification handler code here + CSysApp *pApp=(CSysApp*)AfxGetApp(); + CADDoc* pDoc=pApp->m_pADDoc; + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + CADDigitView* pDigitView=(CADDigitView*)(CWnd::FromHandle(pDoc->m_hWndDigit)); +// int nInputRange; + + //const MSG* pMsg = GetCurrentMessage(); + for (int nCH=0; nCHm_ADScopeCtrl.SetRange(-1000, 1000, nCH); + break; + case ACTS1000_INPUT_N10000_P10000mV: + gl_ScreenVolume = 20000; + gl_InputRange[nCH] = 20000; + gl_PerLsbVoltM[nCH] = (float)(20000.0 / gl_fLsbCount); + pWaveView->m_ADScopeCtrl.SetRange(-10000, 10000, nCH); + break; + + case ACTS1000_INPUT_N5000_P5000mV: + gl_ScreenVolume = 10000; + gl_InputRange[nCH] = 10000; + gl_PerLsbVoltM[nCH] = (float)(10000.0 / gl_fLsbCount); + pWaveView->m_ADScopeCtrl.SetRange(-5000, 5000, nCH); + break; + default: + break; + } + } + + if (m_lSingleCH != 0xFF) + { + + for (int i=0;im_ADScopeCtrl.SetRange(-1000, 1000, i); + break; + case ACTS1000_INPUT_N10000_P10000mV: + + gl_ScreenVolume = 20000; + gl_InputRange[i] = 20000; + gl_PerLsbVoltM[i] = (float)(20000.0 / gl_fLsbCount); + pWaveView->m_ADScopeCtrl.SetRange(-10000, 10000, i); + break; + case ACTS1000_INPUT_N5000_P5000mV: + gl_ScreenVolume = 10000; + gl_InputRange[i] = 10000; + gl_PerLsbVoltM[i] = (float)(10000.0 / gl_fLsbCount); + pWaveView->m_ADScopeCtrl.SetRange(-5000, 5000, i); + break; + default: + break; + } + break; + } + } + } + + pDigitView->Invalidate(); + pWaveView->m_ADScopeCtrl.InvalidateCtrl(); +} + +void CParaCfgView::SetInputRangeComboSel(int *pInputRange) +{ +// m_Combo_VoltRange0.SetCurSel(pInputRange[0]); + +// ADPara.InputRange = pInputRange[0]; +} + +// ôģʽ +void CParaCfgView::OnSelchangeCOMBOTriggerMode() +{ + // TODO: Add your control notification handler code here + + ADPara.TriggerMode = m_ComBo_TriggerMode.GetCurSel(); + + if (ADPara.SampleMode == ACTS1000_SAMPMODE_CONTINUOUS) + { + if (ADPara.TriggerMode==ACTS1000_TRIGMODE_MIDL || ADPara.TriggerMode==ACTS1000_TRIGMODE_PRE) + { + AfxMessageBox(L" ģʽֻΪ󴥷Ӳʱ!"); + m_ComBo_TriggerMode.SetCurSel(ACTS1000_TRIGMODE_POST); + ADPara.TriggerMode = ACTS1000_TRIGMODE_POST; + return; + } + } + + + if (ADPara.TriggerMode == ACTS1000_TRIGMODE_POST || ADPara.TriggerMode == ACTS1000_TRIGMODE_PRE) + { + m_Edit_M_Length.EnableWindow(FALSE); + m_Edit_M_Length.SetWindowText(_T("0")); + ADPara.M_Length = 0; + } + else + { + m_Edit_M_Length.EnableWindow(TRUE); + } + + + if (ADPara.TriggerMode == ACTS1000_TRIGMODE_POST || ADPara.TriggerMode == ACTS1000_TRIGMODE_DELAY) + { + if (ADPara.SampleMode == ACTS1000_SAMPMODE_CONTINUOUS) + { + m_Edit_TrigCount.EnableWindow(FALSE); + } + else + m_Edit_TrigCount.EnableWindow(TRUE); + } + else + { + m_Edit_TrigCount.EnableWindow(FALSE); + m_Edit_TrigCount.EnableWindow(FALSE); + m_Edit_TrigCount.SetWindowText(_T("1")); + ADPara.TrigCount = 1; + } + OnEnKillfocusEditNLength(); + +} + +// void CParaCfgView::OnKillfocusCOMBObAvailableTrig() +// { +// // TODO: Add your control notification handler code here +// // CComboBox* pTrig = (CComboBox*)GetDlgItem(IDC_COMBO_bAvailableTrig); +// // ADPara.bAvailableTrig = pTrig->GetCurSel(); +// } + +void CParaCfgView::OnSelchangeCOMBOReferenceClock() +{ + // TODO: Add your control notification handler code here + ADPara.ReferenceClock = m_Combo_ReferenceClock.GetCurSel(); +// if(ADPara.ReferenceClock != ACTS1000_CLOCKSRC_OUT) +// { +// m_Edit_Frequency.EnableWindow(TRUE); +// } +// else +// { +// m_Edit_Frequency.EnableWindow(FALSE); +// } +} + + + +// void CParaCfgView::OnCHECKbAvailableTrig() +// { +// // TODO: Add your control notification handler code here +// // ADPara.bAvailableTrig = m_Check_bAvailableTrig.GetCheck(); +// } + +void CParaCfgView::OnChangeEDITTrigLevelVolt() +{ + // TODO: Add your control notification handler code here + CString str; + this->m_Edit_TrigLevelVolt.GetWindowText(str); + LONG TrigLevelVolt = (LONG)_tcstol(str, NULL, 10); + +// if(TrigLevelVolt<0 || TrigLevelVolt>10000) +// { +// MessageBox(_T("ƽķΧΪ:(0 ~ 10000)mV")); +// TrigLevelVolt =1000; +// this->m_Edit_TrigLevelVolt.SetWindowText(_T("1000")); +// } +// ADPara.TrigLevelVolt = TrigLevelVolt; + LONG VoltTopRange, VoltBottomRange; + LONG lCH = ADPara.TriggerSource-ACTS1000_TRIGSRC_CH0; + if (lCH<0 || lCH>(ACTS1000_AD_MAX_CHANNELS-1)) + { + lCH = 0; + } + + switch(ADPara.InputRange[lCH]) // ѹ + { + case ACTS1000_INPUT_N1000_P1000mV: // 1000 + VoltTopRange = 1000; + VoltBottomRange = -1000; + break; + case ACTS1000_INPUT_N10000_P10000mV: // 5000 + VoltTopRange = 10000; + VoltBottomRange = -10000; + break; + case ACTS1000_INPUT_N5000_P5000mV: + VoltTopRange = 5000; + VoltBottomRange = -5000; + break; + } + + + if(TrigLevelVoltVoltTopRange) + { + str.Format(L"ƽķΧΪ%dmV%dmV", VoltBottomRange,VoltTopRange); + MessageBox(str, L"Information", MB_ICONWARNING | MB_OK); + if(ADPara.TrigLevelVoltVoltTopRange) + { + ADPara.TrigLevelVolt =VoltTopRange; + } + str.Format(L"%ld", ADPara.TrigLevelVolt); + this->m_Edit_TrigLevelVolt.SetWindowText(str); + } + else + { + ADPara.TrigLevelVolt = TrigLevelVolt; + } +} + +void CParaCfgView::OnChangeEDITMLength() +{ + // TODO: Add your control notification handler code here + + + CSysApp *pApp = (CSysApp *)AfxGetApp(); + CADDoc *pDoc = (CADDoc *)pApp->m_pADDoc; + CADWaveView* pWaveView = (CADWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + + CString strMLength; + CString strNLength; + ULONG nMLength = 0; + ULONG nNLength = 0; + int i = 0; + + CEdit* pEditM_Length = (CEdit*)(GetDlgItem(IDC_EDIT_M_Length)); // ȡIDC_EDIT_M_Length + pEditM_Length->GetWindowText(strMLength); + CEdit* pEditN_Length = (CEdit*)(GetDlgItem(IDC_EDIT_N_Length)); // ȡIDC_EDIT_M_Length + pEditN_Length->GetWindowText(strNLength); + nMLength = _tcstoul(strMLength, NULL, 10); + nNLength = _tcstoul(strMLength, NULL, 10); + + + + { + pWaveView->m_ADScopeCtrl.m_OldMoveX1 = pWaveView->m_ADScopeCtrl.m_OldMoveX1 + (nMLength - ADPara.M_Length); + gl_MLength = nMLength; + ADPara.M_Length = nMLength; + } + + pWaveView->m_ADScopeCtrl.InvalidateCtrl(); + + + gl_nSampleLenth = gl_NLength/* + gl_MLength*/; + CString str; + str.Format(_T("%u"), gl_nSampleLenth); + m_Edit_nSampleLenth.SetWindowText(str); + +} + +void CParaCfgView::OnChangeEDITNLength() +{ + // TODO: Add your control notification handler code here +// CString strNLength; +// CString strMLength; +// ULONG nNLength = 0; +// ULONG nMLength = 0; +// int i = 0; +// +// CEdit* pEditN_Length = (CEdit*)(GetDlgItem(IDC_EDIT_N_Length)); // ȡIDC_EDIT_M_Length +// pEditN_Length->GetWindowText(strNLength); +// CEdit* pEditM_Length = (CEdit*)(GetDlgItem(IDC_EDIT_M_Length)); // ȡIDC_EDIT_M_Length +// pEditM_Length->GetWindowText(strMLength); +// nNLength = _tcstoul(strNLength, NULL, 10); +// nMLength = _tcstol(strNLength, NULL, 10); +// +// i = 0; +// for (int nCH=0; nCH2048) +// { +// ulLen = ulLen-ulLen%2048; +// nNLength = ulLen/gl_nChannelCount/ADPara.TrigCount; +// } +// else +// { +// nNLength = 2048/gl_nChannelCount/ADPara.TrigCount; +// if (nNLength*gl_nChannelCount*ADPara.TrigCount % 2048 != 0) +// { +// nNLength = 2048/gl_nChannelCount; +// } +// } +// strNLength.Format(_T("%d"), nNLength); +// pEditN_Length->SetWindowText(strNLength); +// pEditN_Length->SetSel(0, -1, FALSE); +// } + +//?? +// if (nNLength + gl_MLength > gl_DDR2Lenth/i/2 || nNLength<0) +// { +// if (gl_MLength > gl_DDR2Lenth/i/2) +// { +// gl_MLength = 1024; +// strMLength.Format(_T("%d"), gl_MLength); +// pEditM_Length->SetWindowText(strMLength); +// pEditM_Length->SetSel(0, -1, FALSE); +// } +// strNLength.Format(_T("MγΪ%d,NηΧ:0~%d"), gl_MLength, gl_DDR2Lenth/i/2 - gl_MLength); +// AfxMessageBox(strNLength); +// +// if (gl_NLength<0) +// { +// gl_NLength = 1024; +// } +// else +// { +// gl_NLength = gl_DDR2Lenth/i/2 - gl_MLength; +// +// } +// strNLength.Format(_T("%d"), gl_NLength); +// pEditN_Length->SetWindowText(strNLength); +// pEditN_Length->SetSel(0, -1, FALSE); +// } +// else +// { +// gl_NLength = nNLength; +// ADPara.N_Length = nNLength; +// } + + +// gl_NLength = nNLength; +// ADPara.N_Length = nNLength; +// +// gl_nSampleLenth = gl_MLength + gl_NLength; +// CString str; +// str.Format(_T("%u"), gl_nSampleLenth); +// m_Edit_nSampleLenth.SetWindowText(str); + +} + +void CParaCfgView::OnCHECKbMasterEn() +{ + // TODO: Add your control notification handler code here + ADPara.bMasterEn = m_Check_bMasterEn.GetCheck(); +} + +void CParaCfgView::OnCHECKbClkOutEn() +{ + // TODO: Add your control notification handler code here + ADPara.bClkOutEn = m_Check_bClkOutEn.GetCheck(); + if (ADPara.bClkOutEn) + { + m_Combo_ClkOutSel.EnableWindow(TRUE); + } + else{ + m_Combo_ClkOutSel.EnableWindow(FALSE); + } +} + +void CParaCfgView::OnCHECKbTrigOutEn() +{ + // TODO: Add your control notification handler code here + ADPara.bTrigOutEn = m_Check_bTrigOutEn.GetCheck(); + if (ADPara.bTrigOutEn) + { + m_Combo_TrigOutPolarity.EnableWindow(TRUE); + m_Edit_TrigOutWidth.EnableWindow(TRUE); + } + else{ + m_Combo_TrigOutPolarity.EnableWindow(FALSE); + m_Edit_TrigOutWidth.EnableWindow(FALSE); + } +} + +void CParaCfgView::OnSelchangeCOMBOSyncTrigSignal() +{ + // TODO: Add your control notification handler code here + ADPara.SyncTrigSignal = m_Combo_SyncTrigSignal.GetCurSel(); +} + +void CParaCfgView::OnBUTTONSoftTirg() +{ + // TODO: Add your control notification handler code here + + if (gl_bDeviceADRun) + { + ACTS1000_SetDeviceTrigAD(theApp.m_hDevice); + } +} + +void CParaCfgView::OnKillfocusEDITTrigInterval() +{ + // TODO: Add your control notification handler code here + CString str; + m_Edit_TrigInterva.GetWindowText(str); + long lTmp = _tcstol(str, NULL, 10); + if (lTmp<1) + { + m_Edit_TrigInterva.SetWindowText(_T("1")); + } + + +} + +void CParaCfgView::StartAD() +{ + + gl_bAutoTrig = FALSE; + if (m_Check_TimerTrig.GetCheck() && ADPara.TriggerSource == ACTS1000_TRIGMODE_SOFT) + { + gl_bAutoTrig = TRUE; + CString str; + m_Edit_TrigInterva.GetWindowText(str); + SetTimer(TIMER_TRIGER,_tcstol(str, NULL, 10), NULL); + + } +} + +void CParaCfgView::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: Add your message handler code here and/or call default + + if (nIDEvent == TIMER_TRIGER) + { + + if (gl_bDeviceADRun) + { + ACTS1000_SetDeviceTrigAD(theApp.m_hDevice); + } + else + { + KillTimer(TIMER_TRIGER); + } + + } + + CFormView::OnTimer(nIDEvent); +} + +void CParaCfgView::OnEnKillfocusEditMLength() +{ + // TODO: ڴӿؼ֪ͨ +// CEdit* pEditM_Length = (CEdit*)(GetDlgItem(IDC_EDIT_M_Length)); // ȡIDC_EDIT_M_Length +// ULONG ulTemp = 16/gl_nChannelCount; +// if (gl_nSampleLenth%ulTemp !=0) +// { +// if (!m_bErrorDlg) +// { +// CString str; +// str.Format(L"M+NijӦΪ%d",ulTemp); +// AfxMessageBox(str); +// pEditM_Length->SetFocus(); +// pEditM_Length->SetSel(0, -1, FALSE); +// m_bErrorDlg = TRUE; +// } +// else +// { +// m_bErrorDlg = FALSE; +// } +// +// } + OnEnKillfocusEditNLength(); +} + +ULONGLONG gcd(ULONGLONG a, ULONGLONG b)//Լ +{ + while(b != 0) + { + ULONGLONG t = a; + a = b; + b = t % b; + } + return a; +} +ULONGLONG lcm(ULONGLONG a,ULONGLONG b) //С +{ + ULONGLONG x; + x=gcd(a,b); //gcd() + return a*b/x; +} + +void CParaCfgView::OnEnKillfocusEditNLength() +{ + // TODO: ڴӿؼ֪ͨ + + CString strNLength; + ULONG nNLength = 0; + CEdit* pEditN_Length = (CEdit*)(GetDlgItem(IDC_EDIT_N_Length)); // ȡIDC_EDIT_M_Length + CEdit* pEditM_Length = (CEdit*)(GetDlgItem(IDC_EDIT_M_Length)); // ȡIDC_EDIT_M_Length + pEditN_Length->GetWindowText(strNLength); + nNLength = _tcstoul(strNLength, NULL, 10); + + if (ADPara.SampleMode == ACTS1000_SAMPMODE_FINITE) + { + if (ADPara.TriggerMode==ACTS1000_TRIGMODE_MIDL) + { + if (ADPara.M_Length+nNLength>gl_DDR2Lenth/gl_nChannelCount/2) + { + nNLength = gl_DDR2Lenth/gl_nChannelCount/2-ADPara.M_Length; + } + if (((ADPara.M_Length+nNLength)*gl_nChannelCount)%512 !=0) + { + nNLength=((((ADPara.M_Length+nNLength)*gl_nChannelCount)/512+1)*512)/gl_nChannelCount-ADPara.M_Length; + } + } + else if (ADPara.TriggerMode==ACTS1000_TRIGMODE_PRE) + { + if (nNLength>gl_DDR2Lenth/gl_nChannelCount/2) + { + nNLength = gl_DDR2Lenth/gl_nChannelCount/2; + } + if ((nNLength*gl_nChannelCount)%512 !=0) + { + nNLength=(((nNLength*gl_nChannelCount)/512+1)*512)/gl_nChannelCount; + } + } + else + { + if (ADPara.TrigCount > 0) + { + ULONGLONG ulChushu = gl_nChannelCount*(ADPara.TrigCount); + ULONGLONG ulLen=nNLength; + ulLen = ulLen*ulChushu; + + if (ulLen%512 !=0) + { + + ULONG ulCm = lcm(512,ulChushu); + if (ulLen % ulCm != 0) + { + if (ulLen>ulCm) + { + ulLen = ulLen-ulLen%ulCm; + nNLength = ulLen/ulChushu; + } + else + { + nNLength = ulCm/ulChushu; + } + + + } + } + } + } + } + + strNLength.Format(_T("%u"), nNLength); + pEditN_Length->SetWindowText(strNLength); + pEditN_Length->SetSel(0, -1, FALSE); + + + gl_NLength = nNLength; + ADPara.N_Length = nNLength; + + gl_nSampleLenth = gl_NLength; + if (ADPara.TriggerMode==ACTS1000_TRIGMODE_MIDL) + { + gl_nSampleLenth = gl_NLength + gl_MLength; + } + CString str; + str.Format(_T("%u"), gl_nSampleLenth); + m_Edit_nSampleLenth.SetWindowText(str); +} + +// +// void CParaCfgView::OnCheckCh0() +// { +// // TODO: Add your control notification handler code here +// +// m_pCheck_CH(0)->SetCheck(1); +// m_pCheck_CH(1)->SetCheck(0); +// m_pCheck_CH(2)->SetCheck(0); +// m_pCheck_CH(3)->SetCheck(0); +// EnableVootRange(); +// } +// +// void CParaCfgView::OnCheckCh1() +// { +// // TODO: Add your control notification handler code here +// +// if(!m_pCheck_CH(1)->GetCheck()) +// { +// m_pCheck_CH(0)->SetCheck(1); +// m_pCheck_CH(1)->SetCheck(0); +// m_pCheck_CH(2)->SetCheck(0); +// m_pCheck_CH(3)->SetCheck(0); +// } +// else +// { +// m_pCheck_CH(0)->SetCheck(1); +// m_pCheck_CH(1)->SetCheck(1); +// m_pCheck_CH(2)->SetCheck(0); +// m_pCheck_CH(3)->SetCheck(0); +// } +// EnableVootRange(); +// } +// +// void CParaCfgView::OnCheckCh2() +// { +// // TODO: Add your control notification handler code here +// +// if(!m_pCheck_CH(2)->GetCheck()) +// { +// m_pCheck_CH(0)->SetCheck(1); +// m_pCheck_CH(1)->SetCheck(1); +// m_pCheck_CH(2)->SetCheck(0); +// m_pCheck_CH(3)->SetCheck(0); +// } +// else +// { +// m_pCheck_CH(0)->SetCheck(1); +// m_pCheck_CH(1)->SetCheck(1); +// m_pCheck_CH(2)->SetCheck(1); +// m_pCheck_CH(3)->SetCheck(1); +// } +// EnableVootRange(); +// } +// +// void CParaCfgView::OnCheckCh3() +// { +// // TODO: Add your control notification handler code here +// +// if(!m_pCheck_CH(3)->GetCheck()) +// { +// m_pCheck_CH(0)->SetCheck(1); +// m_pCheck_CH(1)->SetCheck(1); +// m_pCheck_CH(2)->SetCheck(0); +// m_pCheck_CH(3)->SetCheck(0); +// } +// else +// { +// m_pCheck_CH(0)->SetCheck(1); +// m_pCheck_CH(1)->SetCheck(1); +// m_pCheck_CH(2)->SetCheck(1); +// m_pCheck_CH(3)->SetCheck(1); +// } +// EnableVootRange(); +// } +void CParaCfgView::EnableVootRange() +{ + + + CADDoc* pDoc=theApp.m_pADDoc; + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + CADDigitView* pDigitView=(CADDigitView*)(CWnd::FromHandle(pDoc->m_hWndDigit)); + + ULONG ulCount = 0; + for (INT nCH=0; nCHInvalidate(); + pWaveView->m_ADScopeCtrl.InvalidateCtrl(); + + OnSelchangeCOMBOVoltRange(); + +} + +void CParaCfgView::OnEnChangeEditTrigWindow() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ͸֪ͨд CFormView::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + + + +} + + +void CParaCfgView::OnEnChangeEditTrigcount() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ͸֪ͨд CFormView::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + + CString str; + m_Edit_TrigCount.GetWindowText(str); + LONG TrigCount = (LONG)_tcstol(str, NULL, 10); + + +// if(TrigCount<1) +// { +// //MessageBox(str, _T("ڵ1"), MB_ICONWARNING | MB_OK); +// AfxMessageBox(L"ڵ1"); +// if(ADPara.TrigCount<1) +// { +// ADPara.TrigLevelVolt =1; +// } +// str.Format(_T("%ld"), ADPara.TrigCount); +// m_Edit_TrigCount.SetWindowText(str); +// } + if(TrigCount<0) + { + AfxMessageBox(L"ڵ0"); + ADPara.TrigLevelVolt =1; + str.Format(_T("%ld"), ADPara.TrigCount); + m_Edit_TrigCount.SetWindowText(str); + } + else + { + ADPara.TrigCount = TrigCount; + } + + OnEnKillfocusEditNLength(); + +} + + +void CParaCfgView::OnCbnSelchangeComboClkoutsel() +{ + // TODO: ڴӿؼ֪ͨ + + ADPara.ClkOutSel = m_Combo_ClkOutSel.GetCurSel(); + +} + +void CParaCfgView::OnCbnSelchangeComboTrigoutpolarity() +{ + // TODO: ڴӿؼ֪ͨ + ADPara.TrigOutPolarity = m_Combo_TrigOutPolarity.GetCurSel(); +} + +void CParaCfgView::OnEnChangeEditTrigoutwidth() +{ + // TODO: ÿؼ RICHEDIT ؼ + // ͸֪ͨд CFormView::OnInitDialog() + // CRichEditCtrl().SetEventMask() + // ͬʱ ENM_CHANGE ־㵽С + + // TODO: ڴӿؼ֪ͨ + +} + +void CParaCfgView::OnEnKillfocusEditTrigoutwidth() +{ + // TODO: ڴӿؼ֪ͨ + + CString str; + m_Edit_TrigOutWidth.GetWindowText(str); + LONG TrigOutWidth = (LONG)_tcstol(str, NULL, 10); + + + if(TrigOutWidth<50 || TrigOutWidth>50000) + { + //MessageBox(str, _T("ȷΧ[50,50000]"), MB_ICONWARNING | MB_OK); + AfxMessageBox(L"ȷΧ[50,50000],50"); + if(ADPara.TrigOutWidth<50 || ADPara.TrigOutWidth>50000) + { + ADPara.TrigOutWidth =50; + } + str.Format(_T("%ld"), ADPara.TrigOutWidth); + m_Edit_TrigOutWidth.SetWindowText(str); + } + else + { + ADPara.TrigOutWidth = TrigOutWidth; + } +} + +void CParaCfgView::OnEnKillfocusEditTrigwindow() +{ + // TODO: ڴӿؼ֪ͨ + CString str; + m_Edit_TrigWindow.GetWindowText(str); + LONG TrigWindow = (LONG)_tcstol(str, NULL, 10); + + + if(TrigWindow<0) + { + //MessageBox(str, _T("ڵ0"), MB_ICONWARNING | MB_OK); + AfxMessageBox(L"ڵ0,12.5ns,0~12Ϊ0ns,13~24Ϊ12.5ns,25~49Ϊ25ns"); + if(ADPara.TrigWindow<0) + { + ADPara.TrigWindow =0; + } + str.Format(_T("%ld"), ADPara.TrigWindow); + m_Edit_TrigWindow.SetWindowText(str); + } + else + { + ADPara.TrigWindow = TrigWindow; + } +} + +void CParaCfgView::OnEnKillfocusEditFreqdivision() +{ + // TODO: ڴӿؼ֪ͨ + + + CString str; + m_Edit_FreqDivision.GetWindowText(str); + LONG FreqDivision = (LONG)_tcstol(str, NULL, 10); + + + if(FreqDivision2147483647) + { + //MessageBox(str, _T("ƵΧ[1,2147483647]"), MB_ICONWARNING | MB_OK); + str.Format(L"ƵΧ[%d,2147483647]", gl_ADMainInfo.nMinFreqDivision); + AfxMessageBox(str); + if(ADPara.FreqDivision2147483647) + { + ADPara.FreqDivision =gl_ADMainInfo.nMinFreqDivision; + } + str.Format(_T("%d"), ADPara.FreqDivision); + m_Edit_FreqDivision.SetWindowText(str); + } + else + { + ADPara.FreqDivision = FreqDivision; + } + + gl_lFrequency = gl_ADMainInfo.nBaseRate/ADPara.FreqDivision; + + str.Format(_T("%d"), gl_lFrequency); + m_Edit_Frequency.SetWindowText(str); + + + + float fFrequency = gl_lFrequency/1000000.0; // ȡƵֵ(MHz) + float fTimePixel = float(1000.0 / fFrequency); // ÿ(nS) + float fTimeDiv = fTimePixel*50; // ÿ(ÿΪ50,ÿؼһAD) + + if(fTimeDiv < 1000.0) + str.Format(_T("%7.2f nS/Div"), fTimeDiv); + if(fTimeDiv>=1000.0 && fTimeDiv<1000000.0) + str.Format(_T("%7.2f uS/Div"), fTimeDiv/1000); + if(fTimeDiv>=1000000.0 && fTimeDiv<1000000000.0) + str.Format(_T("%7.2f mS/Div"), fTimeDiv/1000000); + if(fTimeDiv >= 1000000000.0) + str.Format(_T("%7.2f S/Div"), fTimeDiv/1000000000); + // ״̬ķʱ + CStatic *pStatic = (CStatic *)m_pADFrm->m_wndShowStatus.GetDlgItem(IDC_STATIC_TimeOfDiv); + pStatic->SetWindowText(str); +} + +void CParaCfgView::OnEnKillfocusEditFrequency() +{ + // TODO: ڴӿؼ֪ͨ + + + CString str; + m_Edit_Frequency.GetWindowText(str); + LONG Frequency = (LONG)_tcstol(str, NULL, 10); + + + if(Frequency<10 || Frequency>gl_ADMainInfo.nMaxRate) + { + str.Format(L"ƵʷΧ[10,%d]", gl_ADMainInfo.nMaxRate); + AfxMessageBox(str); + if(gl_lFrequency<10 || gl_lFrequency>gl_ADMainInfo.nMaxRate) + { + gl_lFrequency =10; + } + str.Format(_T("%d"), gl_lFrequency); + m_Edit_Frequency.SetWindowText(str); + } + else + { + gl_lFrequency = Frequency; + } + + ADPara.FreqDivision = gl_ADMainInfo.nBaseRate/gl_lFrequency; + str.Format(_T("%d"), ADPara.FreqDivision); + m_Edit_FreqDivision.SetWindowText(str); + + if ((ADPara.FreqDivision*gl_lFrequency) != gl_ADMainInfo.nBaseRate) + { + OnEnKillfocusEditFreqdivision(); + } + + + float fFrequency = gl_lFrequency/1000000.0; // ȡƵֵ(MHz) + float fTimePixel = float(1000.0 / fFrequency); // ÿ(nS) + float fTimeDiv = fTimePixel*50; // ÿ(ÿΪ50,ÿؼһAD) + + if(fTimeDiv < 1000.0) + str.Format(_T("%7.2f nS/Div"), fTimeDiv); + if(fTimeDiv>=1000.0 && fTimeDiv<1000000.0) + str.Format(_T("%7.2f uS/Div"), fTimeDiv/1000); + if(fTimeDiv>=1000000.0 && fTimeDiv<1000000000.0) + str.Format(_T("%7.2f mS/Div"), fTimeDiv/1000000); + if(fTimeDiv >= 1000000000.0) + str.Format(_T("%7.2f S/Div"), fTimeDiv/1000000000); + // ״̬ķʱ + CStatic *pStatic = (CStatic *)m_pADFrm->m_wndShowStatus.GetDlgItem(IDC_STATIC_TimeOfDiv); + pStatic->SetWindowText(str); + + +} + +void CParaCfgView::OnCbnSelchangeComboTimebaseclock() +{ + // TODO: ڴӿؼ֪ͨ + ADPara.TimeBaseClock = m_Combo_TimeBaseClock.GetCurSel(); + if(ADPara.TimeBaseClock == ACTS1000_TBCLK_IN) + { + m_Edit_Frequency.EnableWindow(TRUE); + m_Combo_ReferenceClock.EnableWindow(TRUE); + } + else + { + m_Edit_Frequency.EnableWindow(FALSE); + m_Combo_ReferenceClock.EnableWindow(FALSE); + } +} + +void CParaCfgView::OnCbnSelchangeComboSamplemode() +{ + // TODO: ڴӿؼ֪ͨ + ADPara.SampleMode = m_ComBo_SampleMode.GetCurSel(); + + if (ADPara.SampleMode == ACTS1000_SAMPMODE_CONTINUOUS) + { + if (ADPara.TriggerMode==ACTS1000_TRIGMODE_MIDL || ADPara.TriggerMode==ACTS1000_TRIGMODE_PRE) + { + AfxMessageBox(L" ģʽֻΪ󴥷Ӳʱ!"); + m_ComBo_TriggerMode.SetCurSel(ACTS1000_TRIGMODE_POST); + + ADPara.TriggerMode = ACTS1000_TRIGMODE_POST; + } + ADPara.TrigCount = 1; + m_Edit_TrigCount.SetWindowText(L"1"); + } + EnableWindows(TRUE); + +} + +void CParaCfgView::OnCbnSelchangeComboPfisel() +{ + // TODO: ڴӿؼ֪ͨ + + ADPara.PFISel = m_Combo_PFISel.GetCurSel(); + + if ((ADPara.PFISel == ACTS1000_PFISEL_TRIG_OUT) || (gl_ADMainInfo.nSupportPFI==0)) + { + m_Check_bTrigOutEn.EnableWindow(TRUE); + if (m_Check_bTrigOutEn.GetCheck() == TRUE) + { + m_Combo_TrigOutPolarity.EnableWindow(TRUE); + m_Edit_TrigOutWidth.EnableWindow(TRUE); + } + else + { + m_Combo_TrigOutPolarity.EnableWindow(FALSE); + m_Edit_TrigOutWidth.EnableWindow(FALSE); + } + } + else{ + m_Check_bTrigOutEn.EnableWindow(FALSE); + m_Combo_TrigOutPolarity.EnableWindow(FALSE); + m_Edit_TrigOutWidth.EnableWindow(FALSE); + } +} + +void CParaCfgView::OnBnClickedCheckbsavefile() +{ + // TODO: ڴӿؼ֪ͨ + + ADPara.bSaveFile = m_Check_bSaveFile.GetCheck(); + m_Edit_FilePath.EnableWindow(ADPara.bSaveFile); +} + +void CParaCfgView::OnEnKillfocusEditFilepath() +{ + // TODO: ڴӿؼ֪ͨ + CString str; + m_Edit_FilePath.GetWindowText(str); + + _stprintf_s(ADPara.chFileName, 256, _T("%s"), str); + +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ParaCfgView.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ParaCfgView.h new file mode 100644 index 0000000..ce26021 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ParaCfgView.h @@ -0,0 +1,179 @@ +#if !defined(AFX_ParaCfgView_H__6F78B8A1_CC79_11D6_B1D2_CF0B5E784620__INCLUDED_) +#define AFX_ParaCfgView_H__6F78B8A1_CC79_11D6_B1D2_CF0B5E784620__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ParaCfgView.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CParaCfgView form view + +#ifndef __AFXEXT_H__ +#include +#endif + +#include "ADFrm.h" +#include "afxwin.h" +#include "AIChanList.h" +#include "ADDoc.h" +class CParaCfgView : public CFormView +{ +protected: + CParaCfgView(); // protected constructor used by dynamic creation + DECLARE_DYNCREATE(CParaCfgView) + +public: + CADFrame* m_pADFrm; + BOOL m_bErrorDlg; +// Form Data +public: + //{{AFX_DATA(CParaCfgView) + enum { IDD = CG_IDD_ADCHANNEL }; + CEdit m_Edit_TrigInterva; + CButton m_Check_TimerTrig; + CButton m_Button_SoftTirg; + CComboBox m_Combo_SyncTrigSignal; + CButton m_Check_bMasterEn; + CButton m_Check_bClkOutEn; + CButton m_Check_bTrigOutEn; + CEdit m_Edit_nSampleLenth; + //CButton m_Check_bAvailableTrig; + CEdit m_Edit_TrigLevelVolt; + CEdit m_Edit_TrigCount; + CEdit m_Edit_TrigWindow; + CEdit m_Edit_FreqDivision; + CEdit m_Edit_Frequency; + CEdit m_Edit_TrigOutWidth; + CEdit m_Edit_N_Length; + CEdit m_Edit_M_Length; + CComboBox m_Combo_ReferenceClock; + CComboBox m_Combo_TrigOutPolarity; + CComboBox m_Combo_ClkOutSel; + CComboBox m_ComBo_TriggerMode; + + CComboBox m_Combo_SampleLenth; + CComboBox m_Combo_TriggerDir; + CComboBox m_Combo_TriggerSource; + CStatic m_Static_Offset; + CSpinButtonCtrl m_Spin_BufferID; + CSliderCtrl m_Slider_Offset; + CEdit m_Edit_BufferID; + CButton m_Check_Auto; + LONG m_TrigLevelVolt; + CAIChanList m_List_CHParam; + //}}AFX_DATA + +// Attributes +public: + + long Array[80]; + int CountItem; + BOOL m_bInitial; + SCROLLINFO si; + long cyChar; + int iVertPos; + int m_nBits; + int m_nChannelDataBit; + LONG m_lSingleCH; + +// Operations +public: + void EnableVootRange(); + void StartAD(); + void SetInputRangeComboSel(int* pInputRange); + + void EnableWindows(BOOL Flag=TRUE); +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CParaCfgView) + public: + virtual void OnInitialUpdate(); + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); + //}}AFX_VIRTUAL + +// Implementation +protected: + virtual ~CParaCfgView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + // Generated message map functions + //{{AFX_MSG(CParaCfgView) + afx_msg void OnSelchangeCOMBOTriggerSource(); + afx_msg void OnKillFocus(CWnd* pNewWnd); + afx_msg void OnSelchangeCOMBOOutTriggerDir(); + afx_msg void OnCustomdrawSLIDEROffset(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnChangeEDITBufferID(); + afx_msg void OnCHECKAuto(); + afx_msg void OnSelchangeCOMBOVoltRange(); + afx_msg void OnSelchangeCOMBOTriggerMode(); +// afx_msg void OnKillfocusCOMBObAvailableTrig(); + afx_msg void OnSelchangeCOMBOReferenceClock(); +// afx_msg void OnCHECKbAvailableTrig(); + afx_msg void OnChangeEDITTrigLevelVolt(); + afx_msg void OnChangeEDITMLength(); + afx_msg void OnChangeEDITNLength(); + afx_msg void OnCHECKbMasterEn(); + afx_msg void OnCHECKbClkOutEn(); + afx_msg void OnCHECKbTrigOutEn(); + afx_msg void OnSelchangeCOMBOSyncTrigSignal(); + afx_msg void OnBUTTONSoftTirg(); + afx_msg void OnKillfocusEDITTrigInterval(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnEnKillfocusEditMLength(); +public: + afx_msg void OnEnKillfocusEditNLength(); + afx_msg void OnCheckCh(); + afx_msg void OnEnChangeEditTrigcount(); + afx_msg void OnEnChangeEditTrigWindow(); +public: + afx_msg void OnCbnSelchangeComboClkoutsel(); +public: + afx_msg void OnCbnSelchangeComboTrigoutpolarity(); +public: + afx_msg void OnEnChangeEditTrigoutwidth(); +public: + afx_msg void OnEnKillfocusEditTrigoutwidth(); +public: + afx_msg void OnEnKillfocusEditTrigwindow(); +public: + afx_msg void OnEnKillfocusEditFreqdivision(); +public: + afx_msg void OnEnKillfocusEditFrequency(); +public: + CComboBox m_Combo_TimeBaseClock; +public: + afx_msg void OnCbnSelchangeComboTimebaseclock(); +public: + CComboBox m_ComBo_SampleMode; +public: + afx_msg void OnCbnSelchangeComboSamplemode(); +public: + CComboBox m_Combo_PFISel; +public: + afx_msg void OnCbnSelchangeComboPfisel(); +public: + CButton m_Check_bSaveFile; +public: + CEdit m_Edit_FilePath; +public: + afx_msg void OnBnClickedCheckbsavefile(); +public: + afx_msg void OnEnKillfocusEditFilepath(); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ParaCfgView_H__6F78B8A1_CC79_11D6_B1D2_CF0B5E784620__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/PopupMenu.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/PopupMenu.cpp new file mode 100644 index 0000000..9bab2c5 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/PopupMenu.cpp @@ -0,0 +1,630 @@ +// PopupMenu.cpp: implementation of the CPopupMenu class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "PopupMenu.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#define new DEBUG_NEW +#endif + +#ifndef OBM_CHECK +#define OBM_CHECK 32760 // from winuser.h +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CPopupMenu::CPopupMenu() +{ + crMenuText = GetSysColor(COLOR_MENUTEXT); + crMenuTextSel = GetSysColor(COLOR_HIGHLIGHTTEXT); + + cr3dFace = GetSysColor(COLOR_3DFACE); + crMenu = GetSysColor(COLOR_MENU); + crHighlight = GetSysColor(COLOR_HIGHLIGHT); + cr3dHilight = GetSysColor(COLOR_3DHILIGHT); + cr3dShadow = GetSysColor(COLOR_3DSHADOW); + crGrayText = GetSysColor(COLOR_GRAYTEXT); + + m_clrBtnFace = GetSysColor(COLOR_BTNFACE); + m_clrBtnHilight = GetSysColor(COLOR_BTNHILIGHT); + m_clrBtnShadow = GetSysColor(COLOR_BTNSHADOW); + + iSpawnItem = 0; + pSpawnItem = NULL; + + iImageItem = 0; + pImageItem = NULL; + + szImage = CSize(20, 20); + + hMenuFont = NULL; + + NONCLIENTMETRICS ncm; + memset(&ncm, 0, sizeof(ncm)); + ncm.cbSize = sizeof(ncm); + + ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, static_cast(&ncm), 0); + + hGuiFont = ::CreateFontIndirect(&ncm.lfMenuFont); + + // David 08/04/98 - start - bold font handling + hMenuBoldFont = NULL; + CreateBoldFont(); + // David 08/04/98 - end - bold font handling +} + +CPopupMenu::~CPopupMenu() +{ + if (iSpawnItem > 0) + { + for (int t = 0; t < iSpawnItem; t++) + { + if (pSpawnItem[t]) + delete pSpawnItem[t]; + } + + GlobalFree(static_cast(pSpawnItem)); + } + if (iImageItem > 0) + { + GlobalFree(static_cast(pImageItem)); + } + if (hMenuFont) + ::DeleteObject(static_cast(hMenuFont)); + if (hMenuBoldFont) + ::DeleteObject(static_cast(hMenuBoldFont)); +} + +void CPopupMenu::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + // CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); + // CRect rcItem(lpDrawItemStruct->rcItem); + // pDC->FillSolidRect(rcItem, RGB(255,0,0)); + if (lpDrawItemStruct->CtlType == ODT_MENU) + { + UINT state = lpDrawItemStruct->itemState; + BOOL bEnab = !(state & ODS_DISABLED); + BOOL bSelect = (state & ODS_SELECTED) ? TRUE : FALSE; + BOOL bChecked = (state & ODS_CHECKED) ? TRUE : FALSE; + // David 08/04/98 - start - bold font handling + BOOL bBold = (state & ODS_DEFAULT) ? TRUE : FALSE; + // David 08/04/98 - end - bold font handling + + SpawnItem* pItem = reinterpret_cast(lpDrawItemStruct->itemData); + if (pItem) + { + CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); + CFont* pft; + // David 08/04/98 - start - bold font handling + if (!bBold) + pft = CFont::FromHandle(static_cast(hMenuFont) ? hMenuFont : hGuiFont); + else + pft = CFont::FromHandle(static_cast(hMenuBoldFont) ? hMenuBoldFont : hGuiFont); + // David 08/04/98 - end - bold font handling + CFont* of = pDC->SelectObject(pft); + + CRect rc(lpDrawItemStruct->rcItem); + CRect rcImage(rc), rcText(rc); + rcImage.right = rcImage.left + rc.Height(); + rcImage.bottom = rc.bottom; + + if (pItem->iCmd == -3) // is a separator + { + CPen pnDk(PS_SOLID, 1, cr3dShadow); + CPen pnLt(PS_SOLID, 1, cr3dHilight); + CPen * opn = pDC->SelectObject(&pnDk); + pDC->MoveTo(rc.left + 2, rc.top + 2); + pDC->LineTo(rc.right - 2, rc.top + 2); + pDC->SelectObject(&pnLt); + pDC->MoveTo(rc.left + 2, rc.top + 3); + pDC->LineTo(rc.right - 2, rc.top + 3); + pDC->SelectObject(opn); + } + else if (pItem->iCmd == -4) // is a title item + { + CString cs(pItem->cText), cs1; + CRect rcBdr(rcText); + + if (bSelect && bEnab) + { + rcText.top ++; + rcText.left += 2; + } + pDC->FillSolidRect(rcText, crMenu); + pDC->DrawText(cs, rcText, DT_VCENTER | DT_CENTER | DT_SINGLELINE); + if (bSelect && bEnab) + pDC->Draw3dRect(rcBdr, cr3dShadow, cr3dHilight); + } + else + { + rcText.left += rcImage.right + 1; + + int obk = pDC->SetBkMode(TRANSPARENT); + + COLORREF ocr; + if (bSelect) + { + if (pItem->iImageIdx >= 0 || (state & ODS_CHECKED)) + pDC->FillSolidRect(rcText, crHighlight); + else + pDC->FillSolidRect(rc, crHighlight); + + ocr = pDC->SetTextColor(crMenuTextSel); + } + else + { + if (pItem->iImageIdx >= 0 || (state & ODS_CHECKED)) + pDC->FillSolidRect(rcText, crMenu); + else + pDC->FillSolidRect(rc/*rcText*/, crMenu); + ocr = pDC->SetTextColor(crMenuText); + } + + if (pItem->iImageIdx >= 0) + { + int ay = (rcImage.Height() - szImage.cy) / 2; + int ax = (rcImage.Width() - szImage.cx) / 2; + + if (bSelect && bEnab) + pDC->Draw3dRect(rcImage, cr3dHilight, cr3dShadow); + else + { + pDC->Draw3dRect(rcImage, crMenu, crMenu); + } + + + if (bEnab) + { + ilList.Draw(pDC, pItem->iImageIdx, CPoint(rcImage.left + ax, + rcImage.top +ay), ILD_NORMAL); + } + else + { + HICON hIcon = ilList.ExtractIcon(pItem->iImageIdx); + pDC->DrawState(CPoint(rcImage.left + ax, rcImage.top + ay), szImage, + static_cast(hIcon), DST_ICON | DSS_DISABLED, + static_cast(NULL)); + } + } + else + { + /* + if (bChecked) + { + int ay = (rcImage.Height() - szImage.cy) / 2; + int ax = (rcImage.Width() - szImage.cx) / 2; + + ilOther.Draw(pDC, 0, CPoint(rcImage.left + ax, rcImage.top + ay - 2), ILD_NORMAL); + } + */ + if (bChecked) + { + CRect rcTemp = rcImage; + rcTemp.DeflateRect(2, 2); + DrawCheckmark(*pDC, rcTemp, bSelect); + } + + if (bSelect || lpDrawItemStruct->itemAction == ODA_SELECT) + { + COLORREF colorBG = GetSysColor(bSelect ? COLOR_HIGHLIGHT : COLOR_MENU); + // selected or selection state changed: paint text background + CRect rcBG(lpDrawItemStruct->rcItem); // the whole rectangle + rcBG.left += rcImage.Width(); // do not paint over it! + CBrush brush(colorBG); + CBrush* pOldBrush = pDC->SelectObject(&brush); + pDC->PatBlt(rcBG.left, rcBG.top, rcBG.Width(), rcBG.Height(), PATCOPY); + pDC->SelectObject(pOldBrush); + } + + } + + CString cs(pItem->cText), cs1; + CSize sz; + sz = pDC->GetTextExtent(cs); + int ay1 = (rcText.Height() - sz.cy) / 2; + rcText.top += ay1; + rcText.left += 2; + rcText.right -= 15; + + int tf = cs.Find('\t'); + if (tf >= 0) + { + cs1 = cs.Right(cs.GetLength() - tf - 1); + cs = cs.Left(tf); + if (!bEnab) + { + if (!bSelect) + { + CRect rcText1(rcText); + rcText1.InflateRect(-1, - 1); + pDC->SetTextColor(cr3dHilight); + pDC->DrawText(cs, rcText1, DT_VCENTER | DT_LEFT); + pDC->DrawText(cs1, rcText1, DT_VCENTER | DT_RIGHT); + pDC->SetTextColor(crGrayText); + pDC->DrawText(cs, rcText, DT_VCENTER | DT_LEFT); + pDC->DrawText(cs1, rcText, DT_VCENTER | DT_RIGHT); + } + else + { + pDC->SetTextColor(crMenu); + pDC->DrawText(cs, rcText, DT_VCENTER | DT_LEFT); + pDC->DrawText(cs1, rcText, DT_VCENTER | DT_RIGHT); + } + } + else + { + pDC->DrawText(cs, rcText, DT_VCENTER | DT_LEFT); + pDC->DrawText(cs1, rcText, DT_VCENTER | DT_RIGHT); + } + } + else + { + if (!bEnab) + { + if (!bSelect) + { + CRect rcText1(rcText); + rcText1.InflateRect(-1, - 1); + pDC->SetTextColor(cr3dHilight); + pDC->DrawText(cs, rcText1, DT_VCENTER | DT_LEFT | DT_EXPANDTABS); + pDC->SetTextColor(crGrayText); + pDC->DrawText(cs, rcText, DT_VCENTER | DT_LEFT | DT_EXPANDTABS); + } + else + { + pDC->SetTextColor(crMenu); + pDC->DrawText(cs, rcText, DT_VCENTER | DT_LEFT | DT_EXPANDTABS); + } + } + else + pDC->DrawText(cs, rcText, DT_VCENTER | DT_LEFT | DT_EXPANDTABS); + } + pDC->SetTextColor(ocr); + pDC->SetBkMode(obk); + } + + pDC->SelectObject(of); + } + } +} + +void CPopupMenu::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + // lpMeasureItemStruct->itemWidth = 200; + // lpMeasureItemStruct->itemHeight = 25; + if (lpMeasureItemStruct->CtlType == ODT_MENU) + { + SpawnItem* pItem = reinterpret_cast(lpMeasureItemStruct->itemData); + if (pItem) + { + if (pItem->iCmd == -3) // is a separator + { + lpMeasureItemStruct->itemWidth = 10; + lpMeasureItemStruct->itemHeight = 6; + } + else + { + CString cs(pItem->cText); + if (!cs.IsEmpty()) + { + CClientDC dc(AfxGetMainWnd()); + CFont* pft = CFont::FromHandle(hMenuFont ? hMenuFont : hGuiFont); + CFont* of = dc.SelectObject(pft); + CSize osz = dc.GetOutputTabbedTextExtent(cs, 0, NULL); + if (pItem->iCmd == -4) + { + CRect rci(0, 0, 0, 0); + dc.DrawText(cs, rci, DT_CALCRECT | DT_TOP | DT_VCENTER | DT_SINGLELINE); + lpMeasureItemStruct->itemHeight = rci.Height(); + lpMeasureItemStruct->itemWidth = rci.Width(); + } + else + { + lpMeasureItemStruct->itemHeight = szImage.cy + 5; + if (osz.cy > static_cast(lpMeasureItemStruct->itemHeight)) + lpMeasureItemStruct->itemHeight = static_cast(osz.cy); + lpMeasureItemStruct->itemWidth = osz.cx + 2 + 15; + lpMeasureItemStruct->itemWidth += lpMeasureItemStruct->itemHeight > static_cast(szImage.cx) + ? static_cast(lpMeasureItemStruct->itemHeight) : static_cast(szImage.cx); + } + dc.SelectObject(of); + } + else + { + lpMeasureItemStruct->itemHeight = szImage.cy + 5; + lpMeasureItemStruct->itemWidth = 100; + } + } + } + } +} + +BOOL CPopupMenu::CreateBoldFont() +{ + if (hMenuBoldFont) + ::DeleteObject(static_cast(hMenuBoldFont)); + + LOGFONT lgFont; + ::GetObject (hMenuFont ? hMenuFont : hGuiFont, sizeof(lgFont), &lgFont); + lgFont.lfWeight = FW_BOLD; + + hMenuBoldFont = CreateFontIndirect(&lgFont); + return !!hMenuBoldFont; +} + +BOOL CPopupMenu::AddToolBarResource(UINT resId) +{ + // David 08/04/98 - start - put CMenuSpawn in DLL + HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(resId), RT_TOOLBAR); + if (!hInst) + return FALSE; + // David 08/04/98 - end - put CMenuSpawn in DLL + + HRSRC hRsrc = ::FindResource(/*AfxGetResourceHandle()*/hInst, MAKEINTRESOURCE(resId), RT_TOOLBAR); + if (hRsrc == NULL) + return FALSE; + + HGLOBAL hGlb = ::LoadResource(/*AfxGetResourceHandle()*/hInst, hRsrc); + if (hGlb == NULL) + return FALSE; + + + ToolBarData* pTBData = static_cast(::LockResource(hGlb)); + if (pTBData == NULL) + return FALSE; + + ASSERT(pTBData->wVersion == 1); + + CBitmap bmp; + bmp.LoadBitmap(resId); + int nBmpItems = ilList.Add(&bmp, RGB(192, 192, 192)); + bmp.DeleteObject(); + + WORD* pItem = reinterpret_cast(pTBData + 1); + + for (int i = 0; i < pTBData->wItemCount; i++, pItem++) + { + if (*pItem != ID_SEPARATOR) + AddImageItem(nBmpItems++, static_cast(*pItem)); + } + // ** it seem that Windows doesn't free these resource (from Heitor Tome) + ::UnlockResource(hGlb); + ::FreeResource(hGlb); + // ** + return TRUE; +} + +BOOL CPopupMenu::LoadToolBarResource(UINT resId) +{ + + // Ӷ̬⣨.Dll .ExeѰԴʵ + HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(resId), RT_TOOLBAR); + // Դ + if (!hInst) + return FALSE; + + // ѰԴ + HRSRC hRsrc = ::FindResource(/*AfxGetResourceHandle()*/hInst, MAKEINTRESOURCE(resId), RT_TOOLBAR); + if (hRsrc == NULL) + return FALSE; + // Դ䷵ָ + HGLOBAL hGlb = ::LoadResource(/*AfxGetResourceHandle()*/hInst, hRsrc); + if (hGlb == NULL) + return FALSE; + // ToolBarDataΪԶ塣˴Դ + ToolBarData* pTBData = static_cast(::LockResource(hGlb)); + if (pTBData == NULL) + return FALSE; + + ASSERT(pTBData->wVersion == 1); + + // + szImage.cx = static_cast(pTBData->wWidth); + szImage.cy = static_cast(pTBData->wHeight); + // λͼб + if (ilList.Create(szImage.cx, szImage.cy, ILC_COLOR4 | ILC_MASK, pTBData->wItemCount, 0) == FALSE) + return FALSE; + // λͼıɫ + ilList.SetBkColor(cr3dFace); + + // Ϊ˳ʼλͼб + + CBitmap bmp; + // װλͼԴ + bmp.LoadBitmap(resId); + // λͼбмλͼ + ilList.Add(&bmp, RGB(0, 192, 192)); + bmp.DeleteObject(); + + WORD* pItem = reinterpret_cast(pTBData + 1); + int nBmpItems = 0; + for (int i = 0; i < pTBData->wItemCount; i++, pItem++) + { + if (*pItem != ID_SEPARATOR) + AddImageItem(nBmpItems++, static_cast(*pItem)); + } + // ** it seem that Windows doesn't free these resource (from Heitor Tome) + ::UnlockResource(hGlb); + ::FreeResource(hGlb); + // ** + return TRUE; +} + +void CPopupMenu::AddImageItem(const int idx, WORD cmd) +{ + + if (iImageItem == 0) + pImageItem = static_cast(GlobalAlloc(GPTR, sizeof(ImageItem))); + else + pImageItem = static_cast(GlobalReAlloc(static_cast(pImageItem), + sizeof(ImageItem) * (iImageItem + 1), GMEM_MOVEABLE | GMEM_ZEROINIT)); + + ASSERT(pImageItem); + pImageItem[iImageItem].iCmd = static_cast(cmd); + pImageItem[iImageItem].iImageIdx = idx; + iImageItem ++; +} + +void CPopupMenu::RemapMenu(CMenu* pMenu) +{ + static int iRecurse = 0; + iRecurse ++; + + ASSERT(pMenu); + int nItem = pMenu->GetMenuItemCount(); + while ((--nItem) >= 0) + { + UINT itemId = pMenu->GetMenuItemID(nItem); + if (itemId == static_cast(-1)) + { + CMenu* pops = pMenu->GetSubMenu(nItem); + if (pops) + RemapMenu(pops); + if (iRecurse > 0) + { + CString cs; + pMenu->GetMenuString(nItem, cs, MF_BYPOSITION); + if (cs != "") + { + SpawnItem* sp = AddSpawnItem(cs, (iRecurse == 1) ? -4 : -2); + pMenu->ModifyMenu(nItem, MF_BYPOSITION | MF_OWNERDRAW, + static_cast(-1), reinterpret_cast(sp)); + } + } + } + else + { + if (itemId != 0) + { + UINT oldState = pMenu->GetMenuState(nItem, MF_BYPOSITION); + if (!(oldState & MF_OWNERDRAW) && !(oldState & MF_BITMAP)) + { + ASSERT(oldState != (UINT) - 1); + CString cs; + pMenu->GetMenuString(nItem, cs, MF_BYPOSITION); + SpawnItem* sp = AddSpawnItem(cs, itemId); + pMenu->ModifyMenu(nItem, MF_BYPOSITION | MF_OWNERDRAW | oldState, + static_cast(itemId), reinterpret_cast(sp)); + } + } + else + { + UINT oldState = pMenu->GetMenuState(nItem, MF_BYPOSITION); + if (!(oldState & MF_OWNERDRAW) && !(oldState & MF_BITMAP)) + { + ASSERT(oldState != static_cast(-1)); + SpawnItem* sp = AddSpawnItem(_T("--"), -3); + pMenu->ModifyMenu(nItem, MF_BYPOSITION | MF_OWNERDRAW | oldState, + static_cast(itemId), reinterpret_cast(sp)); + } + } + } + } + iRecurse --; +} + +CPopupMenu::SpawnItem * CPopupMenu::AddSpawnItem(const TCHAR* txt, const int cmd) +{ + if (iSpawnItem == 0) + pSpawnItem = static_cast(GlobalAlloc(GPTR, sizeof(SpawnItem))); + else + pSpawnItem = static_cast(GlobalReAlloc(static_cast(pSpawnItem), + sizeof(SpawnItem) * (iSpawnItem + 1), GMEM_MOVEABLE | GMEM_ZEROINIT)); + + ASSERT(pSpawnItem); + + SpawnItem* p = new SpawnItem; + ASSERT(p); + pSpawnItem[iSpawnItem] = p; + _tcscpy(p->cText, txt); + p->iCmd = cmd; + + if (cmd >= 0) + p->iImageIdx = FindImageItem(cmd); + else p->iImageIdx = cmd; + + iSpawnItem++; + return p; +} + +int CPopupMenu::FindImageItem(const int cmd) +{ + for (int t = 0; t < iImageItem; t++) + { + if (pImageItem[t].iCmd == cmd) + return pImageItem[t].iImageIdx; + } + return -1; +} + +void CPopupMenu::EnableMenuItems(CMenu* pMenu, CWnd* pParent) +{ + ASSERT(pMenu); + ASSERT(pParent); + + int nItem = pMenu->GetMenuItemCount(); + CCmdUI state; + state.m_pMenu = pMenu; + state.m_nIndex = nItem - 1; + state.m_nIndexMax = nItem; + + while ((--nItem) >= 0) + { + UINT itemId = pMenu->GetMenuItemID(nItem); + if (itemId == static_cast(-1)) + { + CMenu* pops = pMenu->GetSubMenu(nItem); + if (pops) + EnableMenuItems(pops, pParent); + } + else + { + if (itemId != 0) + { + state.m_nID = itemId; + pParent->OnCmdMsg(itemId, CN_UPDATE_COMMAND_UI, &state, NULL); + state.DoUpdate(pParent, TRUE); + } + } + state.m_nIndex = nItem - 1; + } +} + +BOOL CPopupMenu::DrawCheckmark(CDC& dc, const CRect& rc, BOOL bSelected) +{ + // Use Windows standard + HBITMAP hbmCheck = ::LoadBitmap(NULL, reinterpret_cast(OBM_CHECK)); + + // Center bitmap in distination rectangle + BITMAP bm; + ::GetObject(hbmCheck, sizeof(bm), &bm); + int cx = bm.bmWidth; + int cy = bm.bmHeight; + + CRect rcDest = rc; + CPoint ptSrc = -CPoint((rc.Width() - cx)/2, (rc.Height() - cy)/2); + + // Select checkmark into memory DC + CDC memdc; + memdc.CreateCompatibleDC(&dc); + HBITMAP hOldBM = reinterpret_cast(::SelectObject(memdc, hbmCheck)); + + // Set background color based on selected state + COLORREF colorOld = dc.SetBkColor(GetSysColor(bSelected ? COLOR_MENU : COLOR_3DLIGHT)); + dc.BitBlt(rcDest.left, rcDest.top, rcDest.Width(), rcDest.Height(), + &memdc, ptSrc.x, ptSrc.y, SRCCOPY); + dc.SetBkColor(colorOld); + + ::SelectObject(memdc, hOldBM); // restore + + // draw pushed-in hilight. + dc.DrawEdge(&rcDest, BDR_SUNKENOUTER, BF_RECT); + + return TRUE; +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/PopupMenu.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/PopupMenu.h new file mode 100644 index 0000000..562b923 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/PopupMenu.h @@ -0,0 +1,75 @@ +// PopupMenu.h: interface for the CPopupMenu class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_POPUPMENU_H__F2CEE8B2_014D_11D2_83E4_0000B43382FE__INCLUDED_) +#define AFX_POPUPMENU_H__F2CEE8B2_014D_11D2_83E4_0000B43382FE__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +class CPopupMenu : public CMenu +{ +public: + struct ToolBarData + { + // struct for toolbar resource; guess you already know it ;) + WORD wVersion; + WORD wWidth; + WORD wHeight; + WORD wItemCount; + }; + struct SpawnItem + { + int iImageIdx; + int iCmd; + TCHAR cText[128]; + }; + struct ImageItem + { + int iImageIdx; + int iCmd; + }; + + CPopupMenu(); + virtual ~CPopupMenu(); + + HFONT hMenuBoldFont; + BOOL CreateBoldFont(); + + HFONT hMenuFont, hGuiFont; + CSize szImage; + int FindImageItem(const int cmd); + + SpawnItem* AddSpawnItem(const TCHAR* txt, const int cmd); + void AddImageItem(const int idx, WORD cmd); + + void RemapMenu(CMenu* pMenu); + + CImageList ilList; + CImageList ilOther; + + COLORREF crMenuText, crMenuTextSel; + COLORREF cr3dFace, crMenu, crHighlight, cr3dHilight, cr3dShadow, crGrayText; + COLORREF m_clrBtnFace, m_clrBtnHilight, m_clrBtnShadow; + + int iSpawnItem; + SpawnItem** pSpawnItem; + + int iImageItem; + ImageItem* pImageItem; + + BOOL LoadToolBarResource(UINT resId); + BOOL AddToolBarResource(UINT resId); + + void EnableMenuItems(CMenu* pMenu, CWnd* pParent); + + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); + +private: + BOOL DrawCheckmark(CDC& dc, const CRect& rc, BOOL bSelected); +}; + +#endif // !defined(AFX_POPUPMENU_H__F2CEE8B2_014D_11D2_83E4_0000B43382FE__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/QSortData.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/QSortData.cpp new file mode 100644 index 0000000..035e946 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/QSortData.cpp @@ -0,0 +1,215 @@ +// QSortData.cpp: implementation of the CQSortData class. +////////////////////////////////////////////////////////////////////// +//******************************************************************* +// +// QSortDataʹ˵ +// ܹSHORTָָһȽָȵ,м(ָ) +// ԭͣCQSortData::Sort(SHORT *data, int left, int right) +// +//******************************************************************* +#include "stdafx.h" +#include "QSortData.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// +CQSortData::CQSortData() +{ + m_SortDir = 0; // + m_DataMiddle.Value = 0; + m_DataMiddle.CountNum = 0; + m_DataTypes = 1; + m_bNewData = FALSE; +} + +CQSortData::~CQSortData() +{ + +} + +int CQSortData::GetMaxData() // ȡ +{ + if(m_bNewData) + { + ProcessData(); + m_bNewData = FALSE; + } + return m_DataMax; +} + +int CQSortData::GetMinData() // ȡС +{ + if(m_bNewData) + { + ProcessData(); + m_bNewData = FALSE; + } + return m_DataMin; +} + +int CQSortData::GetMidData() // ȡм +{ + if(m_bNewData) + { + ProcessData(); + m_bNewData = FALSE; + } + return m_DataMiddle.Value; +} +int CQSortData::GetMidDataCount() +{ + if(m_bNewData) + { + ProcessData(); + m_bNewData = FALSE; + } + return m_DataMiddle.CountNum; +} + +int CQSortData::GetDataTypes() // ֵ +{ + if(m_bNewData) + { + ProcessData(); + m_bNewData = FALSE; + } + return m_DataTypes; +} + +int CQSortData::GetSortDir() // ȡ() +{ + return m_SortDir; +} + +void CQSortData::SetSortDir(int nDir) // (ȱʡΪ =0) +{ + m_SortDir = nDir; +} + +//################################################################# +// dataָָϱΪleftrightԪؽ +void CQSortData::SortAsc(LONG *data, int left, int right) +{ + register int i,j; + LONG m,t; + i=left;j=right; + m=data[(int)(left+right)/2]; + + do{ + while(data[i]left) + j--; + if(i <= j) { //i, j ֵ + t = data[i]; + data[i] = data[j]; + data[j] = t; + i++;j--; + } + }while(i<=j); + if(leftm && idata[j] && j>left) + j--; + if(i<=j) { + t=data[i]; + data[i]=data[j]; + data[j]=t; + i++;j--; + } + }while(i<=j); + if(left m_DataMiddle.CountNum ) + { + m_DataMiddle.CountNum = Result[k].CountNum ; + m_DataMiddle.Value = Result[k].Value ; + } + + k++; + Result[k].Value = Buffer[i]; + Result[k].CountNum = 1; + m_DataTypes++; + } + } + + if(Result[k].CountNum > m_DataMiddle.CountNum ) + { + m_DataMiddle.CountNum = Result[k].CountNum ; + m_DataMiddle.Value = Result[k].Value ; + } + //ûм + if(m_DataMiddle.CountNum == 1) + { + AfxMessageBox(_T("ûм")); + m_DataMiddle.CountNum = 0; + } + + delete [] Result; // ͷŶ̬ڴ + Result = NULL; +} + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/QSortData.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/QSortData.h new file mode 100644 index 0000000..accff82 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/QSortData.h @@ -0,0 +1,50 @@ +// QSortData.h: interface for the CQSortData class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_QSORTDATA_H__05802C51_F215_4B0C_A99D_F1D37D869F96__INCLUDED_) +#define AFX_QSORTDATA_H__05802C51_F215_4B0C_A99D_F1D37D869F96__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#define MAX_BUFFER 8192 // + +typedef struct _SORTCOUNT{ + int Value; + int CountNum; +}SORT_COUNT, *pSORT_COUNT; + +class CQSortData +{ + +public: + CQSortData(); +public: + void SetSortDir(int nDir = 0); + int GetSortDir(); + void Sort(LONG *data,int left,int right); + int GetDataTypes(); + int GetMidDataCount(); + int GetMidData(); + int GetMinData(); + int GetMaxData(); + virtual ~CQSortData(); + +private: + BOOL m_bNewData; + int m_DataMax; // + int m_DataMin; // С + int m_DataTypes; // + int m_SortDir; // () + int nBufferSize; // 趯̬ڴС + SORT_COUNT m_DataMiddle; // м + pSORT_COUNT Result; // _SORTCOUNTṹָ, ָ + LONG * Buffer; +private: + void SortAsc(LONG *data, int left, int right); // + void SortDsc(LONG *data, int left, int right); // + void ProcessData(void); +}; + +#endif // !defined(AFX_QSORTDATA_H__05802C51_F215_4B0C_A99D_F1D37D869F96__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ReadMe.txt b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ReadMe.txt new file mode 100644 index 0000000..ed3d067 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ReadMe.txt @@ -0,0 +1,67 @@ +======================================================================== + ̹˵ +======================================================================== +1򣬶ֻʹòݵĿͻMatLabExcelAccessȷ + ݿĸ߼ûԽ߼Ị̇ͨװ + ӦĴתתΪҪļʽڲҪдκ + ʵһ +2ǿ֧֣óMDIĵͼڶ̶߳๦ģһ + չʾõʵݲɼԡԡɿԡ߱ + ЩܸóȫԴķʽչʾȫ +3ǿĸӶȾͱȻҪӺܶ࣬Ҫô๦ܣֻ + ҹ˾ӿٶȱдԼIJɼƳô + Ӧܵļ׳ֻͨһ򵥵cppļֻʾõ + ̣細ĵȸ⡣ +4̷ADʷݻطģ +5AD:ַʽʾѹֵұͼηʽʾ +6ADѹ̷ֶ൵ڴע⣺ѡ˫ԵѹʱɼADֵ + ɵѹֵʱADԭֵĸλҪ󷴣ԲοADDigitView.cppе + CADDigitView::ADDigit(CDC *pDC) + +======================================================================== + ļ˵ +======================================================================== +ACTS1011.h ӿͷļûѵӦóʱļƵĹУҴļҪĶ +ACTS1011_32.lib ӿڵļûѵӦóʱļƵĹ)32λ +ACTS1011_64.lib ӿڵļûѵӦóʱļƵĹ)64λ + +ADThread.cpp ʹ߳̽ADԴʾ +HistDataDoc.cpp HistDataFrm.cpp HistDataView.cpp ADʷݻطŵԴʾ +DIOView.cpp ʾβ +DAView.cpp ʾβģ +stdafx.h ûԶĸȫֱԶ͵Ϣ +======================================================================== + Ƽ¼ +======================================================================== +2019/04/12 V6.00.00 ʾ LYB + + + + + +======================================================================== + Ҫϵ +======================================================================== +CWinApp + CSysApp + +CMDIFrameWnd + CMDITabFrameWnd + CMainFrame + +CMDIChildWnd + CADFrm + +CDocument + CADDoc + +CScrollView + CADDigitView + CADWaveView + +CFormView + CADParaCfgView + CADStatusView + +CWnd + COScopeCtrl \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ReadMe.txt.bak b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ReadMe.txt.bak new file mode 100644 index 0000000..0a2287c --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/ReadMe.txt.bak @@ -0,0 +1,69 @@ +======================================================================== + ̹˵ +======================================================================== +1򣬶ֻʹòݵĿͻMatLabExcelAccessȷ + ݿĸ߼ûԽ߼Ị̇ͨװ + ӦĴתתΪҪļʽڲҪдκ + ʵһ +2ǿ֧֣óMDIĵͼڶ̶߳๦ģһ + չʾõʵݲɼԡԡɿԡ߱ + ЩܸóȫԴķʽչʾȫ +3ǿĸӶȾͱȻҪӺܶ࣬Ҫô๦ܣֻ + ҹ˾ӿٶȱдԼIJɼƳô + Ӧܵļ׳ֻͨһ򵥵cppļֻʾõ + ̣細ĵȸ⡣ +4̷ADʷݻطģ +5AD:ַʽʾѹֵұͼηʽʾ +6ADѹ̷ֶ൵ڴע⣺ѡ˫ԵѹʱɼADֵ + ɵѹֵʱADԭֵĸλҪ󷴣ԲοADDigitView.cppе + CADDigitView::ADDigit(CDC *pDC) + +======================================================================== + ļ˵ +======================================================================== +ACTS1011.h ӿͷļûѵӦóʱļƵĹУҴļҪĶ +ACTS1011_32.lib ӿڵļûѵӦóʱļƵĹ)32λ +ACTS1011_64.lib ӿڵļûѵӦóʱļƵĹ)64λ + +ADThread.cpp ʹ߳̽ADԴʾ +HistDataDoc.cpp HistDataFrm.cpp HistDataView.cpp ADʷݻطŵԴʾ +DIOView.cpp ʾβ +DAView.cpp ʾβģ +stdafx.h ûԶĸȫֱԶ͵Ϣ +======================================================================== + Ƽ¼ +======================================================================== +2017/03/20 V6.00.00 ʾ LYB +2018/01/19 V6.00.01 ޸Ĵʾ LYB +2018/03/22 V6.00.02 ޸Ĵʾ LYB + + + + + +======================================================================== + Ҫϵ +======================================================================== +CWinApp + CSysApp + +CMDIFrameWnd + CMDITabFrameWnd + CMainFrame + +CMDIChildWnd + CADFrm + +CDocument + CADDoc + +CScrollView + CADDigitView + CADWaveView + +CFormView + CADParaCfgView + CADStatusView + +CWnd + COScopeCtrl \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/AD.ICO b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/AD.ICO new file mode 100644 index 0000000..b0303c4 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/AD.ICO differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Dll.rc2 b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Dll.rc2 new file mode 100644 index 0000000..9dda536 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Dll.rc2 @@ -0,0 +1,13 @@ +// +// DLL.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Hist.ico b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Hist.ico new file mode 100644 index 0000000..b0303c4 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Hist.ico differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/IDR_DIO.ICO b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/IDR_DIO.ICO new file mode 100644 index 0000000..24a92dc Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/IDR_DIO.ICO differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/MainFrm.ico b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/MainFrm.ico new file mode 100644 index 0000000..b0303c4 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/MainFrm.ico differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Sys.rc2 b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Sys.rc2 new file mode 100644 index 0000000..fda5de8 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/Sys.rc2 @@ -0,0 +1,13 @@ +// +// SYS.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/TabImage.bmp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/TabImage.bmp new file mode 100644 index 0000000..902ee04 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Res/TabImage.bmp differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/STDAFX.H b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/STDAFX.H new file mode 100644 index 0000000..bdd5b44 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/STDAFX.H @@ -0,0 +1,44 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__D485DEFF_85AB_11D1_B878_A68EB300DD63__INCLUDED_) +#define AFX_STDAFX_H__D485DEFF_85AB_11D1_B878_A68EB300DD63__INCLUDED_ +#pragma warning(disable:4996) +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#include +#include // MFC Automation classes +#include // MFC support for Internet Explorer 4 Common Controls + +#include +///////////////////////////////// +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + +///////////////////////////////// +// ûӲ +#include "UserDef.h" +#define WM_SHOWWAVE WM_USER+100 +#define WM_SHOWDIGIT WM_USER+101 +#define WM_SET_CTRL_FOCUS WM_USER+107 + +#include "ADHistDoc.h" +#include "ADHistWaveView.h" + + //{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__D485DEFF_85AB_11D1_B878_A68EB300DD63__INCLUDED_) + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/StdAfx.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/StdAfx.cpp new file mode 100644 index 0000000..e30b13c --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// Sys.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" +#pragma comment(lib,"winmm") // ý + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.cpp new file mode 100644 index 0000000..3c9a5cd --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.cpp @@ -0,0 +1,814 @@ +// Sys.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "Sys.h" +#include "MainFrm.h" +#include "ADFrm.h" +#include "ADDoc.h" +#include "ADDigitView.h" +#include "ADWaveView.h" +#include "ADHistFrm.h" +#include "ADHistDoc.h" +#include "ADHistDigitView.h" +#include "ADCalibration.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif +///////////////////////////////////////////////////////////////////////////// +#include "ADStatusView.h" +#include "ParaCfgView.h" +extern CADStatusView* pADStatusView; +extern CParaCfgView* pParaCfgView; +// CSysApp +BEGIN_MESSAGE_MAP(CSysApp, CWinApp) + //{{AFX_MSG_MAP(CSysApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + ON_UPDATE_COMMAND_UI(IDM_CloseFile, OnUpdateCloseFile) + ON_UPDATE_COMMAND_UI(IDM_DataFileNew, OnUpdateDataFileNew) + ON_COMMAND(IDM_CloseFile, OnCloseFile) + ON_COMMAND(IDM_DataFileNew, OnDataFileNew) + ON_COMMAND(IDM_StartDeviceAD, OnStartDeviceAD) + ON_COMMAND(IDM_StopDeviceAD, OnStopDeviceAD) + ON_UPDATE_COMMAND_UI(IDM_StopDeviceAD, OnUpdateStopDeviceAD) + ON_COMMAND(IDM_Open_AD, OnOpenAD) + ON_UPDATE_COMMAND_UI(IDM_Open_AD, OnUpdateOpenAD) + ON_COMMAND(IDM_HistoryData, OnHistoryData) + ON_UPDATE_COMMAND_UI(IDM_HistoryData, OnUpdateHistoryData) + ON_UPDATE_COMMAND_UI(IDM_Open_DA, OnUpdateOpenDA) + ON_UPDATE_COMMAND_UI(IDM_StartDeviceAD, OnUpdateStartDeviceAD) + ON_UPDATE_COMMAND_UI(IDM_MDataSave, OnUpdateDataSave) + ON_UPDATE_COMMAND_UI(IDM_MDigitalShow, OnUpdateDigitalShow) + ON_UPDATE_COMMAND_UI(IDM_MGraphicShow, OnUpdateGraphicShow) + ON_COMMAND(IDM_MDataSave, OnMDataSave) + ON_COMMAND(IDM_MDigitalShow, OnMDigitalShow) + ON_COMMAND(IDM_MGraphicShow, OnMGraphicShow) + ON_COMMAND(IDM_ListDeviceDlg, OnListDeviceDlg) + ON_COMMAND(IDM_ADCalibration, OnADCalibration) + //}}AFX_MSG_MAP + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) + // Standard print setup command + ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSysApp construction + +CSysApp::CSysApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance + m_bCreateADFrm = FALSE; + m_bCreateDAFrm = FALSE; + m_ADFrame = NULL; + m_bDeviceCount = FALSE; +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CSysApp object + +CSysApp theApp; +ULONGLONG gl_ReadSizeWords; // ݳ +ULONGLONG gl_DDR2Lenth; +ULONGLONG gl_pulDDR2Length; + +///////////////////////////////////////////////////////////////////////////// +// CSysApp initialization + +BOOL CSysApp::InitInstance() +{ + + for(int i=0; iLoadFrame(IDR_MAINFRAME)) + return FALSE; + + + m_pMainWnd = pMainFrame; + + + // The main window has been initialized, so show and update it. + // pMainFrame->ShowWindow(m_nCmdShow); + pMainFrame->ShowWindow(SW_SHOWMAXIMIZED); // ʹ + + pMainFrame->UpdateWindow(); + // Enable drag/drop open + m_pMainWnd->DragAcceptFiles(); // ֧ϷŹ + + ::SetProp(m_pMainWnd->GetSafeHwnd(), m_pszExeName, (HANDLE)1); + + LONG nPhyID = 0; + if (m_hDevice != INVALID_HANDLE_VALUE) + { + ACTS1000_GetDeviceCurrentID(m_hDevice, NULL, &nPhyID); + } + CString MainFrmName; TCHAR str[100]; + switch (gl_ADMainInfo.nDeviceType>>16) + { + case PXIE_BUS: + if (m_nRevisionID >= PCIE8502D_RID && m_nRevisionID <0xFF) + { + _stprintf(str, _T("ACTS1000-PXIE%04X(%02X)-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_nRevisionID, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + } + else if (m_nRevisionID == 0) + _stprintf(str, _T("ACTS1000-PXIE%04X-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_CurrentDeviceID, nPhyID, gl_pulDDR2Length); + else + _stprintf(str, _T("ACTS1000-PXIE%04X(%C)-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF,'A'+ m_nRevisionID-1, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + + + + /*if (m_nRevisionID >= PCIE8502D_RID && m_nRevisionID <0xFF) + { + _stprintf(str, _T("ACTS1000-PXIE%04X(%02X)-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_nRevisionID, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + } + else if (m_nRevisionID == 0x01) + { + _stprintf(str, _T("ACTS1000-PXIE%04X(A)-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + } + else + { + _stprintf(str, _T("ACTS1000-PXIE%04X-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_CurrentDeviceID, nPhyID, gl_pulDDR2Length); + }*/ + break; + case PCIE_BUS: + if (m_nRevisionID >= PCIE8502D_RID && m_nRevisionID <0xFF) + { + _stprintf(str, _T("ACTS1000-PCIE%04X(%02X)-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_nRevisionID, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + } + else if (m_nRevisionID == 0) + _stprintf(str, _T("ACTS1000-PCIE%04X-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_CurrentDeviceID, nPhyID, gl_pulDDR2Length); + else + _stprintf(str, _T("ACTS1000-PCIE%04X(%C)-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF,'A'+ m_nRevisionID-1, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + + + /*if (m_nRevisionID >= PCIE8502D_RID && m_nRevisionID <0xFF) + { + _stprintf(str, _T("ACTS1000-PCIE%04X(%02X)-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_nRevisionID, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + } + else if (m_nRevisionID == 0x01) + { + _stprintf(str, _T("ACTS1000-PCIE%04X(A)-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + } + else + { + _stprintf(str, _T("ACTS1000-PCIE%04X-%d-%d[%dM] "), gl_ADMainInfo.nDeviceType&0xFFFF, m_CurrentDeviceID,nPhyID, gl_pulDDR2Length); + }*/ + break; + default: + _stprintf(str, _T("ACTS1000-%04X-%d-[%dM] "), gl_ADMainInfo.nDeviceType, m_CurrentDeviceID,gl_pulDDR2Length); + } + + + MainFrmName = pMainFrame->GetTitle(); + MainFrmName = str+MainFrmName; + pMainFrame->SetTitle(MainFrmName); + + OnOpenAD(); // AD豸 + m_ADFrame->BringWindowToTop(); // ADģĻ + + // ȡòϵͳ汾 + DWORD dwVersion = GetVersion(); + // Get the Windows version. + DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); + // Get the build number. + if ((dwVersion < 0x80000000) || (dwWindowsMajorVersion < 4)) // Windows NT + gl_nSampleMode = DMA_MODE; // DMAʽ + else // Windows Me/98/95 + gl_nSampleMode = PRO_MODE; // ѯʽ + + + gl_nSampleMode = PRO_MODE; // ѯʽ + // CG: This line inserted by 'Tip of the Day' component. + + + return TRUE; +} + + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + // No message handlers + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedButtonSet(); +public: + virtual BOOL OnInitDialog(); +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP + ON_BN_CLICKED(IDC_BUTTON_Set, &CAboutDlg::OnBnClickedButtonSet) +END_MESSAGE_MAP() + +// App command to run the dialog +void CSysApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +///////////////////////////////////////////////////////////////////////////// +// CSysApp message handlers + + + +void CSysApp::OnUpdateOpenAD(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(this->m_bCreateADFrm==FALSE?1:0); +} + +void CSysApp::OnOpenAD(void) +{ + if (m_ADFrame != NULL) + { + m_ADFrame->BringWindowToTop(); + return; + } + BeginWaitCursor(); // ʼ© + CDocument* pDoc; + pDoc=pADTemplate->CreateNewDocument(); // ĵ + m_pADDoc=(CADDoc*)pDoc; // ĵ + // ĵ֡ + m_ADFrame=(CADFrame*)pADTemplate->CreateNewFrame(pDoc, NULL); + // Ĭϵĵ + // ĵʵ + // ʼFRAME֡ڣҴFRAMEOnUpdate + pADTemplate->InitialUpdateFrame(m_ADFrame, pDoc); + pDoc->SetTitle(_T("ADɲ")); + + if(pADStatusView != NULL) + { + pDoc->AddView ((CView*)pADStatusView); + } + if(pParaCfgView != NULL) + { + pDoc->AddView((CView*)pParaCfgView); + } + + EndWaitCursor(); // ֹͣ© +} + +void CSysApp::OnHistoryData() +{ + // TODO: Add your command handler code here + CString strNewFileName; + // ļԻ + if (!(DoPromptFileName(strNewFileName, IDS_ProccessHistoryData, + OFN_HIDEREADONLY , TRUE, NULL))) // OFN_CREATEPROMPT:ļʱǷҪ½ + return; + +// CFile file; +// CFileStatus status; +// if (!file.GetStatus(strNewFileName, status)) +// { +// strNewFileName=strNewFileName+" !"; +// AfxMessageBox(strNewFileName,MB_ICONSTOP, 0); +// return; // ļ +// } + + CFile File; + FILE_HEADER m_Header; + + //File.Open(strNewFileName, GENERIC_READ); + if (!File.Open(strNewFileName, GENERIC_READ)) + { + AfxMessageBox(L"ļʧ"); + return ; + } + File.Seek(0,CFile::begin); + int a =File.Read((WORD*)&m_Header,sizeof(m_Header)); // ļϢHistDigitViewཫHistDataFrmĶԻOnInitialUpdate + File.Close(); + if (a == 0) + { + AfxMessageBox(L"ļСΪ0"); + return; + } + + CADHistDoc* pDoc; + BeginWaitCursor(); // ʼ© + pDoc=(CADHistDoc*)pHistDataTemplate->OpenDocumentFile(strNewFileName); // ȴļpDocϢOnOpenDocument + EndWaitCursor(); // ֹͣ© + +} + +void CSysApp::OnUpdateHistoryData(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + +} + + + +void CSysApp::OnUpdateDataFileNew(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable((!gl_bDeviceADRun)&&m_bFirstCreateDeviceFile); +} + +void CSysApp::OnCloseFile() +{ + // TODO: Add your command handler code here + m_pADDoc->OnCloseFile(); +} + +void CSysApp::OnDataFileNew() +{ + // TODO: Add your command handler code here + m_pADDoc->OnDataFileNew(); +} + +void CSysApp::OnUpdateOpenDA(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here +} + +void CSysApp::OnStartDeviceAD() +{ + // TODO: Add your command handler code here + m_pADDoc->StartDeviceAD(); +} + +void CSysApp::OnUpdateStartDeviceAD(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(gl_bDeviceADRun==FALSE?1:0); +} + +void CSysApp::OnStopDeviceAD() +{ + // TODO: Add your command handler code here + m_pADDoc->StopDeviceAD(); +} + +void CSysApp::OnUpdateStopDeviceAD(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->Enable(gl_bDeviceADRun==TRUE?1:0); +} + +void CSysApp::OnUpdateCloseFile(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetRadio (FALSE); + if((nProcessMode == SAVE_MODE) && (bCreateDevice)) + pCmdUI->Enable(FALSE); + else + pCmdUI->Enable(!m_bCloseFile); +} + +void CSysApp::OnUpdateDataSave(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + if(pADStatusView != NULL) + pADStatusView->SetDlgCheck(); + if(m_bFirstCreateDeviceFile) + pCmdUI->Enable(FALSE); + pCmdUI->SetCheck(nProcessMode == SAVE_MODE ? 1:0); +} + +void CSysApp::OnUpdateDigitalShow(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + pCmdUI->SetCheck(nProcessMode == DATA_MODE ? 1:0); + if(pADStatusView != NULL) + pADStatusView->SetDlgCheck(); + CSysApp *pApp=(CSysApp *)AfxGetApp(); + + CADDoc* pDoc=pApp->m_pADDoc; + // ߳ȡͼָ + CADDigitView* pDigitView=(CADDigitView*)(CWnd::FromHandle(pDoc->m_hWndDigit)); + if(nProcessMode == SAVE_MODE) // Ϊ̷ʽ + { + pDigitView->EnableWindow(FALSE); + } + else + { + pDigitView->EnableWindow(TRUE); + } +} + +void CSysApp::OnUpdateGraphicShow(CCmdUI* pCmdUI) +{ + // TODO: Add your command update UI handler code here + if(pADStatusView != NULL) + pADStatusView->SetDlgCheck(); + pCmdUI->SetCheck(nProcessMode == WAVE_MODE ? 1:0); + CSysApp *pApp=(CSysApp *)AfxGetApp(); + CADDoc* pDoc=pApp->m_pADDoc; + // ߳ȡͼָ + + CADWaveView* pWaveView=(CADWaveView*)(CWnd::FromHandle(pDoc->m_hWndWave)); + + if(nProcessMode == SAVE_MODE) // Ϊ̷ʽ + { + pWaveView->EnableWindow(FALSE); + } + else + { + pWaveView->EnableWindow(TRUE); + } +} + +void CSysApp::OnMDataSave() +{ + // TODO: Add your command handler code here + nProcessMode = SAVE_MODE; + if(pADStatusView != NULL) + pADStatusView->SetDlgCheck(); +} + +void CSysApp::OnMDigitalShow() +{ + // TODO: Add your command handler code here + nProcessMode = DATA_MODE; + if(pADStatusView != NULL) + pADStatusView->SetDlgCheck(); +} + +void CSysApp::OnMGraphicShow() +{ + // TODO: Add your command handler code here + nProcessMode = WAVE_MODE; + if(pADStatusView != NULL) + pADStatusView->SetDlgCheck(); +} + +CDocument* CSysApp::OpenDocumentFile(LPCTSTR lpszFileName) +{ + // TODO: Add your specialized code here and/or call the base class + CString str; +// CFile file; +// CFileStatus status; +// if (!file.GetStatus(lpszFileName, status)) +// { +// str=lpszFileName; +// str=str+" !"; +// AfxMessageBox(lpszFileName,MB_ICONSTOP, 0); +// return NULL; // ļ +// } +// + CFile File; + FILE_HEADER m_Header; + //File.Open(lpszFileName, GENERIC_READ); + if (!File.Open(lpszFileName, GENERIC_READ)) + { + AfxMessageBox(L"ļʧ"); + return NULL; + } + File.Seek(0, CFile::begin); + File.Read((WORD*)&m_Header, sizeof(m_Header)); // ļϢHistDigitViewཫHistDataFrameĶԻOnInitialUpdate + File.Close(); + if(m_Header.DeviceNum != DEFAULT_DEVICE_NUM) + { + if(AfxMessageBox(_T("Բ𣬸ļܽ, Ƿ"),MB_YESNO, 0)==IDNO) + return NULL; + //bFile = FALSE; + } + + CADHistDoc* pDoc; + BeginWaitCursor(); // ʼ© + pDoc=(CADHistDoc*)pHistDataTemplate->OpenDocumentFile(lpszFileName); // ȴļpDocϢOnOpenDocument + str = lpszFileName; + //str="ʷݣ"+ str; + str="ʷݣ"; + pDoc->SetTitle(str); // ĵ± + EndWaitCursor(); // ֹͣ© + return pDoc; + //return CWinApp::OpenDocumentFile(lpszFileName); +} + +void CSysApp::OnListDeviceDlg() +{ + // TODO: Add your command handler code here + ACTS1000_ListDeviceDlg(m_hDevice); // б豸 +} + +int CSysApp::ExitInstance() +{ + // TODO: Add your specialized code here and/or call the base class + + ReleaseMutex(m_hMutex); + if(m_hDevice != INVALID_HANDLE_VALUE) + { + ACTS1000_ReleaseDevice(m_hDevice); + m_hDevice = INVALID_HANDLE_VALUE; + } + for(int i=0; iGetWindowText(str); + nPhysIdx = _tcstoul(str, NULL, 10); + if (nPhysIdx>255) + { + nPhysIdx = 255; + } + + + pEdit = (CEdit*)GetDlgItem(IDC_EDIT_SN); + pEdit->GetWindowText(str); + nSerialNum = _tcstoul(str, NULL, 10); + + pEdit = (CEdit*)GetDlgItem(IDC_EDIT_PassWord); + pEdit->GetWindowText(str); + nPassWord = _tcstoul(str, NULL, 10); + + + + ACTS1000_SetDevicePhysID(theApp.m_hDevice, nPhysIdx); + + ACTS1000_SetPassword(nPassWord); + if (!ACTS1000_SetSerialNum(theApp.m_hDevice, nSerialNum)) + { + AfxMessageBox(L"кʧ"); + } + } +} + +BOOL CAboutDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: ڴӶijʼ + + + + if (theApp.m_hDevice != INVALID_HANDLE_VALUE) + { + CString str; + ULONG nSerialNum; + LONG nPhysIdx, nDeviceLgcID; + ACTS1000_GetDeviceCurrentID(theApp.m_hDevice, &nDeviceLgcID, &nPhysIdx); + ACTS1000_GetSerialNum(theApp.m_hDevice, &nSerialNum); + + CEdit* pEdit; + pEdit = (CEdit*)GetDlgItem(IDC_EDIT_PhysID); + str.Format(L"%u", nPhysIdx); + pEdit->SetWindowText(str); + + pEdit = (CEdit*)GetDlgItem(IDC_EDIT_SN); + str.Format(L"%u", nSerialNum); + pEdit->SetWindowText(str); + + + CString strVer; + ULONG ulFmwVersion, ulDriverVersion; + if (ACTS1000_GetDevVersion(theApp.m_hDevice, &ulFmwVersion, &ulDriverVersion)) + { + CStatic* pStatic; + + pStatic = (CStatic*)GetDlgItem(IDC_STATIC_FmwVersion); + str.Format(_T("%u"),ulFmwVersion); + pStatic->SetWindowText(str); + + pStatic = (CStatic*)GetDlgItem(IDC_STATIC_DriverVersion); + str.Format(_T("%u"),ulDriverVersion); + pStatic->SetWindowText(str); + } + + + } + + return TRUE; // return TRUE unless you set the focus to a control + // 쳣: OCX ҳӦ FALSE +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.rc b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.rc new file mode 100644 index 0000000..8377aad --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.rc @@ -0,0 +1,943 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// (л񹲺͹) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +#pragma code_page(936) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 4, 2\r\n" + "#pragma code_page(936)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\Sys.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""l.chs\\afxres.rc"" // Standard components\r\n" + "#include ""l.chs\\afxprint.rc"" // printing/print preview resources\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR 16, 15 +BEGIN + BUTTON ID_FILE_NEW + BUTTON ID_FILE_OPEN + BUTTON ID_FILE_SAVE + SEPARATOR + BUTTON ID_EDIT_CUT + BUTTON ID_EDIT_COPY + BUTTON ID_EDIT_PASTE + SEPARATOR + BUTTON ID_FILE_PRINT + SEPARATOR + BUTTON ID_APP_ABOUT +END + +IDR_TABVIEW_MENU TOOLBAR 16, 16 +BEGIN + BUTTON ID_VIEW_FULLSCREEN + BUTTON ID_FILE_CLOSE + BUTTON 32775 + BUTTON ID_FILE_SAVE + BUTTON ID_WINDOW_SAVE_ALL + BUTTON ID_FILE_PRINT + BUTTON ID_WINDOW_NEW + BUTTON ID_WINDOW_NEXT + BUTTON ID_WINDOW_PREVIOUS + BUTTON ID_WINDOW_CASCADE + BUTTON ID_WINDOW_TILE_HORZ + BUTTON ID_WINDOW_TILE_VERT + BUTTON ID_WINDOW_MANAGE +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU +BEGIN + POPUP "ļ(&F)" + BEGIN + MENUITEM "ADɲ", IDM_Open_AD + MENUITEM SEPARATOR + MENUITEM "طAD", IDM_HistoryData + MENUITEM SEPARATOR + MENUITEM "ļ", ID_FILE_MRU_FILE1 + MENUITEM SEPARATOR + MENUITEM "˳(&X)", ID_APP_EXIT + END + POPUP "(&H)" + BEGIN + MENUITEM " Sys(&A)...", ID_APP_ABOUT + END +END + +IDR_AD MENU +BEGIN + POPUP "ļ(&F)" + BEGIN + MENUITEM "½ļ", IDM_DataFileNew + MENUITEM "ļ", IDM_HistoryData + MENUITEM "رļ", IDM_CloseFile + MENUITEM SEPARATOR + MENUITEM "ļ", ID_FILE_MRU_FILE1 + MENUITEM SEPARATOR + MENUITEM "رϵͳ", ID_FILE_CLOSE + MENUITEM "˳Ӧó", ID_APP_EXIT + END + POPUP "豸(&M)" + BEGIN + MENUITEM "ʼݲɼ F11", IDM_StartDeviceAD + MENUITEM "ֹͣݲɼ F12", IDM_StopDeviceAD + MENUITEM SEPARATOR + MENUITEM "б豸", IDM_ListDeviceDlg + MENUITEM SEPARATOR + END + POPUP "ݴ(&D)" + BEGIN + MENUITEM "ַʽʾ", IDM_MDigitalShow + MENUITEM "ͼηʽʾ", IDM_MGraphicShow + MENUITEM "ݴ̴", IDM_MDataSave + MENUITEM SEPARATOR + MENUITEM "ʾ", IDM_SuperPoseWave + MENUITEM "ƽʾ", IDM_TileWave + MENUITEM SEPARATOR + MENUITEM "мֵ F5", IDM_MoveVolt + END + POPUP "豸У׼" + BEGIN + MENUITEM "ADУ׼(ע:֧迹Ϊ1MŷУ׼)", IDM_ADCalibration + END + POPUP "ͼ(&V)" + BEGIN + MENUITEM "״̬(&S)", IDM_ShowStatusBar + MENUITEM "/", IDM_ShowCfgAnalBar + END + POPUP "ڹ(&W)" + BEGIN + MENUITEM "(&C)", ID_WINDOW_CASCADE + MENUITEM "ƽ̴(&H)", ID_WINDOW_TILE_HORZ + MENUITEM "ƽ̴(&V)", ID_WINDOW_TILE_VERT + MENUITEM "ͼ(&A)", ID_WINDOW_ARRANGE + END + POPUP "ϵͳ(&H)" + BEGIN + MENUITEM " Sys(&A)...", ID_APP_ABOUT + END +END + +IDR_ChooseMode MENU +BEGIN + POPUP "ʾʽ" + BEGIN + MENUITEM "ʮʾ(ƫ)", IDM_TenShow + MENUITEM "ʮʾ(ԭ)", IDM_SixteenShow + MENUITEM "ѹʾ(ƫ)", IDM_DigitalVoltShowMode + END +END + +IDR_HistoryData MENU +BEGIN + POPUP "ļ(&F)" + BEGIN + MENUITEM "ļ", IDM_HistoryData + MENUITEM SEPARATOR + MENUITEM "ļ", ID_FILE_MRU_FILE1 + MENUITEM SEPARATOR + MENUITEM "ADɲ", IDM_Open_AD + MENUITEM SEPARATOR + MENUITEM "رձϵͳ", ID_FILE_CLOSE + END + POPUP "ݻط" + BEGIN + MENUITEM "ʼط\tF9", IDM_History_Start + MENUITEM "ֹͣط\tF10", IDM_History_Stop + MENUITEM SEPARATOR + MENUITEM "λط", IDM_History_Wave + END + POPUP "ڹ(&W)" + BEGIN + MENUITEM "ˢĻ", IDM_ClearView + MENUITEM SEPARATOR + MENUITEM "(&C)", ID_WINDOW_CASCADE + MENUITEM "ƽ̴(&H)", ID_WINDOW_TILE_HORZ + MENUITEM "ƽ̴(&V)", ID_WINDOW_TILE_VERT + MENUITEM "ͼ(&A)", ID_WINDOW_ARRANGE + END +END + +IDR_HisMouseR MENU +BEGIN + POPUP "ʾʽ" + BEGIN + MENUITEM "ʮʾ(ƫ)", IDM_TenShow + MENUITEM "ʮʾ(ԭ)", IDM_SixteenShow + MENUITEM "ѹʾ(ƫ)", IDM_DigitalVoltShowMode + MENUITEM SEPARATOR + MENUITEM "ˢб", IDM_REFURBISH + END +END + +IDR_ListCHParam MENU +BEGIN + POPUP "ͨ" + BEGIN + MENUITEM "ͬ", 32825 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS +BEGIN + "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + "N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT + "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT + "P", ID_FILE_PRINT, VIRTKEY, CONTROL, NOINVERT + "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT + "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT + VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT + VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT + VK_F10, IDM_History_Stop, VIRTKEY, NOINVERT + VK_F11, IDM_StartDeviceAD, VIRTKEY, NOINVERT + VK_F12, IDM_StopDeviceAD, VIRTKEY, NOINVERT + VK_F5, IDM_MoveVolt, VIRTKEY, NOINVERT + VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT + VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT + VK_F9, IDM_History_Start, VIRTKEY, NOINVERT + VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT + VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT + "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT + "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOGEX 0, 0, 271, 251 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION " Sys" +FONT 9, "", 0, 0, 0x0 +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "Sys V6.00.02 ",IDC_STATIC,40,10,119,8,SS_NOPREFIX + LTEXT "Ȩ (C) 2028",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "ȷ",IDOK,142,219,61,19,WS_GROUP + GROUPBOX "ʾ",IDC_STATIC,13,42,237,80 + LTEXT "F5´˼ɼݽȥͨݵмֵٱʾĻϡĻ赽㹻СʱF5ĹܣŴĻIJƽƵĻ룬Ա۲ݾȡͬʱҲͨʾڸͨԭ㣨㣩LSBݸȷ۲ȡٴΰF5ʱƽƲεȹܡ",IDC_STATIC,24,60,208,57 + LTEXT "ID[0:255]",IDC_STATIC,107,151,55,8 + GROUPBOX "",IDC_STATIC,14,133,234,79 + EDITTEXT IDC_EDIT_PhysID,169,147,56,14,ES_AUTOHSCROLL + LTEXT "к",IDC_STATIC,107,186,55,8 + EDITTEXT IDC_EDIT_SN,169,184,56,14,ES_AUTOHSCROLL + GROUPBOX "",IDC_STATIC,91,137,150,67 + LTEXT "",IDC_STATIC,107,167,55,8 + EDITTEXT IDC_EDIT_PassWord,169,166,56,14,ES_PASSWORD | ES_AUTOHSCROLL + PUSHBUTTON "",IDC_BUTTON_Set,48,219,61,19 + LTEXT "̼汾",IDC_STATIC,29,147,55,8 + LTEXT "汾",IDC_STATIC,29,175,55,8 + LTEXT "002180110",IDC_STATIC_FmwVersion,29,160,55,8 + LTEXT "180110002",IDC_STATIC_DriverVersion,29,189,55,8 +END + +IDR_MAINFRAME DIALOG 0, 0, 330, 16 +STYLE DS_SETFONT | WS_CHILD +FONT 9, "" +BEGIN + LTEXT "TODO: Ի",IDC_STATIC,12,4,300,8 +END + +CG_IDD_Status DIALOG 0, 0, 690, 15 +STYLE DS_SETFONT | WS_CHILD +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_EDIT_CountTime,228,2,51,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "A-Bʱ",IDC_STATIC,192,4,36,8 + LTEXT "ƫλ",IDC_STATIC,5,4,35,10 + EDITTEXT IDC_EDIT_Offset,40,2,40,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ʱ",IDC_STATIC,84,4,32,8 + LTEXT "ǰѹ",IDC_STATIC,298,4,35,10 + EDITTEXT IDC_EDIT_Volt,333,2,35,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "",IDC_STATIC,371,4,20,10 + CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,584,4,99,7 + LTEXT "̬ʾ",IDC_STATIC,528,3,49,8 + EDITTEXT IDC_EDIT_MeasureFreq,451,1,72,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ⲿźƵ",IDC_STATIC,400,3,49,8 + LTEXT "div",IDC_STATIC_TimeOfDiv,118,2,73,10,SS_SUNKEN | NOT WS_GROUP +END + +CG_IDD_ADCHANNEL DIALOGEX 0, 0, 133, 506 +STYLE DS_SETFONT | WS_CHILD +FONT 9, "", 0, 0, 0x0 +BEGIN + CONTROL "Զɼ",IDC_CHECK_Auto,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,464,44,10 + CONTROL "Spin1",IDC_SPIN_BufferID,"msctls_updown32",UDS_SETBUDDYINT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,110,462,11,15 + EDITTEXT IDC_EDIT_BufferID,92,463,18,13,ES_AUTOHSCROLL + COMBOBOX IDC_COMBO_TriggerSource,57,247,56,116,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO_OutTriggerDir,57,261,56,121,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Slider1",IDC_SLIDER_Offset,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,5,479,78,14 + LTEXT "ID",IDC_STATIC,65,464,24,10 + LTEXT "Ƶ",IDC_STATIC,7,51,33,8 + LTEXT "Դ ",IDC_STATIC,7,249,41,8,SS_NOTIFY + LTEXT "",IDC_STATIC,7,263,34,8 + GROUPBOX "",IDC_STATIC,1,457,128,40 + LTEXT "Static",IDC_STATIC_Offset,88,479,30,14,SS_SUNKEN + GROUPBOX " ",IDC_STATIC,1,221,128,137 + LTEXT "",IDC_STATIC,7,154,33,9 + LTEXT "ģʽ",IDC_STATIC,7,235,33,8,SS_NOTIFY + COMBOBOX IDC_COMBO_TriggerMode,57,233,56,64,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "ƽ",IDC_STATIC,7,278,36,8 + EDITTEXT IDC_EDIT_TrigLevelVolt,57,276,47,12,ES_AUTOHSCROLL + GROUPBOX "ʱ",IDC_STATIC,1,359,128,56 + COMBOBOX IDC_COMBO_ReferenceClock,60,368,63,155,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_EDIT_N_Length,48,178,67,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_M_Length,48,165,67,12,ES_AUTOHSCROLL + LTEXT "M()",IDC_STATIC,7,167,30,9 + LTEXT "N()",IDC_STATIC,7,180,29,9 + LTEXT "(mV)",IDC_STATIC,106,278,17,8 + EDITTEXT IDC_EDIT_SampleLenth,48,152,67,12,ES_AUTOHSCROLL | WS_DISABLED + LTEXT "οʱ",IDC_STATIC,8,370,36,8 + CONTROL "ǷΪ豸",IDC_CHECK_bMasterEn,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,427,62,8 + COMBOBOX IDC_COMBO_SyncTrigSignal,69,439,56,155,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "ͬԴ",IDC_STATIC,6,441,47,8 + GROUPBOX "",IDC_STATIC,1,186,128,35 + PUSHBUTTON "",IDC_BUTTON_SoftTirg,6,196,53,20 + CONTROL "ʱ",IDC_CHECK_TimerTrig,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,193,45,11 + EDITTEXT IDC_EDIT_TrigInterval,69,205,27,12,ES_AUTOHSCROLL + LTEXT "mS",IDC_STATIC,104,206,8,8 + LTEXT "",IDC_STATIC,7,306,36,8 + EDITTEXT IDC_EDIT_TrigCount,57,303,57,12,ES_AUTOHSCROLL + LTEXT "",IDC_STATIC,7,292,42,8 + EDITTEXT IDC_EDIT_TrigWindow,57,289,47,12,ES_AUTOHSCROLL + LTEXT "nS",IDC_STATIC,106,292,9,8 + CONTROL "ʱ",IDC_CHECK_bClkOutEn,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,6,400,44,10 + CONTROL "",IDC_CHECK_bTrigOutEn,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,332,44,10 + GROUPBOX "ͬ",IDC_STATIC,1,416,128,40 + COMBOBOX IDC_COMBO_ClkOutSel,60,398,63,155,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO_TrigOutPolarity,57,330,63,155,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "",IDC_STATIC,7,345,36,8 + EDITTEXT IDC_EDIT_TrigOutWidth,57,345,41,12,ES_AUTOHSCROLL + LTEXT "nS",IDC_STATIC,105,348,9,8 + LTEXT " Ƶ ",IDC_STATIC,7,39,33,8 + EDITTEXT IDC_EDIT_FreqDivision,47,37,50,12,ES_AUTOHSCROLL + LTEXT "Hz",IDC_STATIC,101,51,8,8 + EDITTEXT IDC_EDIT_Frequency,47,50,50,12,ES_AUTOHSCROLL + COMBOBOX IDC_COMBO_TimeBaseClock,60,383,63,155,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "ʱ",IDC_STATIC,8,385,36,8 + LTEXT "ģʽ",IDC_STATIC,7,64,33,8,SS_NOTIFY + COMBOBOX IDC_COMBO_SampleMode,47,62,65,64,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "",IDC_LIST_CHParam,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,4,78,124,70 + COMBOBOX IDC_COMBO_PFISel,57,316,63,121,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP + LTEXT "PFIѡ",IDC_STATIC_PFI,8,320,31,8,NOT WS_VISIBLE + CONTROL "Զ·",IDC_CHECK_bSaveFile,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,5,65,10 + EDITTEXT IDC_EDIT_FilePath,7,20,118,15,ES_AUTOHSCROLL +END + +CG_IDD_HistoryDlg DIALOGEX 0, 0, 685, 89 +STYLE DS_SETFONT | WS_CHILD +FONT 9, "", 0, 0, 0x1 +BEGIN + GROUPBOX "ļϢ",IDC_STATIC_CardType,7,7,172,52 + PUSHBUTTON "ʼط",IDM_History_Start,573,13,105,20 + PUSHBUTTON "ֹͣط",IDM_History_Stop,573,37,105,21 + GROUPBOX "",IDC_STATIC,190,12,65,46 + LTEXT "ļƫ()",IDC_STATIC,7,64,50,15,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_Offset,58,64,55,15,ES_AUTOHSCROLL + CONTROL "Slider1",IDC_SLIDER_Offset,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,121,64,458,17,WS_EX_TRANSPARENT + LTEXT "ļ",IDC_STATIC,361,18,33,12,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_FileLength,399,18,50,12,ES_AUTOHSCROLL | ES_READONLY + COMBOBOX IDC_COMBO_Rate,295,18,57,167,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "طٶ",IDC_STATIC,260,20,33,8 + LTEXT "Ļλ",IDC_STATIC,260,39,33,8 + EDITTEXT IDC_EDIT_ScreenPos,297,38,57,12,ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT_PerChannel,400,38,50,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ͨ",IDC_STATIC,360,38,33,13,SS_CENTERIMAGE + LISTBOX IDC_FILESINFO,13,16,159,39,NOT LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP + LTEXT "0",IDC_STATIC_PositionA,503,11,49,10,SS_SUNKEN + LTEXT "0",IDC_STATIC_PositionB,504,25,49,10,SS_SUNKEN + CONTROL "Aλ:",IDC_RADIO_PositionA,"Button",BS_AUTORADIOBUTTON,455,12,48,10 + CONTROL "Bλ:",IDC_RADIO_PositionB,"Button",BS_AUTORADIOBUTTON,455,25,48,10 + LTEXT "ƵʴС:",IDC_STATIC,463,49,37,8 + LTEXT "0",IDC_STATIC_Frequency,504,50,49,10,SS_SUNKEN + GROUPBOX "",IDC_STATIC,451,4,111,63 + LTEXT "AB:",IDC_STATIC,471,38,29,8 + LTEXT "0",IDC_STATIC_DistanceAB,504,37,49,10,SS_SUNKEN + PUSHBUTTON "ˢͼ",IDC_BUTTON_RefrushData,193,25,58,14 + PUSHBUTTON "λ",IDC_Goto,597,61,46,18 +END + +CG_IDD_Capability DIALOGEX 0, 0, 116, 381 +STYLE DS_SYSMODAL | DS_SETFONT | WS_CHILD +EXSTYLE WS_EX_TOOLWINDOW +MENU IDR_AD +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + GROUPBOX "ȷ",IDC_STATIC,4,14,108,129 + LTEXT "ƽ",IDC_STATIC,9,49,34,14,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_TriggerVolt,45,49,64,14,ES_AUTOHSCROLL + LTEXT "޴",IDC_STATIC,9,105,35,14,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_OverRange,45,105,64,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "",IDC_STATIC,9,85,34,14,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_AnalyzeCount,45,85,64,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ޱ",IDC_STATIC,9,122,36,14,SS_CENTERIMAGE + EDITTEXT IDC_EDIT_OverRatio,45,122,64,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ƽƵѹ",IDC_STATIC,9,68,36,14,SS_CENTERIMAGE + LTEXT "Ļ",IDC_STATIC,9,28,36,12,SS_CENTERIMAGE + GROUPBOX "ݴʽ",IDC_STATIC,3,148,108,60 + CONTROL "ַʽʾ",IDM_DigitalShow,"Button",BS_AUTORADIOBUTTON | WS_GROUP,17,161,68,14 + CONTROL "ͼηʽʾ",IDM_GraphicShow,"Button",BS_AUTORADIOBUTTON,17,175,69,12 + CONTROL "ݴ̴",IDM_DataSave,"Button",BS_AUTORADIOBUTTON,17,189,68,14 + ICON IDR_MAINFRAME,IDC_STATIC,42,348,20,20 + COMBOBOX IDC_Combo_MoveVolt,45,67,64,101,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_Combo_ScreenVolume,45,28,64,148,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "ƽʾ",IDM_TileWave,"Button",BS_AUTORADIOBUTTON | WS_GROUP,17,264,48,11 + CONTROL "ʾ",IDM_SuperPoseWave,"Button",BS_AUTORADIOBUTTON,17,281,48,11 + GROUPBOX "ʾģʽ",IDC_STATIC,3,242,108,65 +END + +CG_IDD_DIALOG_Save DIALOGEX 0, 0, 694, 17 +STYLE DS_SETFONT | WS_CHILD +FONT 9, "", 0, 0, 0x1 +BEGIN + CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,526,4,155,7 + LTEXT "ļ:",IDC_STATIC,5,4,31,11,SS_CENTERIMAGE + LTEXT "",IDC_FileName,39,4,157,11,SS_CENTERIMAGE,WS_EX_STATICEDGE + LTEXT "̿ÿռ:",IDC_STATIC,200,3,56,11,SS_CENTERIMAGE + LTEXT "",IDC_DiskFree,258,3,58,11,SS_CENTERIMAGE,WS_EX_STATICEDGE + LTEXT "ȫ̴洢:",IDC_STATIC,469,4,52,11 + LTEXT "ļ洢С:",IDC_STATIC,322,3,52,11,SS_CENTERIMAGE + LTEXT "",IDC_FileLenght,379,3,84,11,SS_CENTERIMAGE,WS_EX_STATICEDGE +END + +IDD_DIALOG_Calibration DIALOG 0, 0, 286, 86 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Device Calibration" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "Calibration",IDC_BUTTON_Calibration,95,12,72,25 + CONTROL "Progress1",IDC_PROGRESS_Calibration,"msctls_progress32",WS_BORDER,15,43,256,10 + CTEXT "",IDC_STATIC_Calibration,25,59,239,11 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080404b0" + BEGIN + VALUE "CompanyName", "̩ó޹˾" + VALUE "FileDescription", "Sys Microsoft Ӧó" + VALUE "FileVersion", "V6.00.00.00.03" + VALUE "InternalName", "Sys" + VALUE "LegalCopyright", "Ȩ (C) 2005" + VALUE "OriginalFilename", "Sys.EXE" + VALUE "ProductName", "Sys Ӧó" + VALUE "ProductVersion", "05.11.23" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x804, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 264 + TOPMARGIN, 7 + BOTTOMMARGIN, 244 + END + + CG_IDD_Status, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 683 + TOPMARGIN, 7 + BOTTOMMARGIN, 8 + END + + CG_IDD_ADCHANNEL, DIALOG + BEGIN + RIGHTMARGIN, 132 + TOPMARGIN, 1 + BOTTOMMARGIN, 501 + END + + CG_IDD_HistoryDlg, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 678 + TOPMARGIN, 7 + BOTTOMMARGIN, 82 + END + + CG_IDD_Capability, DIALOG + BEGIN + RIGHTMARGIN, 115 + BOTTOMMARGIN, 378 + END + + CG_IDD_DIALOG_Save, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 683 + TOPMARGIN, 3 + BOTTOMMARGIN, 14 + END + + IDD_DIALOG_Calibration, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 279 + TOPMARGIN, 7 + BOTTOMMARGIN, 79 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog Info +// + +CG_IDD_HistoryDlg DLGINIT +BEGIN + IDC_COMBO_Rate, 0x403, 2, 0 +0x0031, + IDC_COMBO_Rate, 0x403, 2, 0 +0x0032, + IDC_COMBO_Rate, 0x403, 2, 0 +0x0034, + IDC_COMBO_Rate, 0x403, 2, 0 +0x0038, + IDC_COMBO_Rate, 0x403, 3, 0 +0x3031, "\000" + IDC_COMBO_Rate, 0x403, 3, 0 +0x3032, "\000" + IDC_COMBO_Rate, 0x403, 3, 0 +0x3038, "\000" + IDC_COMBO_Rate, 0x403, 5, 0 +0x3031, 0x3432, "\000" + IDC_COMBO_Rate, 0x403, 5, 0 +0x3032, 0x3834, "\000" + 0 +END + +CG_IDD_Capability DLGINIT +BEGIN + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x2031, 0x2020, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x2032, 0x2020, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x2035, 0x2020, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3031, 0x2020, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3032, 0x2020, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3035, 0x2020, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3031, 0x2030, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3032, 0x2030, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3035, 0x2030, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3031, 0x3030, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3032, 0x3030, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3035, 0x3030, 0x2020, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3031, 0x3030, 0x2030, 0x566d, "\000" + IDC_Combo_ScreenVolume, 0x403, 9, 0 +0x3032, 0x3030, 0x2030, 0x566d, "\000" + 0 +END + +CG_IDD_ADCHANNEL DLGINIT +BEGIN + IDC_COMBO_TriggerSource, 0x403, 9, 0 +0xedc8, 0xfebc, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_TriggerSource, 0x403, 9, 0 +0x5444, 0x2852, 0x4650, 0x2949, "\000" + IDC_COMBO_TriggerSource, 0x403, 13, 0 +0xaccd, 0xbdb2, 0xc5d0, 0xc5ba, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_TriggerSource, 0x403, 10, 0 +0xa8cd, 0xc0b5, 0xb430, 0xb7a5, 0x00a2, + IDC_COMBO_TriggerSource, 0x403, 10, 0 +0xa8cd, 0xc0b5, 0xb431, 0xb7a5, 0x00a2, + IDC_COMBO_TriggerSource, 0x403, 10, 0 +0xa8cd, 0xc0b5, 0xb432, 0xb7a5, 0x00a2, + IDC_COMBO_TriggerSource, 0x403, 10, 0 +0xa8cd, 0xc0b5, 0xb433, 0xb7a5, 0x00a2, + IDC_COMBO_OutTriggerDir, 0x403, 11, 0 +0xc2cf, 0xb5bd, 0xd8d1, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_OutTriggerDir, 0x403, 11, 0 +0xcfc9, 0xfdc9, 0xd8d1, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_OutTriggerDir, 0x403, 15, 0 +0xcfc9, 0xc2cf, 0xdfb1, 0xd8d1, 0xf9be, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_TriggerMode, 0x403, 9, 0 +0xd0d6, 0xe4bc, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_TriggerMode, 0x403, 7, 0 +0xf3ba, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_TriggerMode, 0x403, 7, 0 +0xa4d4, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_TriggerMode, 0x403, 13, 0 +0xb2d3, 0xfebc, 0xd3d1, 0xb1ca, 0xa5b4, 0xa2b7, "\000" + IDC_COMBO_ReferenceClock, 0x403, 9, 0 +0xe5b0, 0xd8d4, 0xb1ca, 0xd3d6, "\000" + IDC_COMBO_ReferenceClock, 0x403, 8, 0 +0xe2cd, 0xbfb2, 0x3031, 0x004d, + IDC_COMBO_ReferenceClock, 0x403, 11, 0 +0x5850, 0x5f49, 0x4c43, 0x314b, 0x4d30, "\000" + IDC_COMBO_ReferenceClock, 0x403, 13, 0 +0x5850, 0x6549, 0x435f, 0x4b4c, 0x3031, 0x4d30, "\000" + IDC_COMBO_SyncTrigSignal, 0x403, 6, 0 +0x5254, 0x4749, 0x0030, + IDC_COMBO_SyncTrigSignal, 0x403, 6, 0 +0x5254, 0x4749, 0x0031, + IDC_COMBO_SyncTrigSignal, 0x403, 6, 0 +0x5254, 0x4749, 0x0032, + IDC_COMBO_SyncTrigSignal, 0x403, 6, 0 +0x5254, 0x4749, 0x0033, + IDC_COMBO_SyncTrigSignal, 0x403, 6, 0 +0x5254, 0x4749, 0x0034, + IDC_COMBO_SyncTrigSignal, 0x403, 6, 0 +0x5254, 0x4749, 0x0035, + IDC_COMBO_SyncTrigSignal, 0x403, 6, 0 +0x5254, 0x4749, 0x0036, + IDC_COMBO_SyncTrigSignal, 0x403, 6, 0 +0x5254, 0x4749, 0x0037, + IDC_COMBO_ClkOutSel, 0x403, 9, 0 +0xceb2, 0xbcbf, 0xb1ca, 0xd3d6, "\000" + IDC_COMBO_ClkOutSel, 0x403, 9, 0 +0xf9bb, 0xbcd7, 0xb1ca, 0xd3d6, "\000" + IDC_COMBO_TrigOutPolarity, 0x403, 11, 0 +0xbab8, 0xf6c2, 0xe5b3, 0xe4ca, 0xf6b3, "\000" + IDC_COMBO_TrigOutPolarity, 0x403, 11, 0 +0xfdd5, 0xf6c2, 0xe5b3, 0xe4ca, 0xf6b3, "\000" + IDC_COMBO_TimeBaseClock, 0x403, 9, 0 +0xdac4, 0xbfb2, 0xb1ca, 0xd3d6, "\000" + IDC_COMBO_TimeBaseClock, 0x403, 9, 0 +0xe2cd, 0xbfb2, 0xb1ca, 0xd3d6, "\000" + IDC_COMBO_SampleMode, 0x403, 11, 0 +0xd0d3, 0xdecf, 0xe3b5, 0xc9b2, 0xf9d1, "\000" + IDC_COMBO_SampleMode, 0x403, 9, 0 +0xacc1, 0xf8d0, 0xc9b2, 0xf9d1, "\000" + IDC_COMBO_PFISel, 0x403, 9, 0 +0xa5b4, 0xa2b7, 0xe4ca, 0xf6b3, "\000" + IDC_COMBO_PFISel, 0x403, 9, 0 +0xa5b4, 0xa2b7, 0xe4ca, 0xebc8, "\000" + 0 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\MainFrm.ico" +IDR_AD ICON "res\\AD.ico" +IDR_HistoryData ICON "res\\Hist.ico" +IDR_DIO ICON "res\\idr_dio.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDR_MAINFRAME "̩ʾϵͳ" + IDR_AD "\nSys\nSys\n̩ļ (*.pci)\n.pci\nSys.Document\nSys Document\n̩˾ļ" + CG_IDS_TIPOFTHEDAYHELP "&Help" +END + +STRINGTABLE +BEGIN + AFX_IDS_APP_TITLE "Sys" + AFX_IDS_IDLEMESSAGE "" +END + +STRINGTABLE +BEGIN + ID_INDICATOR_EXT "չ" + ID_INDICATOR_CAPS "д" + ID_INDICATOR_NUM "" + ID_INDICATOR_SCRL "" + ID_INDICATOR_OVR "д" + ID_INDICATOR_REC "¼" + ID_SHOWMOUSEVOLT " " +END + +STRINGTABLE +BEGIN + ID_FILE_NEW "ĵ\n½" + ID_FILE_OPEN "һĵ\n" + ID_FILE_CLOSE "رջĵ\nر" + ID_FILE_SAVE "ĵ\n" + ID_FILE_SAVE_AS "ĵһļ\nΪ" + ID_FILE_PAGE_SETUP "ıӡѡ\nҳ" + ID_FILE_PRINT_SETUP "ıӡӡѡ\nӡ" + ID_FILE_PRINT "ӡĵ\nӡ" + ID_FILE_PRINT_PREVIEW "ʾҳ\nӡԤ" +END + +STRINGTABLE +BEGIN + ID_APP_ABOUT "ʾϢ汾źͰȨ\n" + ID_APP_EXIT "˳Ӧóʾĵ\n˳" +END + +STRINGTABLE +BEGIN + ID_FILE_MRU_FILE1 "򿪸ĵ" + ID_FILE_MRU_FILE2 "򿪸ĵ" + ID_FILE_MRU_FILE3 "򿪸ĵ" + ID_FILE_MRU_FILE4 "򿪸ĵ" + ID_FILE_MRU_FILE5 "򿪸ĵ" + ID_FILE_MRU_FILE6 "򿪸ĵ" + ID_FILE_MRU_FILE7 "򿪸ĵ" + ID_FILE_MRU_FILE8 "򿪸ĵ" + ID_FILE_MRU_FILE9 "򿪸ĵ" + ID_FILE_MRU_FILE10 "򿪸ĵ" + ID_FILE_MRU_FILE11 "򿪸ĵ" + ID_FILE_MRU_FILE12 "򿪸ĵ" + ID_FILE_MRU_FILE13 "򿪸ĵ" + ID_FILE_MRU_FILE14 "򿪸ĵ" + ID_FILE_MRU_FILE15 "򿪸ĵ" + ID_FILE_MRU_FILE16 "򿪸ĵ" +END + +STRINGTABLE +BEGIN + ID_NEXT_PANE "лһ\nһ" + ID_PREV_PANE "лǰһ\nǰһ" +END + +STRINGTABLE +BEGIN + ID_WINDOW_NEW "Ϊĵһ\n½" + ID_WINDOW_ARRANGE "ͼڴڵײ\nͼ" + ID_WINDOW_CASCADE "дڳ໥ص\n" + ID_WINDOW_TILE_HORZ "дڳɻص\nƽ̴" + ID_WINDOW_TILE_VERT "дڳɻص\nƽ̴" + ID_WINDOW_SPLIT "Ĵڷָɴ\nָ" +END + +STRINGTABLE +BEGIN + ID_EDIT_CLEAR "ɾѡ\nɾ" + ID_EDIT_CLEAR_ALL "ȫɾ\nȫɾ" + ID_EDIT_COPY "Ʊѡ󲢽ڼ\n" + ID_EDIT_CUT "бѡ󲢽ڼ\n" + ID_EDIT_FIND "ָ\n" + ID_EDIT_PASTE "\nճ" + ID_EDIT_REPEAT "ظһ\nظ" + ID_EDIT_REPLACE "òͬ滻ָ\n滻" + ID_EDIT_SELECT_ALL "ѡĵ\nѡȫ" + ID_EDIT_UNDO "һ\n" + ID_EDIT_REDO "ִǰѳIJ\nִ" +END + +STRINGTABLE +BEGIN + ID_VIEW_TOOLBAR "ʾع\n" + ID_VIEW_STATUS_BAR "ʾ״̬\n״̬" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCSIZE "ı䴰ڴС" + AFX_IDS_SCMOVE "ı䴰λ" + AFX_IDS_SCMINIMIZE "Сͼ" + AFX_IDS_SCMAXIMIZE "ѴڷŴߴ" + AFX_IDS_SCNEXTWINDOW "лһĵ" + AFX_IDS_SCPREVWINDOW "лǰĵ" + AFX_IDS_SCCLOSE "رջĴڲʾĵ" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCRESTORE "ѴڻָС" + AFX_IDS_SCTASKLIST "" + AFX_IDS_MDICHILD "ô" +END + +STRINGTABLE +BEGIN + AFX_IDS_PREVIEW_CLOSE "رմӡԤģʽ\nȡԤ" + IDS_ProccessHistoryData "򿪴ļ" +END + +STRINGTABLE +BEGIN + IDS_NEW_FILE "½ļ" +END + +STRINGTABLE +BEGIN + CG_ID_VIEW_SETUPDLG "Show or hide SetupDlg\nToggle SetupDlg" + ID_WINDOW_NEXT_PANE "Switch to the next window pane\nNext Pane" + CG_ID_VIEW_SHOWSTATUS "Show or hide ShowStatus\nToggle ShowStatus" + ID_WINDOW_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" + CG_ID_VIEW_SHOWSTATUS1 "Show or hide ShowStatus1\nToggle ShowStatus1" + CG_ID_VIEW_DIALOGBAR "Show or hide DialogBar\nToggle DialogBar" +END + +STRINGTABLE +BEGIN + CG_ID_VIEW_DLGBAR "Show or hide 豸\nToggle 豸" + CG_IDS_TIPOFTHEDAY "Displays a Tip of the Day." + CG_IDS_TIPOFTHEDAYMENU "Ti&p of the Day..." + CG_IDS_DIDYOUKNOW "Did you know..." + CG_IDS_FILE_ABSENT "Tips file does not exist in the prescribed directory" + CG_IDP_FILE_CORRUPT "Trouble reading the tips file" +END + +STRINGTABLE +BEGIN + IDM_CloseFile "رļʹ" +END + +STRINGTABLE +BEGIN + IDR_HistoryData "\nSys\nSys\n̩ļ (*.pci)\n.pci\nSys.Document\nSys Document" +END + +#endif // (л񹲺͹) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// (¹) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_TABIMAGES BITMAP "res\\TabImage.bmp" +#endif // (¹) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE 4, 2 +#pragma code_page(936) +#endif //_WIN32 +#include "res\Sys.rc2" // non-Microsoft Visual C++ edited resources +#include "l.chs\afxres.rc" // Standard components +#include "l.chs\afxprint.rc" // printing/print preview resources +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.sln b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.sln new file mode 100644 index 0000000..98848c0 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sys", "Sys.vcproj", "{991B07A8-2680-4D33-BCE4-F733A1AB6D7E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {991B07A8-2680-4D33-BCE4-F733A1AB6D7E}.Debug|Win32.ActiveCfg = Debug|Win32 + {991B07A8-2680-4D33-BCE4-F733A1AB6D7E}.Debug|Win32.Build.0 = Debug|Win32 + {991B07A8-2680-4D33-BCE4-F733A1AB6D7E}.Debug|x64.ActiveCfg = Debug|x64 + {991B07A8-2680-4D33-BCE4-F733A1AB6D7E}.Debug|x64.Build.0 = Debug|x64 + {991B07A8-2680-4D33-BCE4-F733A1AB6D7E}.Release|Win32.ActiveCfg = Release|Win32 + {991B07A8-2680-4D33-BCE4-F733A1AB6D7E}.Release|Win32.Build.0 = Release|Win32 + {991B07A8-2680-4D33-BCE4-F733A1AB6D7E}.Release|x64.ActiveCfg = Release|x64 + {991B07A8-2680-4D33-BCE4-F733A1AB6D7E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.vcproj b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.vcproj new file mode 100644 index 0000000..9971fd8 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys.vcproj @@ -0,0 +1,1627 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys_32.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys_32.exe new file mode 100644 index 0000000..d106d42 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys_32.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys_64.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys_64.exe new file mode 100644 index 0000000..e63bd8d Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/Sys_64.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlBarDoc.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlBarDoc.cpp new file mode 100644 index 0000000..d6c3348 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlBarDoc.cpp @@ -0,0 +1,273 @@ +// tabbar.cpp : implementation file +// +// This class implements a tab control for MDI windows. +// The tab labels are filled automatically with the titles of the MDI frames. +///////////////////////////////////////////////////////////////////////////// +// +// Copyright ?1998 Written by Dieter Fauth +// mailto:fauthd@zvw.de +// +// This code may be used in compiled form in any way you desire. This +// file may be redistributed unmodified by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name and all copyright +// notices remains intact. If the source code in this file is used in +// any commercial application then a statement along the lines of +// "Portions Copyright ?1999 Dieter Fauth" must be included in +// the startup banner, "About" box or printed documentation. An email +// letting me know that you are using it would be nice as well. That's +// not much to ask considering the amount of work that went into this. +// +// This file is provided "as is" with no expressed or implied warranty. +// The author accepts no liability for any damage/loss of business that +// this product may cause. +// +// ========================================================================== +// HISTORY: +// ========================================================================== +// 1.00 08 May 1999 - Initial release. +// ========================================================================== +// +///////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include +#include <..\src\mfc\afximpl.h> + +#include "resource.h" +#include "TabCtrlBarDoc.h" + +// RCS info +static char rcsid[] = "$Id: $"; + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char BASED_CODE THIS_FILE[] = __FILE__; +#endif + +/////////////////////////////////////////////////////////////////////////////// +// CTabCtrlBarDoc + +CTabCtrlBarDoc::CTabCtrlBarDoc() +{ +} + +/* +CTabCtrlBarDoc::~CTabCtrlBarDoc() +{ +} +*/ + +IMPLEMENT_DYNAMIC(CTabCtrlBarDoc, CControlBar) + +BEGIN_MESSAGE_MAP(CTabCtrlBarDoc, CControlBar) + //{{AFX_MSG_MAP(CTabCtrlBarDoc) + ON_WM_SIZE() + ON_WM_CREATE() + //}}AFX_MSG_MAP + ON_NOTIFY(TCN_SELCHANGE, IDC_MDI_TAB_CTRL, OnSelchange) +END_MESSAGE_MAP() + +/////////////////////////////////////////////////////////////////////////////// + +BOOL CTabCtrlBarDoc::Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID) +{ + ASSERT_VALID(pParentWnd); // must have a parent + + // save the style (some of these style bits are MFC specific) +// m_dwStyle = (UINT)dwStyle; + m_dwStyle = CBRS_ALL; + // translate MFC style bits to windows style bits + dwStyle &= ~CBRS_ALL; + dwStyle |= CCS_NOPARENTALIGN|CCS_NOMOVEY|CCS_NODIVIDER|CCS_NORESIZE; + if (pParentWnd->GetStyle() & WS_THICKFRAME) + dwStyle |= SBARS_SIZEGRIP; + + //dwStyle=CBRS_ALL; + // initialize common controls +// VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG)); + + // create the HWND + CRect rect; rect.SetRectEmpty(); + /* + rect.left=10; + rect.top=10; + rect.right=10; + rect.bottom=20; + */ + + return CWnd::Create(STATUSCLASSNAME, NULL, dwStyle, rect, pParentWnd, nID); +} + +///////////////////////////////////////////////////////////////////////////// +// CTabCtrlBarDoc message handlers + +int CTabCtrlBarDoc::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CControlBar::OnCreate(lpCreateStruct) == -1) + return -1; + + CRect rect; rect.SetRectEmpty(); + //Create the Tab Control + if (!m_tabctrl.Create(WS_VISIBLE|WS_CHILD, rect, this, IDC_MDI_TAB_CTRL)) + { + TRACE0("Unable to create tab control bar\n"); + return -1; + } + + // set "regular" GUI-font + // Use a smaller font for smaller tabs + CFont *font = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)); + m_tabctrl.SetFont(font); + + return 0; +} + +void CTabCtrlBarDoc::OnSize(UINT nType, int cx, int cy) +{ + CControlBar::OnSize(nType, cx, cy); + CRect rect; + if (m_tabctrl.GetSafeHwnd()) + { + GetWindowRect(rect); + m_tabctrl.AdjustRect(TRUE, &rect); + m_tabctrl.SetWindowPos(&wndTop ,0,0,rect.Width()-7, rect.Height(), SWP_SHOWWINDOW); + } +} + +void CTabCtrlBarDoc::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler) +{ + SetTitles(); +} + +// This is called in idle time. +// Here we update the tab labels and selection +void CTabCtrlBarDoc::SetTitles(void) +{ + CString csName; + TC_ITEM tci; + TCHAR buf[MAX_PATH+1]; + CMDIFrameWnd *pMainframe = ((CMDIFrameWnd *)AfxGetMainWnd()); + if (pMainframe == NULL) + return; // no official mainframe window yet + + CMDIChildWnd* pActive = pMainframe->MDIGetActive( NULL ); + + // update all tab labels if neccessary + int numitems = m_tabctrl.GetItemCount(); + for (int item = 0; item < numitems; item++) + { + csName.Empty(); + tci.mask = TCIF_PARAM|TCIF_TEXT; + tci.pszText = buf; + tci.cchTextMax = MAX_PATH; + if (!m_tabctrl.GetItem(item, &tci)) + continue; // skip bad ones (never saw one yet) + + CWnd *pFrame = FromHandle((HWND) tci.lParam); + ASSERT(pFrame != NULL); + if ( pFrame->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)) ) + { + pFrame->GetWindowText(csName); + if (buf != csName) // avoid flicker + { + tci.mask = TCIF_TEXT; + tci.pszText = csName.LockBuffer(); + m_tabctrl.SetItem(item, &tci); + csName.UnlockBuffer(); + } + if (pActive == pFrame) // mark the active one + m_tabctrl.SetCurSel(item); + } + } +} + +// Add a new window handle to the tab control +// Also creates a new tab +void CTabCtrlBarDoc::AddHandle(HWND hWnd) +{ + CWnd *pFrame = FromHandle(hWnd); + ASSERT(pFrame != NULL); + if ( pFrame->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)) ) + { + TC_ITEM tci; + tci.mask = TCIF_PARAM|TCIF_TEXT; + tci.pszText = _T(""); + tci.lParam = (long) hWnd; + m_tabctrl.InsertItem(m_tabctrl.GetItemCount(), &tci); + } +} + +// Remove a new window handle from the tab control +// Also removes the tab +void CTabCtrlBarDoc::RemoveHandle(HWND hWnd) +{ + TC_ITEM tci; + int numitems = m_tabctrl.GetItemCount(); + for (int item = 0; item < numitems; item++) + { + tci.mask = TCIF_PARAM; + m_tabctrl.GetItem(item, &tci); + if (tci.lParam == (long) hWnd) + { + m_tabctrl.DeleteItem(item); + break; + } + } +} + +// The user clicked onto a tab. +// Now select a new MDI child frame +void CTabCtrlBarDoc::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult) +{ + int idx = m_tabctrl.GetCurSel(); + + TC_ITEM tci; + tci.mask = TCIF_PARAM; + if (m_tabctrl.GetItem(idx, &tci)) + { + CWnd *pFrame = FromHandle((HWND) tci.lParam); + ASSERT(pFrame != NULL); + ASSERT_KINDOF(CMDIChildWnd, pFrame); + ((CMDIFrameWnd *)AfxGetMainWnd())->MDIActivate(pFrame); + } + *pResult = 0; +} + +// Almost a copy from CStatusbar: +// The framework calls this function to get an idea of the size. +CSize CTabCtrlBarDoc::CalcFixedLayout(BOOL, BOOL bHorz) +{ + ASSERT_VALID(this); + ASSERT(::IsWindow(m_hWnd)); + + // determinme size of font being used by the status bar + TEXTMETRIC tm; + { + CClientDC dc(NULL); + HFONT hFont = (HFONT)SendMessage(WM_GETFONT); + HGDIOBJ hOldFont = NULL; + if (hFont != NULL) + hOldFont = dc.SelectObject(hFont); + VERIFY(dc.GetTextMetrics(&tm)); + if (hOldFont != NULL) + dc.SelectObject(hOldFont); + } + + // get border information + CRect rect; rect.SetRectEmpty(); + CalcInsideRect(rect, bHorz); + int rgBorders[3]; + DefWindowProc(SB_GETBORDERS, 0, (LPARAM)&rgBorders); + + // determine size, including borders + CSize size; + size.cx = 32767; + size.cy = tm.tmHeight - tm.tmInternalLeading - 1 + + rgBorders[1] * 2 + ::GetSystemMetrics(SM_CYBORDER) * (2+3) + - rect.Height(); + + return size; +} + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlBarDoc.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlBarDoc.h new file mode 100644 index 0000000..58557a2 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlBarDoc.h @@ -0,0 +1,61 @@ +// titlebar.h : header file +// +#ifndef _TABBAR_H_58A62F03_FEFE_11D2_BC0D_006008CCD137 +#define _TABBAR_H_58A62F03_FEFE_11D2_BC0D_006008CCD137 + +///////////////////////////////////////////////////////////////////////////// +#include "TabCtrlDoc.h" + +///////////////////////////////////////////////////////////////////////////// +// CTabBar window +//#define CTabBar_parent CControlBar +class CTabCtrlBarDoc : public CControlBar +{ + DECLARE_DYNAMIC(CTabCtrlBarDoc) +// Construction +public: +// Construction +public: + CTabCtrlBarDoc(); + +// Attributes +public: + void RemoveHandle(HWND hWnd); + void AddHandle(HWND hWnd); + void SetTitles(void); + +// Operations +public: + BOOL Create(CWnd* pParentWnd, + DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP, + UINT nID = AFX_IDW_STATUS_BAR); + +// Implementation +public: +// virtual ~CTabBar(); + virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); + +protected: +// CTabCtrl m_tabctrl; // works also, but the Ex version gives a nice look + CTabCtrlDoc m_tabctrl; + +// Overrides + virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz); + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTabCtrlBarDoc) + //}}AFX_VIRTUAL + +protected: + // Generated message map functions + //{{AFX_MSG(CTabCtrlBarDoc) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + //}}AFX_MSG + afx_msg void OnSelchange(NMHDR* pNMHDR, LRESULT* pResult); + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +#endif + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlDoc.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlDoc.cpp new file mode 100644 index 0000000..9e5160e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlDoc.cpp @@ -0,0 +1,208 @@ +// TabCtrlEx.cpp : implementation file +// + +#include "stdafx.h" +#include "TabCtrlDoc.h" +#include "PopupMenu.h" +#include "Resource.h" +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTabCtrlDoc + +CTabCtrlDoc::CTabCtrlDoc() +{ + m_crSelColour = RGB(0,0,255); + m_crUnselColour = RGB(50,50,50); +} + +CTabCtrlDoc::~CTabCtrlDoc() +{ + m_SelFont.DeleteObject(); + m_UnselFont.DeleteObject(); +} + +BEGIN_MESSAGE_MAP(CTabCtrlDoc, CTabCtrl) + //{{AFX_MSG_MAP(CTabCtrlDoc) + ON_WM_CREATE() + ON_WM_RBUTTONDOWN() + ON_WM_SETFOCUS() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTabCtrlDoc message handlers + +int CTabCtrlDoc::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CTabCtrl::OnCreate(lpCreateStruct) == -1) return -1; + ModifyStyle(0, TCS_OWNERDRAWFIXED); + + return 0; +} + +void CTabCtrlDoc::PreSubclassWindow() +{ + CTabCtrl::PreSubclassWindow(); + ModifyStyle(0, TCS_OWNERDRAWFIXED); +} + +void CTabCtrlDoc::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + CRect rect = lpDrawItemStruct->rcItem; + int nTabIndex = lpDrawItemStruct->itemID; + if (nTabIndex < 0) return; + BOOL bSelected = (nTabIndex == GetCurSel()); + + TCHAR label[64]; + TC_ITEM tci; + tci.mask = TCIF_TEXT|TCIF_IMAGE; + tci.pszText = label; + tci.cchTextMax = 63; + if (!GetItem(nTabIndex, &tci )) return; + + CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); + if (!pDC) return; + int nSavedDC = pDC->SaveDC(); + + // For some bizarre reason the rcItem you get extends above the actual + // drawing area. We have to workaround this "feature". + rect.top += ::GetSystemMetrics(SM_CYEDGE); + + pDC->SetBkMode(TRANSPARENT); + pDC->FillSolidRect(rect, ::GetSysColor(COLOR_BTNFACE)); + + // Draw image + CImageList* pImageList = GetImageList(); + if (pImageList && tci.iImage >= 0) { + + rect.left += pDC->GetTextExtent(_T(" ")).cx; // Margin + + // Get height of image so we + IMAGEINFO info; + pImageList->GetImageInfo(tci.iImage, &info); + CRect ImageRect(info.rcImage); + int nYpos = rect.top; + + pImageList->Draw(pDC, tci.iImage, CPoint(rect.left, nYpos), ILD_TRANSPARENT); + rect.left += ImageRect.Width(); + } + + if (bSelected) { + pDC->SetTextColor(m_crSelColour); + pDC->SelectObject(&m_SelFont); + rect.top -= ::GetSystemMetrics(SM_CYEDGE); + pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER); + } else { + pDC->SetTextColor(m_crUnselColour); + pDC->SelectObject(&m_UnselFont); + pDC->DrawText(label, rect, DT_SINGLELINE|DT_BOTTOM|DT_CENTER); + } + + pDC->RestoreDC(nSavedDC); +} + +///////////////////////////////////////////////////////////////////////////// +// CTabCtrlDoc operations + +void CTabCtrlDoc::SetColours(COLORREF bSelColour, COLORREF bUnselColour) +{ + m_crSelColour = bSelColour; + m_crUnselColour = bUnselColour; + Invalidate(); +} + +void CTabCtrlDoc::SetFonts(CFont* pSelFont, CFont* pUnselFont) +{ + ASSERT(pSelFont && pUnselFont); + + LOGFONT lFont; + int nSelHeight, nUnselHeight; + + m_SelFont.DeleteObject(); + m_UnselFont.DeleteObject(); + + pSelFont->GetLogFont(&lFont); + m_SelFont.CreateFontIndirect(&lFont); + nSelHeight = lFont.lfHeight; + + pUnselFont->GetLogFont(&lFont); + m_UnselFont.CreateFontIndirect(&lFont); + nUnselHeight = lFont.lfHeight; + + SetFont( (nSelHeight > nUnselHeight)? &m_SelFont : &m_UnselFont); +} + + +void CTabCtrlDoc::SetFonts(int nSelWeight, BOOL bSelItalic, BOOL bSelUnderline, + int nUnselWeight, BOOL bUnselItalic, BOOL bUnselUnderline) +{ + // Free any memory currently used by the fonts. + m_SelFont.DeleteObject(); + m_UnselFont.DeleteObject(); + + // Get the current font + LOGFONT lFont; + CFont *pFont = GetFont(); + if (pFont) + pFont->GetLogFont(&lFont); + else { + NONCLIENTMETRICS ncm; + ncm.cbSize = sizeof(NONCLIENTMETRICS); + VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0)); + lFont = ncm.lfMessageFont; + } + + // Create the "Selected" font + lFont.lfWeight = nSelWeight; + lFont.lfItalic = bSelItalic; + lFont.lfUnderline = bSelUnderline; + m_SelFont.CreateFontIndirect(&lFont); + + // Create the "Unselected" font + lFont.lfWeight = nUnselWeight; + lFont.lfItalic = bUnselItalic; + lFont.lfUnderline = bUnselUnderline; + m_UnselFont.CreateFontIndirect(&lFont); + + SetFont( (nSelWeight > nUnselWeight)? &m_SelFont : &m_UnselFont); +} + +void CTabCtrlDoc::OnRButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + // CControlBarؼϰҼʱ˵ + + POINT ptScreen = point; + // ת굽Ļ + ClientToScreen(&ptScreen); + // Զ࣬CMenu + CPopupMenu cMenu; + // ʽ˵ + cMenu.CreatePopupMenu(); + // Ӳ˵ID_VIEW_VIEWTABDz˵IDֵ + + // ӷָ + cMenu.AppendMenu(MF_STRING, ID_FILE_CLOSE, _T("رձ")); + this->GetCurSel(); + cMenu.LoadToolBarResource(IDR_TABVIEW_MENU); + cMenu.RemapMenu(&cMenu); + cMenu.EnableMenuItems(&cMenu, AfxGetMainWnd()); + cMenu.TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, ptScreen.x, + ptScreen.y, AfxGetMainWnd()); + + //*/ + //AfxMessageBox(_T("Ҽtab"); + //CMDIFrameWnd::OnRButtonDown(nFlags, point); +} + +void CTabCtrlDoc::OnSetFocus(CWnd* pOldWnd) +{ + CTabCtrl::OnSetFocus(pOldWnd); + // TODO: Add your message handler code here + +} diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlDoc.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlDoc.h new file mode 100644 index 0000000..beb93e3 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/TabCtrlDoc.h @@ -0,0 +1,60 @@ +#if !defined(AFX_TABCTRLEX_H__28407441_38AF_11D1_ABBA_00A0243D1382__INCLUDED_) +#define AFX_TABCTRLEX_H__28407441_38AF_11D1_ABBA_00A0243D1382__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 +// TabCtrlEx.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CTabCtrlDoc window + +class CTabCtrlDoc : public CTabCtrl +{ +// Construction/destruction +public: + CTabCtrlDoc(); + virtual ~CTabCtrlDoc(); + +// Attributes: +public: + +// Operations +public: + void SetFonts(CFont* pSelFont, CFont* pUnselFont); + void SetFonts(int nSelWeight=FW_SEMIBOLD, BOOL bSelItalic=FALSE, BOOL bSelUnderline=FALSE, + int nUnselWeight=FW_MEDIUM, BOOL bUnselItalic=FALSE, BOOL bUnselUnderline=FALSE); + + void SetColours(COLORREF bSelColour, COLORREF bUnselColour); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTabCtrlDoc) + public: + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + protected: + virtual void PreSubclassWindow(); + //}}AFX_VIRTUAL + +// Implementation +protected: + COLORREF m_crSelColour, m_crUnselColour; + CFont m_SelFont, m_UnselFont; + +// Generated message map functions +protected: + //{{AFX_MSG(CTabCtrlDoc) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnSetFocus(CWnd* pOldWnd); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TABCTRLEX_H__28407441_38AF_11D1_ABBA_00A0243D1382__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/UserDef.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/UserDef.h new file mode 100644 index 0000000..862565f --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/UserDef.h @@ -0,0 +1,172 @@ +#include "ACTS1000.h" // ӿ +#include "ADThread.h" +//############################################################# +// ڿλ̵ij +#define VOLT_RANGE 1000.0 // ̣mV(עС) + + +// +#define MAX_CHANNEL_COUNT ACTS1000_AD_MAX_CHANNELS +#define MAX_SEGMENT 16 +#define MAX_RAM_SIZE (1024*256) // ÿͨRAM() + +#define MAX_RAM_SIZE_32M (1024*1024*32) // ÿͨRAM() + +//############################################################# +// Header define +#define PCI_BUS 0x01 +#define USB_BUS 0x02 +#define ISA_BUS 0x03 +#define PC104_BUS 0x04 +#define PXI_BUS 0x05 +#define PXIE_BUS 0x2012 +#define PCIE_BUS 0x2011 + +#define PRO_MODE 0x01 // ǿղɼ +#define INT_MODE 0x02 // жϲɼ +#define DMA_MODE 0x03 // DMAɼ + +#define AD_FILE_TYPE 0x00 // 洢ADݵļ +#define DA_FILE_TYPE 0x01 // 洢DAݵļ +#define DIO_FILE_TYPE 0x02 // 洢DIOݵļ + +#define DEFAULT_FILE_TYPE AD_FILE_TYPE +//#define DEFAULT_BUS_TYPE PXIE_BUS // 豸(PCI) +#define DEFAULT_DEVICE_NUM 0x6666 // 豸,ǷΪ򱣴ļ + +#define DEFAULT_VOLTBOTTOM_RANGE -50000 +#define DEFAULT_VOLTTOP_RANGE 5000 + +#define DEFAULT_DATA_WIDTH 0x14 // 豸ľ(14λ) + +#define HEAD_END_FLAG 0xAA55AA55 + + +#define PCIE8502D_RID 0xD0 + +#define DATA_MODE 1 // ʾ +#define WAVE_MODE 2 // ʾ +#define SAVE_MODE 3 // ̴ + +// ִʾģʽ +#define DEC_DATAMODE 0 // ʮʾ +#define HEX_DATAMODE 1 // ʮʾ +#define VOLT_DATAMODE 2 // ѹֵʾ + +typedef struct _FILE_HEADER +{ + LONG HeadSizeBytes; // ļͷϢ + LONG FileType; + // 豸ļеijԱ + LONG BusType; // 豸(DEFAULT_BUS_TYPE) + LONG DeviceNum; // Ӧó־(DEFAULT_DEVICE_NUM) + LONG DeviceType; // 豸ı8514 8504 8512 8502... + LONG VoltBottomRange; // (mV) + LONG VoltTopRange; // (mV) + + LONG ChannelCount; // ͨ + LONG DataWidth; // 豸ľ(ֱ) + LONG bXorHighBit; // Ƿλ(Ϊ1) + ACTS1000_PARA_AD ADPara; // Ӳ + ACTS1000_STATUS_AD ADStatus; // Ӳ + ACTS1000_AD_MAIN_INFO ADMainInfo; // Ӳ + LONG CrystalFreq; // Ƶ + ULONGLONG CreateFTime; // ļʱ + ULONG nRevisionID; + BYTE Reserved0[124]; // ṹС1024ֽ + LONG HeadEndFlag; // ͷϢλ +} FILE_HEADER, *PFILE_HEADER; + +//############################################################# +// external declare +extern WORD* ADBuffer[MAX_SEGMENT]; // +extern WORD* ADDrawBuffer; +extern BOOL m_bDrawComp; +extern ACTS1000_PARA_AD ADPara; +extern ACTS1000_PARA_AD OldADPara; +extern ACTS1000_STATUS_AD pADStatus; +extern ACTS1000_AD_MAIN_INFO gl_ADMainInfo; +extern WORD gl_wMaxLSB; +extern float gl_fLsbCount; +extern WORD gl_lLsbHalf; +extern int gl_ScreenVolume; +extern int m_TriggerVolt; +extern int WavePointX; +extern int CurrentIndex; +extern HANDLE hDevice; +extern CEdit* pCountEdit; +extern BOOL m_BounceStop; +extern BOOL m_AnalyzeCheck; +extern BOOL m_bCreateDevice; +extern int glOffset; +extern int glBufferID; +extern int m_BounceCount; +extern float m_AnalyzeAllCount; +extern UINT m_OverLimitCount; +extern BOOL m_bProgress; +extern float Center, PerY; +extern CRect ClientRect; +extern float middle1; +extern BOOL bDrawing; +extern int nChannelArrayClient[MAX_CHANNEL_COUNT]; +extern int DisplayChannel[MAX_CHANNEL_COUNT]; +extern BOOL m_bFirstCreateDeviceFile; +extern int m_ProcessDigitalMode; +extern int m_ProcessGraphicMode; +extern int m_AnalyzeChannel; +extern int m_UpperLimit; +extern int m_LowerLimit; +extern ULONGLONG gl_pulDDR2Length; +extern BOOL gl_bRt; +extern ULONGLONG gl_DDR2Lenth; +extern CEdit* pRangeEdit; +extern CEdit* pRatioEdit; +extern int m_ProcessMoveVolt; +extern int nProcessMode; +extern BOOL bBunch; +extern int m_DigitalDataShowMode; +extern SHORT InUserRegion[MAX_SEGMENT][16384]; +extern BOOL gl_bAutoCollect; +extern float OutAnalogValve; +extern int ReadIndex; +extern HANDLE g_ArrFileOut; +extern HANDLE hEvent; +extern HANDLE hExitEvent; +extern BOOL gl_bDeviceADRun; +extern BOOL gl_bAutoTrig; +extern BOOL bCreateDevice; +extern ULONGLONG FileLenghtWords; +extern BOOL gl_Event; +extern BOOL gl_bCollected; +extern BOOL m_bCloseFile; +extern int gl_MiddleLsb[MAX_CHANNEL_COUNT]; +extern int gl_nSampleMode; +extern BOOL gl_bTileWave; +extern ULONG gl_nSampleLenth; +extern float gl_PerLsbVoltM[MAX_CHANNEL_COUNT]; +extern LONG gl_nTriggerPos; +extern ULONG gl_StartAddr; +extern int gl_nChannelCount; +extern int gl_nSaveFileCount; +extern BOOL gl_bSmlThenSize; + +extern ULONGLONG gl_ReadSizeWords; +#define MsgBox AfxMessageBox +CString strMsg; +extern CString g_strFileFullName; +extern ULONG gl_ChannelArrary[MAX_CHANNEL_COUNT]; +extern ACTS1000_STATUS_AD gl_ADStatus; +extern ULONG m_nSampRangeCount; +extern ULONG m_nSampRangeVal[8]; +extern TCHAR g_strChannelEn[2][64]; +extern TCHAR g_strGain[4][64]; +extern TCHAR g_strRefGround[3][64]; +extern TCHAR g_strAIRange[3][64]; +extern TCHAR g_strInputImped[2][64]; +extern ULONG gl_CHIdx[MAX_CHANNEL_COUNT]; + +extern CCriticalSection gl_Section; +extern ULONG gl_nDrawLen; +extern ULONG gl_nDocDrawLen; +extern ULONG gl_nDrawIdx; +extern ULONG gl_nDocDrawIdx; \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/resource.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/resource.h new file mode 100644 index 0000000..d0667e0 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/resource.h @@ -0,0 +1,302 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Sys.rc +// +#define IDD_ABOUTBOX 100 +#define IDC_MDI_TAB_CTRL_BAR 101 +#define CG_ID_VIEW_SETUPDLG 103 +#define ID_WINDOW_NEXT_PANE 104 +#define CG_IDD_Capability 104 +#define CG_ID_VIEW_SHOWSTATUS 105 +#define ID_WINDOW_PREV_PANE 106 +#define CG_IDD_Status 106 +#define CG_ID_VIEW_SHOWSTATUS1 107 +#define CG_IDD_HistoryDlg 108 +#define CG_ID_VIEW_DIALOGBAR 109 +#define IDC_MDI_TAB_CTRL 110 +#define IDI_TABCTRLBAR 110 +#define IDB_TABIMAGES 111 +#define IDW_PROP_BAR 112 +#define IDR_ADSTATUS_TMPL 114 +#define IDR_ADSTATUS_TMPL1 115 +#define CG_ID_VIEW_DLGBAR 117 +#define IDC_ADDCHANNEL 118 +#define IDB_LIGHTBULB 121 +#define CG_IDS_TIPOFTHEDAY 123 +#define CG_IDS_TIPOFTHEDAYMENU 124 +#define CG_IDS_DIDYOUKNOW 125 +#define CG_IDS_FILE_ABSENT 126 +#define CG_IDP_FILE_CORRUPT 127 +#define IDR_MAINFRAME 128 +#define IDR_AD 129 +#define CG_IDS_TIPOFTHEDAYHELP 130 +#define IDR_TABVIEW_MENU 131 +#define IDI_ICON1 137 +#define IDR_ChooseMode 138 +#define IDB_BITMAP2 140 +#define IDB_BITMAP4 143 +#define IDB_BITMAP5 147 +#define IDB_BITMAP3 148 +#define IDR_HistoryData 151 +#define IDD_DIALOG_IO 155 +#define IDC_CURSOR1 158 +#define CG_IDD_ADCHANNEL 160 +#define IDD_DIALOG_DA 161 +#define IDB_BITMAP6 163 +#define IDB_BITMAP8 165 +#define CG_IDD_DIALOG_Save 166 +#define IDR_HisMouseR 168 +#define IDB_BITMAP1 169 +#define IDR_ICON 170 +#define IDR_DIO 174 +#define IDR_MENU1 176 +#define IDR_ListCHParam 176 +#define IDD_DIALOG_Calibration 178 +#define IDC_BUTTON_Start 1004 +#define IDC_EDIT_Frequence 1006 +#define IDC_COMBO_Frequence 1006 +#define IDC_COMBO_SampleLenth 1007 +#define IDC_COMBO_Channel 1008 +#define IDC_EDIT_UpperLimit 1009 +#define IDC_EDIT_LowerLimit 1010 +#define IDC_EDIT_BunchChannel 1011 +#define IDC_CHECK_StopAndRun 1012 +#define IDC_EDIT_TriggerVolt 1013 +#define IDC_EDIT_OverRange 1014 +#define IDC_EDIT_AnalyzeCount 1015 +#define IDC_EDIT_OverRatio 1016 +#define IDC_Combo_MoveVolt 1017 +#define IDC_CHECK_StopFirstDigitalShow 1020 +#define IDC_EDIT_ScreenVolume 1021 +#define IDC_CHECK_Analyze 1023 +#define IDC_STATIC_ShowXY 1024 +#define IDC_EDIT_CountTime 1025 +#define IDC_EDIT_Offset 1026 +#define IDC_EDIT_Volt 1027 +#define IDC_EDIT_PerTime 1028 +#define IDC_PROGRESS 1030 +#define IDC_EDIT_Cycle0 1037 +#define IDC_STATIC_CardType 1048 +#define IDC_SLIDER_Offset 1049 +#define IDC_SLIDER_MN_Length 1050 +#define IDC_BUTTON_Stop 1052 +#define IDM_History_Stop 1055 +#define IDM_History_Start 1056 +#define IDM_History_Stop2 1057 +#define IDC_Goto 1057 +#define IDC_EDIT_FileLength 1059 +#define IDC_COMBO_Rate 1062 +#define IDC_EDIT_ScreenPos 1063 +#define IDC_EDIT_PerChannel 1064 +#define IDC_CHECK_DO8 1074 +#define IDC_CHECK_DO9 1075 +#define IDC_CHECK_DO10 1076 +#define IDC_CHECK_DO11 1077 +#define IDC_CHECK_DO13 1078 +#define IDC_CHECK_DO12 1079 +#define IDC_CHECK_DO14 1080 +#define IDC_CHECK_DO15 1081 +#define IDC_COMBO_TriggerSource 1083 +#define IDC_COMBO_TriggerMode 1084 +#define IDC_BUTTON_StartWriteDA0 1085 +#define IDC_COMBO_TriggerType 1085 +#define IDC_COMBO_TriggerChannel 1085 +#define IDC_COMBO_TriggerMode2 1085 +#define IDC_COMBO_SampleMode 1085 +#define IDC_COMBO_CouplingType0 1086 +#define IDC_BUTTON_StopWriteDA0 1087 +#define IDC_COMBO_TriggerWhen 1087 +#define IDC_COMBO_ChannelDataBit 1087 +#define IDC_SPIN_Cycle0 1088 +#define IDC_EDIT_Value0 1089 +#define IDC_COMBO_TrigPercent 1089 +#define IDC_CHECK_DI8 1090 +#define IDC_SPIN_Value0 1090 +#define IDC_COMBO_TrigEventCnt 1090 +#define IDC_CHECK_DI9 1091 +#define IDC_COMBO_TriggerWidth 1091 +#define IDC_CHECK_DI10 1092 +#define IDC_CHANNEL 1092 +#define IDC_COMBO_ClockSource 1092 +#define IDC_COMBO_ReferenceClock 1092 +#define IDC_CHECK_DI11 1093 +#define IDC_DELETECHANNEL 1093 +#define IDC_COMBO_HighBitSet 1093 +#define IDC_COMBO_SyncTrigSignal 1093 +#define IDC_CHECK_DI12 1094 +#define IDC_COMBO_HighBitSet_Set 1094 +#define IDC_COMBO_ClkOutSel 1094 +#define IDC_CHECK_DI13 1095 +#define IDC_COMBO_TrigOutPolarity 1095 +#define IDC_CHECK_DI14 1096 +#define IDC_CHECK_Wave 1096 +#define IDC_COMBO_ReferenceClock2 1096 +#define IDC_COMBO_TimeBaseClock 1096 +#define IDC_CHECK_DI15 1097 +#define IDC_COMBO_OutTriggerDir 1100 +#define IDC_COMBO_TriggerClass 1101 +#define IDC_COMBO_OutTriggerDir2 1101 +#define IDC_COMBO_PFISel 1101 +#define IDC_COMBO_bAvailableTrig 1102 +#define IDC_CHECK_CheckOverflow 1103 +#define IDC_CHECK_0 1103 +#define IDC_PICTURE 1108 +#define IDC_FileName 1109 +#define IDC_FileLenght 1110 +#define IDC_DiskFree 1111 +#define IDC_CHECK_1 1114 +#define IDC_CHECK_2 1115 +#define IDC_CHECK_3 1116 +#define IDC_FILESINFO 1117 +#define IDC_CHECK_ClockIn 1118 +#define IDC_CHECK_ClockOut 1119 +#define IDC_EDIT_MeasureFreq 1123 +#define IDC_CHECK0 1124 +#define IDC_CHECK_CH0 1124 +#define IDC_CHECK1 1125 +#define IDC_CHECK_bSetTrigLevel 1125 +#define IDC_CHECK_bAvailableTrig 1125 +#define IDC_CHECK_bSaveFile 1125 +#define IDC_CHECK2 1126 +#define IDC_CHECK_ClockOutput 1126 +#define IDC_CHECK_Channel0 1126 +#define IDC_CHECK_bMasterEn 1126 +#define IDC_CHECK3 1127 +#define IDC_CHECK_Channel1 1127 +#define IDC_CHECK_TimerTrig 1127 +#define IDC_CHECK_bClkOutEn 1128 +#define IDC_COMBO_DisplayChannel 1129 +#define IDC_CHECK_bMasterEn3 1129 +#define IDC_CHECK_bTrigOutEn 1129 +#define IDC_COMBO_DisplayLast 1130 +#define IDC_CHECK_Auto 1136 +#define IDC_SPIN_BufferID 1137 +#define IDC_EDIT_BufferID 1138 +#define IDC_STATIC_Offset 1140 +#define IDC_STATIC_TimeOfDiv 1145 +#define IDC_SCROLLBAR2 1149 +#define IDC_STATIC8 1150 +#define IDC_Combo_ScreenVolume 1151 +#define IDC_SCROLLBAR1 1154 +#define IDC_RADIO_PositionA 1155 +#define IDC_RADIO_PositionB 1156 +#define IDC_STATIC_PositionA 1157 +#define IDC_STATIC_PositionB 1158 +#define IDC_STATIC_Frequency 1159 +#define IDC_STATIC_DistanceAB 1160 +#define IDM_TileWave 1161 +#define IDM_SuperPoseWave 1162 +#define IDC_BUTTON_REFRUSH 1163 +#define IDC_BUTTON_RefrushData 1163 +#define IDC_COMBO_VoltRange0 1166 +#define IDC_COMBO_VoltRange1 1167 +#define IDC_COMBO_VoltRange2 1168 +#define IDC_COMBO_VoltRange3 1169 +#define IDC_EDIT_TrigLevelLsb 1170 +#define IDC_EDIT_TrigLevelVolt 1170 +#define IDC_EDIT_TrigLevelVolt2 1171 +#define IDC_EDIT_TrigWindow 1171 +#define IDC_EDIT_N_Length 1172 +#define IDC_EDIT_M_Length 1173 +#define IDC_STATIC_HighBitSet 1174 +#define IDC_EDIT_SampleLenth 1174 +#define IDC_EDIT_TrigWindow2 1175 +#define IDC_EDIT_TrigOutWidth 1175 +#define IDC_EDIT_FreqDivision 1176 +#define IDC_EDIT_FreqDivision2 1177 +#define IDC_EDIT_Frequency 1177 +#define IDC_BUTTON1 1178 +#define IDC_BUTTON_TrigWindowRead 1178 +#define IDC_BUTTON_SoftTirg 1178 +#define IDC_EDIT_TrigInterval 1179 +#define IDC_EDIT_TrigWindowRead 1180 +#define IDC_BUTTON_Calibration 1180 +#define IDC_COMBO_Range0 1181 +#define IDC_COMBO_Range1 1182 +#define IDC_PROGRESS_Calibration 1182 +#define IDC_COMBO_Range2 1183 +#define IDC_STATIC_Calibration 1183 +#define IDC_COMBO_Range3 1184 +#define IDC_CHECK_CH1 1187 +#define IDC_CHECK_CH2 1188 +#define IDC_CHECK6 1189 +#define IDC_CHECK_CH3 1189 +#define IDC_EDIT_TrigCount 1190 +#define IDC_COMBO_CouplingType1 1191 +#define IDC_COMBO_CouplingType2 1192 +#define IDC_COMBO_CouplingType3 1193 +#define IDC_LIST_CHParam 1194 +#define IDC_STATIC_PFI 1195 +#define IDC_STATIC_FmwVersion 1196 +#define IDC_STATIC_FmwVersion2 1197 +#define IDC_STATIC_DriverVersion 1197 +#define IDC_EDIT1 1197 +#define IDC_EDIT_FilePath 1197 +#define IDC_EDIT_PhysID 1336 +#define IDC_EDIT_PID 1337 +#define IDC_EDIT_SN 1338 +#define IDC_EDIT_PassWord 1339 +#define IDC_BUTTON_Set 1340 +#define IDC_BUTTON_PositionA 1341 +#define IDC_BUTTON_PositionB 1342 +#define IDC_SCROLLBAR_ScreenCur 1343 +#define IDM_CollectData 32772 +#define ID_VIEW_FULLSCREEN 32772 +#define ID_WINDOW_NEXT 32773 +#define ID_WINDOW_PREVIOUS 32774 +#define IDM_DigitalShow 32776 +#define ID_WINDOW_SAVE_ALL 32776 +#define IDM_GraphicShow 32777 +#define ID_WINDOW_MANAGE 32777 +#define IDM_DataFileNew 32781 +#define IDM_ShowCfgAnalBar 32783 +#define IDM_MoveVolt 32784 +#define IDM_TenShow 32785 +#define IDM_SixteenShow 32786 +#define IDM_DigitalVoltShowMode 32787 +#define IDM_ClearView 32791 +#define IDM_History_Digit 32792 +#define IDM_History_Wave 32793 +#define IDM_DataSave 32794 +#define IDM_ProcessHistoryData 32795 +#define IDM_CloseFile 32796 +#define IDM_Open_IO 32800 +#define IDM_ListDevice 32802 +#define IDM_ListDeviceDlg 32802 +#define IDM_WriteDA 32804 +#define IDM_StartDeviceAD 32805 +#define IDM_StopDeviceAD 32806 +#define IDM_Open_AD 32807 +#define IDM_HistoryData 32808 +#define IDM_Open_DA 32809 +#define IDM_ShowStatusBar 32810 +#define IDM_REFURBISH 32811 +#define IDM_NOT_EMPTY_MODE 32811 +#define IDM_MDigitalShow 32812 +#define IDM_MGraphicShow 32813 +#define IDM_MDataSave 32814 +#define IDM_HALF_MODE 32815 +#define IDM_INT_MODE 32816 +#define IDM_Pro_Mode 32818 +#define IDM_Dma_Mode 32819 +#define IDM_StartDA 32820 +#define IDM_Open_DIO 32821 +#define ID_MENU_GetDevVersion 32823 +#define IDM_ADCalibration 32824 +#define IDM_SameParam 32825 +#define ID_SHOWMOUSEVOLT 59142 +#define IDS_ProccessHistoryData 61447 +#define IDC_LISTEDIT 61448 +#define IDS_NEW_FILE 61500 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 177 +#define _APS_NEXT_COMMAND_VALUE 32826 +#define _APS_NEXT_CONTROL_VALUE 1198 +#define _APS_NEXT_SYMED_VALUE 131 +#endif +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/rt_manif32.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/rt_manif32.bin new file mode 100644 index 0000000..31bdf90 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/rt_manif32.bin @@ -0,0 +1,31 @@ + + + + + Small utility exe to make it easy to start "mmc.exe %windir%\system32\comexp.msc" + + + + + + + + + + + true + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/rt_manif64.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/rt_manif64.bin new file mode 100644 index 0000000..739b007 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/rt_manif64.bin @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/sys.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/sys.h new file mode 100644 index 0000000..0ceeb4d --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Advanced/sys.h @@ -0,0 +1,108 @@ +// Sys.h : main header file for the SYS application +// +#include "ADDoc.h" +#include "ADHistDoc.h" +#include "ADFrm.h" + +//#include "ADDigitListFrame.h" + + + + +#if !defined(AFX_SYS_H__D485DEFD_85AB_11D1_B878_A68EB300DD63__INCLUDED_) +#define AFX_SYS_H__D485DEFD_85AB_11D1_B878_A68EB300DD63__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CSysApp: +// See Sys.cpp for the implementation of this class +// + +class CSysApp : public CWinApp +{ +public: + CSysApp(); + +public: + // ڿӴΨһ + BOOL m_bCreateADFrm; + BOOL m_bCreateDAFrm; + + HANDLE m_hDevice; // InitInstanceб, ExitInstanceͷ + BOOL m_bCreateDevice; + HWND m_hParaCfgView; + +public: + CADFrame* m_ADFrame; // ݲɼ֡ + CMultiDocTemplate* pADTemplate; + CMultiDocTemplate* pHistDataTemplate; + CMultiDocTemplate* pDIOTemplate; + + CADDoc* m_pADDigitListDoc; + CADDoc* m_pADDoc; + + HANDLE m_hMutex; +public: + int m_CurrentDeviceID; // ¼ǰ豸ID + BOOL m_bDeviceCount; // жϵǰϵͳǷжACTS1000豸 + ULONG m_nRevisionID; +public: + + + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSysApp) + public: + virtual BOOL InitInstance(); + virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName); + virtual int ExitInstance(); + //}}AFX_VIRTUAL + +// Implementation + //{{AFX_MSG(CSysApp) + afx_msg void OnAppAbout(); + afx_msg void OnUpdateCloseFile(CCmdUI* pCmdUI); + afx_msg void OnUpdateDataFileNew(CCmdUI* pCmdUI); + afx_msg void OnCloseFile(); + afx_msg void OnCollectData(); + afx_msg void OnDataFileNew(); + afx_msg void OnReleaseDevice(); + afx_msg void OnStartDeviceAD(); + afx_msg void OnStopDeviceAD(); + afx_msg void OnUpdateStopDeviceAD(CCmdUI* pCmdUI); + afx_msg void OnOpenAD(); + afx_msg void OnUpdateOpenAD(CCmdUI* pCmdUI); + afx_msg void OnHistoryData(); + afx_msg void OnUpdateHistoryData(CCmdUI* pCmdUI); + afx_msg void OnUpdateOpenDA(CCmdUI* pCmdUI); + afx_msg void OnUpdateStartDeviceAD(CCmdUI* pCmdUI); + afx_msg void OnUpdateDataSave(CCmdUI* pCmdUI); + afx_msg void OnUpdateDigitalShow(CCmdUI* pCmdUI); + afx_msg void OnUpdateGraphicShow(CCmdUI* pCmdUI); + afx_msg void OnMDataSave(); + afx_msg void OnMDigitalShow(); + afx_msg void OnMGraphicShow(); + afx_msg void OnListDeviceDlg(); + afx_msg void OnADCalibration(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +private: +private: +}; + +///////////////////////////////////////////////////////////////////////////// +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SYS_H__D485DEFD_85AB_11D1_B878_A68EB300DD63__INCLUDED_) diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/DelTmp.bat b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/DelTmp.bat new file mode 100644 index 0000000..a534861 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/DelTmp.bat @@ -0,0 +1,51 @@ +@echo off +del /s *.~h +del /s *.~cpp +del /s *.~bpr +del /s *.dof +del /s *.ddp +del /s *.~dfm +del /s *.~ddp +del /s *.log +del /s *.~dpr +del /s *.dcu +del /s *.~pas +del /s *.exp +del /s *.obj +del /s *.sbr +del /s *.idb +del /s *.pch +del /s *.aps +del /s *.bsc +del /s *.obj +del /s *.pdb +del /s *.ncb +del /s *.opt +del /s debug\*.exp +del /s debug\*.bsc +del /s debug\*.obj +del /s debug\*.sbr +del /s debug\*.idb +del /s debug\*.pch +del /s debug\*.ilk +del /s debug\*.pdb +del /s release\*.exp +del /s release\*.bsc +del /s release\*.obj +del /s release\*.sbr +del /s release\*.idb +del /s release\*.pch +del /s release\*.ilk +del /s release\*.pdb +del /s *.suo +del /s *.user +del debug\*.* /q + +del release\*.* /q + +rd debug + +rd X86 /s /q +rd x64 /s /q + +rd release diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/ReadMe.txt b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/ReadMe.txt new file mode 100644 index 0000000..c4c4e94 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/ReadMe.txt @@ -0,0 +1,21 @@ +======================================================================== + ̹˵ +======================================================================== + 1Ϊ׳ֻʾӿڸĵ̣οʹ÷ + 2ʾʹDMAʽADݲɼ̡ + 3ֻʹMatLabExcelAccessݷݣôʹ + VCĸ߼ϲɼʾֵѹʾݴ̵ȹһ + Ķĵͼĸ߼Ӧó󣬶Ҫдκγ + ͬʱ߼û߼ʾҲԴִļķʽչʾ + ١ʾȸ߼ +======================================================================== + ļ˵ +======================================================================== +PXIE8582.h ӿͷļûѵӦóʱļƵĹУҴļҪĶ +PXIE8582.lib ӿڵļûѵӦóʱļƵĹ) +Sys.cpp ʾù̵Դļ + +======================================================================== + Ƽ¼ +======================================================================== +2017/03/11 V6.00 ʾ LYB diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys.cpp new file mode 100644 index 0000000..c2a6aa9 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys.cpp @@ -0,0 +1,262 @@ +// ˵ ʾóѯʽȡAD + +#include "stdafx.h" +#include "windows.h" +#include "stdio.h" +#include "conio.h" + +#include "ACTS1000.h" + +int InputRange; + +#define AD_DATA_LEN 256*1024 // ҪȡʹADݳȣ֣ +USHORT ADBuffer[AD_DATA_LEN]; // 仺(洢ԭʼ) + + +char g_strAIRange[3][64] = {"5~-5V", "1~-1V", "10~-10V"}; +int main(int argc, char* argv[]) +{ + HANDLE hDevice; + int DeviceLgcID; + ULONG ulDDR2Length = 0; + ULONGLONG ulDDR2LengthByte = 0; + + ACTS1000_PARA_AD ADPara; // Ӳ + ACTS1000_STATUS_AD ADStatus; + ULONG nRetSizeWords; + ULONG nAvailSampsPoints; + ULONG nRead; + + int nCurrentChannel = 0,nADChannel = 0; + WORD ADData; + float fVolt; + ACTS1000_AD_MAIN_INFO ADMainInfo; + WORD wMaxLSB = 0x3FFF; + float fLsbCount = 16384.0; + ULONG nSampRangeCount; + ULONG nSampRangeVal[8]; + + + DeviceLgcID = 0; + printf("߼ID:"); + scanf_s("%d", &DeviceLgcID); + hDevice = ACTS1000_CreateDevice(DeviceLgcID); // 豸 + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("CreateDevice error...\n"); + _getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetMainInfo(hDevice,&ADMainInfo); // DDR2ij(λMB) + ACTS1000_GetSupportRangeInfo(hDevice,&nSampRangeCount,nSampRangeVal); + + switch (ADMainInfo.nDeviceType>>16) + { + case 0x2012: + printf("PXIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + case 0x2111: + printf("PCIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + default: + printf("ACTS1000-%04X\n",ADMainInfo.nDeviceType); + } + + for (int i=0; iulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = ADStatus.lSavePoints*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + } + } + } + else + { + + while ( !_kbhit() ) + { + if(!ACTS1000_ReadDeviceAD(hDevice, ADBuffer, nRead, &nRetSizeWords, &nAvailSampsPoints,5.0)) + { + printf("ReadDeviceDmaAD error...\n"); + _getch(); + goto ExitRead; + } + if (nRetSizeWords<=0) + { + continue; + } + ulReadCount+=nRetSizeWords; +#if 1 + ulTmp = GetTickCount()-ulTime; + if (ulTmp/1000>ulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = ulReadCount*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + ULONG nTChannel = 0; + for(int Index=0; Index<8; Index++) + { + for(nADChannel=nTChannel; nADChannel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys_32.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys_32.exe new file mode 100644 index 0000000..53369d3 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys_32.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys_64.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys_64.exe new file mode 100644 index 0000000..ed86b5c Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/Sys_64.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/bin1.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/bin1.bin new file mode 100644 index 0000000..1bc1cd1 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/bin1.bin @@ -0,0 +1,22 @@ + + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/resource.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/resource.h new file mode 100644 index 0000000..dd1c942 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Sys.rc +// +#define IDR_242 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/rt_manif.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/rt_manif.bin new file mode 100644 index 0000000..0708b7a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/rt_manif.bin @@ -0,0 +1,21 @@ + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/stdafx.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/stdafx.cpp new file mode 100644 index 0000000..86bf009 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// Sys.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/stdafx.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/stdafx.h new file mode 100644 index 0000000..12ca09e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Continue/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/DelTmp.bat b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/DelTmp.bat new file mode 100644 index 0000000..a534861 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/DelTmp.bat @@ -0,0 +1,51 @@ +@echo off +del /s *.~h +del /s *.~cpp +del /s *.~bpr +del /s *.dof +del /s *.ddp +del /s *.~dfm +del /s *.~ddp +del /s *.log +del /s *.~dpr +del /s *.dcu +del /s *.~pas +del /s *.exp +del /s *.obj +del /s *.sbr +del /s *.idb +del /s *.pch +del /s *.aps +del /s *.bsc +del /s *.obj +del /s *.pdb +del /s *.ncb +del /s *.opt +del /s debug\*.exp +del /s debug\*.bsc +del /s debug\*.obj +del /s debug\*.sbr +del /s debug\*.idb +del /s debug\*.pch +del /s debug\*.ilk +del /s debug\*.pdb +del /s release\*.exp +del /s release\*.bsc +del /s release\*.obj +del /s release\*.sbr +del /s release\*.idb +del /s release\*.pch +del /s release\*.ilk +del /s release\*.pdb +del /s *.suo +del /s *.user +del debug\*.* /q + +del release\*.* /q + +rd debug + +rd X86 /s /q +rd x64 /s /q + +rd release diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/ReadMe.txt b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/ReadMe.txt new file mode 100644 index 0000000..c4c4e94 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/ReadMe.txt @@ -0,0 +1,21 @@ +======================================================================== + ̹˵ +======================================================================== + 1Ϊ׳ֻʾӿڸĵ̣οʹ÷ + 2ʾʹDMAʽADݲɼ̡ + 3ֻʹMatLabExcelAccessݷݣôʹ + VCĸ߼ϲɼʾֵѹʾݴ̵ȹһ + Ķĵͼĸ߼Ӧó󣬶Ҫдκγ + ͬʱ߼û߼ʾҲԴִļķʽչʾ + ١ʾȸ߼ +======================================================================== + ļ˵ +======================================================================== +PXIE8582.h ӿͷļûѵӦóʱļƵĹУҴļҪĶ +PXIE8582.lib ӿڵļûѵӦóʱļƵĹ) +Sys.cpp ʾù̵Դļ + +======================================================================== + Ƽ¼ +======================================================================== +2017/03/11 V6.00 ʾ LYB diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys.cpp new file mode 100644 index 0000000..da9df7c --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys.cpp @@ -0,0 +1,191 @@ +// ˵ ʾóѯʽȡAD + +#include "stdafx.h" +#include "windows.h" +#include "stdio.h" +#include "conio.h" + +#include "ACTS1000.h" + + +#define AD_DATA_LEN 512*1024 // ҪȡʹADݳȣ֣ +USHORT ADBuffer[AD_DATA_LEN]; // 仺(洢ԭʼ) +LONG ADCallBackFunc(HANDLE hDevice, ULONG nSamplesPerChan, ULONG nChannelCount, void *callbackData) +{ + + ULONG nRetSizeWords; + ULONG nAvailSampsPoints; + if (nSamplesPerChan>(AD_DATA_LEN/nChannelCount)) + { + nSamplesPerChan = AD_DATA_LEN/nChannelCount; + } + + if (hDevice == INVALID_HANDLE_VALUE) + { + return 1; + } + if(!ACTS1000_ReadDeviceAD(hDevice, ADBuffer, nSamplesPerChan*nChannelCount, &nRetSizeWords, &nAvailSampsPoints,0.1)) + { + printf("ACTS1000_ReadDeviceAD error...\n"); + _getch(); + return 2; + } + if (nRetSizeWords!=(nSamplesPerChan*nChannelCount)) + { + printf("nRetSizeWords error...\n"); + _getch(); + return 3; + } + printf("ADBuff[0]=0x%X\n", ADBuffer[0]); + return 0; + +} +int main(int argc, char* argv[]) +{ + int DeviceLgcID; + ULONG ulDDR2Length = 0; + ULONGLONG ulDDR2LengthByte = 0; + + ACTS1000_PARA_AD ADPara; // Ӳ + + int nCurrentChannel = 0,nADChannel = 0; + ACTS1000_AD_MAIN_INFO ADMainInfo; + WORD wMaxLSB = 0x3FFF; + float fLsbCount = 16384.0; + ULONG nSamplesPerChan = 0; + HANDLE hDevice; + int InputRange; + + + + DeviceLgcID = 0; + printf("߼ID:"); + scanf_s("%d", &DeviceLgcID); + hDevice = ACTS1000_CreateDevice(DeviceLgcID); // 豸 + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("CreateDevice error...\n"); + _getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetMainInfo(hDevice,&ADMainInfo); // DDR2ij(λMB) + + switch (ADMainInfo.nDeviceType>>16) + { + case 0x2012: + printf("PXIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + case 0x2111: + printf("PCIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + default: + printf("ACTS1000-%04X\n",ADMainInfo.nDeviceType); + } + + ulDDR2LengthByte = ADMainInfo.nDepthOfMemory; + + wMaxLSB = (WORD)(ADMainInfo.nSampCodeCount - 1); + fLsbCount = (float)ADMainInfo.nSampCodeCount; + + InputRange = ACTS1000_INPUT_N1000_P1000mV; // ҪûӼѡ + + + + + ULONG nRevisionID = 0; + if(!ACTS1000_GetBusInfo(hDevice, NULL, NULL, NULL, &nRevisionID)) + { + printf("ACTS1000_GetBusInfo error...\n"); + } + + memset(&ADPara, 0x00, sizeof(ADPara)); // λȷֵ0(ǿҽ) + + // ԤӲ + ADPara.SampleMode = ACTS1000_SAMPMODE_CONTINUOUS; // ޵ + ADPara.FreqDivision = 1000; + for (int nCH=0; nCH + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys_32.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys_32.exe new file mode 100644 index 0000000..5a77bff Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys_32.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys_64.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys_64.exe new file mode 100644 index 0000000..79b25f2 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/Sys_64.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/bin1.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/bin1.bin new file mode 100644 index 0000000..1bc1cd1 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/bin1.bin @@ -0,0 +1,22 @@ + + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/resource.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/resource.h new file mode 100644 index 0000000..dd1c942 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Sys.rc +// +#define IDR_242 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/rt_manif.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/rt_manif.bin new file mode 100644 index 0000000..0708b7a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/rt_manif.bin @@ -0,0 +1,21 @@ + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/stdafx.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/stdafx.cpp new file mode 100644 index 0000000..86bf009 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// Sys.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/stdafx.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/stdafx.h new file mode 100644 index 0000000..12ca09e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueCallB/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/DelTmp.bat b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/DelTmp.bat new file mode 100644 index 0000000..a534861 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/DelTmp.bat @@ -0,0 +1,51 @@ +@echo off +del /s *.~h +del /s *.~cpp +del /s *.~bpr +del /s *.dof +del /s *.ddp +del /s *.~dfm +del /s *.~ddp +del /s *.log +del /s *.~dpr +del /s *.dcu +del /s *.~pas +del /s *.exp +del /s *.obj +del /s *.sbr +del /s *.idb +del /s *.pch +del /s *.aps +del /s *.bsc +del /s *.obj +del /s *.pdb +del /s *.ncb +del /s *.opt +del /s debug\*.exp +del /s debug\*.bsc +del /s debug\*.obj +del /s debug\*.sbr +del /s debug\*.idb +del /s debug\*.pch +del /s debug\*.ilk +del /s debug\*.pdb +del /s release\*.exp +del /s release\*.bsc +del /s release\*.obj +del /s release\*.sbr +del /s release\*.idb +del /s release\*.pch +del /s release\*.ilk +del /s release\*.pdb +del /s *.suo +del /s *.user +del debug\*.* /q + +del release\*.* /q + +rd debug + +rd X86 /s /q +rd x64 /s /q + +rd release diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/ReadMe.txt b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/ReadMe.txt new file mode 100644 index 0000000..c4c4e94 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/ReadMe.txt @@ -0,0 +1,21 @@ +======================================================================== + ̹˵ +======================================================================== + 1Ϊ׳ֻʾӿڸĵ̣οʹ÷ + 2ʾʹDMAʽADݲɼ̡ + 3ֻʹMatLabExcelAccessݷݣôʹ + VCĸ߼ϲɼʾֵѹʾݴ̵ȹһ + Ķĵͼĸ߼Ӧó󣬶Ҫдκγ + ͬʱ߼û߼ʾҲԴִļķʽչʾ + ١ʾȸ߼ +======================================================================== + ļ˵ +======================================================================== +PXIE8582.h ӿͷļûѵӦóʱļƵĹУҴļҪĶ +PXIE8582.lib ӿڵļûѵӦóʱļƵĹ) +Sys.cpp ʾù̵Դļ + +======================================================================== + Ƽ¼ +======================================================================== +2017/03/11 V6.00 ʾ LYB diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys.cpp new file mode 100644 index 0000000..9b56375 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys.cpp @@ -0,0 +1,208 @@ +// ˵ ʾóѯʽȡAD + +#include "stdafx.h" +#include "windows.h" +#include "stdio.h" +#include "conio.h" + +#include "ACTS1000.h" + +int InputRange; + +#define AD_DATA_LEN 256*1024 // ҪȡʹADݳȣ֣ +float fADBuffer[AD_DATA_LEN]; // 仺(洢ԭʼ) +int main(int argc, char* argv[]) +{ + HANDLE hDevice; + int DeviceLgcID; + ULONG ulDDR2Length = 0; + ULONGLONG ulDDR2LengthByte = 0; + + ACTS1000_PARA_AD ADPara; // Ӳ + ACTS1000_STATUS_AD ADStatus; + ULONG nRetSizeWords; + ULONG nAvailSampsPoints; + ULONG nRead; + + int nCurrentChannel = 0,nADChannel = 0; + ACTS1000_AD_MAIN_INFO ADMainInfo; + + + DeviceLgcID = 0; + printf("߼ID:"); + scanf_s("%d", &DeviceLgcID); + hDevice = ACTS1000_CreateDevice(DeviceLgcID); // 豸 + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("CreateDevice error...\n"); + _getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetMainInfo(hDevice,&ADMainInfo); // DDR2ij(λMB) + + switch (ADMainInfo.nDeviceType>>16) + { + case 0x2012: + printf("PXIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + case 0x2111: + printf("PCIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + default: + printf("ACTS1000-%04X\n",ADMainInfo.nDeviceType); + } + + ulDDR2LengthByte = ADMainInfo.nDepthOfMemory; + + + InputRange = ACTS1000_INPUT_N1000_P1000mV; // ҪûӼѡ + + memset(&ADPara, 0x00, sizeof(ADPara)); // λȷֵ0(ǿҽ) + + // ԤӲ + ADPara.SampleMode = ACTS1000_SAMPMODE_CONTINUOUS; // ޵ + ADPara.FreqDivision = 1; + for (int nCH=0; nCHulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = ADStatus.lSavePoints*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + } + } + } + else + { + + while ( !_kbhit() ) + { + if(!ACTS1000_ReadAnalog(hDevice, fADBuffer, nRead, &nRetSizeWords, &nAvailSampsPoints,5.0)) + { + printf("ReadDeviceDmaAD error...\n"); + _getch(); + goto ExitRead; + } + if (nRetSizeWords<=0) + { + continue; + } + ulReadCount+=nRetSizeWords; +#if 1 + ulTmp = GetTickCount()-ulTime; + if (ulTmp/1000>ulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = ulReadCount*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + ULONG nTChannel = 0; + for(int Index=0; Index<8; Index++) + { + for(nADChannel=nTChannel; nADChannel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys_32.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys_32.exe new file mode 100644 index 0000000..be8ee63 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys_32.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys_64.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys_64.exe new file mode 100644 index 0000000..7ef0f5b Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/Sys_64.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/bin1.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/bin1.bin new file mode 100644 index 0000000..1bc1cd1 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/bin1.bin @@ -0,0 +1,22 @@ + + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/resource.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/resource.h new file mode 100644 index 0000000..dd1c942 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Sys.rc +// +#define IDR_242 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/rt_manif.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/rt_manif.bin new file mode 100644 index 0000000..0708b7a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/rt_manif.bin @@ -0,0 +1,21 @@ + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/stdafx.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/stdafx.cpp new file mode 100644 index 0000000..86bf009 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// Sys.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/stdafx.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/stdafx.h new file mode 100644 index 0000000..12ca09e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/ContinueV/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/DelTmp.bat b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/DelTmp.bat new file mode 100644 index 0000000..a534861 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/DelTmp.bat @@ -0,0 +1,51 @@ +@echo off +del /s *.~h +del /s *.~cpp +del /s *.~bpr +del /s *.dof +del /s *.ddp +del /s *.~dfm +del /s *.~ddp +del /s *.log +del /s *.~dpr +del /s *.dcu +del /s *.~pas +del /s *.exp +del /s *.obj +del /s *.sbr +del /s *.idb +del /s *.pch +del /s *.aps +del /s *.bsc +del /s *.obj +del /s *.pdb +del /s *.ncb +del /s *.opt +del /s debug\*.exp +del /s debug\*.bsc +del /s debug\*.obj +del /s debug\*.sbr +del /s debug\*.idb +del /s debug\*.pch +del /s debug\*.ilk +del /s debug\*.pdb +del /s release\*.exp +del /s release\*.bsc +del /s release\*.obj +del /s release\*.sbr +del /s release\*.idb +del /s release\*.pch +del /s release\*.ilk +del /s release\*.pdb +del /s *.suo +del /s *.user +del debug\*.* /q + +del release\*.* /q + +rd debug + +rd X86 /s /q +rd x64 /s /q + +rd release diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/ReadMe.txt b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/ReadMe.txt new file mode 100644 index 0000000..c4c4e94 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/ReadMe.txt @@ -0,0 +1,21 @@ +======================================================================== + ̹˵ +======================================================================== + 1Ϊ׳ֻʾӿڸĵ̣οʹ÷ + 2ʾʹDMAʽADݲɼ̡ + 3ֻʹMatLabExcelAccessݷݣôʹ + VCĸ߼ϲɼʾֵѹʾݴ̵ȹһ + Ķĵͼĸ߼Ӧó󣬶Ҫдκγ + ͬʱ߼û߼ʾҲԴִļķʽչʾ + ١ʾȸ߼ +======================================================================== + ļ˵ +======================================================================== +PXIE8582.h ӿͷļûѵӦóʱļƵĹУҴļҪĶ +PXIE8582.lib ӿڵļûѵӦóʱļƵĹ) +Sys.cpp ʾù̵Դļ + +======================================================================== + Ƽ¼ +======================================================================== +2017/03/11 V6.00 ʾ LYB diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys.cpp new file mode 100644 index 0000000..7a4f4fd --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys.cpp @@ -0,0 +1,289 @@ +// ˵ ʾóѯʽȡAD + +#include "stdafx.h" +#include "windows.h" +#include "stdio.h" +#include "conio.h" + +#include "ACTS1000.h" + + +#define AD_DATA_LEN 256*1024 // ҪȡʹADݳȣ֣ +USHORT ADBuffer[AD_DATA_LEN]; // 仺(洢ԭʼ) + +int main(int argc, char* argv[]) +{ + HANDLE hDevice; + int DeviceLgcID; + ULONG ulDDR2Length = 0; + + ACTS1000_PARA_AD ADPara; // Ӳ + ACTS1000_STATUS_AD ADStatus; + ULONG nRetSizeWords; + ULONG nAvailSampsPoints; + ULONGLONG nReadSizeRemain; + ULONGLONG nReadSizeWords; + ULONG nRead; + ULONG InputRange = ACTS1000_INPUT_N1000_P1000mV; + + int nADChannel = 0; + WORD ADData; + float fVolt; + ACTS1000_AD_MAIN_INFO ADMainInfo; + WORD wMaxLSB = 0x3FFF; + float fLsbCount = 16384.0; + + DeviceLgcID = 0; + printf("߼ID:"); + scanf_s("%d", &DeviceLgcID); + hDevice = ACTS1000_CreateDevice(DeviceLgcID); // 豸 + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("CreateDevice error...\n"); + _getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetMainInfo(hDevice,&ADMainInfo); // DDR2ij(λMB) + + switch (ADMainInfo.nDeviceType>>16) + { + case 0x2012: + printf("PXIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + case 0x2111: + printf("PCIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + default: + printf("ACTS1000-%04X\n",ADMainInfo.nDeviceType); + } + + wMaxLSB = (WORD)(ADMainInfo.nSampCodeCount - 1); + fLsbCount = (float)ADMainInfo.nSampCodeCount; + + ULONG nRevisionID = 0; + if(!ACTS1000_GetBusInfo(hDevice, NULL, NULL, NULL, &nRevisionID)) + { + printf("ACTS1000_GetBusInfo error...\n"); + } + + memset(&ADPara, 0x00, sizeof(ADPara)); // λȷֵ0(ǿҽ) + + // ԤӲ + ADPara.SampleMode = ACTS1000_SAMPMODE_FINITE; // ޵ + ADPara.FreqDivision = 1; + for (int nCH=0; nCHulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = ADStatus.lSavePoints*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + } + } + } + } + else + { + nReadSizeRemain = nReadSizeWords; + while (nReadSizeRemain>0) + { + if (nReadSizeRemain>=AD_DATA_LEN) + { + nRead = AD_DATA_LEN; + } + else + { + nRead = nReadSizeRemain; + } +NextRead: + + if(_kbhit()) goto ExitRead; + if(!ACTS1000_ReadDeviceAD(hDevice, ADBuffer, nRead, &nRetSizeWords, &nAvailSampsPoints,1.0)) + { + printf("ReadDeviceAD error...\n"); + _getch(); + goto ExitRead; + } + if (nRetSizeWords<=0) + { + goto NextRead; + } + nReadSizeRemain = nReadSizeRemain-nRetSizeWords; + +#if 1 + ulTmp = GetTickCount()-ulTime; + if (ulTmp/1000>ulSecCnt) + { + ulSecCnt = ulTmp/1000; + dResult = (nReadSizeWords-nReadSizeRemain)*1.00/((ulTmp+1)/1000.0); + dResult=dResult/1000000.0; + printf("%dS ",ulSecCnt); + printf("%.3fM/\n",dResult); + ULONG nTChannel = 0; + for(int Index=0; Index<8; Index++) + { + for(nADChannel=nTChannel; nADChannel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys_32.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys_32.exe new file mode 100644 index 0000000..1d95e29 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys_32.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys_64.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys_64.exe new file mode 100644 index 0000000..16bc9a9 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/Sys_64.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/bin1.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/bin1.bin new file mode 100644 index 0000000..1bc1cd1 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/bin1.bin @@ -0,0 +1,22 @@ + + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/resource.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/resource.h new file mode 100644 index 0000000..dd1c942 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Sys.rc +// +#define IDR_242 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/rt_manif.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/rt_manif.bin new file mode 100644 index 0000000..0708b7a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/rt_manif.bin @@ -0,0 +1,21 @@ + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/stdafx.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/stdafx.cpp new file mode 100644 index 0000000..86bf009 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// Sys.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/stdafx.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/stdafx.h new file mode 100644 index 0000000..12ca09e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/Finite/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/DelTmp.bat b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/DelTmp.bat new file mode 100644 index 0000000..a534861 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/DelTmp.bat @@ -0,0 +1,51 @@ +@echo off +del /s *.~h +del /s *.~cpp +del /s *.~bpr +del /s *.dof +del /s *.ddp +del /s *.~dfm +del /s *.~ddp +del /s *.log +del /s *.~dpr +del /s *.dcu +del /s *.~pas +del /s *.exp +del /s *.obj +del /s *.sbr +del /s *.idb +del /s *.pch +del /s *.aps +del /s *.bsc +del /s *.obj +del /s *.pdb +del /s *.ncb +del /s *.opt +del /s debug\*.exp +del /s debug\*.bsc +del /s debug\*.obj +del /s debug\*.sbr +del /s debug\*.idb +del /s debug\*.pch +del /s debug\*.ilk +del /s debug\*.pdb +del /s release\*.exp +del /s release\*.bsc +del /s release\*.obj +del /s release\*.sbr +del /s release\*.idb +del /s release\*.pch +del /s release\*.ilk +del /s release\*.pdb +del /s *.suo +del /s *.user +del debug\*.* /q + +del release\*.* /q + +rd debug + +rd X86 /s /q +rd x64 /s /q + +rd release diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/ReadMe.txt b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/ReadMe.txt new file mode 100644 index 0000000..c4c4e94 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/ReadMe.txt @@ -0,0 +1,21 @@ +======================================================================== + ̹˵ +======================================================================== + 1Ϊ׳ֻʾӿڸĵ̣οʹ÷ + 2ʾʹDMAʽADݲɼ̡ + 3ֻʹMatLabExcelAccessݷݣôʹ + VCĸ߼ϲɼʾֵѹʾݴ̵ȹһ + Ķĵͼĸ߼Ӧó󣬶Ҫдκγ + ͬʱ߼û߼ʾҲԴִļķʽչʾ + ١ʾȸ߼ +======================================================================== + ļ˵ +======================================================================== +PXIE8582.h ӿͷļûѵӦóʱļƵĹУҴļҪĶ +PXIE8582.lib ӿڵļûѵӦóʱļƵĹ) +Sys.cpp ʾù̵Դļ + +======================================================================== + Ƽ¼ +======================================================================== +2017/03/11 V6.00 ʾ LYB diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.cpp new file mode 100644 index 0000000..ca623e2 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.cpp @@ -0,0 +1,202 @@ +// ˵ ʾóѯʽȡAD + +#include "stdafx.h" +#include "windows.h" +#include "stdio.h" +#include "conio.h" + +#include "ACTS1000.h" + +#define AD_DATA_LEN 512*1024 // ҪȡʹADݳȣ֣ +USHORT ADBuffer[AD_DATA_LEN]; // 仺(洢ԭʼ) +ULONGLONG nReadCnt = 0; +LONG ADCallBackFunc(HANDLE hDevice, ULONG nSamplesPerChan, ULONG nChannelCount, void *callbackData) +{ + + ULONG nRetSizeWords; + ULONG nAvailSampsPoints; + if (nSamplesPerChan>(AD_DATA_LEN/nChannelCount)) + { + nSamplesPerChan = AD_DATA_LEN/nChannelCount; + } + + if (hDevice == INVALID_HANDLE_VALUE) + { + return 1; + } + if(!ACTS1000_ReadDeviceAD(hDevice, ADBuffer, nSamplesPerChan*nChannelCount, &nRetSizeWords, &nAvailSampsPoints,0.1)) + { + printf("ACTS1000_ReadDeviceAD error...\n"); + _getch(); + return 2; + } + if (nRetSizeWords!=(nSamplesPerChan*nChannelCount)) + { + printf("nRetSizeWords error...\n"); + _getch(); + return 3; + } + nReadCnt+=nSamplesPerChan; + printf("ADBuff[0]=0x%X\n", ADBuffer[0]); + return 0; + +} +int main(int argc, char* argv[]) +{ + HANDLE hDevice; + int DeviceLgcID; + ULONG ulDDR2Length = 0; + + ACTS1000_PARA_AD ADPara; // Ӳ + ULONGLONG nReadSizeWords; + ULONG InputRange = ACTS1000_INPUT_N1000_P1000mV; + + int nADChannel = 0; + ACTS1000_AD_MAIN_INFO ADMainInfo; + WORD wMaxLSB = 0x3FFF; + float fLsbCount = 16384.0; + + ULONG nSamplesPerChan = 131072; + + DeviceLgcID = 0; + printf("߼ID:"); + scanf_s("%d", &DeviceLgcID); + hDevice = ACTS1000_CreateDevice(DeviceLgcID); // 豸 + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("CreateDevice error...\n"); + _getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetMainInfo(hDevice,&ADMainInfo); // DDR2ij(λMB) + + switch (ADMainInfo.nDeviceType>>16) + { + case 0x2012: + printf("PXIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + case 0x2111: + printf("PCIE%04X\n",ADMainInfo.nDeviceType&0xFFFF); + break; + default: + printf("ACTS1000-%04X\n",ADMainInfo.nDeviceType); + } + + wMaxLSB = (WORD)(ADMainInfo.nSampCodeCount - 1); + fLsbCount = (float)ADMainInfo.nSampCodeCount; + + ULONG nRevisionID = 0; + if(!ACTS1000_GetBusInfo(hDevice, NULL, NULL, NULL, &nRevisionID)) + { + printf("ACTS1000_GetBusInfo error...\n"); + } + + memset(&ADPara, 0x00, sizeof(ADPara)); // λȷֵ0(ǿҽ) + + // ԤӲ + ADPara.SampleMode = ACTS1000_SAMPMODE_FINITE; // ޵ + ADPara.FreqDivision = 1; + for (int nCH=0; nCH=nReadSizeWords) + { + printf("޵(%I64dֽ)ɰ˳\n", nReadCnt*ChannelCount*2); + break; + } + } + + + ACTS1000_StopDeviceAD(hDevice); // ֹͣAD + ACTS1000_ReleaseDeviceAD(hDevice); // ͷAD + ACTS1000_ReleaseDevice(hDevice); // ͷ豸 + _getch(); + return 0; +} + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.exe new file mode 100644 index 0000000..b6961b3 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.ilk b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.ilk new file mode 100644 index 0000000..5cdb032 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.ilk differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.rc b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.rc new file mode 100644 index 0000000..3f4fe29 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.rc @@ -0,0 +1,89 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// (л񹲺͹) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +#pragma code_page(936) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// 24 +// + +1 24 "bin1.bin" +#endif // (л񹲺͹) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Ӣ(Ӣ) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// 24 +// + +40024 24 "rt_manif.bin" +#endif // Ӣ(Ӣ) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.sln b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.sln new file mode 100644 index 0000000..3cd07a8 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sys", "Sys.vcproj", "{0114CEBA-D0CD-4794-A452-527810B9EC66}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Debug|Win32.ActiveCfg = Debug|Win32 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Debug|Win32.Build.0 = Debug|Win32 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Debug|x64.ActiveCfg = Debug|x64 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Debug|x64.Build.0 = Debug|x64 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Release|Win32.ActiveCfg = Release|Win32 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Release|Win32.Build.0 = Release|Win32 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Release|x64.ActiveCfg = Release|x64 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.vcproj b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.vcproj new file mode 100644 index 0000000..2f7a892 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys.vcproj @@ -0,0 +1,431 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys_32.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys_32.exe new file mode 100644 index 0000000..f056b80 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys_32.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys_64.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys_64.exe new file mode 100644 index 0000000..f275228 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/Sys_64.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/bin1.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/bin1.bin new file mode 100644 index 0000000..1bc1cd1 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/bin1.bin @@ -0,0 +1,22 @@ + + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/resource.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/resource.h new file mode 100644 index 0000000..dd1c942 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Sys.rc +// +#define IDR_242 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/rt_manif.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/rt_manif.bin new file mode 100644 index 0000000..0708b7a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/rt_manif.bin @@ -0,0 +1,21 @@ + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/stdafx.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/stdafx.cpp new file mode 100644 index 0000000..86bf009 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// Sys.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/stdafx.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/stdafx.h new file mode 100644 index 0000000..12ca09e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/AD/FiniteCallB/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/DelTmp.bat b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/DelTmp.bat new file mode 100644 index 0000000..a534861 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/DelTmp.bat @@ -0,0 +1,51 @@ +@echo off +del /s *.~h +del /s *.~cpp +del /s *.~bpr +del /s *.dof +del /s *.ddp +del /s *.~dfm +del /s *.~ddp +del /s *.log +del /s *.~dpr +del /s *.dcu +del /s *.~pas +del /s *.exp +del /s *.obj +del /s *.sbr +del /s *.idb +del /s *.pch +del /s *.aps +del /s *.bsc +del /s *.obj +del /s *.pdb +del /s *.ncb +del /s *.opt +del /s debug\*.exp +del /s debug\*.bsc +del /s debug\*.obj +del /s debug\*.sbr +del /s debug\*.idb +del /s debug\*.pch +del /s debug\*.ilk +del /s debug\*.pdb +del /s release\*.exp +del /s release\*.bsc +del /s release\*.obj +del /s release\*.sbr +del /s release\*.idb +del /s release\*.pch +del /s release\*.ilk +del /s release\*.pdb +del /s *.suo +del /s *.user +del debug\*.* /q + +del release\*.* /q + +rd debug + +rd X86 /s /q +rd x64 /s /q + +rd release diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/ReadMe.txt b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/ReadMe.txt new file mode 100644 index 0000000..c4c4e94 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/ReadMe.txt @@ -0,0 +1,21 @@ +======================================================================== + ̹˵ +======================================================================== + 1Ϊ׳ֻʾӿڸĵ̣οʹ÷ + 2ʾʹDMAʽADݲɼ̡ + 3ֻʹMatLabExcelAccessݷݣôʹ + VCĸ߼ϲɼʾֵѹʾݴ̵ȹһ + Ķĵͼĸ߼Ӧó󣬶Ҫдκγ + ͬʱ߼û߼ʾҲԴִļķʽչʾ + ١ʾȸ߼ +======================================================================== + ļ˵ +======================================================================== +PXIE8582.h ӿͷļûѵӦóʱļƵĹУҴļҪĶ +PXIE8582.lib ӿڵļûѵӦóʱļƵĹ) +Sys.cpp ʾù̵Դļ + +======================================================================== + Ƽ¼ +======================================================================== +2017/03/11 V6.00 ʾ LYB diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/StdAfx.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/StdAfx.cpp new file mode 100644 index 0000000..86bf009 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// Sys.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/StdAfx.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/StdAfx.h new file mode 100644 index 0000000..12ca09e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/StdAfx.h @@ -0,0 +1,15 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +#include +#include + + + +// TODO: ڴ˴óҪͷļ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.cpp b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.cpp new file mode 100644 index 0000000..e6124fe --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.cpp @@ -0,0 +1,65 @@ +// ˵ ʾóѯʽȡAD + +#include "stdafx.h" +#include "windows.h" +#include "stdio.h" +#include "conio.h" + +#include "ACTS1000.h" +#pragma warning(disable:4996) +int InputRange; +int SelectInputRange(void); + +#define AD_DATA_LEN 1024*16 // ҪȡʹADݳȣ֣ +USHORT ADBuffer[AD_DATA_LEN]; // 仺(洢ԭʼ) + +int main(int argc, char* argv[]) +{ + HANDLE hDevice; + LONG DevID, LinkType; + LONG DeviceLgcID, DevicePhysID; + + + + DeviceLgcID = 0; +SlectLT: + printf("ѡ豸ʽ:0:߼ 1: "); + scanf_s("%d", &LinkType); + if (LinkType<0 || LinkType>1) + { + goto SlectLT; + } + +SlectID: + printf("ID:"); + scanf_s("%d", &DevID); + if (DevID <0) + { + goto SlectID; + } + switch (LinkType) + { + case 0: + hDevice = ACTS1000_CreateDevice(DevID); // 豸 + break; + case 1: + hDevice = ACTS1000_CreateDeviceEx(DevID); // 豸 + break; + } + + if(hDevice == INVALID_HANDLE_VALUE) + { + printf("ACTS1000_CreateDevice fail"); + _getch(); + return 0; // 豸ʧܣ򷵻 + } + + ACTS1000_GetDeviceCurrentID(hDevice, &DeviceLgcID, &DevicePhysID); + printf("ǰ豸߼ID:%d ID:%d\n", DeviceLgcID, DevicePhysID); + + printf("ID:"); + scanf_s("%d", &DevicePhysID); + ACTS1000_SetDevicePhysID(hDevice, DevicePhysID); + ACTS1000_ReleaseDevice(hDevice); // ͷ豸 + return 0; +} \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.ilk b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.ilk new file mode 100644 index 0000000..5cdb032 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.ilk differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.rc b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.rc new file mode 100644 index 0000000..3f4fe29 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.rc @@ -0,0 +1,89 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// (л񹲺͹) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +#pragma code_page(936) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// 24 +// + +1 24 "bin1.bin" +#endif // (л񹲺͹) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Ӣ(Ӣ) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// 24 +// + +40024 24 "rt_manif.bin" +#endif // Ӣ(Ӣ) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.sln b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.sln new file mode 100644 index 0000000..3cd07a8 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sys", "Sys.vcproj", "{0114CEBA-D0CD-4794-A452-527810B9EC66}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Debug|Win32.ActiveCfg = Debug|Win32 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Debug|Win32.Build.0 = Debug|Win32 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Debug|x64.ActiveCfg = Debug|x64 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Debug|x64.Build.0 = Debug|x64 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Release|Win32.ActiveCfg = Release|Win32 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Release|Win32.Build.0 = Release|Win32 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Release|x64.ActiveCfg = Release|x64 + {0114CEBA-D0CD-4794-A452-527810B9EC66}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.vcproj b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.vcproj new file mode 100644 index 0000000..566ade5 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys.vcproj @@ -0,0 +1,431 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys_32.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys_32.exe new file mode 100644 index 0000000..79ea1dc Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys_32.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys_64.exe b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys_64.exe new file mode 100644 index 0000000..3b3ad5b Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/Sys_64.exe differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/bin1.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/bin1.bin new file mode 100644 index 0000000..1bc1cd1 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/bin1.bin @@ -0,0 +1,22 @@ + + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/main.xml b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/main.xml new file mode 100644 index 0000000..92cfe4d --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/main.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/resource.h b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/resource.h new file mode 100644 index 0000000..dd1c942 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Sys.rc +// +#define IDR_242 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/rt_manif.bin b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/rt_manif.bin new file mode 100644 index 0000000..0708b7a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/VC/Simple/PhysicalID/rt_manif.bin @@ -0,0 +1,21 @@ + + + + + + Wwan DriverTest App + + + + + + + + + + \ No newline at end of file diff --git a/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ACTS1000.cat b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ACTS1000.cat new file mode 100644 index 0000000..3078ad3 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ACTS1000.cat differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ACTS1000.inf b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ACTS1000.inf new file mode 100644 index 0000000..ee9a53e --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ACTS1000.inf @@ -0,0 +1,551 @@ +;=========================================================== +; +; File : ACTS1000.inf +; +; Abstract: Windows INF +; +;=========================================================== + +[Version] +Signature = $Windows NT$ +Provider = %ART% +Class = ART Technology +ClassGUID = {A6FC9E61-C465-11CF-8056-444553415254} +DriverVer = 07/20/2025, 1.6.2.0 +DriverPackageDisplayName = %PackageName% +CatalogFile = ACTS1000.cat +PnpLockdown = 1 + +; ================= Class section ===================== + +[ClassInstall32] +Addreg=ARTClassReg + +[ARTClassReg] +HKR,,,0,%ClassName% +HKR,,Icon,,-5 +HKR,,DeviceCharacteristics,0x10001,0x100 ;Use same security checks on relative opens +HKR,,Security,,%ART_ACCESS_SDDL% ;Allow generic all access to system and built-in Admin. + + +[Manufacturer] +%ART% = ART.Mfg, NTamd64, NTia64 + +[ControlFlags] +ExcludeFromSelect = * + +;----------------------------------------------------------- +; Device identification for 32-bit Windows +;----------------------------------------------------------- +[ART.Mfg] +%PXIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8502 +%PXIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8504 +%PXIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8512 +%PXIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8514 +%PXIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8582 +%PXIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8584 +%PXIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8912 +%PXIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8914 +%PXIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8916 +%PCIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8502 +%PCIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8504 +%PCIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8512 +%PCIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8514 +%PCIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8582 +%PCIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8584 +%PCIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8586 +%PCIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8912 +%PCIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8914 +%PCIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8916 +%PXIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20121E42&REV_00 +%PXIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20121E42&REV_00 +%PXIE8506.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20121E42&REV_00 +%PXIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20121E42&REV_00 +%PXIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20121E42&REV_00 +%PXIE8516.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20121E42&REV_00 +%PXIE8526.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20121E42&REV_00 +%PXIE8562.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20121E42&REV_00 +%PXIE8564.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20121E42&REV_00 +%PXIE8566.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20121E42&REV_00 +%PXIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_00 +%PXIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_00 +%PXIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_00 +%PXIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20121E42&REV_00 +%PXIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20121E42&REV_00 +%PXIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20121E42&REV_00 + +%PXIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20121E42&REV_D0 +%PXIE8504D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20121E42&REV_D0 +%PXIE8506D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20121E42&REV_D0 +%PXIE8512D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20121E42&REV_D0 +%PXIE8514D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20121E42&REV_D0 +%PXIE8516D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20121E42&REV_D0 +%PXIE8526D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20121E42&REV_D0 +%PXIE8562D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20121E42&REV_D0 +%PXIE8564D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20121E42&REV_D0 +%PXIE8566D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20121E42&REV_D0 +%PXIE8582D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_D0 +%PXIE8584D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_D0 +%PXIE8586D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_D0 +%PXIE8912D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20121E42&REV_D0 +%PXIE8914D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20121E42&REV_D0 +%PXIE8916D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20121E42&REV_D0 + +%PCIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_00 +%PCIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20111E42&REV_00 +%PCIE8506.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20111E42&REV_00 +%PCIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20111E42&REV_00 +%PCIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20111E42&REV_00 +%PCIE8516.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20111E42&REV_00 +%PCIE8526.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20111E42&REV_00 +%PCIE8562.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20111E42&REV_00 +%PCIE8564.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20111E42&REV_00 +%PCIE8566.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20111E42&REV_00 +%PCIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_00 +%PCIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_00 +%PCIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_00 +%PCIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20111E42&REV_00 +%PCIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20111E42&REV_00 +%PCIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20111E42&REV_00 +%PCIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_D0 + +%PCIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_D0 +%PCIE8504D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20111E42&REV_D0 +%PCIE8506D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20111E42&REV_D0 +%PCIE8512D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20111E42&REV_D0 +%PCIE8514D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20111E42&REV_D0 +%PCIE8516D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20111E42&REV_D0 +%PCIE8526D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20111E42&REV_D0 +%PCIE8562D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20111E42&REV_D0 +%PCIE8564D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20111E42&REV_D0 +%PCIE8566D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20111E42&REV_D0 +%PCIE8582D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_D0 +%PCIE8584D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_D0 +%PCIE8586D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_D0 +%PCIE8912D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20111E42&REV_D0 +%PCIE8914D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20111E42&REV_D0 +%PCIE8916D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20111E42&REV_D0 + +%PCIE8531C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8531&SUBSYS_20111E42&REV_03 +%PCIE8532C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8532&SUBSYS_20111E42&REV_03 +%PCIE8536C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8536&SUBSYS_20111E42&REV_03 +%PCIE8531D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8531&SUBSYS_20111E42&REV_D0 +%PCIE8532D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8532&SUBSYS_20111E42&REV_D0 +%PCIE8536D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8536&SUBSYS_20111E42&REV_D0 + +%PXIE8582A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_01 +%PXIE8584A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_01 +%PXIE8586A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_01 + +%PCIE8582A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_01 +%PCIE8584A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_01 +%PCIE8586A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_01 + +%PXIE8922.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20121E42&REV_00 +%PCIE8922.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20111E42&REV_00 +%PXIE8922D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20121E42&REV_D0 +%PCIE8922D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20111E42&REV_D0 + +%PXIE858C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_858C&SUBSYS_20121E42&REV_D0 + +;----------------------------------------------------------- +; Device identification for 64-bit Windows x64 +;----------------------------------------------------------- +[ART.Mfg.NTamd64] +%PXIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8502 +%PXIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8504 +%PXIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8512 +%PXIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8514 +%PXIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8582 +%PXIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8584 +%PXIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8912 +%PXIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8914 +%PXIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8916 +%PCIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8502 +%PCIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8504 +%PCIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8512 +%PCIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8514 +%PCIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8582 +%PCIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8584 +%PCIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8586 +%PCIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8912 +%PCIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8914 +%PCIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8916 +%PXIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20121E42&REV_00 +%PXIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20121E42&REV_00 +%PXIE8506.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20121E42&REV_00 +%PXIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20121E42&REV_00 +%PXIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20121E42&REV_00 +%PXIE8516.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20121E42&REV_00 +%PXIE8526.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20121E42&REV_00 +%PXIE8562.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20121E42&REV_00 +%PXIE8564.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20121E42&REV_00 +%PXIE8566.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20121E42&REV_00 +%PXIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_00 +%PXIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_00 +%PXIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_00 +%PXIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20121E42&REV_00 +%PXIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20121E42&REV_00 +%PXIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20121E42&REV_00 + +%PXIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20121E42&REV_D0 +%PXIE8504D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20121E42&REV_D0 +%PXIE8506D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20121E42&REV_D0 +%PXIE8512D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20121E42&REV_D0 +%PXIE8514D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20121E42&REV_D0 +%PXIE8516D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20121E42&REV_D0 +%PXIE8526D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20121E42&REV_D0 +%PXIE8562D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20121E42&REV_D0 +%PXIE8564D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20121E42&REV_D0 +%PXIE8566D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20121E42&REV_D0 +%PXIE8582D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_D0 +%PXIE8584D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_D0 +%PXIE8586D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_D0 +%PXIE8912D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20121E42&REV_D0 +%PXIE8914D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20121E42&REV_D0 +%PXIE8916D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20121E42&REV_D0 + +%PCIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_00 +%PCIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20111E42&REV_00 +%PCIE8506.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20111E42&REV_00 +%PCIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20111E42&REV_00 +%PCIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20111E42&REV_00 +%PCIE8516.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20111E42&REV_00 +%PCIE8526.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20111E42&REV_00 +%PCIE8562.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20111E42&REV_00 +%PCIE8564.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20111E42&REV_00 +%PCIE8566.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20111E42&REV_00 +%PCIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_00 +%PCIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_00 +%PCIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_00 +%PCIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20111E42&REV_00 +%PCIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20111E42&REV_00 +%PCIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20111E42&REV_00 +%PCIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_D0 + +%PCIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_D0 +%PCIE8504D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20111E42&REV_D0 +%PCIE8506D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20111E42&REV_D0 +%PCIE8512D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20111E42&REV_D0 +%PCIE8514D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20111E42&REV_D0 +%PCIE8516D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20111E42&REV_D0 +%PCIE8526D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20111E42&REV_D0 +%PCIE8562D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20111E42&REV_D0 +%PCIE8564D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20111E42&REV_D0 +%PCIE8566D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20111E42&REV_D0 +%PCIE8582D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_D0 +%PCIE8584D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_D0 +%PCIE8586D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_D0 +%PCIE8912D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20111E42&REV_D0 +%PCIE8914D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20111E42&REV_D0 +%PCIE8916D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20111E42&REV_D0 + +%PCIE8531C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8531&SUBSYS_20111E42&REV_03 +%PCIE8532C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8532&SUBSYS_20111E42&REV_03 +%PCIE8536C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8536&SUBSYS_20111E42&REV_03 +%PCIE8531D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8531&SUBSYS_20111E42&REV_D0 +%PCIE8532D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8532&SUBSYS_20111E42&REV_D0 +%PCIE8536D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8536&SUBSYS_20111E42&REV_D0 + +%PXIE8582A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_01 +%PXIE8584A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_01 +%PXIE8586A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_01 + +%PCIE8582A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_01 +%PCIE8584A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_01 +%PCIE8586A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_01 + +%PXIE8922.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20121E42&REV_00 +%PCIE8922.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20111E42&REV_00 +%PXIE8922D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20121E42&REV_D0 +%PCIE8922D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20111E42&REV_D0 + +%PXIE858C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_858C&SUBSYS_20121E42&REV_D0 + +;----------------------------------------------------------- +; Device identification for ia64 +;----------------------------------------------------------- +[ART.Mfg.NTia64] +%PXIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8502 +%PXIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8504 +%PXIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8512 +%PXIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8514 +%PXIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8582 +%PXIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8584 +%PXIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8912 +%PXIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8914 +%PXIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_2012&DEV_8916 +%PCIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8502 +%PCIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8504 +%PCIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8512 +%PCIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8514 +%PCIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8582 +%PCIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8584 +%PCIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8586 +%PCIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8912 +%PCIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8914 +%PCIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_2011&DEV_8916 +%PXIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20121E42&REV_00 +%PXIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20121E42&REV_00 +%PXIE8506.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20121E42&REV_00 +%PXIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20121E42&REV_00 +%PXIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20121E42&REV_00 +%PXIE8516.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20121E42&REV_00 +%PXIE8526.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20121E42&REV_00 +%PXIE8562.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20121E42&REV_00 +%PXIE8564.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20121E42&REV_00 +%PXIE8566.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20121E42&REV_00 +%PXIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_00 +%PXIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_00 +%PXIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_00 +%PXIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20121E42&REV_00 +%PXIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20121E42&REV_00 +%PXIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20121E42&REV_00 + +%PXIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20121E42&REV_D0 +%PXIE8504D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20121E42&REV_D0 +%PXIE8506D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20121E42&REV_D0 +%PXIE8512D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20121E42&REV_D0 +%PXIE8514D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20121E42&REV_D0 +%PXIE8516D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20121E42&REV_D0 +%PXIE8526D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20121E42&REV_D0 +%PXIE8562D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20121E42&REV_D0 +%PXIE8564D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20121E42&REV_D0 +%PXIE8566D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20121E42&REV_D0 +%PXIE8582D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_D0 +%PXIE8584D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_D0 +%PXIE8586D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_D0 +%PXIE8912D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20121E42&REV_D0 +%PXIE8914D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20121E42&REV_D0 +%PXIE8916D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20121E42&REV_D0 + +%PCIE8502.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_00 +%PCIE8504.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20111E42&REV_00 +%PCIE8506.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20111E42&REV_00 +%PCIE8512.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20111E42&REV_00 +%PCIE8514.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20111E42&REV_00 +%PCIE8516.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20111E42&REV_00 +%PCIE8526.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20111E42&REV_00 +%PCIE8562.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20111E42&REV_00 +%PCIE8564.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20111E42&REV_00 +%PCIE8566.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20111E42&REV_00 +%PCIE8582.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_00 +%PCIE8584.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_00 +%PCIE8586.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_00 +%PCIE8912.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20111E42&REV_00 +%PCIE8914.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20111E42&REV_00 +%PCIE8916.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20111E42&REV_00 +%PCIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_D0 + +%PCIE8502D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8502&SUBSYS_20111E42&REV_D0 +%PCIE8504D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8504&SUBSYS_20111E42&REV_D0 +%PCIE8506D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8506&SUBSYS_20111E42&REV_D0 +%PCIE8512D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8512&SUBSYS_20111E42&REV_D0 +%PCIE8514D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8514&SUBSYS_20111E42&REV_D0 +%PCIE8516D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8516&SUBSYS_20111E42&REV_D0 +%PCIE8526D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8526&SUBSYS_20111E42&REV_D0 +%PCIE8562D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8562&SUBSYS_20111E42&REV_D0 +%PCIE8564D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8564&SUBSYS_20111E42&REV_D0 +%PCIE8566D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8566&SUBSYS_20111E42&REV_D0 +%PCIE8582D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_D0 +%PCIE8584D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_D0 +%PCIE8586D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_D0 +%PCIE8912D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8912&SUBSYS_20111E42&REV_D0 +%PCIE8914D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8914&SUBSYS_20111E42&REV_D0 +%PCIE8916D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8916&SUBSYS_20111E42&REV_D0 + +%PCIE8531C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8531&SUBSYS_20111E42&REV_03 +%PCIE8532C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8532&SUBSYS_20111E42&REV_03 +%PCIE8536C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8536&SUBSYS_20111E42&REV_03 +%PCIE8531D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8531&SUBSYS_20111E42&REV_D0 +%PCIE8532D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8532&SUBSYS_20111E42&REV_D0 +%PCIE8536D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8536&SUBSYS_20111E42&REV_D0 + +%PXIE8582A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20121E42&REV_01 +%PXIE8584A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20121E42&REV_01 +%PXIE8586A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20121E42&REV_01 + +%PCIE8582A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8582&SUBSYS_20111E42&REV_01 +%PCIE8584A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8584&SUBSYS_20111E42&REV_01 +%PCIE8586A.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8586&SUBSYS_20111E42&REV_01 + +%PXIE8922.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20121E42&REV_00 +%PCIE8922.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20111E42&REV_00 +%PXIE8922D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20121E42&REV_D0 +%PCIE8922D.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_8922&SUBSYS_20111E42&REV_D0 + +%PXIE858C.DRVDESC%=DDInstall_1000,PCI\VEN_1E42&DEV_858C&SUBSYS_20121E42&REV_D0 + +;----------------------------------------------------------- +; CopyFiles section +; +; Flags: 0x00000004 = COPYFLG_NOVERSIONCHECK +;----------------------------------------------------------- +[CopyFiles_1000] +ACTS1000.sys,,,0x00000004 + +;----------------------------------------------------------- +; Driver installation section +;----------------------------------------------------------- +[DDInstall_1000.NT] +AddReg = AddRegistry_1000 +CopyFiles = CopyFiles_1000 + +;----------------------------------------------------------- +; Device-specific options & registry entries +; +; Security settings are added here to override any class security settings +; imposed on some systems. Refer to "SDDL strings" on MSDN for details. +; +; ART is setting the default access as follows: +; GA -> SY GENERIC_ALL to OS itself +; GA -> BA GENERIC_ALL to Administrators +; GRGWGX -> BU READ/WRITE/EXEC to Built-in User Group +; GRGWGX -> BG READ/WRITE/EXEC to Built-in Guest Group +;----------------------------------------------------------- +[DDInstall_1000.NT.HW] +AddReg = AddRegSecurity + +[AddRegSecurity] +HKR,,Security,,%ART_ACCESS_SDDL% + +;----------------------------------------------------------- +; AddService section +;----------------------------------------------------------- +[DDInstall_1000.NT.Services] +AddService = ACTS1000, 0x00000002, Service_Inst_1000 + +;----------------------------------------------------------- +; AddRegistry section +;----------------------------------------------------------- +[AddRegistry_1000] +HKLM,System\CurrentControlSet\Services\ACTS1000,CommonBufferSize,0x00010003,0x10000 + +;----------------------------------------------------------- +; Service installation section +;----------------------------------------------------------- +[Service_Inst_1000] +ServiceType = 1 ; SERVICE_KERNEL_DRIVER +StartType = 3 ; SERVICE_DEMAND_START +ErrorControl = 0 ; SERVICE_ERROR_IGNORE +ServiceBinary = %12%\ACTS1000.sys + + + +;----------------------------------------------------------- +; Source file information +;----------------------------------------------------------- +[SourceDisksNames] +1 = %InstallDisk% + +[SourceDisksFiles.x86] +ACTS1000.sys = 1,\i386 + +[SourceDisksFiles.amd64] +ACTS1000.sys = 1,\amd64 + +[SourceDisksFiles.ia64] +ACTS1000.sys = 1,\ia64 + +[DestinationDirs] +CopyFiles_ApiDll = 16425 ;16425 = %WinDir%\System32 (supports WOW64) +DefaultDestDir = 12 ;12 = Drivers Directory + + +;----------------------------------------------------------- +; String information +;----------------------------------------------------------- +[Strings] +InstallDisk = "ART Installation Disk" +ART = "ART Technology" +ART_ACCESS_SDDL = "D:P(A;;GA;;;SY)(A;;GRGWGX;;;BA)(A;;GRGWGX;;;BU)(A;;GA;;;BG)" +PackageName = "ART Technology SDK Driver Installation Package" +ClassName = "ART Technology Devices" + +PXIE8502.DRVDESC = "ACTS1000 PXIE8502 4CH 12Bit 40Msps High Speed Digitizer" +PXIE8504.DRVDESC = "ACTS1000 PXIE8504 4CH 14Bit 40Msps High Speed Digitizer" +PXIE8506.DRVDESC = "ACTS1000 PXIE8506 4CH 16Bit 40Msps High Speed Digitizer" +PXIE8512.DRVDESC = "ACTS1000 PXIE8512 4CH 12Bit 80Msps High Speed Digitizer" +PXIE8514.DRVDESC = "ACTS1000 PXIE8514 4CH 14Bit 80Msps High Speed Digitizer" +PXIE8516.DRVDESC = "ACTS1000 PXIE8516 4CH 16Bit 80Msps High Speed Digitizer" +PXIE8526.DRVDESC = "ACTS1000 PXIE8526 4CH 16Bit 125Msps High Speed Digitizer" +PXIE8562.DRVDESC = "ACTS1000 PXIE8562 4CH 12Bit 250Msps High Speed Digitizer" +PXIE8564.DRVDESC = "ACTS1000 PXIE8564 4CH 14Bit 250Msps High Speed Digitizer" +PXIE8566.DRVDESC = "ACTS1000 PXIE8566 4CH 16Bit 250Msps High Speed Digitizer" +PXIE8582.DRVDESC = "ACTS1000 PXIE8582 8CH 12Bit 100Msps High Speed Digitizer" +PXIE8584.DRVDESC = "ACTS1000 PXIE8584 8CH 14Bit 100Msps High Speed Digitizer" +PXIE8586.DRVDESC = "ACTS1000 PXIE8586 8CH 16Bit 100Msps High Speed Digitizer" +PXIE8912.DRVDESC = "ACTS1000 PXIE8912 2CH 12Bit 250Msps High Speed Digitizer" +PXIE8914.DRVDESC = "ACTS1000 PXIE8914 2CH 14Bit 250Msps High Speed Digitizer" +PXIE8916.DRVDESC = "ACTS1000 PXIE8916 2CH 16Bit 250Msps High Speed Digitizer" +PCIE8502.DRVDESC = "ACTS1000 PCIE8502 4CH 12Bit 40Msps High Speed Digitizer" +PCIE8504.DRVDESC = "ACTS1000 PCIE8504 4CH 14Bit 40Msps High Speed Digitizer" +PCIE8506.DRVDESC = "ACTS1000 PCIE8506 4CH 16Bit 40Msps High Speed Digitizer" +PCIE8512.DRVDESC = "ACTS1000 PCIE8512 4CH 12Bit 80Msps High Speed Digitizer" +PCIE8514.DRVDESC = "ACTS1000 PCIE8514 4CH 14Bit 80Msps High Speed Digitizer" +PCIE8516.DRVDESC = "ACTS1000 PCIE8516 4CH 16Bit 80Msps High Speed Digitizer" +PCIE8526.DRVDESC = "ACTS1000 PCIE8526 4CH 16Bit 125Msps High Speed Digitizer" +PCIE8562.DRVDESC = "ACTS1000 PCIE8562 4CH 12Bit 250Msps High Speed Digitizer" +PCIE8564.DRVDESC = "ACTS1000 PCIE8564 4CH 14Bit 250Msps High Speed Digitizer" +PCIE8566.DRVDESC = "ACTS1000 PCIE8566 4CH 16Bit 250Msps High Speed Digitizer" +PCIE8582.DRVDESC = "ACTS1000 PCIE8582 8CH 12Bit 100Msps High Speed Digitizer" +PCIE8584.DRVDESC = "ACTS1000 PCIE8584 8CH 14Bit 100Msps High Speed Digitizer" +PCIE8586.DRVDESC = "ACTS1000 PCIE8586 8CH 16Bit 100Msps High Speed Digitizer" +PCIE8912.DRVDESC = "ACTS1000 PCIE8912 2CH 12Bit 250Msps High Speed Digitizer" +PCIE8914.DRVDESC = "ACTS1000 PCIE8914 2CH 14Bit 250Msps High Speed Digitizer" +PCIE8916.DRVDESC = "ACTS1000 PCIE8916 2CH 16Bit 250Msps High Speed Digitizer" +PXIE8502D.DRVDESC = "ACTS1000 PXIE8502D 4CH 12Bit 40Msps High Speed Digitizer" +PXIE8504D.DRVDESC = "ACTS1000 PXIE8504D 4CH 14Bit 40Msps High Speed Digitizer" +PXIE8506D.DRVDESC = "ACTS1000 PXIE8506D 4CH 16Bit 40Msps High Speed Digitizer" +PXIE8512D.DRVDESC = "ACTS1000 PXIE8512D 4CH 12Bit 80Msps High Speed Digitizer" +PXIE8514D.DRVDESC = "ACTS1000 PXIE8514D 4CH 14Bit 80Msps High Speed Digitizer" +PXIE8516D.DRVDESC = "ACTS1000 PXIE8516D 4CH 16Bit 80Msps High Speed Digitizer" +PXIE8526D.DRVDESC = "ACTS1000 PXIE8526D 4CH 16Bit 125Msps High Speed Digitizer" +PXIE8562D.DRVDESC = "ACTS1000 PXIE8562D 4CH 12Bit 250Msps High Speed Digitizer" +PXIE8564D.DRVDESC = "ACTS1000 PXIE8564D 4CH 14Bit 250Msps High Speed Digitizer" +PXIE8566D.DRVDESC = "ACTS1000 PXIE8566D 4CH 16Bit 250Msps High Speed Digitizer" +PXIE8582D.DRVDESC = "ACTS1000 PXIE8582D 8CH 12Bit 100Msps High Speed Digitizer" +PXIE8584D.DRVDESC = "ACTS1000 PXIE8584D 8CH 14Bit 100Msps High Speed Digitizer" +PXIE8586D.DRVDESC = "ACTS1000 PXIE8586D 8CH 16Bit 100Msps High Speed Digitizer" +PXIE8912D.DRVDESC = "ACTS1000 PXIE8912D 2CH 12Bit 250Msps High Speed Digitizer" +PXIE8914D.DRVDESC = "ACTS1000 PXIE8914D 2CH 14Bit 250Msps High Speed Digitizer" +PXIE8916D.DRVDESC = "ACTS1000 PXIE8916D 2CH 16Bit 250Msps High Speed Digitizer" +PCIE8502D.DRVDESC = "ACTS1000 PCIE8502D 4CH 12Bit 40Msps High Speed Digitizer" +PCIE8504D.DRVDESC = "ACTS1000 PCIE8504D 4CH 14Bit 40Msps High Speed Digitizer" +PCIE8506D.DRVDESC = "ACTS1000 PCIE8506D 4CH 16Bit 40Msps High Speed Digitizer" +PCIE8512D.DRVDESC = "ACTS1000 PCIE8512D 4CH 12Bit 80Msps High Speed Digitizer" +PCIE8514D.DRVDESC = "ACTS1000 PCIE8514D 4CH 14Bit 80Msps High Speed Digitizer" +PCIE8516D.DRVDESC = "ACTS1000 PCIE8516D 4CH 16Bit 80Msps High Speed Digitizer" +PCIE8526D.DRVDESC = "ACTS1000 PCIE8526D 4CH 16Bit 125Msps High Speed Digitizer" +PCIE8562D.DRVDESC = "ACTS1000 PCIE8562D 4CH 12Bit 250Msps High Speed Digitizer" +PCIE8564D.DRVDESC = "ACTS1000 PCIE8564D 4CH 14Bit 250Msps High Speed Digitizer" +PCIE8566D.DRVDESC = "ACTS1000 PCIE8566D 4CH 16Bit 250Msps High Speed Digitizer" +PCIE8582D.DRVDESC = "ACTS1000 PCIE8582D 8CH 12Bit 100Msps High Speed Digitizer" +PCIE8584D.DRVDESC = "ACTS1000 PCIE8584D 8CH 14Bit 100Msps High Speed Digitizer" +PCIE8586D.DRVDESC = "ACTS1000 PCIE8586D 8CH 16Bit 100Msps High Speed Digitizer" +PCIE8912D.DRVDESC = "ACTS1000 PCIE8912D 2CH 12Bit 250Msps High Speed Digitizer" +PCIE8914D.DRVDESC = "ACTS1000 PCIE8914D 2CH 14Bit 250Msps High Speed Digitizer" +PCIE8916D.DRVDESC = "ACTS1000 PCIE8916D 2CH 16Bit 250Msps High Speed Digitizer" + +PCIE8531C.DRVDESC = "ACTS1000 PCIE8531C 4CH 14Bit 20Msps High Speed Digitizer" +PCIE8532C.DRVDESC = "ACTS1000 PCIE8532C 4CH 12Bit 20Msps High Speed Digitizer" +PCIE8536C.DRVDESC = "ACTS1000 PCIE8536C 4CH 16Bit 20Msps High Speed Digitizer" +PCIE8531D.DRVDESC = "ACTS1000 PCIE8531D 4CH 14Bit 20Msps High Speed Digitizer" +PCIE8532D.DRVDESC = "ACTS1000 PCIE8532D 4CH 12Bit 20Msps High Speed Digitizer" +PCIE8536D.DRVDESC = "ACTS1000 PCIE8536D 4CH 16Bit 20Msps High Speed Digitizer" + +PXIE8582A.DRVDESC = "ACTS1000 PXIE8582A 8CH 12Bit 100Msps High Speed Digitizer" +PXIE8584A.DRVDESC = "ACTS1000 PXIE8584A 8CH 14Bit 100Msps High Speed Digitizer" +PXIE8586A.DRVDESC = "ACTS1000 PXIE8586A 8CH 16Bit 100Msps High Speed Digitizer" + +PCIE8582A.DRVDESC = "ACTS1000 PCIE8582A 8CH 12Bit 100Msps High Speed Digitizer" +PCIE8584A.DRVDESC = "ACTS1000 PCIE8584A 8CH 14Bit 100Msps High Speed Digitizer" +PCIE8586A.DRVDESC = "ACTS1000 PCIE8586A 8CH 16Bit 100Msps High Speed Digitizer" + +PXIE8922.DRVDESC = "ACTS1000 PXIE8922 2CH 12Bit 500Msps High Speed Digitizer" +PCIE8922.DRVDESC = "ACTS1000 PCIE8922 2CH 12Bit 500Msps High Speed Digitizer" +PXIE8922D.DRVDESC = "ACTS1000 PXIE8922D 2CH 12Bit 500Msps High Speed Digitizer" +PCIE8922D.DRVDESC = "ACTS1000 PCIE8922D 2CH 12Bit 500Msps High Speed Digitizer" + +PXIE858C.DRVDESC = "ACTS1000 PXIE858C 8CH 16Bit 100Msps High Speed Digitizer" + diff --git a/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/amd64/ACTS1000.sys b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/amd64/ACTS1000.sys new file mode 100644 index 0000000..314697b Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/amd64/ACTS1000.sys differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/i386/ACTS1000.sys b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/i386/ACTS1000.sys new file mode 100644 index 0000000..063ad8d Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/i386/ACTS1000.sys differ diff --git a/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ia64/ACTS1000.sys b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ia64/ACTS1000.sys new file mode 100644 index 0000000..063ad8d Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/Samples/Win32&Win64/ia64/ACTS1000.sys differ diff --git a/Docs/PCIe8586驱动接入资料/docs/API_AND_DATA_FORMAT.md b/Docs/PCIe8586驱动接入资料/docs/API_AND_DATA_FORMAT.md new file mode 100644 index 0000000..5d92100 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/docs/API_AND_DATA_FORMAT.md @@ -0,0 +1,76 @@ +# 接口与数据格式 + +## `IDigitizer` + +| 成员 | 作用 | 前置条件 | +|---|---|---| +| `EnumerateDevicesAsync` | 枚举逻辑设备并读取物理 ID/型号 | 厂商运行库与驱动可用 | +| `OpenAsync` | 按 `DeviceInfo.LogicalId` 创建设备句柄 | 未打开或已关闭 | +| `ConfigureAsync` | 校验并写入 AD 参数 | 已打开、未采集 | +| `StartAcquisitionAsync` | 启动、软件触发并持续返回采样块 | 已打开且已配置 | +| `StopAsync` | 停止 AD 并释放 AD 资源 | 可重复调用 | +| `CloseAsync` | 先停止,再释放设备句柄 | 可重复调用 | + +`Pcie8586Digitizer` 用于真卡;`SimulatedDigitizer` 用于无硬件开发和主项目数据链测试。 + +## 配置 + +```csharp +var config = new AcquisitionConfig( + ChannelCount: 4, + InputRange: InputRange.PlusMinus5V, + ClockDivider: 100, + Mode: AcquisitionMode.Continuous, + FiniteSamplesPerChannel: 10_000); +``` + +此配置启用 CH0–CH3,量程 ±5 V,采样率 1 MS/s。 + +## `SampleBlock` + +```text +Channels[channel][sample] double,单位 V +SampleRateHz 每通道采样率 +StartSampleIndex 此块首点在当前采集任务中的序号 +Timestamp 软件生成块时的本机时间 +ChannelCount 通道数 +SamplesPerChannel 每通道点数 +``` + +原始 DMA word 必须先截断到通道数的整数倍,再解交错。不能把返回的 word 数当作每通道点数。 + +## 文件输出 + +`WaveformWriter` 输出: + +- `.bin`:小端 `float32`,按采样点交错。 +- `.json`:通道数、采样率、量程、每通道点数、布局、单位和时间。 + +Python 读取示例: + +```python +data = np.fromfile(path, dtype=" + net8.0-windows + x64 + x64 + +``` + +若主项目获准随程序分发 DLL,可加入: + +```xml + + + +``` + +## 故障定位 + +- `DllNotFoundException`:DLL 不在应用目录、系统目录或 PATH,或 DLL 的二级依赖缺失。 +- `BadImageFormatException`:宿主进程/DLL 位数不一致。 +- `EntryPointNotFoundException`:DLL 版本与头文件/API 不匹配。 +- 能加载 DLL 但枚举为 0:检查设备管理器、板卡供电、驱动安装、逻辑 ID 和是否被其他进程占用。 +- 启动后无数据:检查软件触发是否执行、通道配置、分频参数和物理输入。 + +发布前应在干净目标机上验证,不能只在安装过完整 SDK 的开发机上验证。 diff --git a/Docs/PCIe8586驱动接入资料/docs/reference/PCIe8582_8584_8586_M使用手册(V6.00.01).pdf b/Docs/PCIe8586驱动接入资料/docs/reference/PCIe8582_8584_8586_M使用手册(V6.00.01).pdf new file mode 100644 index 0000000..3968f12 Binary files /dev/null and b/Docs/PCIe8586驱动接入资料/docs/reference/PCIe8582_8584_8586_M使用手册(V6.00.01).pdf differ diff --git a/Docs/PCIe8586驱动接入资料/examples/ConsoleIntegration/ConsoleIntegration.csproj b/Docs/PCIe8586驱动接入资料/examples/ConsoleIntegration/ConsoleIntegration.csproj new file mode 100644 index 0000000..1188d91 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/examples/ConsoleIntegration/ConsoleIntegration.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0-windows + x64 + enable + enable + + + + + + + diff --git a/Docs/PCIe8586驱动接入资料/examples/ConsoleIntegration/Program.cs b/Docs/PCIe8586驱动接入资料/examples/ConsoleIntegration/Program.cs new file mode 100644 index 0000000..37dcb7d --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/examples/ConsoleIntegration/Program.cs @@ -0,0 +1,44 @@ +using Pcie8586Probe.Hardware; +using Pcie8586Probe.Models; + +using var digitizer = new Pcie8586Digitizer(); +using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(2)); + +var devices = await digitizer.EnumerateDevicesAsync(CancellationToken.None); +if (devices.Count == 0) +{ + Console.Error.WriteLine("未发现设备。请确认板卡、厂商驱动和 ACTS1000_64.dll 均已正确安装。"); + return 1; +} + +var config = new AcquisitionConfig( + ChannelCount: 1, + InputRange: InputRange.PlusMinus5V, + ClockDivider: 100, + Mode: AcquisitionMode.Continuous, + FiniteSamplesPerChannel: 10_000); + +try +{ + await digitizer.OpenAsync(devices[0], CancellationToken.None); + await digitizer.ConfigureAsync(config, CancellationToken.None); + + await foreach (var block in digitizer.StartAcquisitionAsync(cancellation.Token)) + { + Console.WriteLine( + $"起始点={block.StartSampleIndex}, 每通道点数={block.SamplesPerChannel}, " + + $"通道数={block.ChannelCount}, 采样率={block.SampleRateHz:N0} Hz, " + + $"CH0首点={block.Channels[0][0]:F6} V"); + } +} +catch (OperationCanceledException) +{ + // 示例按预定时间结束。 +} +finally +{ + await digitizer.StopAsync(); + await digitizer.CloseAsync(); +} + +return 0; diff --git a/Docs/PCIe8586驱动接入资料/native/README.md b/Docs/PCIe8586驱动接入资料/native/README.md new file mode 100644 index 0000000..ea7e089 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/native/README.md @@ -0,0 +1,7 @@ +# 厂商运行库放置目录 + +本仓库没有 `ACTS1000_64.dll`,因此这里不放置伪文件。 + +如果厂商许可允许随主程序分发,请从与当前硬件驱动匹配的官方 SDK/安装目录取得 `ACTS1000_64.dll`,放到最终主程序 EXE 同目录,或放入本目录并在宿主项目中配置复制到输出目录。 + +文件必须是 x64 版本,并与已安装的内核驱动和 `vendor/include/ACTS1000.h` API 版本匹配。不要从未知来源下载 DLL。 diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/CodeConverter.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/CodeConverter.cs new file mode 100644 index 0000000..239635c --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/CodeConverter.cs @@ -0,0 +1,47 @@ +using Pcie8586Probe.Models; + +namespace Pcie8586Probe.Acquisition; + +public static class CodeConverter +{ + public static double CodeToVolts(ushort code, InputRange range) + { + return range switch + { + InputRange.PlusMinus5V => ((10_000.0 / 65_536.0) * code - 5_000.0) / 1_000.0, + InputRange.PlusMinus1V => ((2_000.0 / 65_536.0) * code - 1_000.0) / 1_000.0, + _ => throw new ArgumentOutOfRangeException(nameof(range), range, null) + }; + } + + public static double[][] Deinterleave(ReadOnlySpan raw, int channelCount, InputRange range) + { + if (channelCount is not (1 or 2 or 4 or 8)) + { + throw new ArgumentOutOfRangeException(nameof(channelCount), "Channel count must be 1, 2, 4, or 8."); + } + + if (raw.Length % channelCount != 0) + { + throw new ArgumentException("Raw sample length must be divisible by channel count.", nameof(raw)); + } + + var samplesPerChannel = raw.Length / channelCount; + var result = new double[channelCount][]; + for (var channel = 0; channel < channelCount; channel++) + { + result[channel] = new double[samplesPerChannel]; + } + + for (var sample = 0; sample < samplesPerChannel; sample++) + { + var baseIndex = sample * channelCount; + for (var channel = 0; channel < channelCount; channel++) + { + result[channel][sample] = CodeToVolts(raw[baseIndex + channel], range); + } + } + + return result; + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/Recorder.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/Recorder.cs new file mode 100644 index 0000000..8955c32 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/Recorder.cs @@ -0,0 +1,79 @@ +using Pcie8586Probe.Models; + +namespace Pcie8586Probe.Acquisition; + +public sealed class Recorder +{ + private readonly object _gate = new(); + private readonly List _blocks = new(); + private long _targetSamplesPerChannel; + private bool _armed; + private bool _completed; + private double _sampleRateHz; + + public bool IsRecording + { + get + { + lock (_gate) + { + return _armed && !_completed; + } + } + } + + public double Progress + { + get + { + lock (_gate) + { + if (_targetSamplesPerChannel <= 0) + { + return 0; + } + + var count = _blocks.Sum(static block => (long)block.SamplesPerChannel); + return Math.Clamp((double)count / _targetSamplesPerChannel, 0, 1); + } + } + } + + public void Start(TimeSpan duration, double sampleRateHz) + { + if (duration <= TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(duration)); + if (sampleRateHz <= 0) throw new ArgumentOutOfRangeException(nameof(sampleRateHz)); + + lock (_gate) + { + _blocks.Clear(); + _sampleRateHz = sampleRateHz; + _targetSamplesPerChannel = Math.Max(1, (long)Math.Round(sampleRateHz * duration.TotalSeconds)); + _armed = true; + _completed = false; + } + } + + public SampleBlock? Add(SampleBlock block) + { + lock (_gate) + { + if (!_armed || _completed) + { + return null; + } + + _blocks.Add(block); + var count = _blocks.Sum(static item => (long)item.SamplesPerChannel); + if (count < _targetSamplesPerChannel) + { + return null; + } + + _completed = true; + _armed = false; + var merged = SampleBlockAssembler.Concat(_blocks); + return SampleBlockAssembler.Slice(merged, 0, (int)_targetSamplesPerChannel) with { SampleRateHz = _sampleRateHz }; + } + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/RingHistoryBuffer.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/RingHistoryBuffer.cs new file mode 100644 index 0000000..60acaf4 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/RingHistoryBuffer.cs @@ -0,0 +1,82 @@ +using Pcie8586Probe.Models; + +namespace Pcie8586Probe.Acquisition; + +public sealed class RingHistoryBuffer +{ + private readonly object _gate = new(); + private readonly Queue _blocks = new(); + private readonly long _maxSamplesPerChannel; + private long _samplesPerChannel; + + public RingHistoryBuffer(double sampleRateHz, double seconds, int maxBytes = 500 * 1024 * 1024) + { + if (sampleRateHz <= 0) throw new ArgumentOutOfRangeException(nameof(sampleRateHz)); + if (seconds <= 0) throw new ArgumentOutOfRangeException(nameof(seconds)); + + var requested = (long)Math.Ceiling(sampleRateHz * seconds); + var memoryBound = Math.Max(1, maxBytes / (8L * 8L)); + _maxSamplesPerChannel = Math.Max(1, Math.Min(requested, memoryBound)); + } + + public long SamplesPerChannel + { + get + { + lock (_gate) + { + return _samplesPerChannel; + } + } + } + + public void Add(SampleBlock block) + { + if (block.SamplesPerChannel == 0) + { + return; + } + + lock (_gate) + { + _blocks.Enqueue(block); + _samplesPerChannel += block.SamplesPerChannel; + + while (_samplesPerChannel > _maxSamplesPerChannel && _blocks.Count > 0) + { + var removed = _blocks.Dequeue(); + _samplesPerChannel -= removed.SamplesPerChannel; + } + } + } + + public SampleBlock? Snapshot() + { + lock (_gate) + { + if (_blocks.Count == 0) + { + return null; + } + + return SampleBlockAssembler.Concat(_blocks); + } + } + + public SampleBlock? Slice(long startInclusive, long endExclusive) + { + if (startInclusive < 0 || endExclusive <= startInclusive) + { + return null; + } + + var snapshot = Snapshot(); + if (snapshot is null || startInclusive >= snapshot.SamplesPerChannel) + { + return null; + } + + var end = Math.Min(endExclusive, snapshot.SamplesPerChannel); + return SampleBlockAssembler.Slice(snapshot, (int)startInclusive, (int)(end - startInclusive)); + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/SampleBlockAssembler.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/SampleBlockAssembler.cs new file mode 100644 index 0000000..76198a5 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/SampleBlockAssembler.cs @@ -0,0 +1,55 @@ +using Pcie8586Probe.Models; + +namespace Pcie8586Probe.Acquisition; + +public static class SampleBlockAssembler +{ + public static SampleBlock Concat(IEnumerable blocks) + { + var list = blocks.ToList(); + if (list.Count == 0) + { + throw new ArgumentException("At least one block is required.", nameof(blocks)); + } + + var first = list[0]; + var channelCount = first.ChannelCount; + var totalSamples = list.Sum(static block => block.SamplesPerChannel); + var channels = new double[channelCount][]; + + for (var channel = 0; channel < channelCount; channel++) + { + channels[channel] = new double[totalSamples]; + var offset = 0; + foreach (var block in list) + { + if (block.ChannelCount != channelCount) + { + throw new InvalidOperationException("All sample blocks must have the same channel count."); + } + + Array.Copy(block.Channels[channel], 0, channels[channel], offset, block.SamplesPerChannel); + offset += block.SamplesPerChannel; + } + } + + return new SampleBlock(channels, first.SampleRateHz, first.StartSampleIndex, first.Timestamp); + } + + public static SampleBlock Slice(SampleBlock block, int start, int count) + { + if (start < 0 || count < 0 || start + count > block.SamplesPerChannel) + { + throw new ArgumentOutOfRangeException(nameof(start)); + } + + var channels = new double[block.ChannelCount][]; + for (var channel = 0; channel < block.ChannelCount; channel++) + { + channels[channel] = new double[count]; + Array.Copy(block.Channels[channel], start, channels[channel], 0, count); + } + + return new SampleBlock(channels, block.SampleRateHz, block.StartSampleIndex + start, block.Timestamp); + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/WaveformWriter.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/WaveformWriter.cs new file mode 100644 index 0000000..98ce848 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Acquisition/WaveformWriter.cs @@ -0,0 +1,56 @@ +using System.Buffers.Binary; +using System.IO; +using System.Text.Json; +using Pcie8586Probe.Models; + +namespace Pcie8586Probe.Acquisition; + +public static class WaveformWriter +{ + public static async Task WriteAsync(SampleBlock block, string outputDirectory, string name, InputRange range, CancellationToken cancellationToken) + { + Directory.CreateDirectory(outputDirectory); + + var safeName = string.Join("_", name.Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries)); + if (string.IsNullOrWhiteSpace(safeName)) + { + safeName = "capture"; + } + + var basePath = Path.Combine(outputDirectory, safeName); + var binaryPath = basePath + ".bin"; + var metadataPath = basePath + ".json"; + + await using (var stream = File.Create(binaryPath)) + { + var bytes = new byte[4]; + for (var sample = 0; sample < block.SamplesPerChannel; sample++) + { + for (var channel = 0; channel < block.ChannelCount; channel++) + { + BinaryPrimitives.WriteSingleLittleEndian(bytes, (float)block.Channels[channel][sample]); + await stream.WriteAsync(bytes, cancellationToken); + } + } + } + + var duration = TimeSpan.FromSeconds(block.SamplesPerChannel / block.SampleRateHz); + var metadata = new + { + channel_count = block.ChannelCount, + sample_rate_hz = block.SampleRateHz, + input_range = range == InputRange.PlusMinus5V ? "5V" : "1V", + samples_per_channel = block.SamplesPerChannel, + dtype = "float32", + layout = "interleaved", + unit = "volt", + recorded_at = DateTimeOffset.Now.ToString("O"), + duration_ms = duration.TotalMilliseconds + }; + + var json = JsonSerializer.Serialize(metadata, new JsonSerializerOptions { WriteIndented = true }); + await File.WriteAllTextAsync(metadataPath, json, cancellationToken); + + return new RecordingResult(block, basePath, binaryPath, metadataPath, duration); + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/IDigitizer.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/IDigitizer.cs new file mode 100644 index 0000000..170951d --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/IDigitizer.cs @@ -0,0 +1,20 @@ +using Pcie8586Probe.Models; + +namespace Pcie8586Probe.Hardware; + +public interface IDigitizer : IDisposable +{ + bool IsOpen { get; } + + ValueTask> EnumerateDevicesAsync(CancellationToken cancellationToken); + + ValueTask OpenAsync(DeviceInfo device, CancellationToken cancellationToken); + + ValueTask ConfigureAsync(AcquisitionConfig config, CancellationToken cancellationToken); + + IAsyncEnumerable StartAcquisitionAsync(CancellationToken cancellationToken); + + ValueTask StopAsync(); + + ValueTask CloseAsync(); +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/Pcie8586Digitizer.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/Pcie8586Digitizer.cs new file mode 100644 index 0000000..92e5fc3 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/Pcie8586Digitizer.cs @@ -0,0 +1,406 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Pcie8586Probe.Acquisition; +using Pcie8586Probe.Models; + +namespace Pcie8586Probe.Hardware; + +public sealed class Pcie8586Digitizer : IDigitizer +{ + private const int InvalidHandle = -1; + private const int MaxChannels = 8; + private const int ReadBufferWords = 256 * 1024; + + private IntPtr _handle; + private AcquisitionConfig _config = AcquisitionConfig.Default; + private bool _started; + + public bool IsOpen => IsValidHandle(_handle); + + public async ValueTask> EnumerateDevicesAsync(CancellationToken cancellationToken) + { + return await Task.Run>(() => + { + var devices = new List(); + IntPtr probe = IntPtr.Zero; + + try + { + probe = Native.ACTS1000_CreateDevice(0); + if (!IsValidHandle(probe)) + { + return devices; + } + + var count = Native.ACTS1000_GetDeviceCount(probe); + for (var logicalId = 0; logicalId < Math.Max(0, count); logicalId++) + { + cancellationToken.ThrowIfCancellationRequested(); + IntPtr device = IntPtr.Zero; + try + { + device = Native.ACTS1000_CreateDevice(logicalId); + if (!IsValidHandle(device)) + { + continue; + } + + var info = default(Native.ACTS1000_AD_MAIN_INFO); + var description = "ACTS1000 digitizer"; + if (Native.ACTS1000_GetMainInfo(device, ref info)) + { + description = FormatDeviceName(info.nDeviceType); + } + + int? physicalId = null; + var lgc = 0; + var phys = 0; + if (Native.ACTS1000_GetDeviceCurrentID(device, ref lgc, ref phys)) + { + physicalId = phys; + } + + devices.Add(new DeviceInfo(logicalId, physicalId, description, false)); + } + finally + { + if (IsValidHandle(device)) + { + Native.ACTS1000_ReleaseDevice(device); + } + } + } + } + catch (DllNotFoundException) + { + return devices; + } + catch (BadImageFormatException) + { + return devices; + } + catch (EntryPointNotFoundException) + { + return devices; + } + finally + { + if (IsValidHandle(probe)) + { + Native.ACTS1000_ReleaseDevice(probe); + } + } + + return devices; + }, cancellationToken); + } + + public ValueTask OpenAsync(DeviceInfo device, CancellationToken cancellationToken) + { + CloseAsync().GetAwaiter().GetResult(); + _handle = Native.ACTS1000_CreateDevice(device.LogicalId); + if (!IsValidHandle(_handle)) + { + _handle = IntPtr.Zero; + throw new InvalidOperationException($"ACTS1000_CreateDevice({device.LogicalId}) failed."); + } + + return ValueTask.CompletedTask; + } + + public ValueTask ConfigureAsync(AcquisitionConfig config, CancellationToken cancellationToken) + { + config.Validate(); + EnsureOpen(); + _config = config; + + var mainInfo = default(Native.ACTS1000_AD_MAIN_INFO); + if (!Native.ACTS1000_GetMainInfo(_handle, ref mainInfo)) + { + throw new Win32Exception("ACTS1000_GetMainInfo failed."); + } + + var ad = new Native.ACTS1000_PARA_AD + { + bChannelArray = new int[MaxChannels], + InputRange = new int[MaxChannels], + CouplingType = new int[MaxChannels], + InputImped = new int[MaxChannels], + FreqDivision = config.ClockDivider, + SampleMode = config.Mode == AcquisitionMode.Continuous ? Native.ACTS1000_SAMPMODE_CONTINUOUS : Native.ACTS1000_SAMPMODE_FINITE, + M_Length = 0, + N_Length = config.Mode == AcquisitionMode.Finite ? checked((uint)config.FiniteSamplesPerChannel) : 32 * 1024, + PFISel = Native.ACTS1000_PFISEL_TRIG_IN, + TriggerMode = Native.ACTS1000_TRIGMODE_POST, + TriggerSource = Native.ACTS1000_TRIGMODE_SOFT, + TriggerDir = Native.ACTS1000_TRIGDIR_NEGATIVE, + TrigLevelVolt = 0, + TrigWindow = 0, + TrigCount = 1, + ReferenceClock = Native.ACTS1000_RECLK_ONBOARD, + TimeBaseClock = Native.ACTS1000_TBCLK_IN, + bMasterEn = 0, + SyncTrigSignal = Native.ACTS1000_STS_TRIGGER0, + bClkOutEn = 0, + ClkOutSel = Native.ACTS1000_CLKOUT_REFERENCE, + bTrigOutEn = 0, + TrigOutPolarity = Native.ACTS1000_TOP_POSITIVE, + TrigOutWidth = 50, + bSaveFile = 0, + chFileName = string.Empty + }; + + var range = config.InputRange == InputRange.PlusMinus5V + ? Native.ACTS1000_INPUT_N5000_P5000mV + : Native.ACTS1000_INPUT_N1000_P1000mV; + + for (var channel = 0; channel < MaxChannels; channel++) + { + ad.bChannelArray[channel] = channel < config.ChannelCount ? 1 : 0; + ad.InputRange[channel] = range; + ad.CouplingType[channel] = Native.ACTS1000_COUPLING_DC; + ad.InputImped[channel] = Native.ACTS1000_IMPED_1M; + } + + if (!Native.ACTS1000_InitDeviceAD(_handle, ref ad)) + { + throw new Win32Exception("ACTS1000_InitDeviceAD failed."); + } + + return ValueTask.CompletedTask; + } + + public async IAsyncEnumerable StartAcquisitionAsync([EnumeratorCancellation] CancellationToken cancellationToken) + { + EnsureOpen(); + + if (!Native.ACTS1000_StartDeviceAD(_handle)) + { + throw new Win32Exception("ACTS1000_StartDeviceAD failed."); + } + + _started = true; + if (!Native.ACTS1000_SetDeviceTrigAD(_handle)) + { + throw new Win32Exception("ACTS1000_SetDeviceTrigAD failed."); + } + + var buffer = new ushort[ReadBufferWords]; + var totalSamplesPerChannel = 0L; + var remainingWords = _config.Mode == AcquisitionMode.Finite + ? _config.FiniteSamplesPerChannel * _config.ChannelCount + : long.MaxValue; + + while (!cancellationToken.IsCancellationRequested && remainingWords > 0) + { + var wordsToRead = (uint)Math.Min(buffer.Length, remainingWords); + uint wordsRead = 0; + uint available = 0; + + var ok = await Task.Run(() => Native.ACTS1000_ReadDeviceAD(_handle, buffer, wordsToRead, ref wordsRead, ref available, 1.0), cancellationToken); + if (!ok) + { + throw new Win32Exception("ACTS1000_ReadDeviceAD failed."); + } + + if (wordsRead == 0) + { + await Task.Delay(1, cancellationToken); + continue; + } + + var alignedWords = (int)(wordsRead / _config.ChannelCount * _config.ChannelCount); + if (alignedWords == 0) + { + continue; + } + + var raw = new ushort[alignedWords]; + Array.Copy(buffer, raw, alignedWords); + var channels = CodeConverter.Deinterleave(raw, _config.ChannelCount, _config.InputRange); + var block = new SampleBlock(channels, _config.SampleRateHz, totalSamplesPerChannel, DateTimeOffset.Now); + totalSamplesPerChannel += block.SamplesPerChannel; + remainingWords -= alignedWords; + yield return block; + } + } + + public ValueTask StopAsync() + { + if (IsOpen && _started) + { + Native.ACTS1000_StopDeviceAD(_handle); + Native.ACTS1000_ReleaseDeviceAD(_handle); + _started = false; + } + + return ValueTask.CompletedTask; + } + + public async ValueTask CloseAsync() + { + await StopAsync(); + if (IsOpen) + { + Native.ACTS1000_ReleaseDevice(_handle); + _handle = IntPtr.Zero; + } + } + + public void Dispose() + { + CloseAsync().GetAwaiter().GetResult(); + } + + private static bool IsValidHandle(IntPtr handle) + { + return handle != IntPtr.Zero && handle.ToInt64() != InvalidHandle; + } + + private static string FormatDeviceName(int deviceType) + { + var prefix = (deviceType >> 16) switch + { + 0x2012 => "PXIE", + 0x2111 => "PCIE", + _ => "ACTS1000-" + }; + return $"{prefix}{deviceType & 0xFFFF:X4}"; + } + + private void EnsureOpen() + { + if (!IsOpen) + { + throw new InvalidOperationException("Device is not open."); + } + } + + private static class Native + { + public const int ACTS1000_INPUT_N5000_P5000mV = 0x00; + public const int ACTS1000_INPUT_N1000_P1000mV = 0x01; + public const int ACTS1000_COUPLING_DC = 0x00; + public const int ACTS1000_IMPED_1M = 0x00; + public const int ACTS1000_SAMPMODE_FINITE = 0x00; + public const int ACTS1000_SAMPMODE_CONTINUOUS = 0x01; + public const int ACTS1000_PFISEL_TRIG_IN = 0x01; + public const int ACTS1000_TRIGMODE_POST = 0x01; + public const int ACTS1000_TRIGMODE_SOFT = 0x00; + public const int ACTS1000_TRIGDIR_NEGATIVE = 0x00; + public const int ACTS1000_RECLK_ONBOARD = 0x00; + public const int ACTS1000_TBCLK_IN = 0x00; + public const int ACTS1000_STS_TRIGGER0 = 0x00; + public const int ACTS1000_CLKOUT_REFERENCE = 0x00; + public const int ACTS1000_TOP_POSITIVE = 0x01; + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct ACTS1000_PARA_AD + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public int[] bChannelArray; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public int[] InputRange; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public int[] CouplingType; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public int[] InputImped; + public int FreqDivision; + public int SampleMode; + public uint M_Length; + public uint N_Length; + public int PFISel; + public int TriggerMode; + public int TriggerSource; + public int TriggerDir; + public int TrigLevelVolt; + public int TrigWindow; + public uint TrigCount; + public int ReferenceClock; + public int TimeBaseClock; + public int bMasterEn; + public int SyncTrigSignal; + public int bClkOutEn; + public int ClkOutSel; + public int bTrigOutEn; + public int TrigOutPolarity; + public int TrigOutWidth; + public int bSaveFile; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string chFileName; + } + + [StructLayout(LayoutKind.Sequential)] + public struct ACTS1000_AD_MAIN_INFO + { + public int nDeviceType; + public int nChannelCount; + public int nDepthOfMemory; + public int nSampResolution; + public int nSampCodeCount; + public int nTrigLvlResolution; + public int nTrigLvlCodeCount; + public int nBaseRate; + public int nMaxRate; + public int nMinFreqDivision; + public int nSupportImped; + public int nSupportPFI; + public int nSupportExtClk; + public int nSupportPXIE100M; + public int nSupportClkOut; + public int nReserved0; + public int nReserved1; + public int nReserved2; + public int nReserved3; + } + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + public static extern IntPtr ACTS1000_CreateDevice(int DeviceID); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_ReleaseDevice(IntPtr hDevice); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + public static extern int ACTS1000_GetDeviceCount(IntPtr hDevice); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_GetDeviceCurrentID(IntPtr hDevice, ref int DeviceLgcID, ref int DevicePhysID); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_GetMainInfo(IntPtr hDevice, ref ACTS1000_AD_MAIN_INFO pMainInfo); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_InitDeviceAD(IntPtr hDevice, ref ACTS1000_PARA_AD pADPara); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_StartDeviceAD(IntPtr hDevice); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_SetDeviceTrigAD(IntPtr hDevice); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_ReadDeviceAD( + IntPtr hDevice, + [Out] ushort[] pADBuffer, + uint nReadSizeWords, + ref uint nRetSizeWords, + ref uint pAvailSampsPoints, + double fTimeout); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_StopDeviceAD(IntPtr hDevice); + + [DllImport("ACTS1000_64.dll", CallingConvention = CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ACTS1000_ReleaseDeviceAD(IntPtr hDevice); + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/SimulatedDigitizer.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/SimulatedDigitizer.cs new file mode 100644 index 0000000..c54a3b8 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Hardware/SimulatedDigitizer.cs @@ -0,0 +1,120 @@ +using System.Runtime.CompilerServices; +using Pcie8586Probe.Acquisition; +using Pcie8586Probe.Models; + +namespace Pcie8586Probe.Hardware; + +public sealed class SimulatedDigitizer : IDigitizer +{ + private AcquisitionConfig _config = AcquisitionConfig.Default; + private bool _isOpen; + private long _nextSampleIndex; + + public bool IsOpen => _isOpen; + + public ValueTask> EnumerateDevicesAsync(CancellationToken cancellationToken) + { + IReadOnlyList devices = + [ + new DeviceInfo(0, 0, "\u6A21\u62DF PCIe8586M \u91C7\u96C6\u5361", true) + ]; + return ValueTask.FromResult(devices); + } + + public ValueTask OpenAsync(DeviceInfo device, CancellationToken cancellationToken) + { + _isOpen = true; + _nextSampleIndex = 0; + return ValueTask.CompletedTask; + } + + public ValueTask ConfigureAsync(AcquisitionConfig config, CancellationToken cancellationToken) + { + config.Validate(); + _config = config; + return ValueTask.CompletedTask; + } + + public async IAsyncEnumerable StartAcquisitionAsync([EnumeratorCancellation] CancellationToken cancellationToken) + { + if (!_isOpen) + { + throw new InvalidOperationException("Device is not open."); + } + + var sampleRate = _config.SampleRateHz; + var blockSamples = (int)Math.Clamp(sampleRate / 30.0, 128, 8192); + var emitted = 0L; + + while (!cancellationToken.IsCancellationRequested) + { + var remaining = _config.Mode == AcquisitionMode.Finite + ? _config.FiniteSamplesPerChannel - emitted + : long.MaxValue; + + if (remaining <= 0) + { + yield break; + } + + var samplesThisBlock = (int)Math.Min(blockSamples, remaining); + var raw = GenerateRaw(samplesThisBlock, _config.ChannelCount, sampleRate, _nextSampleIndex, _config.InputRange); + var channels = CodeConverter.Deinterleave(raw, _config.ChannelCount, _config.InputRange); + var block = new SampleBlock(channels, sampleRate, _nextSampleIndex, DateTimeOffset.Now); + + _nextSampleIndex += samplesThisBlock; + emitted += samplesThisBlock; + yield return block; + + var delayMs = Math.Clamp(samplesThisBlock / sampleRate * 1000.0, 1.0, 50.0); + await Task.Delay(TimeSpan.FromMilliseconds(delayMs), cancellationToken); + } + } + + public ValueTask StopAsync() + { + return ValueTask.CompletedTask; + } + + public ValueTask CloseAsync() + { + _isOpen = false; + return ValueTask.CompletedTask; + } + + public void Dispose() + { + _isOpen = false; + } + + private static ushort[] GenerateRaw(int samplesPerChannel, int channelCount, double sampleRate, long startSample, InputRange range) + { + var raw = new ushort[samplesPerChannel * channelCount]; + var fullScale = range == InputRange.PlusMinus5V ? 5.0 : 1.0; + + for (var sample = 0; sample < samplesPerChannel; sample++) + { + var absoluteSample = startSample + sample; + var time = absoluteSample / sampleRate; + for (var channel = 0; channel < channelCount; channel++) + { + var frequency = 250.0 * (channel + 1); + var signal = Math.Sin(2.0 * Math.PI * frequency * time); + var harmonic = 0.15 * Math.Sin(2.0 * Math.PI * frequency * 0.31 * time + channel); + var noise = 0.01 * Math.Sin(2.0 * Math.PI * (97.0 + channel * 13.0) * time); + var volts = Math.Clamp((signal * 0.65 + harmonic + noise) * fullScale, -fullScale, fullScale); + raw[sample * channelCount + channel] = VoltsToCode(volts, range); + } + } + + return raw; + } + + private static ushort VoltsToCode(double volts, InputRange range) + { + var span = range == InputRange.PlusMinus5V ? 10.0 : 2.0; + var min = range == InputRange.PlusMinus5V ? -5.0 : -1.0; + var normalized = (volts - min) / span; + return (ushort)Math.Clamp(Math.Round(normalized * 65_536.0), 0, 65_535); + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/AcquisitionConfig.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/AcquisitionConfig.cs new file mode 100644 index 0000000..8b6e575 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/AcquisitionConfig.cs @@ -0,0 +1,33 @@ +namespace Pcie8586Probe.Models; + +public sealed record AcquisitionConfig( + int ChannelCount, + InputRange InputRange, + int ClockDivider, + AcquisitionMode Mode, + long FiniteSamplesPerChannel) +{ + public const double BaseSampleRateHz = 100_000_000.0; + + public double SampleRateHz => BaseSampleRateHz / ClockDivider; + + public static AcquisitionConfig Default { get; } = new(1, InputRange.PlusMinus5V, 100, AcquisitionMode.Continuous, 10_000); + + public void Validate() + { + if (ChannelCount is not (1 or 2 or 4 or 8)) + { + throw new ArgumentOutOfRangeException(nameof(ChannelCount), "Channel count must be 1, 2, 4, or 8."); + } + + if (ClockDivider < 1) + { + throw new ArgumentOutOfRangeException(nameof(ClockDivider), "Clock divider must be positive."); + } + + if (Mode == AcquisitionMode.Finite && FiniteSamplesPerChannel < 1) + { + throw new ArgumentOutOfRangeException(nameof(FiniteSamplesPerChannel), "Finite sample count must be positive."); + } + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/AcquisitionMode.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/AcquisitionMode.cs new file mode 100644 index 0000000..8027ab7 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/AcquisitionMode.cs @@ -0,0 +1,7 @@ +namespace Pcie8586Probe.Models; + +public enum AcquisitionMode +{ + Continuous, + Finite +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/DeviceInfo.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/DeviceInfo.cs new file mode 100644 index 0000000..fa37a02 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/DeviceInfo.cs @@ -0,0 +1,10 @@ +namespace Pcie8586Probe.Models; + +public sealed record DeviceInfo(int LogicalId, int? PhysicalId, string Description, bool IsSimulated) +{ + public override string ToString() + { + var id = PhysicalId.HasValue ? $"L{LogicalId}/P{PhysicalId.Value}" : $"L{LogicalId}"; + return $"{id} - {Description}"; + } +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/InputRange.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/InputRange.cs new file mode 100644 index 0000000..ef21de7 --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/InputRange.cs @@ -0,0 +1,7 @@ +namespace Pcie8586Probe.Models; + +public enum InputRange +{ + PlusMinus5V, + PlusMinus1V +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/RecordingResult.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/RecordingResult.cs new file mode 100644 index 0000000..a6f48fa --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/RecordingResult.cs @@ -0,0 +1,8 @@ +namespace Pcie8586Probe.Models; + +public sealed record RecordingResult( + SampleBlock Block, + string BasePath, + string BinaryPath, + string MetadataPath, + TimeSpan Duration); diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/SampleBlock.cs b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/SampleBlock.cs new file mode 100644 index 0000000..8f3025c --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Models/SampleBlock.cs @@ -0,0 +1,12 @@ +namespace Pcie8586Probe.Models; + +public sealed record SampleBlock( + double[][] Channels, + double SampleRateHz, + long StartSampleIndex, + DateTimeOffset Timestamp) +{ + public int ChannelCount => Channels.Length; + + public int SamplesPerChannel => Channels.Length == 0 ? 0 : Channels[0].Length; +} diff --git a/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Pcie8586.Driver.csproj b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Pcie8586.Driver.csproj new file mode 100644 index 0000000..be3e28d --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/Pcie8586.Driver.csproj @@ -0,0 +1,12 @@ + + + + net8.0 + x64 + x64 + enable + enable + Pcie8586.Driver + + + diff --git a/Docs/PCIe8586驱动接入资料/verify-package.ps1 b/Docs/PCIe8586驱动接入资料/verify-package.ps1 new file mode 100644 index 0000000..7abd36a --- /dev/null +++ b/Docs/PCIe8586驱动接入资料/verify-package.ps1 @@ -0,0 +1,31 @@ +param( + [string]$HostOutputDirectory +) + +$ErrorActionPreference = "Stop" +$root = Split-Path -Parent $MyInvocation.MyCommand.Path +$project = Join-Path $root "src\Pcie8586.Driver\Pcie8586.Driver.csproj" +$example = Join-Path $root "examples\ConsoleIntegration\ConsoleIntegration.csproj" +$artifacts = Join-Path $env:TEMP "Pcie8586DriverIntegrationVerify" + +dotnet build $project -c Release -p:Platform=x64 --artifacts-path $artifacts +if ($LASTEXITCODE -ne 0) { + throw "Driver library build failed." +} + +dotnet build $example -c Release -p:Platform=x64 --artifacts-path $artifacts +if ($LASTEXITCODE -ne 0) { + throw "Console integration example build failed." +} + +if ($HostOutputDirectory) { + $dll = Join-Path $HostOutputDirectory "ACTS1000_64.dll" + if (-not (Test-Path -LiteralPath $dll)) { + Write-Warning "ACTS1000_64.dll was not found in host output: $HostOutputDirectory" + } + else { + Write-Host "Found native runtime: $dll" + } +} + +Write-Host "Driver integration package verification succeeded." diff --git a/Docs/固态功率控制器用户使用手册-1.0.docx b/Docs/固态功率控制器用户使用手册-1.0.docx new file mode 100644 index 0000000..05a2cb3 Binary files /dev/null and b/Docs/固态功率控制器用户使用手册-1.0.docx differ diff --git a/Docs/固态功率控制器用户使用手册-1.0.pdf b/Docs/固态功率控制器用户使用手册-1.0.pdf new file mode 100644 index 0000000..5bba551 Binary files /dev/null and b/Docs/固态功率控制器用户使用手册-1.0.pdf differ diff --git a/Docs/开发文档.md b/Docs/开发文档.md new file mode 100644 index 0000000..1355166 --- /dev/null +++ b/Docs/开发文档.md @@ -0,0 +1,576 @@ +# 固态功率控制器动态参数测试系统 — 开发文档 + +> 版本 v1.1 | 技术栈:**C# + WPF + .NET 8** | 口径:**以当前仓库代码为准** +> +> 本文档描述当前仓库的真实结构、配置方式、核心流程和维护约定。 +> 若文档与代码冲突,以代码实现为准,并应同步回写本文档。 + +--- + +## 0. 开发约束 + +对本项目进行新增、修改、排障时,默认遵守以下原则: + +1. **分层隔离优先**:UI 只依赖 ViewModel / Service / Logic,不直接依赖具体设备驱动。 +2. **接口先行**:SSPC、电源、负载、DAQ 一律经 `SSPCTester.Devices.Interfaces` 暴露,真假驱动由配置决定。 +3. **按设备粒度切换 Mock/Real**:当前不再是“一个全局 `MockMode` 管全部设备”,而是每类设备都有自己的 `UseMock`。 +4. **配置分层加载**:程序先读内置默认值,再读 `appsettings.json`,最后读 `%LOCALAPPDATA%\SSPCTester\settings.json`。 +5. **测试态独占**:进入测试后只展示当前项目,禁止切换其他项目,设备连接由测试态独占。 +6. **文档随代码更新**:涉及接口、项目结构、运行方式、持久化格式变化时,要同步更新本文档。 + +--- + +## 1. 项目背景 + +### 1.1 被测对象 + +固态功率控制器(SSPC)用于智能配电场景。本项目按 **24 路** 输出通道建模,通过软件控制每路导通/关断,并测量: + +- 基础通断状态 +- 开启/关断曲线与时间参数 +- 功率损耗与效率 +- 保护功能演示结果 + +### 1.2 当前测试台硬件 + +| 部件 | 型号 | 作用 | 当前代码状态 | +|---|---|---|---| +| 工控机 | Windows x64 | 运行 WPF 主程序 | 已支持 | +| 被测件 SSPC | 24 路 | 控制 24 路导通/关断 | 已有 `SspcModbus` | +| 程控电源 | UDP5080-100 | 输入端电压/电流读取 | 已有真实驱动,控制命令保留接口 | +| 可编程负载 | IT8733P / IT8702P | 输出端电压/电流/功率读取 | 已有真实驱动 | +| 高速采集卡 | PCIe8586 | 曲线波形采集 | 已有 `Pcie8586Daq` | +| 示波器 | Tektronix MDO3024 | 线下校准基准 | 不纳入软件控制 | + +### 1.3 当前实现事实 + +- SSPC 24 路通过 **3 个 Modbus 模块 × 每模块 8 路** 映射。 +- 采集卡实现已经统一为 **PCIe8586**,不再使用旧文档中的 `PCIe9318` 命名。 +- 真假设备切换已经演进为 **每类设备独立 `UseMock`**。 +- 主程序启动后会按配置自动连接 SSPC、电源、负载、DAQ。 +- 根目录脚本 `run.ps1` / `publish.ps1` 已是当前标准运行入口。 + +--- + +## 2. 当前功能范围 + +主流程如下: + +```text +新建/打开项目 +-> 填写项目信息 / 勾选测试项 +-> 进入测试态 +-> 执行基础测试 / 曲线测试 / 功率损耗 / 保护功能 +-> 生成 PDF / Word 报告 +``` + +### 2.1 四大模块 + +| 模块 | 当前实现 | 状态 | +|---|---|---| +| 基础测试 | 24 路逐路开/关、读电压电流、判定稳态关断 | 已实现 | +| 开启与关断曲线 | 支持开通/关断波形采集、指标计算、独立曲线视窗、波形落盘 | 已实现 | +| 功率损耗 | 使用 UDP5080 读输入端,IT87xx 读输出端功率/电压/电流 | 已实现 | +| 保护功能 | UI、数据结构和演示结果生成已完成,真实联动未接 | 框架完成 | + +### 2.2 指标口径 + +当前计算与判定主要围绕以下指标: + +- `1.1` 开启时间:到达输入电压 90% 的时间 +- `1.2` 关闭时间:下降到输入电压 10% 的时间 +- `1.5` 上升/下降时间:10%~90% 或 90%~10% 时间 +- `1.9` 电压降:`Vin - Vout` +- `1.10 / 1.13` 功率损耗、效率 +- `1.14+` 保护功能相关故障时间与演示状态 + +阈值定义和最终判断以 `Project.CurveThresholds` 与各页结果模型为准。 + +--- + +## 3. 技术栈 + +| 用途 | 当前选型 | 说明 | +|---|---|---| +| UI | WPF + .NET 8 | `net8.0-windows`,x64 | +| MVVM | `CommunityToolkit.Mvvm` | `ObservableObject` / `RelayCommand` | +| 配置 | `Microsoft.Extensions.Configuration` | JSON + 用户设置覆盖 | +| DI / Host | `Microsoft.Extensions.Hosting` | 启动时装配所有服务 | +| Modbus | `NModbus` | SSPC 串口控制 | +| 串口 | `System.IO.Ports` | SSPC/部分设备底层通信 | +| 波形绘制 | `ScottPlot` / `ScottPlot.WPF` | 曲线页与报告插图 | +| 报告 | `QuestPDF` + `DocumentFormat.OpenXml` | PDF 与 Word 双实现 | +| Web 预览 | `Microsoft.Web.WebView2` | 报告页 PDF 预览 | +| 日志 | Serilog | Debug + 文件输出 | + +--- + +## 4. 解决方案结构 + +### 4.1 分层 + +```text +UI (WPF / XAML / ViewModel) + -> Logic (测试流程 / 计算 / 报告 / 存储) + -> Devices.Interfaces (统一设备接口) + -> Devices.Drivers.Mock / Real (具体驱动) +``` + +依赖方向始终是 **上层只依赖下层抽象**。 +例如 UI 只拿到 `ISspc`,不直接感知背后是 `MockSspc` 还是 `SspcModbus`。 + +### 4.2 当前解决方案 + +```text +SSPCTester.sln +├── SSPCTester.UI/ # WPF 主程序(启动项) +│ ├── Views/ # 页面与窗口 +│ ├── ViewModels/ # MVVM 视图模型 +│ ├── Controls/ # 自定义控件(含曲线控件) +│ ├── Resources/ # Tokens / Controls / Icons +│ ├── Converters/ # 状态与颜色转换 +│ └── Services/ # 用户设置、应用配置等 +├── SSPCTester.Logic/ # 业务层 +│ ├── Testing/ # 测试模块与运行器 +│ ├── Calculation/ # 曲线/功率计算纯函数 +│ ├── Report/ # PDF/Word 报告实现 +│ ├── Storage/ # 项目与波形持久化 +│ └── Models/ # 项目、结果、阈值、枚举 +├── SSPCTester.Devices/ # 设备抽象与驱动 +│ ├── Interfaces/ # ISspc / IPowerSupply / ILoad / IDaq +│ ├── Drivers/Mock/ # Mock 驱动 +│ ├── Drivers/Real/ # 真设备驱动 +│ ├── Drivers/ConfigurableDevices.cs # 按设备切换 Mock/Real +│ ├── Protocol/ # 协议辅助 +│ └── Config/ # 设备配置模型 +├── SSPCTester.Tests/ # xUnit 测试 +├── SSPCTester.Seed/ # 示例项目/种子数据生成 +└── Docs/PCIe8586驱动接入资料/src/Pcie8586.Driver/ + # 采集卡独立驱动类库,被 Devices/Tests 引用 +``` + +### 4.3 关键脚本 + +- `run.ps1`:发布 UI、可选执行单测、可选灌入种子数据、最后启动发布产物 +- `publish.ps1`:单独发布 WPF 程序 +- `SSPCTester.Seed/WriteQualifiedProjects.ps1`:生成演示项目 + +--- + +## 5. 配置与驱动切换 + +### 5.1 配置加载顺序 + +程序启动时配置来源按优先级叠加: + +1. 内置默认配置 +2. `SSPCTester.UI/appsettings.json` +3. `%LOCALAPPDATA%\SSPCTester\settings.json` + +用户在设置页修改的路径、报告格式等,最终写到用户目录,不回写仓库里的 `appsettings.json`。 + +### 5.2 当前切换策略 + +当前采用 **每类设备独立切换**: + +- `Devices:Sspc:UseMock` +- `Devices:PowerSupply:UseMock` +- `Devices:Load:UseMock` +- `Devices:Daq:UseMock` + +`Devices:MockMode` 仅保留兼容旧配置用途,不应再作为新逻辑入口。 + +### 5.3 当前 `appsettings.json` 示例 + +```json +{ + "Devices": { + "MockMode": false, + "Sspc": { + "UseMock": false, + "AutoConnect": true, + "PortName": "COM1", + "BaudRate": 9600, + "ModuleAddresses": [1, 2, 3] + }, + "PowerSupply": { + "UseMock": false, + "AutoConnect": true, + "Host": "192.168.6.5", + "Port": 5025 + }, + "Load": { + "UseMock": false, + "AutoConnect": true, + "Host": "192.168.200.100", + "Port": 30000 + }, + "Daq": { + "UseMock": false, + "AutoConnect": true, + "LogicalDeviceId": 0, + "ChannelCount": 4, + "PreTriggerMs": 10, + "PostTriggerMs": 40 + } + }, + "Storage": { + "ProjectsRoot": "%LOCALAPPDATA%\\SSPCTester\\Projects" + }, + "Report": { + "SavePath": "%LOCALAPPDATA%\\SSPCTester\\Reports", + "Format": "Pdf" + } +} +``` + +--- + +## 6. 设备接口 + +所有设备接口均为异步接口,默认支持 `CancellationToken`。 + +### 6.1 公共连接接口 + +```csharp +public interface IDeviceConnection +{ + bool IsConnected { get; } + string DisplayName { get; } + Task ConnectAsync(CancellationToken ct = default); + Task DisconnectAsync(); + event EventHandler? ConnectionChanged; +} +``` + +### 6.2 SSPC + +```csharp +public interface ISspc : IDeviceConnection +{ + int ChannelCount { get; } + Task TurnOnAsync(int physicalSlot, CancellationToken ct = default); + Task TurnOffAsync(int physicalSlot, CancellationToken ct = default); + Task FlashAsync(int physicalSlot, int milliseconds, CancellationToken ct = default); + Task GetChannelStateAsync(int physicalSlot, CancellationToken ct = default); + Task ReadMeasurementAsync(int physicalSlot, CancellationToken ct = default); + Task> ReadMeasurementsAsync(CancellationToken ct = default); +} +``` + +### 6.3 电源 + +```csharp +public interface IPowerSupply : IDeviceConnection +{ + Task SetVoltageAsync(double volts, CancellationToken ct = default); + Task SetCurrentLimitAsync(double amps, CancellationToken ct = default); + Task OutputAsync(bool on, CancellationToken ct = default); + Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default); + Task QueryIdentityAsync(CancellationToken ct = default); +} +``` + +### 6.4 负载 + +```csharp +public readonly record struct PowerReading(double Volts, double Amps, double Watts); + +public interface ILoad : IDeviceConnection +{ + Task SetModeAsync(LoadMode mode, CancellationToken ct = default); + Task SetValueAsync(double value, CancellationToken ct = default); + Task InputAsync(bool on, CancellationToken ct = default); + Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default); + Task ReadPowerAsync(CancellationToken ct = default); + Task QueryIdentityAsync(CancellationToken ct = default); +} +``` + +### 6.5 DAQ + +```csharp +public interface IDaq : IDeviceConnection +{ + Task> EnumerateDevicesAsync(CancellationToken ct = default); + Task CaptureAsync(int[] channels, int sampleRateHz, double durationSec, CancellationToken ct = default); + Task ReadInstantAsync(int[] channels, CancellationToken ct = default); + Task CaptureAroundActionAsync( + DaqActionCaptureRequest request, + Func action, + CancellationToken ct = default); + event EventHandler? SampleReceived; +} +``` + +`CaptureAroundActionAsync()` 是当前曲线测试的核心接口: +先进入预采集,再在触发点附近执行开关动作,以得到统一对齐的波形。 + +--- + +## 7. 核心业务逻辑 + +### 7.1 测试模块统一入口 + +`Logic/Testing` 中已经落地: + +```csharp +public interface ITestModule +{ + string Name { get; } + Task RunAsync(TestContext ctx, IProgress progress, CancellationToken ct); +} +``` + +`TestContext` 当前持有: + +- `Project` +- `ISspc` +- `IPowerSupply` +- `ILoad` +- `IDaq` + +`TestRunner` 依据 `Project.Selection` 串行执行模块。 + +### 7.2 浏览态 / 测试态 + +当前程序已实现两种应用状态: + +- **浏览态**:左侧树显示全部项目,可自由切换 +- **测试态**: + - 只显示当前项目 + - 顶部展示“测试进行中”状态条 + - 可中止测试 + - 设备连接视为当前项目独占 + +这一逻辑由 `MainViewModel.AppState` 控制。 + +### 7.3 基础测试 + +当前基础测试实现采用 `ISspc.ReadMeasurementAsync()` 直接读取每路电压/电流: + +```text +TurnOnAsync(ch) +-> Delay +-> ReadMeasurementAsync(ch) +-> 记录 VoltageOn / CurrentOn +-> TurnOffAsync(ch) +-> WaitForStableOffAsync(ch) +-> 根据导通和关断稳态结果判定 Pass / Fail +``` + +说明: + +- 不是旧文档中的 `Daq.ReadInstant()` 方案 +- “关断是否稳定”通过 `BasicTestCriteria.WaitForStableOffAsync()` 判定 + +### 7.4 曲线测试 + +当前代码存在两套相关逻辑: + +1. **Logic 模块批处理**:`CurveTest.cs` + - 一次完成开通与关断两段采集 + - 适用于测试模块整体执行 +2. **UI 曲线页交互**:`CurveTestViewModel` + - 已拆成两个独立按钮: + - `开启曲线测试` + - `关断曲线测试` + - 开/关曲线各自保存、各自绘图、各自维护视窗范围 + +当前页与弹窗的“起点 / 终点 / 默认”已经拆成两套独立状态: + +- `RisingViewStartMs` / `RisingViewEndMs` +- `FallingViewStartMs` / `FallingViewEndMs` + +这些值会写回 `CurveResultRow` 并持久化。 + +状态规则: + +- 两半都没做:`Untested` +- 只完成一半:`Measured` +- 两半都完成后:才根据 4 个指标判 `Pass / Fail` + +### 7.5 功率损耗 + +当前正式实现采用: + +- `UDP5080` 读取输入端 `Vin / Iin` +- `IT87xx` 读取输出端 `Vout / Iout / Pout` + +这是当前在用方案。 +仓库中仍保留旧的 `PowerTestLegacy`(DAQ 思路),但未作为正式模块注册。 + +### 7.6 保护功能 + +当前保护功能页和逻辑层是**演示框架**: + +- UI 已完成 +- 结果模型已完成 +- `ProtectTest` 目前生成演示数据 +- 未接真实故障触发与真实曲线采集链路 + +### 7.7 报告 + +当前报告支持: + +- PDF +- Word +- PDF + Word + +报告特性: + +- 基于项目与勾选项动态生成 +- 曲线插图由 `CurveImageRenderer` 生成 +- 报告文件名不是固定 `report.docx`,而是动态解析后输出 +- 报告页通过 `WebView2` 预览 PDF + +--- + +## 8. 数据存储 + +### 8.1 项目目录 + +每个项目一个目录,目录根路径由 `Storage:ProjectsRoot` 决定。 +典型内容: + +- `project.json` +- `curves/` +- 生成出的 PDF / Word 报告 + +### 8.2 项目对象 + +`Project` 当前持久化内容包括: + +- DUT 信息 +- 测试站点信息 +- 测试项勾选 +- 报告配置 +- 基础测试、曲线测试、功率损耗、保护功能结果 +- 曲线阈值 +- 四页测试说明文本 + +### 8.3 波形存储格式 + +波形不是简单的 JSON,而是: + +- `curves/*.bin`:float32 二进制采样数据 +- `curves/*.json`:元数据 + +元数据包含: + +- 采样率 +- 触发点位置 +- 通道角色/名称/单位 +- 标定参数 + +### 8.4 旧数据兼容 + +`CurveResultRow` 中保留了旧字段: + +- `ViewStartMs` +- `ViewEndMs` + +新逻辑优先使用: + +- `RisingViewStartMs / RisingViewEndMs` +- `FallingViewStartMs / FallingViewEndMs` + +缺失时会回退到旧字段,兼容老项目。 + +--- + +## 9. 运行与发布 + +### 9.1 本地运行 + +推荐命令: + +```powershell +PowerShell -ExecutionPolicy Bypass -File .\run.ps1 +``` + +该脚本默认行为: + +1. `dotnet publish` UI 到 `publish\win-x64` +2. 可选执行测试 +3. 可选执行种子数据生成 +4. 直接启动 `publish\win-x64\SSPCTester.UI.exe` + +### 9.2 常用参数 + +- `-Test`:执行 `SSPCTester.Tests` +- `-Seed`:执行 `SSPCTester.Seed` +- `-CleanSeed`:清空项目目录后重新灌入种子数据 +- `-NoLaunch`:只发布不启动 + +### 9.3 发布 + +推荐命令: + +```powershell +PowerShell -ExecutionPolicy Bypass -File .\publish.ps1 +``` + +当前默认发布参数是: + +- `Release` +- `win-x64` +- `SelfContained = true` +- `SingleFile = false` + +说明: + +- 当前脚本明确没有走 WPF 单文件发布默认方案 +- 发布时会检查 `ACTS1000_64.dll` 是否存在 + +### 9.4 运行环境 + +源码构建至少需要: + +- Windows x64 +- .NET 8 SDK x64 +- WebView2 Runtime + +若只运行现成发布版,则至少需要满足发布产物依赖和本机驱动/DLL 条件。 + +--- + +## 10. 当前状态与后续工作 + +### 10.1 已完成 + +- WPF 主程序骨架、主题资源、页面导航 +- 浏览态 / 测试态切换 +- 项目新建、加载、保存 +- 基础测试、曲线测试、功率损耗、保护功能页 +- PDF / Word 报告生成 +- 真/假设备可按设备粒度切换 +- 实际 SSPC / 电源 / 负载 / PCIe8586 驱动接入代码 + +### 10.2 待统一 / 待完善 + +- 保护功能仍为演示逻辑,未接真实测试链路 +- 功率损耗旧版 `PowerTestLegacy` 仍在仓库,后续应明确去留 +- 曲线弹窗窗口已实现,但当前主页面尚未提供入口按钮 +- 报告生成对新旧曲线视窗字段的使用口径后续建议统一 + +--- + +## 11. 风险与注意事项 + +1. **DAQ 仍是最高风险点**:厂商 DLL、设备 ID、采样参数、输入量程和触发时序都依赖现场。 +2. **Modbus 地址和端口仍需现场核实**:虽然当前实现已支持 3 模块映射,但设备地址/串口号应视现场配置为准。 +3. **电源与负载真实驱动已接入,但控制命令支持度需按实物验证**。 +4. **所有长流程应贯穿 `CancellationToken`**,中止后优先保证设备回到安全状态。 +5. **示波器不纳入软件控制**,仅作为线下校准基准。 +6. **任何涉及数据模型持久化格式的修改,都要考虑旧项目兼容**。 + +--- + +## 12. 维护建议 + +1. 改接口前,先同步修改 `Devices.Interfaces`、实现类、DI 装配和本文档。 +2. 改项目结构前,先检查 `run.ps1`、`publish.ps1`、`Seed`、测试项目是否受影响。 +3. 改曲线页前,注意当前已经有“主页面 + 弹窗 + 报告图”的三处视窗相关逻辑。 +4. 改报告前,确认 `ReportViewModel`、`Logic/Report`、`WebView2` 预览链路同时保持可用。 +5. 若发现文档内容再次与代码偏离,应优先更新本文档,而不是继续在过时约束上开发。 diff --git a/Docs/用户使用手册-lin.docx b/Docs/用户使用手册-lin.docx new file mode 100644 index 0000000..53ed0d0 Binary files /dev/null and b/Docs/用户使用手册-lin.docx differ diff --git a/Docs/用户使用手册.docx b/Docs/用户使用手册.docx new file mode 100644 index 0000000..6d27b6a Binary files /dev/null and b/Docs/用户使用手册.docx differ diff --git a/Docs/用户使用手册.md b/Docs/用户使用手册.md new file mode 100644 index 0000000..7cdd964 --- /dev/null +++ b/Docs/用户使用手册.md @@ -0,0 +1,2148 @@ +--- +title: "固态功率控制器(SSPC)动态参数测试系统用户使用手册" +subtitle: "SSPCTester v1.0" +author: "SPC-DynaTest 项目组" +date: "2026-06-25" +lang: zh-CN +toc-title: "目 录" +--- + +# 文档信息 + +| 项目 | 内容 | +| ------------ | ------------------------------------------------------------ | +| 文档名称 | 固态功率控制器(SSPC)动态参数测试系统用户使用手册 | +| 适用软件 | SSPCTester v1.0 | +| 文档编号 | SPC-DT-UM-001 | +| 适用读者 | 现场测试人员、质量评审人员 | +| 文档版本 | V1.0 | +| 发布日期 | 2026-06-25 | +| 编制 / 审核 / 批准 | (由现场负责人签署) | + +**修订记录** + +| 版本 | 日期 | 修订内容 | 修订人 | +| ---- | ---------- | -------------- | ------ | +| V1.0 | 2026-06-25 | 首次正式发布 | | + +--- + +# 阅读约定 + +为方便阅读,本手册使用以下统一约定。 + +**字体与样式** + +- `等宽字体` 表示文件路径、命令、配置键、寄存器地址等技术内容。 +- **粗体** 表示界面上的按钮、菜单或控件名称,例如 **开始测试**。 +- *斜体* 用于术语首次出现时的标识。 + +**信息提示** + +> **【提示】** 用于补充说明或操作建议。 + +> **【注意】** 用于强调可能影响测试结果或数据准确性的事项。 + +> **【警告】** 用于强调可能造成人身伤害、设备损坏或不可恢复后果的事项。 + +**插图占位** + +本手册中以 `[插图:XXX]` 的形式标注界面截图位置。正式发布前由现场人员补充对应截图。 + +**通道编号约定** + +本系统所有"通道号"均指**物理插位**,编号为 1–24。Modbus 从站地址、线圈号、寄存器偏移仅在底层通信中使用,用户无需关心。 + +--- + +\newpage + +# 第 1 章 产品概述 + +## 1.1 产品简介 + +**固态功率控制器(SSPC)动态参数测试系统**(以下简称"本系统"或 SSPCTester)是一套面向 24 路固态功率控制器的自动化测试平台,用于在生产、入厂复检、定型试验等环节,对 SSPC 的动态特性、功率损耗、保护功能等关键参数进行自动化测量、判定与报告输出。 + +软件采用 **C# / WPF / .NET 8** 架构,运行于 Windows x64 平台。配合外部高速数据采集卡、程控电源、可编程电子负载、Modbus-RTU 控制板等硬件,实现对被测件 24 路通道的逐路加电、波形采集、参数计算与合格判定。 + +## 1.2 适用范围 + +本系统适用于以下使用场景: + +- 24 路结构的固态功率控制器(SSPC)成品测试; +- 同结构组件的型式试验、抽样验收、出厂检验; +- 现场维修后的功能复检; +- 设计阶段对开关特性的对比验证。 + +## 1.3 主要功能特性 + +| 功能模块 | 主要能力 | +| ---------------- | ------------------------------------------------------------------------ | +| **基础测试** | 24 路通道逐路或一键导通/关断,实时读取电压电流,自动判定通断是否正常 | +| **开启与关断曲线** | 高速采集卡同步采样开关过程波形,自动计算开启时间、上升时间、关断时间、下降时间 | +| **功率损耗测试** | 同时采集输入/输出两端的电压电流,计算电压降、功率损耗与转换效率 | +| **保护功能演示** | 支持跳闸、短路、过温、过压、欠压、限流共 6 类保护项目的演示与记录 | +| **项目管理** | 以"被测件 = 项目"为单位组织测试数据,支持历史项目浏览与重测 | +| **报告生成** | 一键生成 PDF 格式专业测试报告,含封面、综合判定、各模块数据及波形 | +| **设备管理** | 集中管理 SSPC 控制板、程控电源、可编程负载、高速采集卡的连接、参数与标定 | +| **模拟模式** | 提供完整 Mock 驱动,无需真实硬件即可演练与培训 | + +## 1.4 系统组成 + +本系统由"软件 + 硬件"两部分构成。 + +**软件部分** + +- SSPCTester.UI:基于 WPF 的主程序(`SSPCTester.UI.exe`); +- SSPCTester.Logic:业务逻辑层(测试流程、计算、报告生成、项目存储); +- SSPCTester.Devices:设备抽象与驱动层(含 Mock 与真实驱动)。 + +**硬件部分** + +| 部件 | 推荐型号 | 用途 | 通讯方式 | +| ---------------- | ----------------------- | ------------------------------------------ | ----------------- | +| 工业控制计算机 | x86_64 工控机 | 运行 SSPCTester、安装 PCIe 采集卡 | — | +| SSPC 测控板 | 24 路 Modbus-RTU 控制板 | 控制 24 路继电器开关,回采电压/电流 | Modbus-RTU 串口 | +| 程控电源 | UDP5080-100 | 给 SSPC 供电(电压/电流可调) | LAN / SOCKET 5025 | +| 直流电子负载 | IT8702P | 模拟 SSPC 输出端的负载 | LAN / Socket 30000 | +| 高速数据采集卡 | PCIe8586(ACTS 系列) | 同步采集 SSPC 开关瞬态电压/电流波形 | PCIe | +| 串口扩展卡 | 8 口 UART | 提供 SSPC 控制板使用的 COM 端口 | PCIe / PCI | + +[插图:系统整体硬件连接示意图] + +## 1.5 技术规格摘要 + +| 项目 | 规格 | +| ------------ | ----------------------------------------------------------------- | +| 测试通道数 | 24(物理插位 1–24) | +| 采样率 | 高速采集卡 100 MHz / 可分频,典型 100 kHz | +| 采集时长 | 单次开/关瞬态典型 50 ms(PreTrigger 10 ms + PostTrigger 40 ms) | +| 电压量程 | SSPC 端 0 – 100 V;采集卡 ±5 V / ±1 V(可选) | +| 电流量程 | SSPC 端 ±60 A | +| 通讯协议 | Modbus-RTU(SSPC),SOCKET / SCPI(电源、负载),厂商 API(采集卡)| +| 判定输出 | 合格 / 不合格 / 已测 / 未测 | +| 报告格式 | PDF(A4,含封面、数据表、波形图、综合判定) | +| 项目数据格式 | JSON + 二进制波形(`.bin` + `.json` 元数据) | + +## 1.6 运行环境要求 + +| 项目 | 最低要求 | 推荐 | +| -------- | --------------------------------------- | ----------------------------- | +| 操作系统 | Windows 10 x64(1909 及以后) | Windows 11 x64 | +| 运行时 | .NET 8 Desktop Runtime(自包含部署可免装)| .NET 8 | +| CPU | 4 核 2.0 GHz | 6 核及以上 | +| 内存 | 4 GB | 8 GB | +| 硬盘 | 5 GB 可用空间 | 20 GB SSD | +| 扩展槽 | 1 × PCIe(采集卡)+ 1 × PCIe/PCI(串口扩展)| 同左 | +| 网络 | 1 × 千兆以太网(电源 / 负载所在网段) | 千兆以太网 + 独立交换机 | +| 显示器 | 1920 × 1080 | 1920 × 1080 及以上 | +| 权限 | 当前用户对 `%LOCALAPPDATA%` 有写权限 | 同左 | + +--- + +\newpage + +# 第 2 章 安全注意事项与作业前检查 + +> **【警告】** 本系统在测试过程中可能向被测件施加最高 100 V 直流电压、最大 60 A 电流。所有作业必须遵循下列安全规范,由经培训的人员执行。 + +## 2.1 一般安全要求 + +1. **培训资质**:操作人员应接受电气安全与本系统操作培训,熟悉急停位置与紧急断电流程。 +2. **个人防护**:作业时穿戴防静电手腕带、绝缘手套;带电换接电缆严禁徒手操作。 +3. **设备接地**:工控机、SSPC 工装、程控电源、电子负载机壳必须可靠接保护地(PE),接地电阻 ≤ 4 Ω。 +4. **环境要求**:作业环境温度 5 ℃ – 40 ℃、相对湿度 ≤ 75 %、无导电粉尘与腐蚀性气体。 +5. **急停**:测试台应配置就近可达的红色急停按钮,能在 1 秒内切断电源至 SSPC 与电子负载。 + +## 2.2 高压与高电流防护 + +- 程控电源输出电压 ≥ 36 V 时,应视为危险电压,禁止在带电状态下接触输出端子。 +- 电子负载在大电流回吸状态下,输入端子温升较高,断电后应等待 ≥ 60 秒再触摸。 +- 测试电缆截面积应与最大测试电流匹配(建议 60 A 段使用 ≥ 10 mm² 多股铜线)。 + +## 2.3 ESD 与设备保护 + +- 拔插 SSPC 被测件前,必须先停止测试、断开程控电源输出。 +- 高速采集卡与 SSPC 信号端禁止热插拔;必须在工控机断电状态下安装。 +- 同一被测件不应在带电状态下重复插拔工装座,避免触点电弧。 + +## 2.4 作业前检查清单 + +每次开机测试前,按以下顺序检查并签字确认。 + +| 序号 | 检查项 | 标准 | 确认 | +| ---- | ------------------------------------------------------------ | ---------------------------- | ---- | +| 1 | 工装座、被测件外观、端子 | 无变形、无烧蚀、无松动 | □ | +| 2 | 测试电缆、信号线 | 绝缘完好、无破皮、连接牢靠 | □ | +| 3 | 接地线导通 | 电阻 ≤ 4 Ω | □ | +| 4 | 程控电源初始设定 | 输出关闭、电压电流上限符合规程 | □ | +| 5 | 电子负载初始设定 | 输入关闭、模式为 CC、电流 0 A | □ | +| 6 | 急停按钮 | 弹起、可用 | □ | +| 7 | 工控机电源、UPS 状态 | 正常 | □ | +| 8 | 软件版本 | 与受控版本一致 | □ | +| 9 | `device-profile.json` 校验和 | 与发布记录一致 | □ | +| 10 | 上次测试残留状态 | 已清理;已断电 | □ | + +## 2.5 异常处置原则 + +发生以下任一情况,应立即按"先切电源、后查软件"的顺序处置: + +- 被测件冒烟、异味、温度异常升高; +- 程控电源、电子负载出现报警; +- 测试中电流持续超出软件设定上限; +- 工控机死机或软件无响应。 + +处置步骤: + +1. **拍下急停按钮**,切断 SSPC 供电与负载回路; +2. 关闭程控电源主开关; +3. 待设备冷却后,断开被测件,记录现象与时间; +4. 由维护人员排查根因,必要时联系研发支持。 + +[插图:操作台急停按钮与设备布置示意] + +--- + +\newpage + +# 第 3 章 硬件接线与首次使用 + +## 3.1 设备布置 + +推荐的测试台布置如下: + +[插图:测试台俯视布置图] + +- **左侧**:程控电源 UDP5080-100、可编程电子负载 IT8702P; +- **中部**:被测件 SSPC 工装座,背面引出 24 路接线端子; +- **右侧**:工控机(含 PCIe8586 采集卡与串口扩展卡)、显示器; +- **正面**:急停按钮、状态指示灯。 + +## 3.2 SSPC 控制板接线 + +SSPC 控制板包含三部分接线: + +1. **主功率回路**(程控电源 → SSPC 输入端 → 24 路输出 → 24 个负载端子); +2. **Modbus-RTU 控制串口**(串口扩展卡 → SSPC 控制板的 RS-485 接口); +3. **采集卡引线**(采集卡 4 路差分输入 → SSPC 测试点)。 + +**主功率回路连接** + +| 端子 | 连接对象 | 备注 | +| ---------- | ------------------------------ | --------------------- | +| `V+_IN` | 程控电源 + | 主供电正端 | +| `V-_IN` | 程控电源 − | 主供电负端 | +| `CH1`–`CH24` | 各路输出 → 负载切换矩阵 → 电子负载 | 单路最大 60 A | +| `GND` | 共地 | 与电源、负载共地 | + +> **【注意】** 务必在 **程控电源输出关闭、电子负载输入关闭** 状态下接线。 + +**控制串口连接** + +| 工控机端 | SSPC 控制板端 | +| -------------- | ------------- | +| 串口扩展卡某 COM 口(如 COM1) | RS-485 A / B / GND | + +> **【提示】** 该 COM 口名称将在软件中配置为 `Devices.Sspc.PortName`。 + +## 3.3 程控电源 UDP5080-100 接线 + +UDP5080-100 通过 **LAN(TCP/IP SOCKET,端口 5025)** 与工控机通信。 + +| 项目 | 推荐值 | +| ---------- | ----------------------- | +| IP 地址 | `192.168.6.5` | +| 端口 | `5025` | +| 协议 | TCP/IP SOCKET(SCPI 风格命令) | +| 子网 | `255.255.255.0` | +| 默认网关 | `192.168.6.1`(或留空) | + +接线步骤: + +1. 将 UDP5080 后面板 LAN 口连接到工控机网卡或同网段交换机; +2. 通过电源前面板菜单设置上表 IP; +3. 在工控机执行 `ping 192.168.6.5`,应正常响应; +4. 主功率端子按 3.2 节接到 SSPC 输入端。 + +[插图:UDP5080-100 LAN 配置界面] + +## 3.4 直流电子负载 IT8702P 接线 + +IT8702P 通过 **LAN(Socket,端口 30000)** 与工控机通信。 + +| 项目 | 推荐值 | +| ---------- | ----------------------- | +| IP 地址 | `192.168.200.100` | +| 端口 | `30000` | +| 协议 | TCP/IP Socket | +| 子网 | `255.255.255.0` | + +接线步骤: + +1. 通过负载前面板系统菜单配置 IP; +2. 工控机 `ping 192.168.200.100` 验证; +3. 负载输入端 +/- 接至 SSPC 输出回路(与被测通道串联); +4. 负载默认工作模式为恒流 CC,最大电流应不超过被测通道额定值。 + +> **【提示】** 若 UDP5080 与 IT8702P 不在同一网段,可在工控机配置两块网卡或为同一网卡添加两个 IP(路由表无需修改)。 + +## 3.5 PCIe8586 高速采集卡通道分配 + +PCIe8586 用于采集 SSPC 开关瞬态波形以及功率损耗的输入端电压。默认 4 通道配置如下: + +| 物理通道 | 角色 (Role) | 推荐用途 | 量程 | +| -------- | ---------------- | ---------------- | ------ | +| CH0 | `OutputVoltage` | SSPC 输出端电压 | ±5 V | +| CH1 | `OutputCurrent` | SSPC 输出端电流 | ±5 V | +| CH2 | `InputVoltage` | SSPC 输入端电压 | ±5 V | +| CH3 | `InputCurrent` | SSPC 输入端电流 | ±5 V | + +> **【注意】** 采集卡量程为低压差分输入,被测 28 V 主回路必须经过**外部分压/电流互感器调理**后,再接入采集卡,并在软件设置中进行**标定**(详见 6.6 节)。 + +[插图:采集卡接线与外部调理板示意] + +## 3.6 COM 端口分配 + +| 设备 | 推荐 COM 口 | 默认波特率 | +| --------------- | ----------- | ---------- | +| SSPC 控制板 | COM1 | 9600 | +| 程控电源(备用) | COM2 | 9600 | +| 电子负载(备用) | COM3 | 9600 | + +> **【提示】** 程控电源与电子负载默认采用 LAN 通信;预留 COM 仅用于备份或现场临时调试。 + +## 3.7 首次上电顺序 + +按以下顺序通电,可避免感性负载尖峰冲击: + +1. 接通工控机 UPS; +2. 启动工控机,登录 Windows; +3. 接通串口扩展卡所在电源(如独立); +4. 通电程控电源(输出保持关闭); +5. 通电电子负载(输入保持关闭); +6. 启动 SSPCTester 软件(详见第 4 章); +7. 由软件 **连接所有设备**,确认 4 个设备绿灯均亮; +8. 在系统设置或首次使用页面中确认通信参数无误; +9. 进入项目信息页,开始首次测试。 + +## 3.8 首次使用前的软件检查 + +| 序号 | 检查项 | 结果 | +| ---- | ----------------------------------------------------- | ---- | +| 1 | `Config\device-profile.json` 存在且校验通过 | □ | +| 2 | 设置页四设备 IP/COM 口与现场实际一致 | □ | +| 3 | 设置页 **Mock 模式** 全部关闭 | □ | +| 4 | 采集卡 4 路通道角色、Scale/Offset 已标定,IsCalibrated 勾选 | □ | +| 5 | 项目数据路径、报告路径已确认存在并可写 | □ | + +--- + +\newpage + +# 第 4 章 软件安装与启动 + +## 4.1 安装包结构 + +软件以**绿色发布**方式提供,无需安装程序。典型目录结构: + +``` +SSPCTester\ +├── SSPCTester.UI.exe ← 主程序 +├── SSPCTester.UI.deps.json +├── SSPCTester.UI.runtimeconfig.json +├── appsettings.json ← 出厂默认配置 +├── Config\ +│ └── device-profile.json ← Modbus 24 路映射 +├── LatoFont\ ← 报告字体 +├── zh-Hans\、zh-Hant\、ja\、… ← 本地化资源 +└── *.dll ← 运行时依赖 +``` + +## 4.2 部署步骤 + +1. 将完整发布目录解压/拷贝到工控机本地磁盘(推荐 `C:\SSPCTester\`)。**不要**部署到只读目录或网络盘。 +2. 确认 `Config\device-profile.json` 存在且与现场 SSPC 控制板配置一致。 +3. 右键 `SSPCTester.UI.exe` → 属性 → 解除锁定(如系统提示)。 +4. 首次运行建议以"普通用户"启动,确保对 `%LOCALAPPDATA%\SSPCTester\` 目录有写权限。 + +> **【提示】** 升级时直接覆盖发布目录;**用户数据**(项目、报告、用户设置)保存在 `%LOCALAPPDATA%\SSPCTester\`,不会被覆盖。 + +## 4.3 关键文件清单 + +| 文件 / 目录 | 用途 | +| ----------------------------------------------------- | ------------------------------------------ | +| `SSPCTester.UI.exe` | 主程序入口 | +| `appsettings.json` | 出厂默认配置 | +| `Config\device-profile.json` | Modbus 协议与 24 路映射(关键配置文件) | +| `%LOCALAPPDATA%\SSPCTester\settings.json` | 当前用户在设置页保存的硬件配置 | +| `%LOCALAPPDATA%\SSPCTester\Projects\` | 项目数据根目录 | +| `%LOCALAPPDATA%\SSPCTester\Reports\` | 报告默认输出目录 | +| `%LOCALAPPDATA%\SSPCTester\Logs\app-YYYYMMDD.log` | 应用日志(按天滚动,保留 7 天) | + +## 4.4 启动方式 + +**方式 A — 双击启动(推荐)** + +直接双击 `SSPCTester.UI.exe`。 + +**方式 B — 通过启动脚本** + +在解决方案根目录下使用 `run.ps1`: + +```powershell +PowerShell.exe -ExecutionPolicy Bypass -File .\run.ps1 +``` + +`run.ps1` 默认启动 `publish\win-x64\SSPCTester.UI.exe`,并将工作目录设为发布目录,确保读取 `appsettings.json` 与 `Config\device-profile.json`。 + +## 4.5 启动顺序说明 + +软件启动时按下列顺序工作: + +1. 读取 `appsettings.json` 出厂默认配置; +2. 叠加用户本地配置 `%LOCALAPPDATA%\SSPCTester\settings.json`(若存在); +3. 初始化日志系统(Serilog → 文件 + UI 日志面板); +4. 构造依赖注入容器,注册四类设备驱动(Mock + 真实); +5. 创建主窗体并加载历史项目列表; +6. 若 `AutoConnect=true`,后台依次连接 4 类设备; +7. 主窗体显示,进入"浏览态"。 + +## 4.6 首次启动检查 + +软件启动后,主界面顶部应能看到 **设备连接面板**(详见 5.3)。检查项: + +- 4 个设备指示灯(SSPC、电源、负载、采集卡)显示连接状态; +- 任意一个未连接时,可点击 **连接全部**; +- 底部日志面板应能看到启动信息(蓝色 INFO 行)。 + +[插图:主窗体首次启动时的全貌] + +## 4.7 退出软件 + +通过主窗体右上角 **关闭** 按钮退出。退出时软件自动: + +1. 保存当前用户设置到 `%LOCALAPPDATA%\SSPCTester\settings.json`; +2. 依次断开 SSPC、电源、负载、采集卡; +3. 若 `Sspc.CloseAllRelaysOnDisconnect=true`,先全部关断 24 路继电器; +4. 关闭日志文件。 + +> **【注意】** 严禁通过任务管理器强制结束进程;强制结束可能导致继电器停留在通态、波形文件不完整。 + +--- + +\newpage + +# 第 5 章 主界面总览 + +## 5.1 整体布局 + +启动后,主界面分为四个区域: + +``` +┌──────────────────────────────────────────────────────────┐ +│ 顶部:标题栏 + 设备连接面板(折叠/展开)+ 设置按钮 │ +├──────────────┬───────────────────────────────────────────┤ +│ 侧栏:项目树 │ 内容区:根据状态切换不同页面 │ +│ │ - 首页 / 项目信息 / 测试主页 / 报告 / 设置 │ +├──────────────┴───────────────────────────────────────────┤ +│ 底部:日志面板(最近 500 条,可滚动) │ +└──────────────────────────────────────────────────────────┘ +``` + +[插图:主界面整体布局] + +## 5.2 浏览态与测试态 + +软件存在两种工作状态: + +| 状态 | 触发 | 侧栏项目树 | 顶部状态条 | +| -------------- | ------------------- | --------------------- | -------------------- | +| **浏览态** | 默认;测试完成或中止 | 显示全部项目,可自由切换 | 无 | +| **测试态** | 点击 **开始测试** | **仅显示当前项目** | 显示橙色"测试进行中" | + +> **【设计说明】** 测试期间设备被独占,隐藏其他项目可避免误操作。 + +## 5.3 设备连接面板 + +位于标题栏右下方。展开后包含: + +| 控件 | 含义 | +| ------------------- | ------------------------------------------------------ | +| SSPC 指示 | 绿=已连接、灰=未连接;下方文本显示"Mock"或"真实" | +| 电源指示 | 同上 | +| 负载指示 | 同上 | +| 采集卡指示 | 同上 | +| **连接全部** | 同时连接所有未连接的设备 | +| **断开全部** | 同时断开所有已连接的设备 | +| **打开设置页** | 快速进入第 6 章描述的设置页 | + +[插图:设备连接面板展开状态] + +## 5.4 侧栏项目树 + +侧栏列出当前所有项目。每个项目展开后有三个子节点: + +- **项目信息**:被测件与现场信息编辑(第 8 章); +- **测试主页**:四个测试模块的 Tab 容器(第 9–12 章); +- **报告页**:生成测试报告(第 13 章)。 + +**操作** + +- 单击项目名:选中并显示项目概况; +- 双击项目名:直接打开"项目信息"页; +- 单击子节点:切换到对应页面。 + +[插图:侧栏项目树] + +## 5.5 内容区页面切换 + +| 入口 | 显示页面 | +| -------------------- | ---------------------- | +| 启动后默认 | 首页(最近项目列表) | +| 点击 **新建项目** | 新建项目对话框 → 项目信息 | +| 项目树 → 项目信息 | 项目信息页 | +| 项目信息 → 开始测试 | 测试主页(标签页容器) | +| 项目树 → 报告页 | 报告页 | +| 标题栏 → 设置 | 设置页 | + +## 5.6 日志面板 + +底部日志面板展示最近 500 条事件,按时间倒序滚动。 + +| 等级 | 颜色 | 含义示例 | +| ------------ | ----- | --------------------------------- | +| Info(信息) | 黑/蓝 | 启动、连接成功、保存设置 | +| Success(成功)| 绿色 | 测试合格、报告生成成功 | +| Warning(警告)| 橙色 | 配置缺失、单次重试、未标定通道 | +| Error(错误)| 红色 | 通信失败、CRC 错误、文件写入失败 | + +> **【提示】** 详细历史日志请查看 `%LOCALAPPDATA%\SSPCTester\Logs\app-YYYYMMDD.log`。 + +## 5.7 颜色与图标约定 + +测试结果在表格、徽标、状态条中统一使用以下四种状态: + +| 图标 / 文本 | 颜色 | 含义 | +| ----------- | ------------- | ------------------------------------------ | +| ● 合格 | 绿 `#2e9e5b` | 所有判定项通过 | +| ● 不合格 | 红 `#d23b3b` | 任一判定项失败 | +| ● 测试中 | 蓝 `#1a73c4` | 当前正在采集 / 等待响应 | +| ● 已测 | 蓝 `#1a73c4` | 已采集但本模块无合格判定(如功率损耗) | +| ○ 未测 | 灰 `#8a929d` | 尚未执行 | + +数值(电压、电流、时间)一律使用等宽字体显示,确保小数点对齐。 + +--- + +\newpage + +# 第 6 章 系统设置 + +设置页用于配置硬件连接参数、采集卡通道、报告与项目存储路径。所有修改在点击 **保存并重新连接** 后写入用户配置文件,并尝试重新连接受影响的设备。 + +[插图:系统设置页全貌] + +## 6.1 进入设置页 + +- 标题栏右侧 **设置** 按钮;或 +- 设备连接面板 → **打开设置**。 + +## 6.2 SSPC Modbus 配置 + +| 字段 | 含义 | +| ------------------------------ | -------------------------------------------------------------------- | +| **使用 Mock** | 勾选后改用模拟驱动,无需真实串口。培训/演练时使用 | +| **启动时自动连接** | 软件启动后是否自动尝试连接 | +| **断开时全部关断** | 软件退出或断开 SSPC 时,是否自动写入全部 24 路 OFF 命令 | +| **记录原始帧** | 在日志中记录每一帧 Modbus 收发,便于排障 | +| **端口名 (PortName)** | 串口名,下拉框列出系统可用 COM 口;也可手工填写 | +| **波特率 (BaudRate)** | 默认 9600 | +| **数据位 / 校验 / 停止位** | 默认 8 / None / One | +| **读超时 (ReadTimeoutMs)** | 默认 500 ms | +| **重试次数 (Retry)** | 默认 2 | +| **设备 Profile 路径** | 默认 `Config/device-profile.json` | +| **连接 / 测试** 按钮 | 触发实际连接并显示结果 | +| **断开** 按钮 | 主动断开连接 | +| **状态** | 实时显示 "已连接" / "未连接" / "连接失败" 等 | + +> **【注意】** 若 **使用 Mock = false** 但 **PortName** 在系统中不存在,连接会失败并在日志中显示 "端口不存在"。请先在 Windows "设备管理器 → 端口" 中确认实际 COM 号。 + +## 6.3 程控电源 UDP5080-100 配置 + +| 字段 | 含义 | +| --------------------- | ------------------------------------- | +| **使用 Mock** | 模拟模式 | +| **启动时自动连接** | 是否自启动连接 | +| **IP 地址** | 默认 `192.168.6.5` | +| **端口** | 默认 `5025`(SOCKET / SCPI) | +| **测试连接** 按钮 | 建立 TCP 连接并发送身份查询,验证可达性 | +| **状态** | "已连接" / "未连接" / "超时" | + +> **【提示】** 测试连接成功后,软件会在日志中显示电源型号字符串,可据此确认对端硬件。 + +## 6.4 直流电子负载 IT8702P 配置 + +| 字段 | 含义 | +| --------------------- | ------------------------------------- | +| **使用 Mock** | 模拟模式 | +| **启动时自动连接** | 是否自启动连接 | +| **IP 地址** | 默认 `192.168.200.100` | +| **端口** | 默认 `30000` | +| **测试连接** 按钮 | 验证可达性 | +| **状态** | 同上 | + +## 6.5 PCIe8586 高速采集卡配置 + +| 字段 | 含义 | +| ----------------------------- | ----------------------------------------------------- | +| **使用 Mock** | 模拟驱动,生成逼真的 RC 上升/下降波形 | +| **启动时自动连接** | 是否自启动连接 | +| **设备列表** | 下拉框显示当前枚举到的物理采集卡(含逻辑 ID 与序列号) | +| **刷新设备** | 重新枚举 | +| **连接 / 测试** 按钮 | 打开选定卡并执行一次自检 | +| **通道数 (ChannelCount)** | 1 / 2 / 4 / 8 | +| **量程 (InputRange)** | `PlusMinus5V`(±5V)或 `PlusMinus1V`(±1V) | +| **时钟分频 (ClockDivider)** | 基准 100 MHz,分频后即采样率(如 1000 → 100 kHz) | +| **实际采样率** | 自动计算 = 100 MHz ÷ 时钟分频 | +| **Pre-Trigger (ms)** | 触发前采样窗口,默认 10 ms | +| **Post-Trigger (ms)** | 触发后采样窗口,默认 40 ms | +| **总采集时长** | = Pre + Post(默认 50 ms) | + +> **【注意】** 28 V 主功率信号必须经过外部分压或互感器调理后才能接入采集卡。请勿直接接入超出 ±5 V 量程的信号,否则可能损坏前端 AD。 + +## 6.6 采集卡通道角色与标定 + +采集卡配置区下方的通道表(DataGrid),每行对应一个物理通道: + +| 列 | 说明 | +| ----------------- | ------------------------------------------------------------------------- | +| **CH** | 物理通道号 0–7 | +| **Role** | 通道角色,决定该通道在测试中的用途: | +| | - `OutputVoltage`:SSPC 输出端电压(曲线测试必需 / 功率损耗输入端电压来源) | +| | - `OutputCurrent`:SSPC 输出端电流 | +| | - `InputVoltage`:SSPC 输入端电压(备用) | +| | - `InputCurrent`:SSPC 输入端电流(备用) | +| | - `Unconfigured`:未配置,不参与任何测试 | +| **Name** | 显示名称,可自定义中文 | +| **Scale** | 标定系数 K(工程值 = K × 采样值 + Offset) | +| **Offset** | 标定偏置 B | +| **IsCalibrated** | 是否已标定。**未勾选时,依赖该通道的真实测试会被阻止** | + +**典型标定流程** + +1. 拆除被测件,将基准信号源接入 CH0; +2. 注入已知电压 Vref(如 28.00 V); +3. 在工程值 = K × x + B 中: + - 取两个不同 Vref 值,记下采集卡读数 x₁ 与 x₂; + - 解方程:K = (Vref1 − Vref2) / (x₁ − x₂),B = Vref1 − K·x₁; +4. 填写到表格对应行,勾选 **IsCalibrated**; +5. 点击 **保存并重新连接**。 + +> **【提示】** 重新插拔分压板或更换电缆后,应重新标定。建议每三个月进行一次例行复检。 + +## 6.7 报告设置 + +| 字段 | 含义 | +| ---------- | ------------------------------------------------- | +| **保存路径** | 报告默认输出目录,默认 `%LOCALAPPDATA%\SSPCTester\Reports` | +| **浏览** | 弹出目录选择对话框 | +| **格式** | 单选;当前仅支持 PDF(Word 选项已灰显,后续版本提供) | + +## 6.8 项目数据路径 + +| 字段 | 含义 | +| ------------- | ----------------------------------------------------- | +| **项目根目录** | 所有项目存放位置,默认 `%LOCALAPPDATA%\SSPCTester\Projects` | +| **浏览** | 选择目录 | + +> **【注意】** 修改后已有项目不会自动迁移,请先手动将旧目录中的 `project.json` 与 `curves` 等内容复制到新路径,再重新启动软件。 + +## 6.9 "保存并重新连接" + +页面底部的统一保存按钮。点击后: + +1. 将所有控件值序列化到 `%LOCALAPPDATA%\SSPCTester\settings.json`; +2. 调用所有受影响设备的"断开 → 重新连接"流程; +3. 在日志面板输出每个设备的最终状态。 + +> **【提示】** 设置页修改不影响发布目录中的 `appsettings.json`。如需调整出厂默认值,请由维护人员单独修改 `appsettings.json` 并重新分发。 + +## 6.10 配置文件优先级 + +``` +出厂默认 (appsettings.json) + ↓ 覆盖 +用户配置 (%LOCALAPPDATA%\SSPCTester\settings.json) + ↓ 覆盖 +本次运行的临时修改(未保存) +``` + +> **【提示】** 若希望"恢复出厂",可直接删除 `%LOCALAPPDATA%\SSPCTester\settings.json`,下次启动时自动读取 `appsettings.json` 重建。 + +--- + +\newpage + +# 第 7 章 项目管理 + +## 7.1 项目概念 + +本系统以"**一个被测件 = 一个项目**"组织数据。一个项目内可以包含多次测试运行,但只保留最近一次完整的结果集;如需历史比对,建议另建项目并在项目名中包含序列号。 + +每个项目都对应磁盘上一个目录,结构如下: + +``` +%LOCALAPPDATA%\SSPCTester\Projects\ +└── {项目名}\ + ├── project.json ← 项目元数据 + 各模块结果 + ├── curves\ ← 曲线测试的波形原始数据 + │ ├── CH01_on_20260618_153022234.bin + │ ├── CH01_on_20260618_153022234.json + │ ├── CH01_off_20260618_153023876.bin + │ └── CH01_off_20260618_153023876.json + └── report.pdf ← 最近一次生成的报告 +``` + +## 7.2 新建项目 + +从以下任一入口打开 **新建项目** 对话框: + +- 首页右上角 **新建项目** 按钮; +- 首页空状态 **新建项目** 提示按钮; +- 侧栏底部 **+** 按钮。 + +[插图:新建项目对话框] + +| 字段 | 必填 | 说明 | +| --------------- | ---- | ------------------------------------------ | +| **项目名称** | ✓ | 唯一;用于磁盘目录名(会自动去除非法字符) | +| **被测件编号** | ✓ | 例如 `SSPC-2026-001` | +| **型号** | | 被测件型号 | +| **测试人员** | | 默认登录用户名,可手工修改 | + +点击 **创建** 后: + +1. 在项目根目录下创建 `{项目名}` 目录; +2. 写入初始 `project.json`; +3. 自动跳转到该项目的"项目信息"页(第 8 章)。 + +> **【注意】** 项目名一旦创建不可重命名(会导致旧报告中的报告编号与目录失配)。如需更名,请新建项目并手工迁移数据。 + +## 7.3 打开历史项目 + +**方式 A — 首页最近项目表** + +首页表格列出全部项目,列含义: + +| 列 | 含义 | +| --------------- | --------------------------------------------- | +| **项目名称** | 项目目录名 | +| **被测件编号** | 来自 `project.json` 中的 `Dut.SerialNumber` | +| **最近测试时间** | `LastTestedAt`,无则显示 "—" | +| **综合判定** | 合格 / 不合格 / 已测 / 未测 徽标 | +| **操作** | **打开** 按钮 | + +- 单击行 → 选中项目; +- 双击行 → 打开"项目信息"页; +- 点击 **打开** → 打开"项目信息"页。 + +**方式 B — 侧栏项目树** + +侧栏列出全部项目,单击项目名展开 3 个子节点,单击子节点即可进入对应页面。 + +## 7.4 删除 / 备份项目 + +软件本身不提供"删除项目"按钮,避免误操作。 + +- **备份**:直接拷贝 `%LOCALAPPDATA%\SSPCTester\Projects\{项目名}\` 目录到归档位置; +- **删除**:在 Windows 资源管理器中删除对应项目目录,下次启动后该项目从列表中消失。 + +> **【提示】** 已生成的 PDF 报告位于该项目目录内,如需保留请在删除项目前另存。 + +## 7.5 项目命名建议 + +为便于查找与统计,建议项目命名包含: + +``` +{产品型号}-{被测件编号}-{日期或批次} +``` + +例如:`SSPC-24P-A001-20260625`、`SSPC-A001-LOT2026Q2-003`。 + +--- + +\newpage + +# 第 8 章 项目信息与测试参数配置 + +打开项目后默认进入"项目信息"页。本页用于完善被测件资料、记录测试环境、勾选要执行的测试项。 + +[插图:项目信息页全貌] + +## 8.1 被测件信息 + +| 字段 | 含义 | +| ------------- | ------------------------------------------ | +| **设备名称** | 例如 "24 路固态功率控制器" | +| **设备型号** | 产品型号 | +| **设备编号** | 被测件序列号 / 单号;建议唯一 | +| **生产厂家** | 被测件来源 | + +## 8.2 测试现场信息 + +| 字段 | 含义 | +| ---------------- | ---------------------------------------------------------------------- | +| **测试人员** | 操作员姓名 | +| **测试日期** | 日期选择器,默认当天 | +| **环境温度 (℃)** | 建议 23 ± 5 | +| **相对湿度 (%)** | 建议 ≤ 75 | +| **大气压 (kPa)** | 建议 86 – 106 | +| **备注** | 多行文本,可记录特殊条件、被测件状态、临时设备替换等 | + +> **【注意】** 环境参数会随报告一并输出,建议按现场实测填写。 + +## 8.3 测试项选择 + +页面下方的 4 个复选框对应四大测试模块: + +| 复选框 | 对应模块 | 章节 | +| --------------- | ---------------------- | ----- | +| **基础测试** | 24 路开/关与稳定性 | 第 9 章 | +| **开启与关断曲线** | 高速波形采集与时间指标 | 第 10 章 | +| **功率损耗** | 输入/输出双端功率测量 | 第 11 章 | +| **保护功能** | 6 类保护演示 | 第 12 章 | + +> **【提示】** 这里的勾选影响两处: +> +> 1. 进入测试主页后,未勾选模块的 Tab 仍可点开但不会进入"必测"流程; +> 2. 报告生成时,可选择仅输出已勾选模块的章节(详见第 13 章)。 + +## 8.4 开始测试 + +页面右下角 **开始测试** 按钮。点击后: + +1. 软件切换到"测试态"; +2. 侧栏只保留当前项目; +3. 顶部出现橙色"测试进行中"状态条; +4. 内容区切换到"测试主页"(标签页容器),默认显示"基础测试"。 + +> **【注意】** 测试态期间,无法切换到其他项目;如需中止,点击顶部状态条的 **中止** 按钮。中止后已采集数据保留,未执行模块状态保持"未测"。 + +[插图:测试主页(标签页容器)默认视图] + +--- + +\newpage + +# 第 9 章 基础测试 + +**基础测试**用于验证 SSPC 24 路通道的开/关功能和稳定性。它是后续曲线、功率、保护测试的前提:基础不通过,后续模块通常也无法获得有效数据。 + +[插图:基础测试 Tab 页全貌] + +## 9.1 测试目的 + +- 验证每一路继电器能否按命令导通; +- 验证导通后能否读到有效电压、电流; +- 验证关断命令后输出端能否回零并稳定; +- 给出每路通道的合格 / 不合格判定。 + +## 9.2 界面布局 + +页面自上而下分为三层: + +1. **统计条**(顶部一行):已完成 X / 24、合格 X、不合格 X、未测 X; +2. **操作区**(右上角):刷新频率(2 Hz / 5 Hz)、**清空结果**、**一键测试全部**; +3. **通道表格**(主区域):24 行,每行对应一路通道。 + +| 列 | 含义 | +| ----------- | ------------------------------------------ | +| **CH** | 通道号(1–24) | +| **V** | 当前/最近一次导通时的电压(V) | +| **A** | 当前/最近一次导通时的电流(A) | +| **关断电压** | 关断命令稳定后的电压(V) | +| **状态** | 合格 / 不合格 / 测试中 / 未测 徽标 | +| **操作** | 行内 **开** / **关** 按钮 | + +## 9.3 单通道开/关流程 + +**步骤 1:点击某行的 "开"** + +软件执行: + +1. 向 SSPC 控制板发送对应物理插位的 ON 命令(Modbus 功能码 0x05,写入 0xFF00); +2. 等待响应回声并刷新该行的电压、电流; +3. 启动后台轮询任务,按"刷新频率"(2 Hz 或 5 Hz)持续读取该通道测量。 + +**步骤 2:观察读数** + +- **V** 列应稳定在被测件额定电压附近(如 28 V); +- **A** 列应等于电子负载设定值(如 1 A); +- 若读数明显偏离,可点击 **关** 终止;并检查接线、负载、电源。 + +**步骤 3:点击该行的 "关"** + +软件执行: + +1. 停止后台轮询; +2. 发送 OFF 命令(功能码 0x05,写入 0x0000); +3. 进入稳定等待:在 2 秒超时内,连续读取该通道电压; +4. 当电压 < 0.5 V 且**连续 2 次**满足该条件时,认为已稳定关断; +5. 综合开通时与关断时的结果,给出 **合格 / 不合格** 判定。 + +## 9.4 一键测试全部 + +点击右上角 **一键测试全部** 按钮,软件将自动对 CH1–CH24 依次执行"开 → 短暂稳定 → 关 → 稳定判定",并在每路完成后立刻刷新该行状态与顶部统计。 + +> **【提示】** 一键测试期间,**统计条** 实时累加;按 **中止** 可在当前通道完成后停止。 + +## 9.5 刷新频率说明 + +| 频率 | 适用 | +| -------- | ------------------------------------------------------ | +| **2 Hz** | 默认。CPU 占用低,适合 24 路并行场景或老旧工控机 | +| **5 Hz** | 更细腻的读数动态显示,适合验证负载阶跃响应或观察波动 | + +> **【注意】** 刷新频率仅影响 UI 显示;判定逻辑仍以 SSPC 控制板返回的离散测量为准。 + +## 9.6 判定准则 + +| 判定结果 | 条件 | +| ---------- | -------------------------------------------------------------------- | +| **合格** | 通信无错误 ✓ 且 导通电压 > 1.0 V ✓ 且 关断稳定(连续 2 次电压 < 0.5 V)✓ | +| **不合格** | 任一条件不满足 | +| **测试中** | 已发出 ON / OFF 命令,正在等待稳定 | +| **未测** | 尚未点击 **开** | + +稳定等待超时 **2 秒**;超时后视为不合格。 + +> **【提示】** 若被测件存在续流回路或大容性负载,关断后电压回零可能超过 2 秒,应在硬件侧补加放电电阻或在维护版本中调整阈值。 + +## 9.7 清空结果 + +**清空结果** 按钮会将当前表格中所有行的状态恢复为"未测",电压、电流清零。**已写入项目的结果不会立即被清除**,仅在下次"开始测试"或退出/重进项目时同步。 + +## 9.8 常见现象解释 + +| 现象 | 可能原因 | 处理 | +| ----------------------------- | ----------------------------------------- | ----------------------------------- | +| 导通 V 列读到 0 V | 程控电源未输出 / 主回路断线 | 检查电源面板状态、主回路 | +| 关断 V 列长期保持 1–2 V | 续流回路 / 负载电感效应 | 加放电电阻或延长稳定窗口 | +| 行状态长期为"测试中" | SSPC 控制板未响应 / 串口被其他程序占用 | 查看日志中的 Modbus 帧 / 重启软件 | +| 行状态翻红,但电压正常 | 关断稳定未满足(电压 ≥ 0.5 V 或 2 秒超时) | 见上一行 | +| 行状态翻红,电压全 0 | 通道实际未接负载或主电源关闭 | 检查接线 | + +--- + +\newpage + +# 第 10 章 开启与关断曲线测试 + +**曲线测试**通过高速采集卡同步采样 SSPC 开关瞬态,自动计算 4 个关键时间参数:**开启时间、上升时间、关断时间、下降时间**。本模块对应指标 1.1 – 1.6。 + +[插图:曲线测试 Tab 页全貌] + +## 10.1 测试目的 + +| 参数 | 定义 | +| ------------ | -------------------------------------------------------------------- | +| **开启时间** | 控制信号发出 → 输出电压达到 90% Vmax 的时间 | +| **上升时间** | 输出电压由 10% Vmax 上升到 90% Vmax 的时间 | +| **关断时间** | 控制信号撤销 → 输出电压降至 10% Vmax 的时间 | +| **下降时间** | 输出电压由 90% Vmax 下降到 10% Vmax 的时间 | + +其中 Vmax 取**采集波形电压样点 95 百分位的均值**,自动剔除瞬态尖峰。 + +## 10.2 界面布局 + +页面自上而下分为四区: + +1. **标题与说明**:模块名 + 测试基准说明; +2. **左侧参数卡**:通道选择、4 个阈值、**采集当前通道**、**在新窗口查看曲线**; +3. **右侧波形区**:上下两个波形控件——**开启曲线**(上升)与 **关断曲线**(下降); +4. **底部结果表**:CH / 开启时间 / 上升时间 / 关断时间 / 下降时间 / 状态。 + +[插图:曲线测试左右分栏视图] + +## 10.3 阈值设置 + +阈值用于判定时间参数是否合格。出厂默认值: + +| 阈值 | 默认值 | 含义 | +| ----------------- | ------ | -------------------------- | +| `MaxOnTimeMs` | 5.0 ms | 开启时间上限 | +| `MaxRiseTimeMs` | 3.0 ms | 上升时间上限 | +| `MaxOffTimeMs` | 5.0 ms | 关断时间上限 | +| `MaxFallTimeMs` | 3.0 ms | 下降时间上限 | + +> **【提示】** 阈值随项目保存(位于 `project.json` 的 `CurveThresholds` 字段),可针对不同型号被测件调整。 + +## 10.4 采集流程 + +点击 **采集当前通道** 后,软件自动执行以下步骤: + +1. **前置校验**: + - 若采集卡为真实硬件,检查至少有一个 `OutputVoltage` 角色且已标定的通道; + - 若校验失败,弹出提示并终止; +2. **置初态**:发送 OFF 命令并等待稳定(避免起点电压不稳定); +3. **开启曲线采集**: + - 启动采集卡,Pre-Trigger = 10 ms,Post-Trigger = 40 ms(共 50 ms); + - 在采集开始后 10 ms(PreTrigger 时刻)发送 ON 命令; + - 采集结束后取得"上升波形"`risingCurve`; +4. **计算上升指标**: + - $V_{max} = \text{p95}(v[i])$ + - 开启时间 = 首次 v(t) ≥ 0.9 Vmax 的时间 − 触发时刻 + - 上升时间 = (首次 v ≥ 0.9 Vmax) − (首次 v ≥ 0.1 Vmax) +5. **间歇 100 ms**; +6. **关断曲线采集**:同上,但触发时发送 OFF 命令;得到"下降波形"`fallingCurve`; +7. **计算下降指标**: + - 关断时间 = 首次 v(t) ≤ 0.1 Vmax 的时间 − 触发时刻 + - 下降时间 = (首次 v ≤ 0.1 Vmax) − (首次 v ≤ 0.9 Vmax) +8. **持久化**:波形数据保存到 `Projects\{项目名}\curves\` 目录; +9. **更新 UI**:表格新增/刷新行、绘制波形、给出 **合格 / 不合格** 判定。 + +> **【注意】** 时间基准取自 Modbus 命令的**发送时刻**,并非硬件级别的触发同步。因此,对硬件同步精度有更高要求的场合,需要使用外部触发信号配合上位机 GPIO 调用。 + +## 10.5 波形显示 + +每个波形控件展示: + +- **电压曲线**:蓝色(开启)或红色(关断); +- **网格**:浅灰,时间间隔自适应; +- **阈值辅助线**:90% Vmax 与 10% Vmax(虚线); +- **触发点标记**:纵向短线; +- **悬停光标**(鼠标移入时):显示当前点 t / V 数值。 + +支持鼠标滚轮缩放、左键拖动平移、双击复位。 + +点击 **在新窗口查看曲线** 可弹出独立全屏窗口,便于打印或截图。 + +[插图:曲线放大窗口] + +## 10.6 波形文件存储 + +每次采集都会保存两组文件(一组对应上升、一组对应下降): + +| 文件类型 | 命名样例 | 内容 | +| -------- | ----------------------------------------- | ----------------------------------- | +| `.bin` | `CH01_on_20260618_153022234.bin` | float32 小端序,多通道交错样点流 | +| `.json` | `CH01_on_20260618_153022234.json` | 采样率、触发时刻、通道角色、标定参数 | + +> **【提示】** 波形原始数据由报告生成器读取并嵌入 PDF。如需在第三方工具中复盘,可用 Python / MATLAB 按元数据中描述的格式解析。 + +## 10.7 判定准则 + +| 判定结果 | 条件 | +| ---------- | ----------------------------------------------------------------- | +| **合格** | 4 个时间指标均 ≤ 阈值 ✓ 且 数值有效(非 NaN) ✓ | +| **不合格** | 任一指标超阈值,或采样数据异常(Vmax 过低、波形不收敛) | +| **测试中** | 正在采集 | +| **未测** | 当前通道未采集 | + +## 10.8 注意事项 + +- 采集卡必须配置一个 **`OutputVoltage` 角色且已标定** 的通道,否则真实硬件下采集会被拒绝; +- 当负载为大容性时,下降时间可能显著加大,应在工程上对阈值进行评估; +- 采集前确认负载已连接,否则 Vmax 取不到有效幅值; +- 高速采集对噪声敏感,连接线缆应尽量短,避免与强电流回路并行。 + +--- + +\newpage + +# 第 11 章 功率损耗测试 + +**功率损耗测试**同时测量 SSPC 输入端与输出端的电压、电流,计算电压降、功率损耗、效率。本模块对应指标 1.7 – 1.10、1.13。 + +[插图:功率损耗测试 Tab 页全貌] + +## 11.1 测试目的 + +- 在固定工作点下,测得 SSPC 的输入功率 Pin 和输出功率 Pout; +- 计算电压降 ΔV、功率损耗 Ploss、效率 η; +- 为器件选型、热设计、电源容量评估提供数据依据。 + +## 11.2 界面布局 + +页面自上而下分为三区: + +1. **左侧参数卡**:通道选择、采集次数、采集间隔、**测量当前通道**; +2. **中部实时读数卡**:Vin / Iin / Pin、Vout / Iout / Pout、损耗 / 效率; +3. **底部汇总表**:CH / Vin / Iin / Pin / Vout / Iout / Pout / 损耗 / 效率 / 状态。 + +## 11.3 参数说明 + +| 参数 | 默认值 | 说明 | +| ------------------ | ------ | ------------------------------------- | +| **采集次数 (N)** | 5 | 单次测量内连续采样 N 次,取算术平均 | +| **采集间隔 (ms)** | 100 | 相邻两次采样的间隔 | + +总采样耗时 ≈ N × 间隔 = 500 ms(默认)。 + +## 11.4 数据来源 + +| 物理量 | 来源 | +| ------------ | -------------------------------------------------------------------- | +| **Vout** | SSPC 控制板 Modbus 测量(继电器端电压回路) | +| **Iout** | SSPC 控制板 Modbus 测量(电流互感器 / Hall 元件回路) | +| **Vin** | 高速采集卡的 `OutputVoltage` 角色通道瞬时值(外部分压后) | +| **Iin** | 等于 Iout(SSPC 为串联开关,主回路电流不分支) | + +> **【注意】** "输入端电压"在采集卡上挂在 `OutputVoltage` 角色通道,这是历史遗留命名。它实际指向 SSPC 输入端的测点。维护人员可在采集卡通道表中将 `Name` 字段改为"输入电压",但 `Role` 必须保持 `OutputVoltage`。 + +## 11.5 测量流程 + +点击 **测量当前通道**,软件执行: + +1. SSPC 打开指定通道; +2. 等待 50 ms 稳定; +3. 循环 N 次: + - 读 SSPC Modbus 测量:得到 Vout、Iout; + - 读采集卡 `OutputVoltage` 通道瞬时值:得到 Vin; + - 累加 → 间隔 IntervalMs; +4. 取平均:$\bar{V}_{in}$、$\bar{V}_{out}$、$\bar{I}$; +5. 计算衍生量并刷新实时读数 + 汇总表: + +$$ +\Delta V = \bar{V}_{in} - \bar{V}_{out} +$$ + +$$ +P_{in} = \bar{V}_{in} \cdot \bar{I},\quad P_{out} = \bar{V}_{out} \cdot \bar{I} +$$ + +$$ +P_{loss} = P_{in} - P_{out} +$$ + +$$ +\eta = \dfrac{P_{out}}{P_{in}} \times 100\% +$$ + +6. SSPC 关断该通道。 + +## 11.6 结果状态 + +| 状态 | 含义 | +| -------- | --------------------------------------------------- | +| **已测** | 已完成采集并计算了完整指标。本模块**不给出合格/不合格**判定,由质量人员对照规范评估 | +| **测试中** | 正在采集 | +| **未测** | 尚未点击 **测量当前通道** | + +> **【提示】** 若需要"自动判定",可在维护版本中在 `PowerLossRow` 中接入阈值(例如 ΔV ≤ 0.5 V、η ≥ 99 %)。 + +## 11.7 常见误差源 + +| 误差源 | 影响 | 缓解 | +| --------------------------------- | -------------------------- | ------------------------------- | +| 采样数过少(N ≤ 2) | 噪声未平均掉,η 抖动 | 增大 N 到 10 以上 | +| 负载未稳定(刚切换工作点) | 电压电流瞬态 | 采集前确认负载已稳定 ≥ 100 ms | +| 采集卡通道未标定 / Scale 偏差 | Vin 漂移 | 重新标定 | +| Modbus 电流量程精度低于实际范围 | I 分辨率不足 | 选择匹配量程的设备 Profile | +| 共模噪声进入分压板 | Vin 抖动 | 调理板加滤波 / 调整接地 | + +## 11.8 注意事项 + +- 采集卡必须有 **`OutputVoltage` 角色且已标定** 的通道,否则真实硬件下采集会被拒绝; +- 测量期间不应同时执行基础测试或曲线测试,以免竞争 SSPC 串口; +- 对效率极高(η > 99.5 %)的器件,建议提升 N 与间隔,必要时使用更高精度电流测量配置。 + +--- + +\newpage + +# 第 12 章 保护功能测试 + +**保护功能测试**用于演示 SSPC 的 6 类保护:跳闸、短路、过温、过压、欠压、限流。本模块对应指标 1.14、1.17、1.19、1.21 – 1.23。 + +> **【说明】** 当前版本保护功能采用 **演示框架**,不会真正向被测件施加破坏性故障,仅展示"如何在系统中记录与呈现保护结果"。实际故障注入需要外部专用工装,由后续版本接入。 + +[插图:保护功能测试 Tab 页全貌] + +## 12.1 测试目的 + +- 验证软件框架对 6 类保护项的记录、展示能力; +- 为后续接入真实故障注入设备建立结果数据格式; +- 形成"演示报告",配合质量评审展示规程符合性。 + +## 12.2 界面布局 + +| 区域 | 内容 | +| ---------------- | ----------------------------------------------------- | +| **顶部警告条** | 提示"当前模块为框架占位,不执行真实故障注入" | +| **左侧参数卡** | 6 个保护项复选框 + 4 个阈值输入 + **生成演示结果** | +| **右侧波形占位** | 显示"框架占位"提示 | +| **底部结果表** | 保护类型 / 触发条件 / 关断时间 / 结果 | + +## 12.3 保护项与默认触发条件 + +| 复选框 | 保护类型 | 触发条件 | 关断时间参考 | +| ------------- | -------- | ------------------------------------- | ------------ | +| **跳闸** | Trip | 电流 ≥ 1.5 × 额定电流,持续 t > 50 ms | < 80 ms | +| **短路** | Short | 输出负载阻抗 ≤ 1 mΩ | < 10 ms | +| **过温** | OverTemp | 器件温度 ≥ 85 ℃ | < 200 ms | +| **过压** | OverVolt | Vin ≥ 阈值(默认 32 V) | < 50 ms | +| **欠压** | UnderVolt | Vin ≤ 阈值(默认 22 V) | < 50 ms | +| **限流** | Limit | I ≥ 阈值(默认 1.2 A) | < 30 ms | + +## 12.4 阈值参数 + +| 阈值 | 默认值 | 说明 | +| ---------------------- | ------ | -------------- | +| **过压阈值 (V)** | 32.0 | OverVolt 触发 | +| **欠压阈值 (V)** | 22.0 | UnderVolt 触发 | +| **过流阈值 (A)** | 1.2 | Limit 触发 | +| **过温阈值 (℃)** | 85.0 | OverTemp 触发 | + +## 12.5 生成演示结果 + +1. 勾选要演示的保护项; +2. 必要时修改阈值; +3. 点击 **生成演示结果**; +4. 结果表自动填充每个勾选项的演示数据(关断时间在合理范围内随机模拟,状态固定为 Pass)。 + +## 12.6 结果表字段 + +| 列 | 含义 | +| -------------- | ------------------------------------------ | +| **保护类型** | Trip / Short / OverTemp / ... | +| **触发条件** | 文本描述(如 "I ≥ 1.5 × Irated") | +| **关断时间 (ms)** | 演示数据,符合 12.3 表的参考范围 | +| **结果** | Pass(演示模式恒为 Pass) | + +## 12.7 注意事项 + +- 演示结果**不代表被测件真实保护性能**,不可作为型式试验依据; +- 报告输出包含本模块时,应在备注栏注明"保护项为框架演示数据"; +- 后续接入真实故障注入硬件时,本表字段保持兼容,只是结果来源改变。 + +--- + +\newpage + +# 第 13 章 测试报告 + +完成一项或多项测试后,使用本模块生成 PDF 报告。 + +[插图:测试报告页全貌] + +## 13.1 进入报告页 + +- 侧栏 → 项目 → **报告页**; +- 或者完成全部测试后,软件提示"前往报告页"。 + +## 13.2 报告内容勾选 + +| 复选框 | 内容 | +| --------------------- | ----------------------------------- | +| **封面 + 综合判定** | 必选;包含报告标题、被测件信息、综合判定徽标、签名区 | +| **基础测试** | 是否包含基础测试 24 行表格 | +| **开启与关断曲线** | 是否包含曲线测试表格与嵌入波形图 | +| **功率损耗** | 是否包含功率损耗汇总表 | +| **保护功能** | 是否包含保护功能结果表 | + +## 13.3 文件名与路径 + +| 字段 | 说明 | +| ----------- | ---------------------------------------------------- | +| **文件名** | 默认 `项目名_YYYYMMDD.pdf`,可手工修改 | +| **保存路径** | 默认取自系统设置的报告路径;可点击 **浏览** 修改 | +| **上次输出路径** | 显示最近一次生成的完整文件路径,可点击 **打开文件夹** | + +**建议文件名格式** + +``` +{项目名}_{被测件编号}_{YYYYMMDD}.pdf +``` + +例如:`SSPC-A001_SSPC-2026-001_20260625.pdf`。 + +## 13.4 生成报告流程 + +1. 勾选要包含的章节; +2. 修改文件名(如需要); +3. 点击 **生成报告**; +4. 软件依次: + - 调用 `ProjectStore.SaveAsync` 持久化最新项目数据; + - 调用 `ReportGenerator.Generate` 用 QuestPDF 渲染 PDF; + - 写入目标路径; + - 在日志面板与"上次输出路径"显示结果。 +5. 点击 **打开文件夹** 可直接定位到 PDF。 + +## 13.5 报告结构 + +报告统一采用 A4 纸张、深蓝标题、表格化展示。 + +**封面** + +- 报告标题("固态功率控制器动态参数测试报告") +- 报告编号:`SPC-YYYYMMDD-XXXXX`(自动生成) +- 产品信息:名称、型号、编号、生产厂家 +- 测试日期、测试人员 +- 编制 / 审核 / 批准 签名区(空格供手工签字) + +**报告体** + +| 章节 | 内容 | +| ---------------- | -------------------------------------------------------------------- | +| 被测件 + 现场信息 | 双栏表格 | +| 基础测试 | 24 行 × 4 列(CH / V / A / 状态) | +| 曲线测试 | N 行 × 5 列(CH + 4 时间指标 + 状态),每行后附上升与下降波形图 | +| 功率损耗 | N 行 × 9 列(CH / Vin / Iin / Pin / Vout / Iout / Pout / 损耗 / 效率) | +| 保护功能 | 6 行(保护类型 / 触发条件 / 关断时间 / 结果) | +| 综合判定 | 大号徽标 + 文字结论 | + +**页眉 / 页脚** + +- 页眉:报告编号 + 项目名称 +- 页脚:页码 X / Y + 生成时间 + +## 13.6 综合判定逻辑 + +综合判定根据项目中所有结果集(`BasicResults`、`CurveResults`、`PowerResults`、`ProtectResults`)的状态取最差值: + +| 优先级(从高到低) | 综合判定 | +| ---------- | -------- | +| 1. 任一不合格 | 不合格 | +| 2. 全部合格 | 合格 | +| 3. 有测量但无判据 | 已测 | +| 4. 仍在执行 | 进行中 | +| 5. 全部未执行 | 未测 | + +> **【提示】** 功率损耗模块只产生"已测"状态,不会拉低综合判定;保护功能演示数据为 Pass,不会拉低综合判定。 + +## 13.7 报告样张 + +[插图:测试报告封面样张] + +[插图:测试报告内页(基础测试表格)] + +[插图:测试报告内页(曲线测试 + 波形图)] + +## 13.8 注意事项 + +- 报告生成依赖项目目录写权限;如遇 "拒绝访问" 错误,请检查路径或换到本地用户目录; +- 若曲线测试章节波形丢失(`curves/` 目录文件被外部清理),报告中对应位置会显示"波形数据缺失"; +- 当前仅支持 PDF;后续会提供 Word/DOCX 输出。 + +--- + +\newpage + +# 第 14 章 端到端操作演练 + +本章以"新建项目 → 完成四项测试 → 生成报告"为主线,给出一次完整的现场操作演练,便于新员工快速上手。 + +> **【场景设定】** 被测件为某型号 24 路 SSPC,序列号 `SSPC-2026-001`,常温常压环境,由测试员 **张三** 执行。 + +## 14.1 准备 + +### 14.1.1 硬件准备 + +1. 按 3.1 节布置完成; +2. 程控电源 UDP5080-100 已通过 LAN 接入工控机网卡,可 `ping 192.168.6.5`; +3. 电子负载 IT8702P 已通过 LAN 接入工控机第二张网卡(或同一网卡多 IP),可 `ping 192.168.200.100`; +4. SSPC 控制板已通过 RS-485 接入 `COM1`; +5. 采集卡 4 路通道按 3.5 节接线并完成标定; +6. 急停按钮就位、UPS 正常; +7. 被测件已上电(程控电源仍**保持输出关闭**)。 + +### 14.1.2 软件启动 + +1. 双击 `C:\SSPCTester\SSPCTester.UI.exe`; +2. 进入主界面后展开设备连接面板; +3. 点击 **连接全部**; +4. 等待 4 个设备指示灯依次变绿; +5. 若任一设备未连接,进入 **设置** 检查 6.2 – 6.5 节描述的参数。 + +## 14.2 新建项目 + +1. 首页 → **新建项目**; +2. 填写: + - 项目名称:`SSPC-A001-20260625` + - 被测件编号:`SSPC-2026-001` + - 型号:`SSPC-24P-A` + - 测试人员:`张三` +3. 点击 **创建**; +4. 软件跳转至"项目信息"页。 + +## 14.3 填写项目信息 + +| 字段 | 填入 | +| -------- | -------------------------- | +| 设备名称 | 24 路固态功率控制器 | +| 设备型号 | SSPC-24P-A | +| 设备编号 | SSPC-2026-001 | +| 生产厂家 | XX 公司 | +| 测试人员 | 张三 | +| 测试日期 | 2026-06-25 | +| 环境温度 | 23 | +| 相对湿度 | 55 | +| 大气压 | 101 | +| 备注 | 入厂复检;常温常压 | + +勾选全部 4 项测试: + +- ✓ 基础测试 +- ✓ 开启与关断曲线 +- ✓ 功率损耗 +- ✓ 保护功能 + +[插图:项目信息页填写完成状态] + +## 14.4 开始测试 + +1. 点击右下 **开始测试**; +2. 软件切换到测试态,顶部出现橙色"测试进行中"; +3. 默认显示"基础测试"Tab。 + +## 14.5 执行基础测试 + +1. 在程控电源前面板设置:电压 28 V、限流 5 A、**开输出**; +2. 在电子负载前面板设置:CC 模式、电流 1.0 A、**开输入**; +3. 在软件中将刷新频率选择为 **2 Hz**; +4. 点击 **一键测试全部**; +5. 观察统计条:已完成 X / 24 持续递增; +6. 等待 24 路全部完成(典型 60 – 90 秒); +7. 检查统计:合格 24、不合格 0;如有不合格行,记录通道号并按 15.3 节排查。 + +[插图:基础测试完成后的 24 行表格] + +## 14.6 执行曲线测试 + +1. 切换到 **开启与关断曲线** Tab; +2. 阈值保持默认(5 / 3 / 5 / 3 ms); +3. 选择通道:`CH1`; +4. 点击 **采集当前通道**; +5. 等待约 200 – 300 ms,开启与关断波形依次显示; +6. 检查时间参数是否落在阈值内(默认全部 < 5 ms); +7. 改选 `CH2`、`CH3`、`CH4`,重复采集; +8. 必要时点击 **在新窗口查看曲线** 进行复核; + +> **【提示】** 实际验收一般覆盖 24 路全部;本节为节约篇幅仅演示 4 路。 + +[插图:曲线测试 4 路完成后的视图] + +## 14.7 执行功率损耗测试 + +1. 切换到 **功率损耗** Tab; +2. 参数保持默认(采集 5 次、间隔 100 ms); +3. 选择通道:`CH1`,点击 **测量当前通道**; +4. 中部实时读数显示: + - Vin ≈ 28.05 V,Iin ≈ 1.000 A + - Vout ≈ 27.92 V,Iout ≈ 1.000 A + - 损耗 ≈ 0.13 W,效率 ≈ 99.54 % +5. 表格新增 CH1 一行; +6. 切换 `CH2`、`CH3`、`CH4`,重复测量。 + +[插图:功率损耗测试完成后的实时读数与汇总表] + +## 14.8 生成保护功能演示结果 + +1. 切换到 **保护功能** Tab; +2. 勾选全部 6 项保护; +3. 阈值保持默认; +4. 点击 **生成演示结果**; +5. 表格出现 6 行 Pass 状态记录。 + +## 14.9 生成报告 + +1. 中止测试或等待四模块完成后,软件回到浏览态; +2. 侧栏 → 项目 → **报告页**; +3. 勾选全部章节; +4. 文件名修改为 `SSPC-A001_SSPC-2026-001_20260625.pdf`; +5. 点击 **生成报告**; +6. 等待 2 – 5 秒,日志面板提示"报告生成成功"; +7. 点击 **打开文件夹**,确认 PDF 已生成; +8. 双击 PDF 复核内容:封面、各章节表格、波形图、综合判定徽标。 + +[插图:报告页生成成功提示] + +## 14.10 收尾 + +1. 在软件中点击 **断开全部**; +2. 关闭电子负载输入、程控电源输出; +3. 退出软件(顶部 × 按钮,软件自动保存设置并断开设备); +4. 关闭电子负载主电源、程控电源主电源; +5. 拔下被测件; +6. 整理工装与电缆。 + +--- + +\newpage + +# 第 15 章 故障排除与常见问题 + +本章按"启动 → 设备连接 → 测量 → 判定 → 报告 → 性能"的故障类别整理,每条均给出现象、可能原因、处理步骤。 + +## 15.1 启动类故障 + +### 15.1.1 双击 `.exe` 无任何反应 + +| 可能原因 | 处理 | +| ----------------------------------------- | ------------------------------------------------------- | +| 缺少 .NET 8 Desktop Runtime | 安装 .NET 8 Desktop Runtime;或使用自包含发布版本 | +| 文件被解压锁定 | 右键 `.exe` → 属性 → **解除锁定** | +| 杀毒软件拦截 | 在杀毒软件中将发布目录加入信任名单 | +| 用户权限不足 | 以普通用户启动;不要使用"以管理员身份运行" | + +### 15.1.2 启动后立即崩溃;日志提示 device-profile.json 加载失败 + +| 可能原因 | 处理 | +| ----------------------------------------- | ------------------------------------------------------- | +| `Config\device-profile.json` 缺失 | 从发布包中恢复该文件 | +| 文件被改成非 UTF-8 或语法错误 | 用 VS Code 打开校验 JSON 语法 | +| `schemaVersion` 不是 `"1.0"` | 与现场 SSPC 控制板版本不匹配;联系维护人员获取匹配版本 | +| 24 路 `physicalSlot` 不连续 / 寄存器偏移重复 | 用比对工具检查与原始发布版本的差异 | + +### 15.1.3 启动后日志中提示"用户设置加载失败,使用默认配置" + +| 可能原因 | 处理 | +| ----------------------------------------- | ------------------------------------------------------- | +| `%LOCALAPPDATA%\SSPCTester\settings.json` 损坏 | 删除该文件,软件下次启动自动重建 | + +## 15.2 设备连接类故障 + +### 15.2.1 SSPC 连接失败 / 状态显示"未连接" + +**现象**:基础测试点击 **开** 无反应,日志显示 `SerialPort: 端口不存在` 或 `Modbus: 读超时`。 + +| 可能原因 | 处理 | +| ----------------------------------------- | ------------------------------------------------------- | +| **PortName 不存在** | 设置 → SSPC → 端口名 改为系统实际的 COM 号 | +| 串口被其他程序占用 | 关闭串口调试助手 / 串口监视工具 | +| 串口扩展卡驱动未正常加载 | 重启工控机;必要时重装驱动 | +| 设备 Profile 路径填错 | 改回默认 `Config/device-profile.json` | +| `UseMock = false` 但 SSPC 控制板未通电 | 通电 SSPC 控制板 | +| 波特率 / 校验位与现场不符 | 改为现场实际参数(默认 9600 8-N-1) | + +### 15.2.2 电源 UDP5080 连接失败 + +**现象**:设备指示灯灰色;日志显示 `Socket connect 192.168.6.5:5025 timeout`。 + +| 可能原因 | 处理 | +| ------------------ | ----------------------------------------------- | +| IP 不通 | 工控机执行 `ping 192.168.6.5`;检查网卡 IP 在同网段 | +| 网线 / 交换机故障 | 重插网线,更换网口 | +| 电源前面板未启用 LAN | 进入电源系统菜单确认 LAN 已启用 | +| 防火墙拦截 5025 端口 | 在 Windows 防火墙允许 SSPCTester.UI.exe | + +### 15.2.3 电子负载 IT8702P 连接失败 + +| 可能原因 | 处理 | +| ---------------------- | --------------------------------------------------- | +| IP 不通 | 同 15.2.2 | +| 端口非 30000 | 修改设置或更新负载侧端口 | +| 负载前面板未开启 LAN | 系统菜单启用 LAN | +| 负载主电源未开 / 急停按下 | 排查硬件 | + +### 15.2.4 PCIe8586 采集卡连接失败 + +| 可能原因 | 处理 | +| ----------------------------------- | ----------------------------------------------------- | +| 采集卡未在 PCIe 槽中识别 | 关机重插;BIOS 中检查 PCIe 槽状态 | +| 厂商驱动 (`ACTS1000_64.dll`) 缺失 | 从厂商驱动包重新安装 | +| 选错逻辑 ID | 设置 → 采集卡 → **刷新设备** → 重新选择 | +| 工控机系统时间与采集卡时钟不一致 | 同步系统时间;重启采集卡 | +| 采集卡前端进入保护 | 检查输入信号是否超量程,断电 30 秒后重连 | + +## 15.3 测量类异常 + +### 15.3.1 基础测试"继电器无反应" + +> **现场最常见故障。** + +| 可能原因 | 处理 | +| ------------------------------------------ | ------------------------------------------------------- | +| 设置中 SSPC `UseMock = false`,但 `PortName` 不存在 | 改为正确 COM 口 | +| 串口波特率与控制板不一致 | 改为现场实际波特率 | +| 主电源未开 | 通电 | +| SSPC 控制板掉电 | 检查 24 V 供电 | +| `device-profile.json` 的从站地址与现场不符 | 由维护人员校对 | + +### 15.3.2 功率测试读数全为 0 + +| 可能原因 | 处理 | +| ---------------------------------------------- | --------------------------------------------- | +| 采集卡处于 Mock 模式 | 设置 → 采集卡 → 关闭 Mock | +| 采集卡通道没有 `OutputVoltage` 角色 / 未标定 | 设置 → 通道表 → 配置 + 标定 | +| Scale = 0 或未填 | 重新计算并填写 Scale / Offset | +| 外部分压板未通电 | 通电 | +| Modbus 读取的电压 / 电流寄存器返回 0 | 检查负载电流是否真的为 0 | + +### 15.3.3 曲线测试报错"未找到已标定的 OutputVoltage 通道" + +| 可能原因 | 处理 | +| ---------------------------------------------- | --------------------------------------------- | +| 采集卡通道 Role 全为 `Unconfigured` | 设置 → 至少配置一个 `OutputVoltage` | +| 已配置但 `IsCalibrated = false` | 按 6.6 节完成标定并勾选 | + +### 15.3.4 曲线时间指标显示 NaN 或异常大 + +| 可能原因 | 处理 | +| ---------------------------------------------------------- | --------------------------------------------- | +| Vmax 取不到(电压幅值过小) | 检查负载是否接通、量程是否合适 | +| 波形未在采集窗口内完成跳变(开/关时间 > 50 ms) | 增大 PostTriggerMs | +| 采集卡通道接错位置 / 极性反 | 重新接线 | +| 噪声极大导致首次过阈值误判 | 检查地线 / 屏蔽 / 缩短线缆 | + +### 15.3.5 基础测试"关断电压"列长期偏高 + +| 可能原因 | 处理 | +| ---------------------- | --------------------------------------------- | +| 续流回路 / 电感储能 | 加放电电阻 | +| 测量端有偏置 | 用万用表复核 SSPC 输出端实际电压 | +| Modbus 测量量程偏差 | 校对 `device-profile.json` 中 `voltage.range` | + +## 15.4 判定类异常 + +### 15.4.1 全部 24 路基础测试不合格 + +- 多半为 SSPC 通信不通;先按 15.3.1 排查。 + +### 15.4.2 曲线测试个别通道偏慢 + +| 可能原因 | 处理 | +| ------------------------------ | ------------------------------------- | +| 该通道实际开关速度慢 | 记录并由质量评审决定 | +| 该通道接线接触不良 | 紧固接线 | +| 采集卡端外部调理板老化 | 由维护人员复检调理板 | + +### 15.4.3 多次重测结果不一致 + +| 可能原因 | 处理 | +| ------------------------------ | ------------------------------------- | +| 电源 / 负载未稳定 | 测前等待 ≥ 100 ms | +| 噪声较大 | 检查接地 / 屏蔽 / 远离强电源 | +| 室温 / 器件温度大幅变化 | 控制环境条件 | + +## 15.5 报告生成失败 + +| 可能原因 | 处理 | +| --------------------------------- | ------------------------------------------- | +| 报告路径无写权限 | 改到 `%LOCALAPPDATA%` 内 / 当前用户文档目录 | +| 文件名包含非法字符(`*`, `?`, `:`) | 修改文件名 | +| 同名文件被 Word/Adobe Reader 打开 | 关闭打开该 PDF 的程序 | +| 曲线波形文件 (`curves\`) 被外部清理 | 重新执行曲线测试或在备注中说明 | + +## 15.6 性能与稳定性 + +### 15.6.1 一键测试 24 路过慢 + +| 可能原因 | 处理 | +| ------------------------- | ------------------------------------------ | +| 单路稳定等待 2 秒被频繁触发 | 检查负载是否过容性 | +| 串口超时 + 重试 2 次 | 检查串口稳定性 | +| 工控机 CPU 占用过高 | 关闭无关程序 | + +### 15.6.2 高刷新频率下 UI 卡顿 + +- 将刷新频率改回 2 Hz; +- 关闭日志面板的实时滚动; +- 升级工控机内存到 8 GB+。 + +### 15.6.3 长时间运行后日志面板"刷不动" + +- 日志面板上限 500 条;超出后自动丢弃旧条目,属正常现象; +- 历史日志在文件中完整保留。 + +--- + +\newpage + +# 第 16 章 维护与日志 + +## 16.1 日志位置 + +| 类别 | 位置 | 说明 | +| ---------- | ----------------------------------------------------- | ---------------------------------------- | +| 应用日志 | `%LOCALAPPDATA%\SSPCTester\Logs\app-YYYYMMDD.log` | 按天滚动,自动保留最近 7 天 | +| UI 日志 | 主界面底部日志面板 | 最近 500 条;重启后清空 | +| 项目日志 | `Projects\{项目名}\project.json` 末尾的事件字段 | 仅记录关键事件 | + +> **【提示】** 报障时请同时附 `app-YYYYMMDD.log` 与对应项目目录。 + +## 16.2 项目数据备份 + +**何时备份** + +- 现场验收前后; +- 软件升级前; +- 月度归档。 + +**备份方法** + +将 `%LOCALAPPDATA%\SSPCTester\Projects\` 整个目录复制到外部归档存储(移动硬盘 / NAS / 归档服务器)。 + +**还原方法** + +将归档目录还原到目标工控机的同路径下,启动软件即可在首页列表中看到。 + +## 16.3 配置升级 + +### 16.3.1 升级 `appsettings.json` + +- 出厂默认配置升级一般跟随 `SSPCTester.UI.exe` 升级一起发布; +- 用户在设置页保存过的值不会被覆盖(位于 `%LOCALAPPDATA%`)。 + +### 16.3.2 升级 `device-profile.json` + +> **【注意】** 该文件直接决定 24 路通道与硬件的映射关系,必须由授权维护人员替换。 + +升级步骤: + +1. 对原文件取 SHA256 校验值并归档; +2. 停止 SSPCTester; +3. 将新文件替换到 `Config\device-profile.json`; +4. 启动 SSPCTester,确认日志中显示"profile 加载成功,schemaVersion 1.0,channels 24"; +5. 用 **基础测试 → 一键测试全部** 复核 24 路与现场实际配对正确。 + +## 16.4 软件升级流程 + +1. 下载新版本发布包(zip); +2. 备份 `%LOCALAPPDATA%\SSPCTester\` 整目录; +3. 退出 SSPCTester; +4. 将旧版发布目录改名(保留以便回滚); +5. 解压新版到原路径; +6. 启动 SSPCTester,检查版本号; +7. 在设置页确认参数; +8. 进行一次基础测试回归。 + +## 16.5 例行检查表 + +| 周期 | 检查项 | +| ---- | ------------------------------------------------------------ | +| 每日 | 接地、急停、电源、负载初始状态 | +| 每周 | 设置页 Mock 模式、版本号、磁盘剩余空间 | +| 每月 | `app-*.log` 中错误统计;归档项目目录 | +| 每季 | 采集卡通道标定复检(详见 6.6 节);接插件检查 | +| 每年 | 程控电源 / 电子负载送计量校准;操作员资格复审 | + +## 16.6 联系与支持 + +- 软件技术支持:SPC-DynaTest 项目组 +- 现场维护:由用户单位维修部门负责 +- 厂商接口:UDP5080-100、IT8702P、PCIe8586 厂商技术支持热线 + +--- + +\newpage + +# 附录 A 23 项指标完整定义表 + +> **说明**:本附录列出 SSPC 动态参数测试的 23 项标准指标。表格指明每项指标的定义、典型测试方法、判定准则,以及在本软件中的覆盖位置。"软件位置"列指向本手册中对应章节,"未实现"表示当前版本由人工评估。 + +| 编号 | 中文名 | 单位 | 定义 | 测试方法 | 判定准则 | 软件位置 | +| ---- | ------------------ | ---- | ----------------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------- | --------------- | +| 1.1 | 开启时间 | ms | 控制信号有效 → 输出电压上升到 90% Vmax 的时间 | 高速采集 + 上升沿百分位测试 | ≤ MaxOnTimeMs(默认 5) | 第 10 章 | +| 1.2 | 关闭时间 | ms | 控制信号撤销 → 输出电压下降到 10% Vmax 的时间 | 高速采集 + 下降沿百分位测试 | ≤ MaxOffTimeMs(默认 5) | 第 10 章 | +| 1.3 | 控制延迟时间 | ms | 控制端电平变化 → 内部驱动信号到达 | 厂商方法;本软件等同于"开启时间"近似 | 由型号规范确定 | 第 10 章(近似) | +| 1.4 | 释放延迟时间 | ms | 控制端撤销 → 内部驱动撤销 | 同上 | 由型号规范确定 | 第 10 章(近似) | +| 1.5 | 负载电压上升/下降时间 | ms | 负载侧电压 10% – 90% Vmax 的过渡时间 | 高速采集 + 双阈值测试 | ≤ MaxRiseTimeMs / MaxFallTimeMs(默认 3)| 第 10 章 | +| 1.6 | 输出电压超调量 | % | 开启后稳态值与瞬态峰值之差与稳态值之比 | 高速采集 + 峰值/稳态计算 | 由规范确定 | 未实现(人工评估)| +| 1.7 | 通态电阻 Ron | mΩ | 稳态导通时,输出电流为 I 时的等效串联电阻 = (Vin − Vout) / I | 功率损耗模块测得 ΔV / I | ≤ 规范值 | 第 11 章 | +| 1.8 | 通态压降 ΔV | V | 稳态导通时,输入端 − 输出端电压差 | 功率损耗模块直接测得 | ≤ 规范值 | 第 11 章 | +| 1.9 | 电压降 | V | 同 1.8 ΔV | 同上 | ≤ 规范值 | 第 11 章 | +| 1.10 | 功率损耗 Ploss | W | Pin − Pout | 功率损耗模块直接计算 | ≤ 规范值 | 第 11 章 | +| 1.11 | 待机功耗 | W | 控制信号 OFF、输出无电流时器件自身消耗 | 厂商方法 | 由规范确定 | 未实现(人工评估)| +| 1.12 | 控制功耗 | W | 控制端电源消耗 | 厂商方法 | 由规范确定 | 未实现(人工评估)| +| 1.13 | 效率 η | % | Pout / Pin × 100% | 功率损耗模块直接计算 | ≥ 规范值 | 第 11 章 | +| 1.14 | 跳闸时间 | ms | 过流条件持续后 → 输出电压降至 10% Vmax 的时间 | 故障注入 + 高速采集(演示) | ≤ 规范值 | 第 12 章(演示) | +| 1.15 | I²t 容量 | A²·s | 跳闸前允许的电流平方积分 | 厂商方法 | 由规范确定 | 未实现 | +| 1.16 | 过载能力 | ×Irated | 允许短时承受的过载倍数 | 厂商方法 | 由规范确定 | 未实现 | +| 1.17 | 短路保护 | — | 输出阻抗 ≤ 1 mΩ 条件下能否正常保护 | 故障注入(演示) | 保护动作,结果 = Pass | 第 12 章(演示) | +| 1.18 | 短路分断能力 | A | 短路保护时允许的最大电流 | 厂商方法 | 由规范确定 | 未实现 | +| 1.19 | 过温保护 | ℃ | 温度达到阈值后器件断开 | 故障注入 / 加热实验 | 保护动作,结果 = Pass | 第 12 章(演示) | +| 1.20 | 温升 | ℃ | 长期工作下结温与环温之差 | 厂商方法 | 由规范确定 | 未实现 | +| 1.21 | 过压保护 | V | Vin ≥ 阈值后器件断开 | 故障注入 | 保护动作 | 第 12 章(演示) | +| 1.22 | 欠压保护 | V | Vin ≤ 阈值后器件断开或拒绝导通 | 故障注入 | 保护动作 | 第 12 章(演示) | +| 1.23 | 限流保护 | A | I ≥ 阈值后器件限流或断开 | 故障注入 | 保护动作 | 第 12 章(演示) | + +> **【提示】** 编号 1.3 / 1.4 / 1.6 / 1.11 / 1.12 / 1.15 / 1.16 / 1.18 / 1.20 在当前软件版本中由人工评估;后续版本将逐步纳入自动测试。 + +\newpage + +# 附录 B Modbus 通信参数参考 + +## B.1 串口参数 + +| 项目 | 值 | +| ------------ | ----------------- | +| 协议 | Modbus-RTU | +| 波特率 | 9600 | +| 数据位 | 8 | +| 校验 | None | +| 停止位 | 1 | +| 读超时 | 500 ms | +| 重试次数 | 2 | +| CRC | CRC16-Modbus(低字节在前) | + +## B.2 24 路继电器映射 + +> 物理插位为业务唯一编号。从站地址、线圈号仅在协议层使用。 + +| 物理插位 | 从站 | 线圈 | 物理插位 | 从站 | 线圈 | +| -------- | ---- | ---- | -------- | ---- | ---- | +| 1 | 1 | 7 | 13 | 2 | 3 | +| 2 | 1 | 6 | 14 | 2 | 2 | +| 3 | 1 | 5 | 15 | 2 | 1 | +| 4 | 1 | 4 | 16 | 2 | 0 | +| 5 | 1 | 3 | 17 | 3 | 7 | +| 6 | 1 | 2 | 18 | 3 | 6 | +| 7 | 1 | 1 | 19 | 3 | 5 | +| 8 | 1 | 0 | 20 | 3 | 4 | +| 9 | 2 | 7 | 21 | 3 | 3 | +| 10 | 2 | 6 | 22 | 3 | 2 | +| 11 | 2 | 5 | 23 | 3 | 1 | +| 12 | 2 | 4 | 24 | 3 | 0 | + +**写继电器**(功能码 0x05) + +| 字段 | 值 | +| -------- | -------- | +| 功能码 | 0x05 | +| 开启值 | 0xFF00 | +| 关闭值 | 0x0000 | + +## B.3 电压采集寄存器偏移 + +> 电压采集从站固定为 `4`,功能码 `0x03`,起始寄存器 `0`,寄存器数 `24`,量程 `100.0` V,公式 `B`:实际值 = DATA / 100。 + +| 物理插位 | 偏移 | 物理插位 | 偏移 | 物理插位 | 偏移 | 物理插位 | 偏移 | +| -------- | ---- | -------- | ---- | -------- | ---- | -------- | ---- | +| 1 | 0 | 7 | 6 | 13 | 12 | 19 | 18 | +| 2 | 1 | 8 | 7 | 14 | 13 | 20 | 19 | +| 3 | 2 | 9 | 8 | 15 | 14 | 21 | 20 | +| 4 | 3 | 10 | 9 | 16 | 15 | 22 | 21 | +| 5 | 4 | 11 | 10 | 17 | 16 | 23 | 22 | +| 6 | 5 | 12 | 11 | 18 | 17 | 24 | 23 | + +## B.4 电流采集寄存器偏移 + +> 电流采集从站固定为 `5`,功能码 `0x03`,起始寄存器 `0`,寄存器数 `24`,量程 `60.0` A,公式 `A`:实际值 = DATA / 10000 × 60,有符号 (Int16 二进制补码)。 + +| 物理插位 | 偏移 | 物理插位 | 偏移 | +| -------- | ---- | -------- | ---- | +| 1 | 4 | 13 | 2 | +| 2 | 19 | 14 | 21 | +| 3 | 5 | 15 | 3 | +| 4 | 18 | 16 | 20 | +| 5 | 6 | 17 | 8 | +| 6 | 17 | 18 | 15 | +| 7 | 7 | 19 | 9 | +| 8 | 16 | 20 | 14 | +| 9 | 0 | 21 | 10 | +| 10 | 23 | 22 | 13 | +| 11 | 1 | 23 | 11 | +| 12 | 22 | 24 | 12 | + +## B.5 CRC16-Modbus 校验 + +| 项目 | 值 | +| -------- | ------------------------------- | +| 多项式 | 0xA001(反向 0x8005) | +| 初值 | 0xFFFF | +| 字节序 | 低字节在前 | + +## B.6 数据公式 + +| 公式标识 | 计算式 | 适用 | +| -------- | ------------------------------- | ------------------ | +| A | 实际值 = DATA / 10000 × range | 电流(双向量程) | +| B | 实际值 = DATA / range | 电压(单向量程) | + +\newpage + +# 附录 C PCIe8586 采集卡技术参数 + +## C.1 硬件规格 + +| 项目 | 规格 | +| ---------- | -------------------------- | +| 形态 | PCIe x4 | +| 操作系统 | Windows x64 | +| 通道数 | 8(可配置启用 1 / 2 / 4 / 8)| +| 采样率 | 基准 100 MHz,可分频 | +| 量程 | ±5 V 或 ±1 V(软件可选) | +| 原始数据 | 16 位有符号 / 无符号码值 | +| DMA 布局 | 多通道交错(CH0[0]、CH1[0]、CH0[1]、CH1[1]…)| +| 同步触发 | 软件触发;可选外部触发 | +| 厂商 DLL | `ACTS1000_64.dll` | + +## C.2 调用顺序(参考) + +``` +EnumerateDevices → Open → Configure → Start → SoftwareTrigger + → Read Loop → Stop → ReleaseAD → Close +``` + +## C.3 通道角色枚举 + +| Role | 中文 | 用途 | +| ---------------- | ---------- | ------------------------------------ | +| `OutputVoltage` | 输出电压 | 曲线测试电压源;功率损耗输入端电压来源 | +| `OutputCurrent` | 输出电流 | 曲线测试电流参考 | +| `InputVoltage` | 输入电压 | 备用 | +| `InputCurrent` | 输入电流 | 备用 | +| `Unconfigured` | 未配置 | 该通道不参与任何测试 | + +## C.4 采样率换算 + +$$ +\text{ActualSampleRateHz} = \frac{100\,000\,000}{\text{ClockDivider}} +$$ + +| ClockDivider | 实际采样率 | +| -----------: | ----------- | +| 1 | 100 MHz | +| 10 | 10 MHz | +| 100 | 1 MHz | +| **1000** | **100 kHz** | +| 10000 | 10 kHz | + +> **【提示】** 100 kHz 已能满足 SSPC 毫秒级开关瞬态采样需求;更高采样率会显著增加数据量。 + +## C.5 触发与采集窗口 + +| 字段 | 默认 | 说明 | +| ---------------- | ---- | ------------------------------------------ | +| `PreTriggerMs` | 10 | 触发前采样时长(用于观察控制信号到达前波形) | +| `PostTriggerMs` | 40 | 触发后采样时长(观察整个开/关跳变过程) | +| 总时长 | 50 | Pre + Post | + +\newpage + +# 附录 D 程控电源 UDP5080-100 接入参数 + +## D.1 默认 LAN 参数 + +| 项目 | 值 | +| -------- | --------------- | +| 协议 | TCP/IP SOCKET | +| IP | `192.168.6.5` | +| 端口 | `5025` | +| 子网 | `255.255.255.0` | +| 命令风格 | SCPI | + +## D.2 SCPI 命令示例 + +| 操作 | 命令 | +| ------------ | ----------------------------- | +| 身份查询 | `*IDN?` | +| 设置电压 | `VOLT 28.0` | +| 设置限流 | `CURR 5.0` | +| 输出开启 | `OUTP ON` | +| 输出关闭 | `OUTP OFF` | +| 读电压 | `MEAS:VOLT?` | +| 读电流 | `MEAS:CURR?` | + +> **【提示】** 实际接入由 SSPCTester 内部驱动封装,用户无需在 UI 中手工发送 SCPI。 + +## D.3 注意事项 + +- 主回路连接前务必将 OUTP 设为 OFF; +- 修改 IP 后请刷新 ARP 或重启网卡; +- 长时间不使用时关闭 OUTP,延长寿命。 + +\newpage + +# 附录 E 直流电子负载 IT8702P 接入参数 + +## E.1 默认 LAN 参数 + +| 项目 | 值 | +| -------- | ------------------- | +| 协议 | TCP/IP Socket | +| IP | `192.168.200.100` | +| 端口 | `30000` | +| 子网 | `255.255.255.0` | + +## E.2 工作模式 + +| 模式 | 含义 | 应用示例 | +| ---- | ---------- | --------------------------------- | +| CC | 恒流 | 设置 1.0 A,模拟典型负载(默认) | +| CV | 恒压 | 不常用 | +| CR | 恒阻 | 配合特殊故障演示 | +| CP | 恒功率 | 配合特殊故障演示 | + +## E.3 注意事项 + +- 接入主回路前确保输入关闭; +- CC 模式下电流设置应不超过被测 SSPC 通道额定电流; +- 长时间大功率回吸前确认散热风道无遮挡。 + +\newpage + +# 附录 F 术语表 + +| 术语 | 中文 / 英文 | 解释 | +| -------------- | ---------------------- | -------------------------------------------------------------------- | +| SSPC | Solid-State Power Controller | 固态功率控制器,本系统的被测对象 | +| 物理插位 | Physical Slot | 24 路 SSPC 通道的业务编号,1 – 24 | +| 模块地址 | Slave Address | Modbus 协议中的从站编号(1 / 2 / 3) | +| 线圈 | Coil | Modbus 中可写的离散输出,功能码 0x05 | +| 寄存器 | Register | Modbus 中可读的 16 位数据单元,功能码 0x03 | +| 寄存器偏移 | Register Offset | 在 24 寄存器回包中的零基位置(0 – 23) | +| CRC | Cyclic Redundancy Check | 循环冗余校验,本系统使用 CRC16-Modbus | +| Modbus-RTU | — | 工业串行通信协议,本系统 SSPC 控制板使用 | +| 跳脱 / 跳闸 | Trip | 过流保护动作 | +| I²t | — | 电流平方积分,过流保护熔断特征量 | +| 额定电流 | Rated Current | 器件规定条件下可长期承受的最大电流 | +| 上升时间 | Rise Time | 信号从 10% 到 90% 幅值的时间 | +| 下降时间 | Fall Time | 信号从 90% 到 10% 幅值的时间 | +| 电压降 | Voltage Drop | 输入端 − 输出端电压之差 | +| 功率损耗 | Power Loss | 输入功率 − 输出功率 | +| 效率 | Efficiency | 输出功率 / 输入功率 | +| DAQ | Data Acquisition | 数据采集,特指本系统的 PCIe8586 高速采集卡 | +| 触发 | Trigger | 采集卡开始记录数据的同步信号 | +| 浏览态 | Browsing Mode | 默认状态,可自由切换项目 | +| 测试态 | Testing Mode | 测试进行中,设备独占 | +| 综合判定 | Overall Status | 所有结果状态的最差值 | +| Mock | — | 模拟驱动,用于无硬件环境下的演练 | +| Profile | Device Profile | 设备描述文件,本系统指 `device-profile.json` | + +\newpage + +# 附录 G 配置文件样本 + +## G.1 `appsettings.json`(节选) + +```json +{ + "Devices": { + "MockMode": false, + "Sspc": { + "UseMock": false, + "AutoConnect": true, + "PortName": "COM1", + "BaudRate": 9600, + "DataBits": 8, + "Parity": "None", + "StopBits": "One", + "ReadTimeoutMs": 500, + "Retry": 2, + "DeviceProfilePath": "Config/device-profile.json", + "CloseAllRelaysOnDisconnect": true, + "LogRawFrames": true, + "ModuleAddresses": [ 1, 2, 3 ], + "ChannelsPerModule": 8 + }, + "PowerSupply": { + "UseMock": false, + "AutoConnect": true, + "IpAddress": "192.168.6.5", + "Port": 5025 + }, + "Load": { + "UseMock": false, + "AutoConnect": true, + "IpAddress": "192.168.200.100", + "Port": 30000 + }, + "Daq": { + "UseMock": false, + "AutoConnect": true, + "LogicalDeviceId": 0, + "ChannelCount": 4, + "InputRange": "PlusMinus5V", + "ClockDivider": 1000, + "PreTriggerMs": 10, + "PostTriggerMs": 40, + "Channels": [ + { "PhysicalChannel": 0, "Role": "OutputVoltage", "Name": "输出电压", "Scale": 1.0, "Offset": 0.0, "IsCalibrated": true }, + { "PhysicalChannel": 1, "Role": "OutputCurrent", "Name": "输出电流", "Scale": 1.0, "Offset": 0.0, "IsCalibrated": true }, + { "PhysicalChannel": 2, "Role": "InputVoltage", "Name": "输入电压", "Scale": 1.0, "Offset": 0.0, "IsCalibrated": true }, + { "PhysicalChannel": 3, "Role": "InputCurrent", "Name": "输入电流", "Scale": 1.0, "Offset": 0.0, "IsCalibrated": true } + ] + } + }, + "Storage": { + "ProjectsRoot": "%LOCALAPPDATA%\\SSPCTester\\Projects" + }, + "Report": { + "SavePath": "%LOCALAPPDATA%\\SSPCTester\\Reports", + "Format": "Pdf" + } +} +``` + +## G.2 `device-profile.json`(简化样例,仅前 4 路) + +```json +{ + "schemaVersion": "1.0", + "profileId": "spc-dynatest-modbus-24ch", + "serialDefaults": { + "baudRate": 9600, "dataBits": 8, "parity": "None", + "stopBits": 1, "readTimeoutMs": 500, "retry": 2, + "protocol": "ModbusRTU" + }, + "frame": { + "registerBytes": 2, "dataByteOrder": "BigEndian", + "crc": "CRC16Modbus", "crcByteOrder": "LittleEndian" + }, + "relay": { + "functionCodeWrite": 5, + "onValue": "0xFF00", "offValue": "0x0000" + }, + "voltage": { + "slave": 4, "functionCodeRead": 3, + "startRegister": 0, "registerCount": 24, + "range": 100.0, "unit": "V", + "formula": "B", "signed": false + }, + "current": { + "slave": 5, "functionCodeRead": 3, + "startRegister": 0, "registerCount": 24, + "range": 60.0, "unit": "A", + "formula": "A", "signed": true + }, + "channels": [ + { "physicalSlot": 1, "relay": { "slave": 1, "coil": 7 }, + "voltage": { "registerOffset": 0 }, "current": { "registerOffset": 4 } }, + { "physicalSlot": 2, "relay": { "slave": 1, "coil": 6 }, + "voltage": { "registerOffset": 1 }, "current": { "registerOffset": 19 } }, + { "physicalSlot": 3, "relay": { "slave": 1, "coil": 5 }, + "voltage": { "registerOffset": 2 }, "current": { "registerOffset": 5 } }, + { "physicalSlot": 4, "relay": { "slave": 1, "coil": 4 }, + "voltage": { "registerOffset": 3 }, "current": { "registerOffset": 18 } } + // …其余 20 行省略 + ] +} +``` + +\newpage + +# 附录 H 文件目录与默认路径速查 + +| 类型 | 路径 | +| ---------------- | ------------------------------------------------------------- | +| 主程序 | `<安装目录>\SSPCTester.UI.exe` | +| 出厂配置 | `<安装目录>\appsettings.json` | +| Modbus 映射 | `<安装目录>\Config\device-profile.json` | +| 用户设置 | `%LOCALAPPDATA%\SSPCTester\settings.json` | +| 项目数据 | `%LOCALAPPDATA%\SSPCTester\Projects\` | +| 报告输出 | `%LOCALAPPDATA%\SSPCTester\Reports\` | +| 应用日志 | `%LOCALAPPDATA%\SSPCTester\Logs\app-YYYYMMDD.log` | +| 单项目目录 | `Projects\{项目名}\` | +| 单项目元数据 | `Projects\{项目名}\project.json` | +| 单项目波形 | `Projects\{项目名}\curves\CH{nn}_{on|off}_{时间戳}.{bin|json}` | +| 单项目报告 | `Projects\{项目名}\report.pdf` | + +`<安装目录>` 推荐 `C:\SSPCTester\`。`%LOCALAPPDATA%` 通常为 `C:\Users\<用户名>\AppData\Local`。 + +\newpage + +# 附录 I 修订记录 + +| 版本 | 日期 | 修订内容 | 修订人 | 审核 / 批准 | +| ----- | ---------- | ----------------- | -------- | ----------- | +| V1.0 | 2026-06-25 | 首次正式发布 | | | +| | | | | | +| | | | | | + +--- + +**— 文档结束 —** + diff --git a/Driver/IT8702P/IT8700&IT8700P&IT8700Pplus Programming Guide-CN.pdf b/Driver/IT8702P/IT8700&IT8700P&IT8700Pplus Programming Guide-CN.pdf new file mode 100644 index 0000000..6a4c816 Binary files /dev/null and b/Driver/IT8702P/IT8700&IT8700P&IT8700Pplus Programming Guide-CN.pdf differ diff --git a/Driver/IT8702P/IT8702P_Driver_Integration_Guide.md b/Driver/IT8702P/IT8702P_Driver_Integration_Guide.md new file mode 100644 index 0000000..8e36978 --- /dev/null +++ b/Driver/IT8702P/IT8702P_Driver_Integration_Guide.md @@ -0,0 +1,373 @@ +# IT8702P 电子负载驱动接入文档(C# / WPF / .NET 8) + +> 本文档供 AI 开发助手作为实现依据使用。目标:在 C# + WPF + .NET 8 主项目中, +> 通过 LAN Socket 接入 ITECH IT8702P 电子负载,采集**电压 / 电流 / 功率**三项数据, +> 既能实时绑定到界面显示,也能由后台连续记录。 +> +> **AI 开发约束**:严格遵循本文协议与命令格式。不要臆造未在本文出现的 SCPI 命令; +> 命令一律以 `\n` 结尾;查询命令必须读完整行响应后再发下一条;设置类命令前必须已发送 `SYST:REM`。 + +--- + +## 1. 通讯概览 + +| 项目 | 值 | +|------|-----| +| 物理接口 | LAN(以太网) | +| 传输协议 | 标准 TCP(raw socket / SCPI-RAW),与普通 socket 编程完全一致 | +| 默认 IP | `192.168.200.100`(以设备实际配置为准,需可在设置中修改) | +| 端口 | `30000` | +| 命令语言 | SCPI(ASCII 文本,大小写不敏感) | +| 命令结束符 | `\n`(LF,0x0A) | +| 响应结束符 | `\n`(按行读取) | +| 编码 | ASCII | +| 通道 | 主机带多负载模块;默认操作 `CH1`,可切换(`CHANnel <1-8>`) | + +要点: + +- 不需要 VISA、不需要厂商驱动 / SDK,`System.Net.Sockets.TcpClient` 直接连接即可。 +- **同步请求-应答模型**:每条查询命令发出后必须读回一行响应,才能发下一条;否则设备会报 `Query Interrupted`,且数据丢失。 +- 设备内部一次测量约几 ms 到十几 ms,单点轮询实际刷新率为每秒数十次量级,**不适合高速波形采集**(高速场景由独立采集卡负责,不在本驱动范围内)。 + +--- + +## 2. SCPI 命令清单(仅本项目所需) + +### 2.1 连接与会话 + +| 命令 | 类型 | 说明 | +|------|------|------| +| `*IDN?` | 查询 | 返回厂商/型号/序列号/固件版本,逗号分隔。用于连接自检 | +| `SYST:REM` | 设置 | 进入远程模式。**任何设置类命令前必须先发**。只读测量不强制,但建议连接后即发 | +| `SYST:LOC` | 设置 | 返回本地模式(前面板控制)。断开会话时可选发送 | +| `SYST:ERR?` | 查询 | 读取错误队列下一条,格式 `,`,如 `0,"No Error"`。无错时返回 `0,No Error` | +| `*CLS` | 设置 | 清除状态/错误队列 | + +### 2.2 通道选择(多模块寻址) + +| 命令 | 类型 | 说明 | +|------|------|------| +| `CHAN ` | 设置 | 选择当前操作通道,`n` 取 1–8。默认 `CHAN 1`。后续命令作用于该通道 | +| `CHAN?` | 查询 | 返回当前选中通道号 `` | +| `CHAN:ID?` | 查询 | 返回当前通道模块的型号/序列号/固件,逗号分隔 | + +> 单通道使用时,连接后发一次 `CHAN 1` 即可;切换通道时重发 `CHAN `。 + +### 2.3 测量(核心:电压 / 电流 / 功率) + +| 命令 | 类型 | 返回 | 说明 | +|------|------|------|------| +| `MEAS:VOLT?` | 查询 | `` | 触发一次新测量并返回电压(V)。较慢 | +| `MEAS:CURR?` | 查询 | `` | 触发一次新测量并返回电流(A) | +| `MEAS:POW?` | 查询 | `` | 触发一次新测量并返回功率(W) | +| `FETC:VOLT?` | 查询 | `` | 取最近一次采样的电压,不重新测量。较快 | +| `FETC:CURR?` | 查询 | `` | 取最近采样电流 | +| `FETC:POW?` | 查询 | `` | 取最近采样功率 | + +返回值为 ASCII 科学计数字符串,如 `2.971700E+00`,用 `double.Parse(s, CultureInfo.InvariantCulture)` 解析。 + +> **`MEAS` vs `FETC`**:`MEAS` 每次强制重新测量,数值最新但慢;`FETC` 取设备已有采样,快但可能略滞后。连续轮询场景推荐 `FETC` 以提升刷新率。 + +### 2.4 合并查询(一次往返取三个值,强烈推荐) + +SCPI 允许用分号在一条消息里串多个查询,**一次往返**拿回多值,往返次数从 3 次降到 1 次: + +```text +MEAS:VOLT?;:MEAS:CURR?;:MEAS:POW? +``` + +- 第二条及之后每条查询前加 `:`,表示回到命令根路径(否则会拼接出错误路径)。 +- 响应为分号分隔的一行,如 `2.971700E+00;1.040000E+00;3.090000E+00`,按 `;` 拆分解析。 +- `FETC` 同理可合并:`FETC:VOLT?;:FETC:CURR?;:FETC:POW?` + +--- + +## 3. 标准交互流程 + +```text +[连接] + TcpClient.Connect(ip, 30000) + 设置 TcpClient.NoDelay = true // 关闭 Nagle,消除小包延迟 + 发送 *IDN? → 读回一行,校验包含 "IT87" 字样,确认设备正确 + 发送 SYST:REM + 发送 CHAN 1 +[采集循环](按设定周期,如每 50~200ms 一次) + 发送 FETC:VOLT?;:FETC:CURR?;:FETC:POW? + 读回一行 → 按 ';' 拆分 → 解析为 (V, I, P) + 推送给 UI(绑定)与 后台记录器(队列) +[断开] + 发送 SYST:LOC(可选) + 关闭 socket +``` + +错误处理约定: + +- 每条查询发送后若在超时内(建议 1–3 s)未读到完整行 → 视为通讯异常,触发重连流程。 +- 周期性(或异常后)发送 `SYST:ERR?` 检查设备侧错误队列,非 `0,No Error` 则记录日志。 +- 读响应以 `\n` 为行边界;TCP 可能分包,需循环 `Read` 直到读到 `\n`。 + +--- + +## 4. C# 实现指引(.NET 8) + +### 4.1 分层结构建议 + +``` +Driver 层 It8702pClient —— 纯通讯:连接、收发、按行读取、命令封装 +采集层 AcquisitionService —— 后台采集循环(Task + PeriodicTimer),产出读数 +分发层 读数 → ① UI 绑定(INotifyPropertyChanged,Dispatcher 回主线程) + → ② 记录器(Channel 写入文件/数据库,独立消费者) +ViewModel 层 绑定 Voltage / Current / Power 与 IsConnected 等状态 +``` + +设计要点(对应"实时绑定 + 后台记录两者都要"): + +- **采集只跑一遍**,结果同时分发给 UI 和记录器,避免对设备发起两套独立轮询(同步协议下并发查询会互相打断)。 +- UI 更新必须切回 UI 线程:`Application.Current.Dispatcher.Invoke(...)` 或在采集 Task 中用 `IProgress`。 +- 后台记录用 `System.Threading.Channels.Channel`:采集线程只管入队(非阻塞),单独的写盘消费者出队,互不阻塞,避免磁盘 IO 拖慢采集节奏。 +- 所有 socket 收发集中在 Driver 层,**全程串行**(同一时刻只有一条命令在途)。如有多处调用,用 `SemaphoreSlim(1,1)` 串行化,杜绝 `Query Interrupted`。 + +### 4.2 数据模型 + +```csharp +public readonly record struct Reading( + DateTime TimestampUtc, + int Channel, + double Voltage, // V + double Current, // A + double Power); // W +``` + +### 4.3 Driver 层参考实现 + +```csharp +using System.Globalization; +using System.Net.Sockets; +using System.Text; + +public sealed class It8702pClient : IDisposable +{ + private readonly SemaphoreSlim _gate = new(1, 1); + private TcpClient? _tcp; + private NetworkStream? _stream; + + public bool IsConnected => _tcp?.Connected ?? false; + + public async Task ConnectAsync(string ip, int port = 30000, int channel = 1, + CancellationToken ct = default) + { + _tcp = new TcpClient { NoDelay = true }; // 关闭 Nagle + await _tcp.ConnectAsync(ip, port, ct); + _stream = _tcp.GetStream(); + _stream.ReadTimeout = 3000; + _stream.WriteTimeout = 3000; + + var idn = await QueryAsync("*IDN?", ct); + if (!idn.Contains("IT87", StringComparison.OrdinalIgnoreCase)) + throw new InvalidOperationException($"意外的设备标识: {idn}"); + + await SendAsync("SYST:REM", ct); // 进入远程模式 + await SendAsync($"CHAN {channel}", ct); // 选择通道 + } + + /// 一次往返采集 V/I/P。 + public async Task<(double V, double I, double P)> ReadVipAsync(CancellationToken ct = default) + { + // FETC 较快;如需每次强制重测可换成 MEAS + var resp = await QueryAsync("FETC:VOLT?;:FETC:CURR?;:FETC:POW?", ct); + var parts = resp.Split(';', StringSplitOptions.TrimEntries); + if (parts.Length < 3) + throw new FormatException($"响应格式异常: {resp}"); + return (ParseNum(parts[0]), ParseNum(parts[1]), ParseNum(parts[2])); + } + + public Task SelectChannelAsync(int channel, CancellationToken ct = default) + => SendAsync($"CHAN {channel}", ct); + + public async Task ReadErrorAsync(CancellationToken ct = default) + => await QueryAsync("SYST:ERR?", ct); + + // ---- 底层收发(全程串行)---- + + private async Task SendAsync(string cmd, CancellationToken ct) + { + await _gate.WaitAsync(ct); + try { await WriteLineAsync(cmd, ct); } + finally { _gate.Release(); } + } + + private async Task QueryAsync(string cmd, CancellationToken ct) + { + await _gate.WaitAsync(ct); + try + { + await WriteLineAsync(cmd, ct); + return await ReadLineAsync(ct); + } + finally { _gate.Release(); } + } + + private async Task WriteLineAsync(string cmd, CancellationToken ct) + { + var bytes = Encoding.ASCII.GetBytes(cmd + "\n"); + await _stream!.WriteAsync(bytes, ct); + } + + // TCP 可能分包,循环读到 '\n' 为止 + private async Task ReadLineAsync(CancellationToken ct) + { + var sb = new StringBuilder(); + var buf = new byte[1]; + while (true) + { + int n = await _stream!.ReadAsync(buf, ct); + if (n == 0) throw new IOException("连接已关闭"); + char c = (char)buf[0]; + if (c == '\n') break; + if (c != '\r') sb.Append(c); + } + return sb.ToString().Trim(); + } + + private static double ParseNum(string s) + => double.Parse(s, NumberStyles.Float, CultureInfo.InvariantCulture); + + public void Dispose() + { + try { _stream?.Dispose(); _tcp?.Dispose(); } catch { /* 忽略 */ } + _gate.Dispose(); + } +} +``` + +### 4.4 采集服务参考实现 + +```csharp +using System.Threading.Channels; + +public sealed class AcquisitionService : IAsyncDisposable +{ + private readonly It8702pClient _client; + private readonly Channel _record = Channel.CreateUnbounded(); + private CancellationTokenSource? _cts; + private Task? _loop; + + public AcquisitionService(It8702pClient client) => _client = client; + + /// 供后台记录器消费的读数流。 + public ChannelReader Records => _record.Reader; + + /// UI 通过此回调实时获取读数(在 ViewModel 中切回 UI 线程)。 + public event Action? ReadingReceived; + + public void Start(int channel, TimeSpan period) + { + _cts = new CancellationTokenSource(); + _loop = RunAsync(channel, period, _cts.Token); + } + + private async Task RunAsync(int channel, TimeSpan period, CancellationToken ct) + { + using var timer = new PeriodicTimer(period); + while (await timer.WaitForNextTickAsync(ct)) + { + try + { + var (v, i, p) = await _client.ReadVipAsync(ct); + var reading = new Reading(DateTime.UtcNow, channel, v, i, p); + + ReadingReceived?.Invoke(reading); // → UI + _record.Writer.TryWrite(reading); // → 记录器(非阻塞入队) + } + catch (OperationCanceledException) { break; } + catch (Exception ex) + { + // TODO: 记录日志 / 触发重连 + System.Diagnostics.Debug.WriteLine($"采集异常: {ex.Message}"); + } + } + } + + public async ValueTask DisposeAsync() + { + _cts?.Cancel(); + if (_loop is not null) + try { await _loop; } catch { /* 忽略 */ } + _record.Writer.TryComplete(); + _cts?.Dispose(); + } +} +``` + +### 4.5 ViewModel 绑定要点 + +```csharp +public sealed class MainViewModel : INotifyPropertyChanged +{ + private double _voltage, _current, _power; + public double Voltage { get => _voltage; private set => Set(ref _voltage, value); } + public double Current { get => _current; private set => Set(ref _current, value); } + public double Power { get => _power; private set => Set(ref _power, value); } + + // 订阅 AcquisitionService.ReadingReceived,并切回 UI 线程: + private void OnReading(Reading r) => + Application.Current.Dispatcher.Invoke(() => + { + Voltage = r.Voltage; + Current = r.Current; + Power = r.Power; + }); + + // ... INotifyPropertyChanged / Set 实现略 + public event PropertyChangedEventHandler? PropertyChanged; + private void Set(ref T field, T value, [System.Runtime.CompilerServices.CallerMemberName] string? name = null) + { field = value; PropertyChanged?.Invoke(this, new(name)); } +} +``` + +后台记录消费者(独立运行,写文件/数据库): + +```csharp +await foreach (var r in acquisition.Records.ReadAllAsync(ct)) +{ + // 写 CSV / SQLite / 其他。IO 慢也不会阻塞采集循环 + await writer.WriteLineAsync( + $"{r.TimestampUtc:O},{r.Channel},{r.Voltage},{r.Current},{r.Power}"); +} +``` + +--- + +## 5. 配置项(建议放入主项目设置) + +| 配置 | 默认值 | 说明 | +|------|--------|------| +| `Ip` | `192.168.200.100` | 设备 IP,可改 | +| `Port` | `30000` | 固定,一般不改 | +| `Channel` | `1` | 操作通道,可切换 1–8 | +| `PeriodMs` | `100` | 采集周期(毫秒)。过小无意义,受设备测量速度限制 | +| `UseFetch` | `true` | `true` 用 `FETC`(快),`false` 用 `MEAS`(每次重测) | +| `TimeoutMs` | `3000` | 收发超时 | + +--- + +## 6. 易错点检查清单(AI 实现时务必核对) + +- [ ] 每条命令结尾加 `\n`。 +- [ ] 设置类命令前已发送 `SYST:REM`。 +- [ ] 查询发出后**读完整行响应再发下一条**;所有收发经 `SemaphoreSlim` 串行化。 +- [ ] 合并查询时第二条起每条前加 `:`(回根路径)。 +- [ ] 数字解析用 `CultureInfo.InvariantCulture`(避免逗号小数点区域问题)。 +- [ ] 读响应循环到 `\n`,处理 TCP 分包。 +- [ ] `TcpClient.NoDelay = true`。 +- [ ] UI 更新切回 Dispatcher 线程。 +- [ ] 采集只一套循环,结果分发给 UI 与记录器,不开两套独立轮询。 +- [ ] 不要在本驱动里追求高速波形——高速由独立采集卡负责。 + +--- + +## 7. 范围说明 + +本驱动只覆盖**连接、通道选择、V/I/P 采集**及配套的错误读取。 +若后续需要控制负载(CC/CV/CR/CW 设置、输入开关、保护读取、List/动态测试等), +另需扩展命令集,不在本文档范围内。高速暂态波形采集由独立采集卡完成,与本驱动并行运行、互不干扰。 diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/entries b/Driver/UDP5080-100/UNI-T SDK/.svn/entries new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/entries @@ -0,0 +1 @@ +12 diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/format b/Driver/UDP5080-100/UNI-T SDK/.svn/format new file mode 100644 index 0000000..48082f7 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/format @@ -0,0 +1 @@ +12 diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/01/01849e18e86fe7c3b3087c3f870ec16b52091b0a.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/01/01849e18e86fe7c3b3087c3f870ec16b52091b0a.svn-base new file mode 100644 index 0000000..5ff2d53 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/01/01849e18e86fe7c3b3087c3f870ec16b52091b0a.svn-base @@ -0,0 +1,1966 @@ + + + + ucics + + + + + 物理单位信息 + + + + + 单位类型,比如Time、Freq等。具体定义见文档。 + + + + + 量级,比如k、n,p,M等。具体定义见文档。 + + + + + 物理单位量级 + + + + + + + + + + / + + + + + + + + + + + + + + + 标准单位 + + + + + K + + + + + + + + + + + + + + + + + + + + 物理单位类型 + + + + + 无效的类型 + + + + + 频率(Hz) + + + + + 时间(s) + + + + + 面积(Vs) + + + + + 采样率(Sa/s) + + + + + 点数(Sa) + + + + + 峰峰值(V) + + + + + 电压 + + + + + 电流(A) + + + + + db(dB) + + + + + VV (VV) + + + + + 百分比(%) + + + + + 度数(°) + + + + + 瓦特,功率(W) + + + + + 未知单位(U) + + + + + 物理量数值 + + + 4Byte align -> 8Bytes, + 所有示波器都通过指令"mea:all?;"读取参数测量数据。 + 读取到的就是 MeaValue v[50] (固定长度), + 各参数的位置索引由定义。 + + + + + 测量值 + + + + + 物理单位 + + + + + 是否有效。 0 表示无效; 1表示有效。 + + + + + 是否存在。 0 表示存在; 1表示不存在。 + + + + + 参数测量数据包的通用定义。 + + + + + 最大值 + + + + + 最小值 + + + + + High(Top)-高电平(顶端值) + + + + + Middle-中间值 + + + + + Low(Bottom) - 低电平(底端值) + + + + + VPP-峰峰值 + + + + + 幅度值 + + + + + 平均值 + + + + + 周期平均值 + + + + + 均方根 + + + + + 周期均方值 + + + + + 面积 + + + + + 周期面积 + + + + + 过冲 + + + + + 预冲 + + + + + 周期 + + + + + 频率 + + + + + 上升时间 + + + + + 下降时间 + + + + + 正脉宽 + + + + + 负脉宽 + + + + + 正占空比 + + + + + 负占空比 + + + + + 上升延时 + + + + + 下升延时 + + + + + 相位 + + + + + FRR + + + + + FRF + + + + + FFR + + + + + FFF + + + + + LRF + + + + + LRR + + + + + LFR + + + + + LFF + + + + + 突发脉冲 + + + + + 固定位50个参数 + + + + + b0 : SYNC; b1 : channel(CH1); b2 : Trigger + + + + + SYNC Key + + + + + Channel Key + + + + + Trigger Key + + + + + 模拟C/C++的堆内存的操作:申请、释放、转换 + + + + + 创建指定大小(bytes)的非托管内存空间 + + + + + + 创建基于所给字节数组的非托管内存空间。默认数据会被拷贝到非托管内存空间。 + + 托管字节数组 + + + + 创建基于所给整形数据的非托管内存空间。默认数据会被拷贝到非托管内存空间。 + + 托管整形数组 + 起始拷贝位置 needCopy = true 时有效 + 拷贝数量 + + + + allocate storage for count elements of type ty + + + + + + + 创建基于所给对象数据的非托管内存空间 + + 托管对象数据 + true : 拷贝托管字节数组的数据到非托管内存空间; false : 不拷贝 + + + + 提供Pointer到IntPtr的运算符。 + + Pointer类型对象 + IntPtr + + + + 析构器 + + + + + 将内存数据转换所给的结构体类型数据。 + + 要转换的结构体 + 要转换的结构体 + + + + 指向非托管内存的指针 + + + + + 非托管内存空间的地址 + + + + + 非托管内存空间的大小(bytes) + + + + + 通信方式 + + + + + USB通信 + + + + + LAN通信 + + + + + 串口通信 + + + + + 信号源的通道号 + + + + + 通道1的编号 + + + + + 通道2的编号 + + + + + 代表所有通道的编号 + + + + + 非通道编号 + + + + + 开关状态,占用1个字节。 + + + + + 关闭状态 + + + + + 打开状态 + + + + + UCI所有接口返回的错误状态编码。如果接口返回小于0,则可以从本定义中找到对应的解释。 + + + + + 没有任何错误 + + + + + 错误(基础编码,所有错误码都在这个编码基础上定义) + + + + + 资源初始化错误 + + + + + 无效的会话 + + + + + 操作超时 + + + + + 操作失败 + + + + + 不支持的操作 + + + + + 内存空间不足 + + + + + 系统繁忙,无法响应 + + + + + 通信异常,不可逆! + + + + + 未知的错误 + + + + + 建立连接的字符串地址格式错误 + + + + + 连接还未建立 + + + + + 连接已断开 + + + + + 不支持的通信方式 + + + + + 未发现指定的设备 + + + + + 不支持的设备 + + + + + 需要先执行查询设备的操作 + + + + + 查询网络设备失败 + + + + + USB设备地址只在执行查询设备操作后才有效, + + + 从UCI库导出的USB设备地址,只是一个列表索引,不是真正的设备地址。 + + + + + 未发现U盘接入 + + + + + 按键已经锁定 + + + + + 命令格式错误 + + + + + 只支持单条命令 + + + + + 一条命令只支持一个属性 + + + + + 不支持的命令 + + + + + 发送命令失败 + + + + + 协议数据格式错误 + + + + + 设备端写文件到flash失败! + + + + + 未发现有效数据 + + + + + 命令消息错误,请命令参数是否符合协议 + + + + + 无效的表达式 + + + + + 参数错误 + + + + + 参数提供的空间太小 + + + + + 所提供的文件名太长(最长50个字节) + + + + + 参数所给的数据大小与协议不匹配(防止数据错误) + + + + + 数字溢出 + + + + + 超出范围 + + + + + 数据未全部读取完 + + + + + 数据校验失败 + + + + + 无效的数据 + + + + + 数据压缩失败 + + + + + 数据解压缩失败 + + + + + 数据传输失败 + + + + + 数据传输失败 + + + + + 拒绝访问 + + + + + An unspecified error occurred. + + + + + The file could not be located. + + + + + All or part of the path is invalid + + + + + The permitted number of open files was exceeded. + + + + + There was an attempt to use an invalid file handle + + + + + The current working directory cannot be removed + + + + + There are no more directory entries + + + + + There was an error trying to set the file pointer + + + + + There was a hardware error + + + + + SHARE.EXE was not loaded, or a shared region was locked + + + + + There was an attempt to lock a region that was already locked + + + + + The disk is full + + + + + The end of file was reached + + + + + 写文件到磁盘失败 + + + + + 信号源任意波下载方式 + + + + + 以载波方式加载 + + + + + 以调制波方式加载 + + + + + 将ARB文件写到Flash. + + + + + UCI读接口用的读参数。 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 返回的数据量数据,具体意义视具体命令而定; + + + + + 读超时 + + + + + 附加数据,大多数情况下是不需要的,可设置为IntPtr.Zero. + + + + + 附加数据大小 + + + + + UCI写接口的写参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 返回的数据量数据,具体意义视具体命令而定; + + + + + 超时 + + + + + 接口SendCommand使用的参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 命令参数1 + + + + + 命令参数2 + + + + + 超时 + + + + + 写任意波文件的参数 + + + + + 通道号,一般CH1=0,依次类推 + + + + + 任意波(ARB)加载方式 + + + + + 写文件的参数,2个Bytes.(模拟C中的联合体) + + + + + 预留的数据段 + + + + + 任意波(ARB)文件参数 + + + + + 接口WriteFromFile的接口参数。 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 文件路径 + + + + + 要写入的文件长度(=0表示全部写入) + + + + + 接口ReadToFile使用的参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 文件路径 + + + + + 要写入的文件长度(=0表示全部写入) + + + + + 最终输出文件的路径 + + + + + 设备按键LED状态数据 + + + + + Noise按键LED开关状态 + + + + + UTILTY按键LED开关状态 + + + + + STORGE按键LED开关状态 + + + + + RAMP按键LED开关状态 + + + + + PULSE按键LED开关状态 + + + + + COUNTER按键LED开关状态 + + + + + USER按键LED开关状态 + + + + + DIGTAL按键LED开关状态 + + + + + HARMONIC按键LED开关状态 + + + + + DC按键LED开关状态 + + + + + TRGGER按键LED开关状态 + + + + + CH2按键LED开关状态 + + + + + SWAPCH按键LED开关状态 + + + + + ARB按键LED开关状态 + + + + + CH1按键LED开关状态 + + + + + SINE按键LED开关状态 + + + + + SQUARE按键LED开关状态 + + + + + 通信节点类型 + + + 在QParams中是按位与,在Node中取的是enum值。 + + + + + 网络设备类型 + + + + + USB设备类型 + + + + + USB设备的描述符 + + + + + PID + + + + + VID + + + + + 地址 + + + + + 4字段数据类型 + + + + + 字段1 + + + + + 字段2 + + + + + 字段3 + + + + + 字段4 + + + + + IP地址 + + + 填充顺序为 f1(192).f2(168).f3(1).f4(253) - 小端模式 + + + + + 分字段存取 + + + + + 32为整数表示的IP地址 + + + + + LAN口通信的设备描述符 + + + + + IP地址(字符串类型) + + + + + IP地址 + + + + + 网络端口(TCPIP连接用的端口号) + + + + + 查询到的设备节点的参数 + + + + + 通信接口方式 + + + + + 设备名 + + + + + 设备类型( 信号源 = SG, 示波器 = DSO, UPO = UPO;) + + + + + LAN口参数 + + + + + USB接口参数 + + + + + 连接字符串 + + + + + 序列号 + + + + + 设备状态 + + + + + 设备显示名称 + + + + + 串口描述 + + + + + 友好名称 + + + + + 端口号 + + + + + 查询参数 + + + + + 要查询的节点类型,按位与,数据取自QueryNodeType定义 + eg: QueryNodeType.USB | QueryNodeType.LAN + + + + + Ports的长度 + + + + + 端口集,指向int类型; + + + + + PVID数据的长度 + + + + + 存放PID和VID信息的指向INT类型的缓冲区地址, + int 类型对应的格式 :PID(高16bit) + VID(低16bit) + + + + + 查询字符串,nullptr时表示查询所有设备,否则查询指定设备名的设备。 + + + + + UCI使用的消息类型 + + + + + 与设备建立的连接已经断开 + + + 目前只支持LAN口访问的连接的侦测 + wParams LAN : 端口号(十进制); + Reserved LAN : IP 地址 + + + + + 文件传输消息 + + + wParams 总帧数; + lParams 帧计数; -1 : 开始传输; [0,wParams)传输中, 等于wParams传输结束-> + UCIMSGProc return -1 : 表示中断传输. + + + + + USB插拔消息 + + + wParams : 使用低16位,其中,高8位为pid,低8位为vid; + lParams : 事件类型, 移除 = 0, 插入 = 1; + Reserved : USB插入移除事件的设备的设备名 + + + + + USB设备事件 + + + + + USB 设备移除事件 + + + + + USB 设备接入事件 + + + + + UCI 消息数据 + + + + + 发送消息的会话ID + + + + + UCI消息,按EUCIMSG解析 + + + + + 消息参数,每个消息的使用意义不一样 + + + + + 消息参数,每个消息的使用意义不一样 + + + + + 保留字段,每个消息的使用意义不一样 + + + + + 带单位的数值 + + + + + 数值 + + + + + 单位量级 + + + + + 带单位的数值 + + + + + 数值 + + + + + 单位量级 + + + + + 万用表和毫伏表数据帧 + + + + + 主显字符串(20个字符) + + + + + 副显字符串或(20个字符) + + + + + 主显数值(8Bytes) + + + + + 副显数值(8Bytes) + + + + + 标记位(8Bytes) + + + + + UCI会话(与设备建立会话) + 本接口是的面向对象封装版本。 + 会在UCISession对象释放时自动关闭会话,并做所有资源清理,且提供若干 + 实用接口。 + + + + + 构造器 + + + + + 析构器 + + + + + 打开设备,建立会话。 + + 设备地址。可以通过查询接口获取,也可以通过查看文档获取。 + 超时。在该时间内指令未完成,就返回超时错误! + + 查看说明。 + + + + + 关闭会话 + + + + + 获取错误描述信息。 + + + 通过该接口获取错误码对应的错误描述信息, 错误码可以查看。 + 所有错误码都是小于0的整数。 + + + + + 写数据 + + 指令字符串 + + 要写到设备的字节流数据,如果是内置类型(如int等), + 可以使用BitConverter.GetBytes转换 + + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据 + + 指令字符串 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(short类型),是的封装版本 + + 指令字符串 + short 类型数据 + 超时 + + 查看说明。 + + + + + 写数据(double类型),是的封装版本 + + 指令字符串 + double 类型数据 + 超时 + + 查看说明。 + + + + + 写数据(int类型),是的封装版本 + + 指令字符串 + int 类型数据 + 超时 + + 查看说明。 + + + + + 写数据(任何类型),是的封装版本 + + 数据类型,struct 或者内置类型 + 指令字符串 + 写入的数据 + 超时 + + 查看说明。 + + + + + 读数据的基础接口。 + + 指令字符串 + 接收数据的缓冲区 + 超时 + + 查看说明。 + + + + + 读数据(dobule类型)。是的封装版本 + + 指令字符串 + 要读取的double类型数据 + 超时 + + 查看说明。 + + + + + 读数据(int类型)。是的封装版本 + + 指令字符串 + 要读取的int类型数据 + 超时 + + 查看说明。 + + + + + 读数据(short类型)。是的封装版本 + + 指令字符串 + 要读取的short类型数据 + 超时 + + 查看说明。 + + + + + 读取数据(泛型版本,支持内置类型、结构体数据)(结构体大小必须是确定的) + + 内置类型或结构体类型,必须是确定的已经序列化的结构体(大小是确定的)。 + 指令字符串 + 要读取的数据 + 超时 + 查看说明。 + + 比如uci.u_Field的大小就是确定的,可以使用本接口。 + + + + + 判断接口返回值是否错误 + + 接口返回值 + true : 正确; false : 错误 + + + + 判断接口返回值是否正确 + + 接口返回值 + true : 正确; false : 错误 + + + + 获取会话ID + + + + + 设备地址,只有设备被打开时,才会存在。 + + + + + 当前设备是否已经打开 + + + + + uci接口的C语言接口到C#接口的适配接口 + 建议不要直接使用本类中提供的方法。 + 而是使用提供的方式。 + + + + + 无效的会话ID + + + + + 打开设备,建立会话。 + + + + + + + + + 查询设备 + + 要查询的设备信息, + 接收查询结果的节点数组 + _nodes的个数 + 超时 + + 小于0:错误; >=0 查询到的设备个数。 + + + 查询字符串示例: LAN:4162,5000;USB:0x1234#0x5345,0x7777#0x5345; + 格式是:"{通信类型名称 : 设备参数 ;}" + 每个通信类型数据以';'结尾;':'之前是节点名,节点名是内置的,网络通信是"LAN",USB通信是"USB"。 + LAN通信的参数是端口号,以','分割. + USB通信的参数是PID(第一个)和VID(第二个),每组数据以','号分割,PID和VID以'#'分割。 + + + + + 查找串口 + + + + + + + + 写数据。 新程序请直接使用接口。 + + 会话ID,由获得 + 接口参数 + 要写入的数据 + 数据长度 + + + + + 写数据。 是的非封装版本。 + + 会话ID,由获得 + 指令字符串 + 超时 + 要写入的数据 + 数据长度 + + + + + + + 会话ID,由获得 + + + + + + 读参数 + + 会话ID,由获得 + + + + + + + + 读参数(Read的参数未封装版本) + + 会话ID,由获得 + + + + + + + + + 关闭会话 + + 会话ID,由获得 + + + + + 写文件到设备 + + 会话ID,由获得 + + + + + + 写文件到设备,是WriteFromFile参数非封装接口 + + 会话ID,由获得 + 指令字符串 + 要发送的文件路径 + 超时s + + + + + 读文件 + + 会话ID,由获得 + + + + + + + + 会话ID,由获得, + 如果使用表示写的是全局属性。 + + + + + + + + 添加事件订阅 + + + + + + + 得到错误描述。接口错误码小于0,错误码定义见 + + + + + + 得到错误描述。原始接口,不要直接使用。 请使用。 + + + + + + 获取单位类型编码对应的单位名 + + 单位类型编码,编码定义见 + 单位名 + + + + 将当前单位的数值自动转换到合适的单位类型,以使数值小于进制。比如2300Hz,转换后就是2.3kHzs + + 当前值 + 当前单位编码 + 进制,一般为1000,比如频率的进制是1000 + + + + + 将当前单位的数值转换到指定的单位。 + + 当前数值 + 当前单位编码 + 要转换到的单位编码 + 进制,一般为1000,比如频率的进制是1000 + 返回转换后的数值,比如2.3KHz 转换为Hz就是2300Hz + 注意单位编码必须如EScale定义的,连续递增的量。 + + + + 获取单位类型编码对应的单位名 + + 单位类型编码,编码定义见 + 单位名 + + + + 在主程序退出之前调用本接口以清除uci.dll内部资源。 + 本接口只是针对C#接口使用。否则在退出时会有异常出现。 + + + + + 转换PID和VID未32位整数。 + + + + + + + + 判断接口返回值是否代表错误 + + 接口返回值 + + + + + 判断接口返回值是否代表正确 + + 接口返回值 + + + + + 查询在线的设备(建议不再使用该接口,可用代替) + + 查询参数 + 输出设备信息的缓冲区 + 入参是要查询的设备数量,出参是已经查询到的设备数量 + 超时 + + >=0正确,否则错误。 + + + + + 对压缩像素数据进行解压缩(适用于UTG4000A系列\UTG2025A NEW) + + 压缩之后的数据地址(按32bit寻址) + 压缩的数据大小,注意是int类型。 + 存放解压缩后的像素数据缓冲区 + 像素点数 + 小于0 错误,错误码见UnZipError, >=0解压缩后的大小(像素数) + + _dst缓冲区大小是屏幕宽度 * 屏幕高度, 比如800*480的屏幕, + 解压缩后就是 800*480 = 384000.即_dst_size = 384000. + + + + + alg_UnCompressPixels 接口的另一版本, 缓冲区全部是字节流 + + 压缩之后的数据地址,字节流 + 字节流长度 + 接收解压缩后的数据的字节流缓冲区 + _dst缓冲区的长度(Bytes) + 参考 + + + + 对压缩像素数据进行解压缩(适用于UTG2025A和UTG2062A) + + 压缩之后的数据地址 + 压缩的数据大小,字节数 + 存放解压缩后的像素数据缓冲区 + 像素点数*3, 24bit + 小于 0 错误,错误码见UnZipError, >=0解压缩后的大小(字节数) + + _des缓冲区大小应该是480*272*3 + + + + + 1000A信号源使用的图像数据的解压算法 + + 从设备端读取到的完整数据包 + _src 指向的数据大小Bytes + 输出的32bit的像素数据的缓冲区 + 图像的宽度 + 图像的高度 + 小于 0 错误,错误码见UnZipError, >=0解压缩后的像素个数 + + + + 通知事件的委托函数,由使用。 + + + + + + + 解压缩返回算法返回的错误码 + + + + + 参数错误 + + + + + 接收非压缩数据的缓冲区大小不够 + + + + + 提供一些做跨平台数据转换时的常用接口 + + + + + 将字节数组转换为结构体数组 + + 结构体类型 + 被转换的字节数组 + 用于数据的结构体数组 + 要转换的结构体数量 + + + + + + byte数组转结构体 + + byte数组 + 结构体类型 + 转换后的结构体, 转换失败返回null + + + + 结构体转byte数组 + + 要转换的结构体 + 转换后的byte数组 + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/02108918cca689fff42029bc8fa3465d1da42ab3.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/02108918cca689fff42029bc8fa3465d1da42ab3.svn-base new file mode 100644 index 0000000..ee7d288 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/02108918cca689fff42029bc8fa3465d1da42ab3.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/026198609bfb6b7f5ae71bcbb8d22f5ed62eff4e.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/026198609bfb6b7f5ae71bcbb8d22f5ed62eff4e.svn-base new file mode 100644 index 0000000..61d4b86 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/026198609bfb6b7f5ae71bcbb8d22f5ed62eff4e.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/02ec5ac48773d6c4b51c9f622071c4edf3568081.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/02ec5ac48773d6c4b51c9f622071c4edf3568081.svn-base new file mode 100644 index 0000000..1f4c886 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/02/02ec5ac48773d6c4b51c9f622071c4edf3568081.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/07/07fa0b2f00ba82a440bfeacafd8b0b8d1b3e4ee7.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/07/07fa0b2f00ba82a440bfeacafd8b0b8d1b3e4ee7.svn-base new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/07/07fa0b2f00ba82a440bfeacafd8b0b8d1b3e4ee7.svn-base @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/09/093c61508308abb3199e749680d3bd2d334302b0.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/09/093c61508308abb3199e749680d3bd2d334302b0.svn-base new file mode 100644 index 0000000..db013ce Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/09/093c61508308abb3199e749680d3bd2d334302b0.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/09/093f29b9deecbeea63b235805986b59441f95669.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/09/093f29b9deecbeea63b235805986b59441f95669.svn-base new file mode 100644 index 0000000..a629417 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/09/093f29b9deecbeea63b235805986b59441f95669.svn-base @@ -0,0 +1,449 @@ +/******************************************************************** + created: 2015/01/14 + author: M.Yang + purpose: UCIʹõйUTG4000&UTG8000Ķ + *********************************************************************/ +#ifndef UTG4162_h__ +#define UTG4162_h__ + +#ifdef __cplusplus +namespace uci { + namespace utg4162 { +#endif // __cplusplus + + /////////////////////////////////Key Define///////////////////////////// + + //@brief : UTG4000&UTG8000ϵл͵尴ֵ塣 + //@remark: + typedef enum _SGKeys { + Key_F1 = 0, + Key_F2, + Key_F3, + Key_F4, + Key_F5, + Key_F6, + Key_0 = '0', + Key_1, + Key_2, + Key_3, + Key_4, + Key_5, + Key_6, + Key_7, + Key_8, + Key_9, + Key_Dot, + Key_Symbol, + Key_Right, + Key_Left, + Key_Ok, + Key_Up, + Key_Down, + // + Key_User, + Key_Digital, + Key_Counter, + Key_Mod, + Key_Sweep, + Key_Bst, + Key_Sine, + Key_Noise, + Key_Square, + Key_Ramp, + Key_Pulse, + Key_Arb, + Key_Harmonic, + Key_DC, + Key_Ch1, + Key_Ch2, + Key_Trigger, + Key_SwapCh, + Key_OtherPage, + Key_Preset, + Key_Storge, + Key_StorgeL, + Key_Utility, + Key_Help, + Key_HelpL, + Key_Esc, + Key_PrScreen, + Key_Null = 0xff + }SGKeys; + + inline int GetKeyIndex(SGKeys _code) { + return (_code >= Key_F1 && _code < Key_F6) ? _code : _code - '0' + 6; + }; + + + //@brief : жϰǷ + //@param _code : ֵ + //@param _v : ǰ״̬64bitʹָ"lock?"ȡ + //@return : == 0 δ + //@remarks : + inline int IsKeyLocked(SGKeys _code, long long _v) { + return _v & ((long long)1 << GetKeyIndex(_code)); + }; + + //@brief : LED״̬ + //@remarks : 0 ʾ 1 ʾ + typedef struct _LEDStatus { + char Noise; + char UTILTY; + char STORGE; + char RAMP; + char PULSE; + char COUNTER; + char USER; + char DIGTAL; + char HARMONIC; + char DC; + char TRGGER; + char CH2; + char SWAPCH; + char ARB; + char CH1; + char SINE; + char SQUARE; + }LEDStatus; + + + /////////////////////////////////File Load///////////////////////////// + //@brief : Ⲩļطʽ + typedef enum _ARBWriteMode { + //@brief : زʽ + ARB_MODE_CARRIER = 0, + //@brief : ԵƲʽ + ARB_MODE_MOD, + }ARBWriteMode; + + //@brief : صļŽ + typedef enum _FileMedium { + //@brief : ŵRAM + FM_RAM = 0, + //@brief : ŵROM + FM_ROM, + //@brief : ŵTF + FM_TF, + //@brief : ŵU + FM_UDISK + }FileMedium; + + + /////////////////////////////////Parameters Address Define///////////////////////////// + //ģʽ + typedef enum _EWorkMode : long long { + //@brief : ģʽ + WM_BASE = 0, + //@brief : Ʋģʽ + WM_MODE, + //@brief : ɨƵģʽ + WM_SWEEP, + //@brief : ⧷ + WM_BURST, + }EWorkMode; + + // + typedef enum _EBaseWave : long long { + //@brief : Ҳ + BASE_SINE = 0, + //@brief : + BASE_SQUARE = 1, + //@brief : б + BASE_RAMP = 3, + //@brief : 岨 + BASE_PULSE = 4, + //@brief : + BASE_NOISE = 5, + //@brief : Ⲩ + BASE_ARB = 6, + //@brief : г + BASE_HARMONIC = 7, + //@brief : ֱ + BASE_DC = 8 + }EBaseWave; + + typedef enum _EModeType : long long { + MT_AM = 0, + MT_FM = 1, + MT_PM = 2, + MT_ASK = 3, + MT_FSK = 4, + MT_PSK = 5, + MT_BPSK = 6, + MT_QPSK = 7, + MT_OSK = 8, + MT_QAM = 9, + MT_PWM = 10, + MT_SUM = 11, + }EModeType; + + //Ʋ + typedef enum _EModeWaveType : long long { + MOD_WAVE_SINE = 0, + MOD_WAVE_SQUARE = 1, + MOD_WAVE_UPRAMP = 2, + MOD_WAVE_DNRAMP = 3, + MOD_WAVE_NOISE = 4, + MOD_WAVE_ARB = 5, + }EModeWaveType; + + //@brief : źԴ + //@remark: ʹrpָдʹwpָ + //@example: wp@ch:0@addr:0x8000@v:0; + // rp@ch:0@addr:0x8000; + // вĶӦ8bytesdouble + typedef enum _enumRemoteMessage { + //@brief : ģʽ + //@remark: {IO:WR}{DATA:EWorkMode} + RM_WORK_MODE = 0x8000, + + //{ + //@brief : ͨ + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_CH_SW = 0x8001, + //@brief : ͬ + //@remark: {IO:WR}{DATA: 0-OFF1-ON2-reverse} + RM_CH_SYNC_SW, + //@brief : ͨ + //@remark: {IO:WR}{DATA: 0OFF1ON} + RM_CH_REVERTSE, + //@brief : ͨ迹 + //@remark: {IO:WR}{DATA: 1~1000} + RM_CH_LOAD, + //@brief : ͨʹ + //@remark: {IO:WR}{DATA: 0OFF1ON} + RM_CH_OUTPUT_LIMIT_ENABLE, + //@brief : ͨ͵ƽ + //@remark: {IO:WR}{DATA: -10V~MAX_LEVEL} + RM_CH_OUTPUT_LIMIT_MIN_LEVEL, + //@brief : ͨߵƽ + //@remark: {IO:WR}{DATA: MIN_LEVEL~10V} + RM_CH_OUTPUT_LIMIT_MAX_LEVEL, + + //@brief : + //@remark: {IO:WR}{DATA:EBaseWave} + RM_BASE_WAVE_TYPE = 0x8008, + //@brief : Ƶ(λHz) + //@remark: {IO:WR}{DATA: 1uHz~ǰƵ} + RM_BASE_FREQ, + //@brief : λ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_BASE_PHASE = 0x800A, + //@brief : (λVPP) + //@remark: {IO:WR}{DATA: 1mVpp~10Vpp50ŷķ} + RM_BASE_AMP_VPP, + //@brief : (λVRMS) + //@remark: {IO:WR}{DATA: 1mVRMS~5Vpp50ŷķ} + RM_BASE_AMP_VRMS, + //@brief : (λVDBM) + //@remark: {IO:WR}{DATA: -53.010VDBM~26.99VDBM50ŷķ} + RM_BASE_AMP_VDBM, + //@brief : ƫ(λV) + //@remark: {IO:WR}{DATA: -5VRMS~5Vpp50ŷķ} + RM_BASE_OFFSET, + //@brief : ߵƽ(λV) + //@remark: {IO:WR}{DATA: BASE_LOW~5Vpp50ŷķ} + RM_BASE_HIGHT = 0x800F, + //@brief : ͵ƽ(λV) + //@remark: {IO:WR}{DATA: -5VRMS~BASE_HIGHT50ŷķ} + RM_BASE_LOW = 0x8010, + //@brief : ռձȶԷռձȡ岨ռձȡDzԳƶȹ + //@remark: {IO:WR}{DATA: 0~100} + RM_BASE_DUTY, + //@brief : 岨ʱ(λs) + //@remark: {IO:WR}{DATA: min ~ *0.4} + RM_BASE_RISETIME, + //@brief : 岨½ʱ(λs) + //@remark: {IO:WR}{DATA: min ~ *0.4} + RM_BASE_FALLTIME, + //@brief : Ⲩģʽ + //@remark: {IO:WR}{DATA:0OFF1ON} + RM_BASE_ARB_PLAY_ENABLE, + //@brief : г - ģʽ + //@remark: {IO:WR} + //{DATA: + //0: , + //1: ż, + //2: ȫ, + //3: USER,Զ + // } + RM_BASE_HARMOIC_TYPE = 0x8080, + //@brief :г,RM_BASE_HARMOIC_TYPE=USERʱЧ + //@remark: {IO:WR}{DATA:BIT14BIT0ֱӦ2~16гأBIT15Ӧǿƿ} + RM_BASE_HARMONIC_ONOFF, + //N(2~16)г,Կַ: + //EG:N=3(г),AMP = 1Vpp, PHASE = 90 + //1: + //1ָгRM_HARMONIC_NUM = N(2~16), + //2趨гķȺλ, + // RM_HARMONIC_SN_AMP_N = 1.0; RM_HARMONIC_SN_PHASE_N = 90.0; + //1:ֱõгķȺλ + //RM_HARMONIC_SN_AMP_3 = 1.0, RM_HARMONIC_SN_PHASE_3 = 90.0, + + //@brief : г + //@remark: {IO:WR}{DATA:1~15} + RM_HARMONIC_NUM, + //@brief : гVpp + //@remark: {IO:WR}{DATA:0~} + RM_HARMONIC_SN_AMP_N, + //@brief : гλ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_HARMONIC_SN_PHASE_N = 0x8084, + //@brief : г ͬRM_HARMONIC_SN_AMP_N + RM_HARMONIC_SN_AMP_2, + RM_HARMONIC_SN_AMP_3, + RM_HARMONIC_SN_AMP_4, + RM_HARMONIC_SN_AMP_5, + RM_HARMONIC_SN_AMP_6, + RM_HARMONIC_SN_AMP_7 = 0x808A , + RM_HARMONIC_SN_AMP_8, + RM_HARMONIC_SN_AMP_9, + RM_HARMONIC_SN_AMP_10, + RM_HARMONIC_SN_AMP_11, + RM_HARMONIC_SN_AMP_12 = 0x808F, + RM_HARMONIC_SN_AMP_13 = 0x8090, + RM_HARMONIC_SN_AMP_14, + RM_HARMONIC_SN_AMP_15, + RM_HARMONIC_SN_AMP_16, + //@brief : гλ RM_HARMONIC_SN_PHASE_N + RM_HARMONIC_SN_PHASE_2, + RM_HARMONIC_SN_PHASE_3, + RM_HARMONIC_SN_PHASE_4, + RM_HARMONIC_SN_PHASE_5, + RM_HARMONIC_SN_PHASE_6, + RM_HARMONIC_SN_PHASE_7, + RM_HARMONIC_SN_PHASE_8 = 0x809A, + RM_HARMONIC_SN_PHASE_9, + RM_HARMONIC_SN_PHASE_10, + RM_HARMONIC_SN_PHASE_11, + RM_HARMONIC_SN_PHASE_12, + RM_HARMONIC_SN_PHASE_13 = 0x809F, + RM_HARMONIC_SN_PHASE_14 = 0x80A0, + RM_HARMONIC_SN_PHASE_15, + RM_HARMONIC_SN_PHASE_16, + //} + + //{MOD + //@brief : ģʽ + //@remark: {IO:WR}{DATA:EModeType} + RM_MOD_TYPE = 0x8100, + //Ʋ + //0: MOD_SINE, + //1: MOD_SQUARE, + //2: MOD_UPRAMP, + //3: MOD_DNRAMP, + //4: MOD_NOISE, + //5: MOD_ARB, + //@brief : Ʋ + //@remark: {IO:WR}{DATA:EModeWaveType} + RM_MOD_WAVE, + //@brief : ƲƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~200KHz} + RM_MOD_FREQ, + //@brief : Ʋʣλs + //@remark: {IO:WR}{DATA: 2ms~1Ms} + RM_MOD_RATE, + //@brief : ȣλ% + //@remark: {IO:WR}{DATA: 0~120} + RM_MOD_SCOPE, + //@brief : Դ + //@remark: {IO:WR}{DATA: 0-Internal,1-External} + RM_MOD_SOURCE, + //@brief : FMƵλHz + //@remark: {IO:WR}{DATA: 0~زǰƵ} + RM_MOD_FRE_DEV, + //@brief : PM (λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_MOD_PHASE_DEV, + //@brief : FSKƵλHz + //@remark: {IO:WR}{DATA: 0~زƵ} + RM_MOD_HOP_FREQ, + //@brief : BPSKԴ + //@remark: {IO:WR} + //{DATA: + //0: PN7, + //1: PN9, + //2: PN15, + //3: PN21, + //} + RM_MOD_DATA_SOURCE = 0x8109, + //@brief : BPSKλQPSKλ1,(λ) + //@remark: {IO:WR}{DATA: -360~360}} + RM_MOD_PSK_PHASE1, + //@brief : QPSKλ2(λ) + //@remark: {IO:WR}{DATA:-360~360}} + RM_MOD_PSK_PHASE2, + //@brief : QPSKλ3(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_MOD_PSK_PHASE3, + //@brief : OSKʱ(λs) + //@remark: {IO:WR}{DATA: 8ns~200s} + RM_MOD_OSC_TIME, + //@brief : QAMIQ MAM + //@remark: {IO:WR}{DATA: 0-4QAM,1-8QAM,2-16QAM,3-32QAM,4-64QAM,5-128QAM,6-256QAM,} + RM_MOD_IQ_MAP, + //@brief : PWMռձȲֵ + //@remark: {IO:WR}{DATA: 0~PULS DUTY} + RM_MOD_DUTY_DEV, + //} + + //{SWEEP + //@brief : ɨƵ + //@remark: {IO:WR}{DATA: 0ԣ1} + RM_SWEEP_TYPE = 0x8200, + //@brief : ɨƵԴ + //@remark: {IO:WR}{DATA: 0ڲ1ⲿ2ֶ} + RM_SWEEP_SOURCE, + //@brief : ɨƵʱ(λs) + //@remark: {IO:WR}{DATA: 1ms~500s} + RM_SWEEP_TIME, + //@brief : ɨƵʼƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~زƵ} + RM_SWEEP_START_FREQ, + //@brief : ɨƵֹͣƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~زƵ} + RM_SWEEP_STOP_FREQ, + //@brief : ͬƵʣλHz + //@remark: {IO:WR}{DATA: RM_SWEEP_START_FREQ~RM_SWEEP_STOP_FREQ} + RM_SWEEP_SYNC_FREQ, + //@brief : ɨƵ + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_SWEEP_TIRG_OUT, + //} + + //{BURST + //@brief : ⧷ + //@remark: {IO:WR}{DATA: + //0: N, + //1: , + //2: ſ + //} + RM_BURST_TYPE = 0x8300, + //@brief : ⧷Դ + //@remark: {IO:WR}{DATA: 0ڲ1ⲿ2ֶ} + RM_BURST_SOURCE, + //@brief : + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_BURST_TIRG_OUT, + //@brief : ⧷ڣλs + //@remark: {IO:WR}{DATA: 1~500} + RM_BURST_PERIOD, + //@brief : ⧷λ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_BURST_PHASE, + //@brief : ⧷λ + //@remark: {IO:WR}{DATA: 1~50000} + RM_BURST_CYCLES, + //@brief : + //@remark: {IO:WR}{DATA: 0-Rise1-Fall} + RM_BURST_TIRG_EDGE, + //} + }ERemoteMessage; + + +#ifdef __cplusplus + } +} +#endif // __cplusplus + +#endif // UTG4162_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0c/0c913e6d0653f59e638bec4e58644a6b5d8debff.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0c/0c913e6d0653f59e638bec4e58644a6b5d8debff.svn-base new file mode 100644 index 0000000..4d6cae2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0c/0c913e6d0653f59e638bec4e58644a6b5d8debff.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0e/0e7d9d09ec1d49dced5d649156153a87aa9c5d1f.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0e/0e7d9d09ec1d49dced5d649156153a87aa9c5d1f.svn-base new file mode 100644 index 0000000..46ff680 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0e/0e7d9d09ec1d49dced5d649156153a87aa9c5d1f.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0f/0ff64e9ab5917a02e9ad592a044727ea77720429.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0f/0ff64e9ab5917a02e9ad592a044727ea77720429.svn-base new file mode 100644 index 0000000..acdee3b Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/0f/0ff64e9ab5917a02e9ad592a044727ea77720429.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/11/110da8e75ebf975335e31c8257ec4476de83b324.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/11/110da8e75ebf975335e31c8257ec4476de83b324.svn-base new file mode 100644 index 0000000..e182c40 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/11/110da8e75ebf975335e31c8257ec4476de83b324.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/12/12e086f3e31eb6c02a5a8b83fa1bb6b16a1a6768.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/12/12e086f3e31eb6c02a5a8b83fa1bb6b16a1a6768.svn-base new file mode 100644 index 0000000..d5c7202 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/12/12e086f3e31eb6c02a5a8b83fa1bb6b16a1a6768.svn-base @@ -0,0 +1,325 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {09EFA3E1-C64B-468C-9980-A583295E0001} + UCIDemoProj + MFCProj + + + + Application + true + v120_xp + Unicode + Static + + + Application + true + v120_xp + Unicode + Static + + + Application + true + v120_xp + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + + + + + + + + + + + + + + + + + + + + + + + true + $(OutDir);$(LibraryPath) + + + true + $(OutDir);$(LibraryPath) + + + true + $(OutDir);$(LibraryPath) + + + false + UCI_DEMO + + + false + UCI_DEMO + + + false + UCI_DEMO + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + true + + + Windows + true + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + true + + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + true + + + Windows + true + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + true + + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + true + + + Windows + true + + + false + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + false + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/13/139e55c6a5b8ce7bb9964860b1ffb3127bcf1840.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/13/139e55c6a5b8ce7bb9964860b1ffb3127bcf1840.svn-base new file mode 100644 index 0000000..e5b817a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/13/139e55c6a5b8ce7bb9964860b1ffb3127bcf1840.svn-base @@ -0,0 +1,449 @@ +/*! + * \created : 2016/12/28 + * \author : M.Yang + * \purpose : ģUTD2000M\UTD4000M\UTD2000CEX-EDUϵлʹõѡͲѡ붨塣 + */ +#ifndef ItemCode_COMVer2_h__ +#define ItemCode_COMVer2_h__ + +#ifdef __cplusplus +namespace comApiEx +{ +#endif + +enum E_SWITCH_STATE +{ + SWITCH_OFF, + SWITCH_ON, +}; + +#pragma region Channel +typedef enum{ + CH_Invalid_ID = -1, + CH_1_ID = 0, + CH_2_ID, + CH_MATH_ID, + CH_REF_A_ID, + CH_REF_B_ID, + CH_MAX_CNT, +}E_CHANNEL_ID; + +enum E_REF_SRC +{ + REF_A = 0, + REF_B, +}; + +enum E_CH_COUPLING_TYPE +{ + CH_COUPLING_DC = 0, + CH_COUPLING_AC, + CH_COUPLING_GND, +}; + +enum E_CH_BANDLIMIT +{ + CH_BANDLIMIT_FULL, + CH_BANDLIMIT_HALF, + CH_BANDLIMIT_20MHZ, +}; + +// +typedef enum { + CH_PROBE_1X = 0, + CH_PROBE_10X, + CH_PROBE_100X, + CH_PROBE_1000X, + + //2017-3-13CEM + CH_PROBE_2X, + CH_PROBE_5X, + CH_PROBE_20X, + CH_PROBE_50X, + CH_PROBE_200X, + CH_PROBE_500X, + CH_PROBE_1MX, + CH_PROBE_2MX, + CH_PROBE_5MX, + CH_PROBE_10MX, + CH_PROBE_20MX, + CH_PROBE_50MX, + CH_PROBE_100MX, + CH_PROBE_200MX, + CH_PROBE_500MX, +}CH_PROBE; + +#pragma endregion Channel + +#pragma region Trigger +////////////////////////////Trigger/////////////////////////////////// +//2017-3-13ӴںǷ +enum E_TRIG_TYPE +{ + TRIG_TYPE_EDGE = 0, //: + TRIG_TYPE_PLUSE_WIDTH, //: + TRIG_TYPE_VIDEO, //: Ƶ + TRIG_TYPE_SLOPE, //: б + TRIG_TYPE_WINDOW, //: ڣ + TRIG_TYPE_RUNT, //: Ƿ +}; + +enum E_TRIG_SOURCE +{ + TRIG_CH1 = CH_1_ID, + TRIG_CH2 = CH_2_ID, + TRIG_EXT, + TRIG_EXT_5, //EXT/5 + TRIG_AC_LINE = 4, + TRIG_ALTER, +}; + +enum E_TIRG_COUPLING +{ + TIRG_COUPLING_DC = 0, + TIRG_COUPLING_AC, + TIRG_COUPLING_L_RESTRAIN, //trigger coupling low frequency restrain + TIRG_COUPLING_H_RESTRAIN, //trigger coupling high frequency restrain + TIRG_COUPLING_NOISE_REJ, // +}; + +enum E_TRIG_MODE +{ + TRIG_MODE_AUTO = 0, + TRIG_MODE_NORMAL, + TRIG_MODE_SINGLE, +}; + +enum E_TRIG_EDGE_SLOPE +{ + TRIG_EDGE_SLOP_RISE = 0, + TRIG_EDGE_SLOP_FALL, + TRIG_EDGE_SLOP_RISE_FALL, +}; + +enum E_PULSE_POLAR +{ + PULSE_POLAR_N = 0, + PULSE_POLAR_P , +}; + +//2017-3-13PULSE_CONDITION_GT_LT +enum E_PULSE_CONDITION +{ + PULSE_CONDITION_LT = 0, //pulse condition less than + PULSE_CONDITION_GT, //pulse condition greater than + PULSE_CONDITION_ET, //pulse condition equal to + + PULSE_CONDITION_NO_EQUAL, //pulse not equal to , add by yzz [RESERVE] + PULSE_CONDITION_GT_LT, +}; + +enum E_TRIG_VIDEO_STANDARD +{ + TRIG_Video_NTSC = 0, + TRIG_Video_PAL, +}; + +//Ƶ-ͬʽ(0)ż(1)(2)ָ(3) +enum E_TRIG_VIDEO_SYNC_MODE +{ + TRIG_Video_SyncMode_Odd = 0, + TRIG_Video_SyncMode_Even, + TRIG_Video_SyncMode_ALL, + TRIG_Video_SyncMode_Specified, +}; + +enum E_SLOP_POLARITY +{ + SLOP_POLAR_FALL = 0, + SLOP_POLAR_RISE, +}; + +//2017-3-13SLOP_WHEN_GT_LT +enum E_SLOP_WHEN +{ + SLOP_WHEN_LT = 0, + SLOP_WHEN_GT, + SLOP_WHEN_Equal, + SLOP_WHEN_GT_LT, +}; + +enum E_SLOP_THRESHOLD +{ + SLOP_THRESHOLD_LOW = 0, + SLOP_THRESHOLD_HIGH, + SLOP_THRESHOLD_LOW_HIGH, +}; + +// +enum E_WINDOE_WHEN +{ + TRIG_SCOPE_WHEN_ENTER = 0, + TRIG_SCOPE_WHEN_EXIT, + TRIG_SCOPE_WHEN_TIME, +}; +// Ƿ +enum E_RUNT_WHEN +{ + TRIG_RUNT_WHEN_NO = 0, + TRIG_RUNT_WHEN_GT, + TRIG_RUNT_WHEN_LT, + TRIG_RUNT_WHEN_GT_LT, +}; + +#pragma endregion Trigger + +#pragma region Math +/////////////////////////////Math////////////////////////////////////// +enum E_MATH_TYPE +{ + MATH_TYPE_MATH = 0, + MATH_TYPE_FFT, + MATH_TYPE_FILTER, +}; + +enum E_MATH_OP_SIGN +{ + OP_SIGN_ADD = 0, + OP_SIGN_SUB, + OP_SIGN_MULTIPLY, + OP_SIGN_DIVIDE, +}; + +enum E_FFT_WINDOW +{ + FFT_WIN_HAMMING = 0, + FFT_WIN_BLACKMAN, + FFT_WIN_RECTANGLE, + FFT_WIN_HANNING +}; + +enum E_FFT_UNIT +{ + FFT_UNIT_VRMS = 0, + FFT_UNIT_DBVRMS, +}; + +enum E_FILTER_TYPE +{ + FILTER_LOW = 0, + FILTER_HIGH, + FILTER_BAND, + FILTER_BAND_STOP, //Ӵ +}; + +enum E_MATH_ZOOM_RATE +{ + ZOOM_RATE_DIV_1, + ZOOM_RATE_DIV_10, + ZOOM_RATE_DIV_100, + ZOOM_RATE_DIV_1000, +}; +#pragma endregion Math + +#pragma region Acquire +////////////////////////////Acquire////////////////////////////////// +//2017-3-13Ӹ߷ֱ +enum E_ACQ_MODE +{ + ACQ_MODE_NORMAL = 0, + ACQ_MODE_PEAK, + ACQ_MODE_AVERAGE, + ACQ_MODE_HIGHRESOLUTION, +}; + +enum E_SAMPLE_MODE +{ + ACQ_SAMPLE_EQUIVALENT = 0, + ACQ_SAMPLE_REAL, + ACQ_SAMPLE_SCAN, +}; +//32m,3.2m,32k,3.2k +enum E_ACQ_SAV_DEPTH +{ + ACQ_DEPTH_NORMAL = 0, + ACQ_DEPTH_DEPTH, + ACQ_DEPTH_32M, + ACQ_DEPTH_3POINT2M, + ACQ_DEPTH_32K, + ACQ_DEPTH_3POINT2K, + +}; +#pragma endregion Acquire + +#pragma region Display +////////////////////////////Display////////////////////////////////// +enum E_DISPLAY_TYPE +{ + DISPLAY_TYPE_YT = 0, + DISPLAY_TYPE_XY, +}; + +enum E_DISPLAY_FORMAT +{ + DISPLAY_FORMAT_VECTOR = 0, + DISPLAY_FORMAT_DOT, +}; + +enum E_Display_Graticule +{ + Display_Graticule_Full, + Display_Graticule_Grid, + Display_Graticule_CrossHair, + Display_Graticule_Frame, +}; + +enum E_Dislay_PersistTime +{ + Display_PersistTime_Auto, + Display_PersistTime_Short, + Display_PersistTime_Long, + Display_PersistTime_Unlimited, +}; +#pragma endregion Display + +#pragma region Utility +////////////////////////////Utility////////////////////////////////// +enum E_Utility_Skin +{ + UTILITY_SKIN_CLASSIC, + UTILITY_SKIN_TRADITIONAL, + UTILITY_SKIN_MODERN, +}; + +enum E_Utility_Menu_Display_Time +{ + UTILITY_MENU_DISPLAY_T5S, + UTILITY_MENU_DISPLAY_T10S, + UTILITY_MENU_DISPLAY_T20S, + UTILITY_MENU_DISPLAY_TMANUAL, + + UTILITY_MENU_DISPLAY_T1S, + UTILITY_MENU_DISPLAY_T2S, +}; + +enum E_Utility_Language +{ + UTILITY_LANG_ZHCN, // + UTILITY_LANG_ZHTW, // + UTILITY_LANG_ENGLISH, //Ӣ + UTILITY_LANG_GERMAN, // + UTILITY_LANG_RUSSIANS, // + + UTILITY_LANG_ESPANOL, // + UTILITY_LANG_PORTUGUESE, // + UTILITY_LANG_FRENCH, // + UTILITY_LANG_DUTCH, // +}; + +enum E_Utility_AutoSet +{ + UTILITY_AUTOSET_LOCK_ON, + UTILITY_AUTOSET_LOCK_OFF, +}; + +enum E_Utility_PassFail_AllowTesting +{ + UTILITY_PF_ALLOWTEST_COLSE, + UTILITY_PF_ALLOWTEST_OPEN, +}; + +enum E_Utility_PassFail_Output +{ + UTILITY_PF_OUTPUT_PASS, + UTILITY_PF_OUTPUT_FAIL, +}; + +enum E_Utility_PassFail_DisplayInfo +{ + UTILITY_PF_DISPLAYINFO_OPEN, + UTILITY_PF_DISPLAYINFO_CLOSE, +}; + +enum E_Utility_PassFail_Operation +{ + UTILITY_PF_OPERATION_PLAY, + UTILITY_PF_OPERATION_STOP, +}; + +enum E_Utility_PassFail_StopSet_Type +{ + UTILITY_PF_STOPSET_TYPE_PASSTIMES, + UTILITY_PF_STOPSET_TYPE_FAILTIME, +}; + +enum E_Utility_PassFail_StopSet_Condition +{ + UTILITY_PF_STOPSET_CONDITION_GT_EQU, + UTILITY_PF_STOPSET_CONDITION_LT_EQU, +}; +#pragma endregion Utility + +#pragma region Storage +////////////////////////////Storage////////////////////////////////// +enum E_STORAGE_TYPE +{ + STORAGE_TYPE_SETTING, + STORAGE_TYPE_WAVE, + STORAGE_TYPE_BITMAP, +}; + + +enum E_STORAGE_REFWAVE_FILE_FORMAT +{ + STORAGE_REFWAVE_FILE_FMT_CSV, + STORAGE_REFWAVE_FILE_FMT_INNER, +}; + +#pragma endregion Storage + +#pragma region Cursor +enum E_CURSOR_TYPE +{ + CURSOR_TYPE_TIME, + CURSOR_TYPE_VOLTAGE, + CURSOR_TYPE_TRACK, + CURSOR_TYPE_DUMP, + CURSOR_TYPE_CLOSED, +}; + +enum E_CURSOR_MODE +{ + CURSOR_MODE_INDEPENDENT, + CURSOR_MODE_TRACK, +}; + +enum E_CURSOR_H_UNIT +{ + CURSOR_UNIT_H_BASE, + CURSOR_UNIT_H_PERCENT, +}; + +enum E_CURSOR_V_UNIT +{ + CURSOR_UNIT_V_SECOND, + CURSOR_UNIT_V_HERTZ, + CURSOR_UNIT_V_PERCENT, + CURSOR_UNIT_V_DEGREE, +}; + +enum E_CURSOR_POS +{ + CURSOR_POS_CURRENT = 3, + CURSOR_POS_6DIV, +}; +#pragma endregion Cursor + +enum E_Measure_Edge +{ + Measure_Edge_Fall, + Measure_Edge_Rise, +}; + + +#ifdef __cplusplus +} +#endif + + +#endif // ItemCode_COMVer2_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/173328d3e0c1e8992f68896fd3ba6725d504a61d.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/173328d3e0c1e8992f68896fd3ba6725d504a61d.svn-base new file mode 100644 index 0000000..26264d5 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/173328d3e0c1e8992f68896fd3ba6725d504a61d.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/177f6bbc9f1338c71ff22d83ae29b82d5125dbec.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/177f6bbc9f1338c71ff22d83ae29b82d5125dbec.svn-base new file mode 100644 index 0000000..8a33c26 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/177f6bbc9f1338c71ff22d83ae29b82d5125dbec.svn-base @@ -0,0 +1,62 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 资源文件 + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/17f5e32ab78c4109b06baffcf9276d9d929f9199.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/17f5e32ab78c4109b06baffcf9276d9d929f9199.svn-base new file mode 100644 index 0000000..26824f3 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/17/17f5e32ab78c4109b06baffcf9276d9d929f9199.svn-base @@ -0,0 +1,2253 @@ + + + + ucics + + + + + 物理单位信息 + + + + + 单位类型,比如Time、Freq等。具体定义见文档。 + + + + + 量级,比如k、n,p,M等。具体定义见文档。 + + + + + 物理单位量级 + + + + + + + + + + / + + + + + + + + + + + + + + + 标准单位 + + + + + K + + + + + + + + + + + + + + + + + + + + 物理单位类型 + + + + + 无效的类型 + + + + + 频率(Hz) + + + + + 时间(s) + + + + + 面积(Vs) + + + + + 采样率(Sa/s) + + + + + 点数(Sa) + + + + + 峰峰值(V) + + + + + 电压 + + + + + 电流(A) + + + + + db(dB) + + + + + VV (VV) + + + + + 百分比(%) + + + + + 度数(°) + + + + + 瓦特,功率(W) + + + + + 未知单位(U) + + + + + 物理量数值 + + + 4Byte align -> 8Bytes, + 所有示波器都通过指令"mea:all?;"读取参数测量数据。 + 读取到的就是 MeaValue v[50] (固定长度), + 各参数的位置索引由定义。 + + + + + 测量值 + + + + + 物理单位 + + + + + 是否有效。 0 表示无效; 1表示有效。 + + + + + 是否存在。 0 表示存在; 1表示不存在。 + + + + + 参数测量数据包的通用定义。 + + + + + 最大值 + + + + + 最小值 + + + + + High(Top)-高电平(顶端值) + + + + + Middle-中间值 + + + + + Low(Bottom) - 低电平(底端值) + + + + + VPP-峰峰值 + + + + + 幅度值 + + + + + 平均值 + + + + + 周期平均值 + + + + + 均方根 + + + + + 周期均方值 + + + + + 面积 + + + + + 周期面积 + + + + + 过冲 + + + + + 预冲 + + + + + 周期 + + + + + 频率 + + + + + 上升时间 + + + + + 下降时间 + + + + + 正脉宽 + + + + + 负脉宽 + + + + + 正占空比 + + + + + 负占空比 + + + + + 上升延时 + + + + + 下升延时 + + + + + 相位 + + + + + FRR + + + + + FRF + + + + + FFR + + + + + FFF + + + + + LRF + + + + + LRR + + + + + LFR + + + + + LFF + + + + + 突发脉冲 + + + + + 固定位50个参数 + + + + + b0 : SYNC; b1 : channel(CH1); b2 : Trigger + + + + + SYNC Key + + + + + Channel Key + + + + + Trigger Key + + + + + 模拟C/C++的堆内存的操作:申请、释放、转换 + + + + + 创建指定大小(bytes)的非托管内存空间 + + + + + + 创建基于所给字节数组的非托管内存空间。默认数据会被拷贝到非托管内存空间。 + + 托管字节数组 + + + + 创建基于所给整形数据的非托管内存空间。默认数据会被拷贝到非托管内存空间。 + + 托管整形数组 + 起始拷贝位置 needCopy = true 时有效 + 拷贝数量 + + + + allocate storage for count elements of type ty + + + + + + + 创建基于所给对象数据的非托管内存空间 + + 托管对象数据 + true : 拷贝托管字节数组的数据到非托管内存空间; false : 不拷贝 + + + + 提供Pointer到IntPtr的运算符。 + + Pointer类型对象 + IntPtr + + + + 析构器 + + + + + 将内存数据转换所给的结构体类型数据。 + + 要转换的结构体 + 要转换的结构体 + + + + 指向非托管内存的指针 + + + + + 非托管内存空间的地址 + + + + + 非托管内存空间的大小(bytes) + + + + + 通信方式 + + + + + USB通信 + + + + + LAN通信 + + + + + 串口通信 + + + + + 信号源的通道号 + + + + + 通道1的编号 + + + + + 通道2的编号 + + + + + 代表所有通道的编号 + + + + + 非通道编号 + + + + + 开关状态,占用1个字节。 + + + + + 关闭状态 + + + + + 打开状态 + + + + + UCI所有接口返回的状态编码。如果小于0,则代表发生错误;反之,代表正确。 + #TODO:检查完整性 + + + + + 没有任何错误 + + + + + 错误(基础编码,所有错误码都在这个编码基础上定义) + + + + + 资源初始化错误 + + + + + 无效的会话 + + + + + 操作超时 + + + + + 操作失败 + + + + + 不支持的操作 + + + + + 内存空间不足 + + + + + 系统繁忙,无法响应 + + + + + 通信异常,不可逆! + + + + + 未知的错误 + + + + + 建立连接的字符串地址格式错误 + + + + + 连接还未建立 + + + + + 连接已断开 + + + + + 不支持的通信方式 + + + + + 未发现指定的设备 + + + + + 不支持的设备 + + + + + 需要先执行查询设备的操作 + + + + + 查询网络设备失败 + + + + + USB设备地址只在执行查询设备操作后才有效, + + + 从UCI库导出的USB设备地址,只是一个列表索引,不是真正的设备地址。 + + + + + 未发现U盘接入 + + + + + 按键已经锁定 + + + + + 命令格式错误 + + + + + 只支持单条命令 + + + + + 一条命令只支持一个属性 + + + + + 不支持的命令 + + + + + 发送命令失败 + + + + + 协议数据格式错误 + + + + + 设备端写文件到flash失败! + + + + + 未发现有效数据 + + + + + 命令消息错误,请命令参数是否符合协议 + + + + + 无效的表达式 + + + + + 参数错误 + + + + + 参数提供的空间太小 + + + + + 所提供的文件名太长(最长50个字节) + + + + + 参数所给的数据大小与协议不匹配(防止数据错误) + + + + + 数字溢出 + + + + + 超出范围 + + + + + 数据未全部读取完 + + + + + 数据校验失败 + + + + + 无效的数据 + + + + + 数据压缩失败 + + + + + 数据解压缩失败 + + + + + 数据传输失败 + + + + + 数据传输失败 + + + + + 拒绝访问 + + + + + An unspecified error occurred. + + + + + The file could not be located. + + + + + All or part of the path is invalid + + + + + The permitted number of open files was exceeded. + + + + + There was an attempt to use an invalid file handle + + + + + The current working directory cannot be removed + + + + + There are no more directory entries + + + + + There was an error trying to set the file pointer + + + + + There was a hardware error + + + + + SHARE.EXE was not loaded, or a shared region was locked + + + + + There was an attempt to lock a region that was already locked + + + + + The disk is full + + + + + The end of file was reached + + + + + 写文件到磁盘失败 + + + + + 信号源任意波下载方式 + + + + + 以载波方式加载 + + + + + 以调制波方式加载 + + + + + 将ARB文件写到Flash. + + + + + UCI读接口()用的读参数。 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + (废弃)返回的数据量数据,具体意义视具体命令而定; + 返回的数据量由接口的返回值确定。 + + + + + 读超时,单位ms,1000 = 1s + + + + + 附加数据,大多数情况下是不需要的,可设置为IntPtr.Zero. + + + + + 附加数据大小 + + + + + UCI写接口的写参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 返回的数据量数据,具体意义视具体命令而定; + + + + + 超时 + + + + + 接口SendCommand使用的参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 命令参数1 + + + + + 命令参数2 + + + + + 超时 + + + + + 写任意波文件的参数 + + + + + 通道号,一般CH1=0,依次类推 + + + + + 任意波(ARB)加载方式 + + + + + 写文件的参数,2个Bytes.(模拟C中的联合体) + + + + + 预留的数据段 + + + + + 任意波(ARB)文件参数 + + + + + 接口WriteFromFile的接口参数。 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 文件路径 + + + + + 指令执行超时,在该时间内指令为完成,就返回! + + + + + 接口ReadToFile使用的参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 文件路径 + + + + + 指令执行超时,在该时间内指令为完成,就返回! + + + + + 最终输出文件的路径 + + + + + 设备按键LED状态数据 + + + + + Noise按键LED开关状态 + + + + + UTILTY按键LED开关状态 + + + + + STORGE按键LED开关状态 + + + + + RAMP按键LED开关状态 + + + + + PULSE按键LED开关状态 + + + + + COUNTER按键LED开关状态 + + + + + USER按键LED开关状态 + + + + + DIGTAL按键LED开关状态 + + + + + HARMONIC按键LED开关状态 + + + + + DC按键LED开关状态 + + + + + TRGGER按键LED开关状态 + + + + + CH2按键LED开关状态 + + + + + SWAPCH按键LED开关状态 + + + + + ARB按键LED开关状态 + + + + + CH1按键LED开关状态 + + + + + SINE按键LED开关状态 + + + + + SQUARE按键LED开关状态 + + + + + 通信节点类型 + + + 在QParams中是按位与,在Node中取的是enum值。 + + + + + 网络设备类型 + + + + + USB设备类型 + + + + + USB设备的描述符 + + + + + PID + + + + + VID + + + + + 地址 + + + + + 4字段数据类型 + + + + + 字段1 + + + + + 字段2 + + + + + 字段3 + + + + + 字段4 + + + + + IP地址 + + + 填充顺序为 f1(192).f2(168).f3(1).f4(253) - 小端模式 + + + + + 分字段存取 + + + + + 32为整数表示的IP地址 + + + + + LAN口通信的设备描述符 + + + + + IP地址(字符串类型) + + + + + IP地址 + + + + + 网络端口(TCPIP连接用的端口号) + + + + + 查询到的设备节点的参数 + + + + + 通信接口方式 + + + + + 设备名 + + + + + 设备类型( 信号源 = SG, 示波器 = DSO, UPO = UPO;) + + + + + LAN口参数 + + + + + USB接口参数 + + + + + 连接字符串 + + + + + 序列号 + + + + + 设备状态 + + + + + 设备显示名称 + + + + + 串口描述 + + + + + 友好名称 + + + + + 端口号 + + + + + 查询参数 + + + + + 要查询的节点类型,按位与,数据取自QueryNodeType定义 + eg: QueryNodeType.USB | QueryNodeType.LAN + + + + + Ports的长度 + + + + + 端口集,指向int类型; + + + + + PVID数据的长度 + + + + + 存放PID和VID信息的指向INT类型的缓冲区地址, + int 类型对应的格式 :PID(高16bit) + VID(低16bit) + + + + + 查询字符串,nullptr时表示查询所有设备,否则查询指定设备名的设备。 + + + + + UCI使用的消息类型 + + + + + 与设备建立的连接已经断开 + + + 目前只支持LAN口访问的连接的侦测 + wParams LAN : 端口号(十进制); + Reserved LAN : IP 地址 + + + + + 文件传输消息 + + + wParams 总帧数; + lParams 帧计数; -1 : 开始传输; [0,wParams)传输中, 等于wParams传输结束-> + UCIMSGProc return -1 : 表示中断传输. + + + + + USB插拔消息 + + + wParams : 使用低16位,其中,高8位为pid,低8位为vid; + lParams : 事件类型, 移除 = 0, 插入 = 1; + Reserved : USB插入移除事件的设备的设备名 + + + + + USB设备事件 + + + + + USB 设备移除事件 + + + + + USB 设备接入事件 + + + + + UCI 消息数据 + + + + + 发送消息的会话ID + + + + + UCI消息,按解析 + + + + + 消息参数,每个消息的使用意义不一样 + + + + + 消息参数,每个消息的使用意义不一样 + + + + + 保留字段,每个消息的使用意义不一样 + + + + + 带单位的数值 + + + + + 数值 + + + + + 单位量级 + + + + + 带单位的数值 + + + + + 数值 + + + + + 单位量级 + + + + + 万用表和毫伏表数据帧 + + + + + 主显字符串(20个字符) + + + + + 副显字符串或(20个字符) + + + + + 主显数值(8Bytes) + + + + + 副显数值(8Bytes) + + + + + 标记位(8Bytes) + + + + + UCI会话(与设备建立会话) + 本接口是的面向对象封装版本。 + 会在UCISession对象释放时自动关闭会话,并做所有资源清理,且提供若干 + 实用接口。 + + + + + 构造器 + + 一般设置为true,在程序退出时会调用 + UCIInterop.ExInstance()进行资源清除。 + + + + + 析构器 + + + + + 打开设备,建立会话。 + + + 设备地址。获取方式:
+ 1、可以通过查询接口获取;
+ 2、也可以通过查看文档获取。
+ 3、使用提供的示例程序查询获取
+ + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + + static Session _com = new Session(true); + //... + var r = _com.Open("[C:DSO][D:DSO-E][T:USB][PID:0x5537][VID:0x4348][EI:0x82][EO:0x2][CFG:1][I:0][addr:0]"); + if (!OutputResult(r, "打开设备")){return false;} + //... + static bool OutputResult(int r, string msg) + { + string s = "[" + msg + "]"; + if (Session.Error(r)) + { + s += string.Format("失败,错误码:{0},错误信息:{1}", + r, _com.GetLastError()); + } + else + { + s += "成功!"; + } + Console.WriteLine(s); + return r >= 0; + } + + +
+ + + 打开交换机 + + 交换机地址 + 超时。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 内部使用接口 + + + + + 关闭会话 + + + 在设备未打开时调用不会执行任何操作。 + + + + + 获取最近一次调用UCI接口后的反馈信息。 + + + 反馈的文本字符串,与此描述对应的状态码可以查看。 + + + 返回的描述信息,可以设置中文和英文两个版本,设置方式如下: + + //设置为中文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession,"lang:zh-Hans;", null, 0); + + + //设置为英文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:en-US;", null, 0); + + 示例代码参见 + + + + + 写数据(字节流,基础接口) + + + 指令字符串,请查阅各机型编程手册获取 + + 要写到设备的字节流数据,如果是内置类型(如int等), + 可以使用转换: + + int v = 10; + byte[] arrayV = BitConverter.GetBytes(v); + + + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(纯指令文本) + + + 指令字符串,请查阅各机型编程手册获取 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(short类型) + + + 指令字符串,请查阅各机型编程手册获取 + short 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(double类型) + + + 指令字符串,请查阅各机型编程手册获取 + double 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(int类型) + + + 指令字符串,请查阅各机型编程手册获取 + int 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(任何类型) + + + 数据类型,struct 或者内置类型 + 指令字符串,请查阅各机型编程手册获取 + 写入的数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + 适用于结构体等类型数据的写操作。 + 也可以使用,但必须先使用 + 将结构体转换为Byte[] + + + + + 读数据(基础接口) + + 指令字符串,请查阅各机型编程手册获取 + 接收数据的缓冲区 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 如果需要将读取到的字节流转换为其它常见的数据类型,请使用 + 类提供的方法进行转换。 + + + + //打包读取所有参数测量结果--适用于所有示波器 + //... + static Session _com = new Session(true); + //... + //固定的50个参数,一个参数8Bytes,共400Bytes + byte[] allMeaBytes = new byte[50 * 8]; + r = _com.Read("mea:all?;", allMeaBytes); + if (r > 0) + { + //转换为结构体 + uci.Model.mea.MeaValue[] allMea = new uci.Model.mea.MeaValue[50]; + uci.Utility.ByteArrayToStructArray(allMeaBytes, ref allMea, 50); + } + + + + + + 读数据(dobule类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的double类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToDouble(byte[], 0) 将Byte[]转换为double + + + + + 读数据(int类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的int类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToInt32(byte[], 0) 将Byte[]转换为int + + + + + 读数据(short类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的short类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToInt16(byte[], 0) 将Byte[]转换为short + + + + + 读取数据(泛型版本,支持内置类型、结构体数据)(结构体大小必须是确定的) + + + 内置类型或结构体类型,必须是确定的已经序列化的结构体(大小是确定的)。 + 指令字符串,请查阅各机型编程手册获取 + 要读取的数据 + 超时。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 适用于读取结构体数据,比如的大小就是确定的。 + + + + + 写文件 + + 指令字符串 + 要发送的文件路径 + 指令执行超时(ms),在该时间内指令为完成,就返回! + 具体描述,请查看说明。 + + + + 读文件 + + 读文件参数 + 具体描述,请查看说明。 + + + + 判断接口返回值是否错误 + + 接口返回值 + true : 正确; false : 错误 + + + + 判断接口返回值是否正确 + + 接口返回值 + true : 正确; false : 错误 + + + + (内部)制作远程访问指令文本 + + 通用UCI指令文本,与具体机型对应。 + 远程访问的类型 + 超时。在该时间内指令未完成,就返回超时错误! + 数据长度 + 返回制作好的指令文本 + + + + 获取会话ID + + + + + 设备地址,只有设备被打开时,才会存在。 + + + + + 当前设备是否已经打开 + + + + + 是否时交换机通信模式(普通设备通信无需理会) + + + + + UCIInterop类是对uci.dll导出的C语言接口的适配。
+ 基本会话接口请结合 使用
+ +
+
+ + + 无效的会话ID + + + + + 打开设备,建立会话。 + + 设备地址。获取方式:
+ 1、可以通过查询接口获取;
+ 2、也可以通过查看文档获取。
+ 3、使用提供的示例程序查询获取
+ + 返回的会话ID + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 请参考 + +
+ + + 查询设备(私有,不公开,因为参数类型对于CS环境而言过于抽象,此即可与C接口直接对应) + + 查询操作的参数 + 输出数据的缓冲区地址 + 输出数据的缓冲区大小(Bytes) + 具体描述,请查看说明。 + + + + 查询设备 + + + + 要查询的设备信息 + 接收查询结果的节点数组 + _nodes的个数 + 超时 + + 小于0:错误; >=0 查询到的设备个数。 + + + 查询文本串的格式是:“{通信类型名称 : 设备参数 ;}”
+ 每个通信类型数据以';'结尾;':'之前是节点名,节点名是内置的,网络通信是"LAN",USB通信是"USB"。
+ LAN通信的参数是端口号,以','分割.
+ USB通信的参数是PID(第一个)和VID(第二个),每组数据以','号分割,PID和VID以'&'分割。
+ 示例:
+ + string msg = "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + + UCI接口查询是要指定要查询的设备信息后,才可查询!
+ 目前支持的全部USB设备:
+ 示波器、信号源和电源:
+ "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348;"
+ 万用表(HID)
+ "USB:0xE008&0x1A86,0xEA80&0x10C4;"
+ 目前支持的LAN口设备:
+ 8000 : UTG2000A&UTG7000B 系列;
+ 5000 : UPO2000S&UPO7000Z 系列;
+ 4162 : UTG4000A&UTG8000D 系列
+ 18191: UTP3000C&UTP8000M 系列
+ "LAN:5000,4162,8000,18191;"
+ 请注意:串口需要使用接口: 单独查询。
+
+ + + string queryMsg = "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348"; //查询USB设备 + //queryMsg += ";LAN:4162,5000";//查询网络设备 + queryMsg += ";"; + uci.Node[] nodes = new uci.Node[10]; + int count = UCIInterop.QueryNodesX(queryMsg, nodes, nodes.Length, 2000); + if (count > 0) + { + Console.WriteLine("查询到的满足条件的USB设备数量:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("[{0}]:{1}", i, nodes[i].UCIAddr); + } + } + else + { + OutputResult(count, "查询设备"); + } + + +
+ + + 查找串口 + + 接收端口描述的数据地址,调用者只需要做初始化即可。 + _nodes的个数 + 具体描述,请查看说明。 + + 此查询不包括任何的协议,只是查询串口。如果要查询指定协议的设备,请遍历打开串口 + 并使用指定协议进行验证。 + + uci.COMPort[] comPorts = new uci.COMPort[10]; + count = UCIInterop.QueryCOMPort(comPorts, comPorts.Length); + if (count > 0) + { + Console.WriteLine("Ports:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("{0} - COM{1} : {2}", i, comPorts[i].Port, comPorts[i].FriendlyName); + } + } + else if (count == 0) + { + Console.WriteLine("未查询到任何串口设备"); + } + else + { + OutputResult(count, "查询串口设备"); + } + //* Ports:1 + //* 0 - COM3 : Silicon Labs CP210x USB to UART Bridge (COM3) + + + + + + + 写数据。 可以使用简化版本的接口: + + 会话ID,由获得 + 接口参数 + 要写入的数据 + 数据长度 + 具体描述,请查看说明。 + + + + 写数据。 是的非封装版本。 + + 会话ID,由获得 + 指令字符串 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 要写入的数据 + 数据长度 + 具体描述,请查看说明。 + + + + 发送指令 + + 会话ID,由获得 + 指令参数 + 具体描述,请查看说明。 + + 具体哪些指令支持此接口,请参考各机型文档。 + + + + + 读参数。请使用 + + 会话ID,由获得 + 读接口参数 + 接收数据的缓冲区 + 接收数据的缓冲区的长度 + 具体描述,请查看说明。 + + + + 读参数(的参数未封装版本) + + 会话ID,由获得 + 读指令文本 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 接收数据的缓冲区 + 接收数据的缓冲区的长度 + 具体描述,请查看说明。 + + 可参考 + + + + + 关闭会话 + + 会话ID,由获得 + 具体描述,请查看说明。 + + + + 写文件到设备 + + 会话ID,由获得 + 写文件参数 + 具体描述,请查看说明。 + + + + 写文件到设备,是参数非封装接口 + + 会话ID,由获得 + 指令字符串 + 要发送的文件路径 + 指令执行超时(ms),在该时间内指令为完成,就返回! + 具体描述,请查看说明。 + + + + 读文件 + + 会话ID,由获得 + 读文件参数 + 具体描述,请查看说明。 + + + + 写属性。 + + 会话ID,由获得, + 如果使用表示写的是全局属性。 + 属性指令文本 + 属性参数数据 + 属性参数数据长度(字节) + 具体描述,请查看说明。 + + 返回的描述信息,可以设置中文和英文两个版本,设置方式如下: + + //设置为中文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession,"lang:zh-Hans;", null, 0); + //设置为英文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:en-US;", null, 0); + + 订阅设备更改通知。设备在接入和移除时会触发改通知。 + + uci_SetAttribute(UCIInterop.InvalidSession, "devchange:1;", null, 0); + + 注意:需要使用 订阅通知。 + + + + + 添加事件订阅 + + 委托签名请见 + 目前默认返回0. + + + + 获取最近一次调用UCI接口后的反馈信息。 + 详细描述请参考: + + + 反馈的文本字符串,与此描述对应的状态码可以查看。 + + + + + (内部使用) 得到错误描述。原始接口,不要直接使用。 请使用。 + + + + + + (内部)获取单位类型编码对应的单位名 + + 单位类型编码,编码定义见 + 物理单位名,也可以参考的定义自己建表查找。 + + + + 将当前单位的数值自动转换到合适的单位类型,以使数值小于进制。比如2300Hz,转换后就是2.3kHz + + 当前值 + 当前单位编码 + 进制,一般为1000,比如频率的进制是1000 + 返回物理量(数值+单位量级) + + + + 将当前单位的数值转换到指定的单位。 + + 当前数值 + 当前单位编码 + 要转换到的单位编码 + 进制,一般为1000,比如频率的进制是1000 + 返回转换后的数值,比如2.3KHz 转换为Hz就是2300Hz + 注意单位编码必须如EScale定义的,连续递增的量。 + + + + 获取单位类型编码对应的单位名 + + 单位类型编码,编码定义见 + 物理单位名,也可以参考的定义自己建表查找。 + + + + 在主程序退出之前调用本接口以清除uci.dll内部资源。 + 本接口只是针对C#接口使用。否则在退出时会有异常出现。 + + + + + 转换PID和VID为32位整数。 + + USB PID + USB VID + 转换好的PVID : 高16位为pid,低16位为vid. + + + + 判断接口返回值是否代表错误,辅助接口。 + 内部代码: return (r < 0); + + 接口返回值 + false :接口返回的状态码代表发生错误,反正,执行成功! + + + + 判断接口返回值是否代表正确,辅助接口 + 内部代码: return (r >= 0); + + 接口返回值 + false :接口返回的状态码代表发生错误,反正,执行成功! + + + + 查询在线的设备(建议不再使用该接口,可用代替) + + 查询参数 + 输出设备信息的缓冲区 + 入参是要查询的设备数量,出参是已经查询到的设备数量 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + + + 对压缩像素数据进行解压缩(适用于UTG4000A系列\UTG2025A NEW) + + 压缩之后的数据地址(按32bit寻址) + 压缩的数据大小,注意是int类型。 + 存放解压缩后的像素数据缓冲区 + 像素点数 + 小于0 错误,错误码见UnZipError, >=0解压缩后的大小(像素数) + + _dst缓冲区大小是屏幕宽度 * 屏幕高度, 比如800*480的屏幕, + 解压缩后就是 800*480 = 384000.即_dst_size = 384000. + + + + + alg_UnCompressPixels 接口的另一版本, 缓冲区全部是字节流 + + 压缩之后的数据地址,字节流 + 字节流长度 + 接收解压缩后的数据的字节流缓冲区 + _dst缓冲区的长度(Bytes) + 参考 + + + + 对压缩像素数据进行解压缩(适用于UTG2025A和UTG2062A) + + 压缩之后的数据地址 + 压缩的数据大小,字节数 + 存放解压缩后的像素数据缓冲区 + 像素点数*3, 24bit + 小于 0 错误,错误码见UnZipError, >=0解压缩后的大小(字节数) + + _des缓冲区大小应该是480*272*3 + + + + + 1000A信号源使用的图像数据的解压算法 + + 从设备端读取到的完整数据包 + _src 指向的数据大小Bytes + 输出的32bit的像素数据的缓冲区 + 图像的宽度 + 图像的高度 + 小于 0 错误,错误码见UnZipError, >=0解压缩后的像素个数 + + + + 使用ZBMP算法压缩的位图数据的解压缩算法 + + 原始数据 + 原始数据长度 + 接收解压后数据的缓冲区 + _des的长度 + 小于0 : 错误,请查看 + + + + 通知事件的委托函数,由使用。 + + 通知附带的消息参数 + 视消息协议而定 + + + + 解压缩返回算法返回的错误码 + + + + + 参数错误 + + + + + 接收非压缩数据的缓冲区大小不够 + + + + + alg_UnZipBMP接口返回的错误码 + + + + + 参数错误 + 地址不能为空,长度不能为0,接收解压缩的缓冲区不能被存放压缩数据的缓冲区小 + + + + + 存储空间不足 + + + + + 错误的窗大小 + + + + + 压缩数据格式错误 + + + + + 压缩数据有误 + + + + + 提供一些做跨平台数据转换时的常用接口 + + + + + 将字节数组转换为结构体数组 + + 结构体类型 + 被转换的字节数组 + 用于数据的结构体数组 + 要转换的结构体数量 + + + + + + byte数组转结构体 + + byte数组 + 结构体类型 + 转换后的结构体, 转换失败返回null + + + + 结构体转byte数组 + + 要转换的结构体 + 转换后的byte数组 + +
+
diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/19/19901e1c0b06417e6df4a2272687bb534bb817ab.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/19/19901e1c0b06417e6df4a2272687bb534bb817ab.svn-base new file mode 100644 index 0000000..5b81cf5 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/19/19901e1c0b06417e6df4a2272687bb534bb817ab.svn-base @@ -0,0 +1,218 @@ +/******************************************************************** + created: 2014/12/22 + author: M.Yang + purpose: UCI(united communicate interface) +*********************************************************************/ + +#ifndef uci_h__ +#define uci_h__ + +#include "ucidef.h" + +////////////////////////////////////////////////////////////////////////// +// ڽӿڷص״ֵ̬ +// < 0 : ʾ +// ӦĴϢͨuci_GetLastErrorȡ,Ķucidef.hļС +// < UCI_ERRĴΪlibusbĴ롣 +////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +namespace uci { +extern "C"{ +#endif + //@brief : ִỰ޹صIJѯ + //@param PRParams _params : ѯIJ + //@param u_byte * _data : ݵĻַ + //@param u_size _dataCount : ݵĻСBytes + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_Query(_in_out PRParams _params, _in_out u_byte* _data, _in u_size _dataCount); + + //@brief : ѯͨŽڵ + //@param _in const QParams * _params : ѯ + //@param _out Node * _outBuf : ŲѯĽڵ + //@param _in_out u_size * _nodeCnt : ΪҪȡĽڵΪʵʶȡĽڵ + //@param _in u_size _timeOut : ѯʱ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_QueryNodes(_in const QParams* _params, _out Node* _outBuf, + _in_out u_size* _nodeCnt, _in u_size _timeOut); + + //@brief : ѯͨŽڵ + //@param _msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _nodes : ŲѯĽڵ + //@param _node_count : ҪѯĽڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX(u_cstring _msg, Node* _nodes, u_size _node_count, _in u_size _timeout); + + //@brief : 豸 + //@param u_cstring _addr : 豸ַ '\0'β + //@param u_session * _session : ѽĻỰID. + //@param u_uint32 _timeOut : ӳʱʱ ms + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + // UCI_SUCCESS + // UCI_ERR_ARGS_WRONG; + // UCI_ERR_RES_INIT_ERROR; + // UCI_ERR_CONNECT_ADDR_WRONG; + // UCI_ERR_CONNECT_FAILED; + // UCI_ERR_CONNECT_TIMEOUT] + //@remarks : ĵ + u_status _UCIAPI uci_Open(u_cstring _addr, u_session* _session, u_uint32 _timeOut); + + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 + u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + //@brief : ִ + //@param u_session _session : ỰID + //@param PCommandParams _params : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SendCommand(u_session _session, PCommandParams _params); + + //@brief : UCI¼ + //@param uciNotify _pNotify : ӦUCI¼Ļص + //@return u_status _UCIAPI : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SetNotify(UCIMSGProc _pNotify); + + //@brief : + //@param _msg : ַ + //@param _obj : ݻַ + //@param _objSize : ݻС + //@return : 鿴ļеġڽӿڷص״ֵ̬˵s + //@remarks : Ŀǰֻ֧л԰汾Ͷ豸ͷĵ¼鿴ĵ + u_status _UCIAPI uci_SetAttribute(u_session _sesn, u_cstring _msg, const u_object* _obj, u_size _objSize); + + //@brief : ѯ + //@param u_session _sesn : + //@param u_attr _name : + //@param u_attr_v * _value : + //@return u_status _UCIAPI : + //@remarks : + u_status _UCIAPI uci_GetAttribute(u_session _sesn, u_cstring _msg, u_object* _obj, u_size _objSize); + + //@brief : д + //@param u_session _session : ỰID + //@param PWParam _params : д + //@param const u_byte * _data : Ҫдݻַ ΪNULL + //@param u_size _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_params.CMDStringѾҪдֶˣʹuci_FormatWriteӿڣ + // _data != NULLַ_params.CMDStringֻܰһ䡣 + u_status _UCIAPI uci_Write(u_session _session, PWParams _params, const u_byte* _data, u_size _len); + + //@brief : д + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@param _data : Ҫдݻַ ΪNULL + //@param _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_msgѾҪдֶˣ + // _data != NULLַ_msgֻܰһ䡣 + u_status _UCIAPI uci_WriteX(u_session _session, u_cstring _msg, + u_uint32 _timeout, const u_byte* _data, u_size _len); + + //@brief : ֻдַָдָӿ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteSimple(u_session _session, u_cstring _msg, u_uint32 _timeout); + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + //@brief : ȡ + //@param u_session _session : ỰID + //@param PRParams _params : + //@param u_byte * _data : ݵĻ + //@param u_size _dataLen : ݵĻССЭ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ʹuci_ReadX汾 + u_status _UCIAPI uci_Read(u_session _session, PRParams _params, u_byte* _data, u_size _dataLen); + + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 + u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, + u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + //@brief : дļ + //@param u_session _session : ỰID + //@param WFileParams * _info : ļϢ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteFromFile(u_session _session, WFileParams* _info); + + //@brief : дļ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : Ҫдļ·ļ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_WriteFromFileļ򻯰汾 + u_status _UCIAPI uci_WriteFromFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout); + + //@brief : Read data synchronously and store the transferred data in a file. + //@param u_session _session : ỰID + //@param RFileParams _params : Ҫݵļ· + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_ReadToFile(u_session _session, RFileParams* _params); + + //@brief : ȡļ + //@param _session : ỰID. + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : ݵش̵ļ·ļͺ׺ + //Ǿ·Ҳ··ͨ_filePathFinalȡ· + //@param _timeout : ʱ + //@param _filePathFinal : 嵽صļľ· + //@param _filePathFinalLength : _filePathFinalijȣַ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_ReadToFileķǷװ汾 + u_status _UCIAPI uci_ReadToFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength); + + //@brief : رջỰ + //@param u_session _session : ҪرյĻỰID + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + u_status _UCIAPI uci_Close(u_session _session); + + //@brief : һβӦĴ״̬Ϣ + //@return u_cstring : Ϣ + //@remarks : ͨuci_SetAttributeôϢ԰汾 + u_cstring _UCIAPI uci_GetLastError(void); + + //@brief : ˳UCIʵʱá + //@remarks : ˳ʱãͷڲԴ + // ӿڲһҪʹá ֻ.NETйܻ£ + // ͨuci_SetAttribute uci_SetNotifyӿ + // 豸Ƴ¼ʱ˳ʱʹá + void _UCIAPI uci_ExInstance(); +#ifdef __cplusplus +} + +} +#endif +#endif // uci_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/1a/1aa65b3ae8da361de60143a2301dd2b83aff36d6.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/1a/1aa65b3ae8da361de60143a2301dd2b83aff36d6.svn-base new file mode 100644 index 0000000..da0fc1f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/1a/1aa65b3ae8da361de60143a2301dd2b83aff36d6.svn-base @@ -0,0 +1,117 @@ +/*! +* \created : 2016/10/10 +* \author : M.Yang +* \purpose : ṩλı׼ +* \remarks : еλĶ嶼Ա׼λΪ0Сڱ׼λΪݼڱ׼λʱΪ +* ĺôǣԱ֤Ա׼λΪ׼չ +*/ + +#ifndef Unit_h__ +#define Unit_h__ + +#ifdef __cplusplus +namespace unit { + extern "C"{ +#endif +#ifdef __cplusplus + typedef enum _EScale : char { +#else + typedef enum _EScale { +#endif // DEBUG + SCALE_p = -4, + SCALE_n, + SCALE_u, + SCALE_m, + SCALE_STD = 0, + SCALE_K, + SCALE_M, + SCALE_G, + SCALE_T, + }EScale; + +#ifdef __cplusplus + typedef enum _EType : char{ +#else + typedef enum _EType { +#endif // __cplusplus + TYPE_INVALID = -1, + TYPE_FREQ, + TYPE_TIME, + TYPE_AREA, //(Vs) + TYPE_SAMPLERATE,//ʣSa/s + TYPE_POINT, //Sa + TYPE_VPP, //ֵ + TYPE_VOLTAGE,//ѹ + TYPE_CURRENT,// + TYPE_DB, //DB + TYPE_VV, // + TYPE_PERCENT,//ٷֱ + TYPE_DEGREE, // + TYPE_WATT, //أ + TYPE_UNKNOWN,// δ֪λ + }EType; + + typedef struct _CodeName { + char Code; + char Name[5]; + }CodeName; + + static const CodeName ScaleTabel[] = { + { SCALE_p, "p" }, + { SCALE_n, "n" }, + { SCALE_u, "u" }, + { SCALE_m, "m" }, + { SCALE_STD,"" }, + { SCALE_K, "K" }, + { SCALE_M, "M" }, + { SCALE_G, "G" }, + { SCALE_T, "T" } + }; + + static const CodeName TypeTabel[] = { + { TYPE_FREQ, "Hz" }, + { TYPE_TIME, "s" }, + { TYPE_AREA, "Vs" }, + { TYPE_SAMPLERATE, "Sa/s" }, + { TYPE_POINT, "Sa" }, + { TYPE_VPP, "Vpp" }, + { TYPE_VOLTAGE, "V" }, + { TYPE_CURRENT, "A" }, + { TYPE_DB, "dB" }, + { TYPE_VV, "VV" }, + { TYPE_PERCENT, "%" }, + { TYPE_DEGREE, "" }, + { TYPE_WATT, "W" }, + { TYPE_UNKNOWN, "U" }, + }; + + const char* _UCIAPI uci_UnitFindTypeName(char _code); + + const char* _UCIAPI uci_UnitFindScaleName(char _code); + //@brief : ǰλֵתָĵλ + //@param _cur_value : ǰֵ + //@param _cur_unit : ǰλ + //@param _des_unit : Ҫתĵλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@return : תֵ2.3KHz תΪHz2300Hz + //@remarks : עⵥλEScaleģ + double _UCIAPI uci_UnitConvertTo(double _cur_value, int _cur_unit, int _des_unit, double _scale); + + typedef struct _UVale { + double Value; + long long Unit; + }UVale; + + //@brief : ǰλֵԶתʵĵλͣʹֵСڽơ2300Hzת2.3KHzs + //@param _value : ǰֵ + //@param _unit : ǰλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@remarks : עⵥλEScaleģ + UVale _UCIAPI uci_UnitRefresh(double _value, char _unit, double _scale); + +#ifdef __cplusplus + } +} +#endif + +#endif // Unit_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/1d/1d748e0329cd455e902d25c1d58bd2b724bca569.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/1d/1d748e0329cd455e902d25c1d58bd2b724bca569.svn-base new file mode 100644 index 0000000..2710e96 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/1d/1d748e0329cd455e902d25c1d58bd2b724bca569.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/21/2135702838bb80f45633d0621ea0c70b366b3e4d.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/21/2135702838bb80f45633d0621ea0c70b366b3e4d.svn-base new file mode 100644 index 0000000..5da7c68 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/21/2135702838bb80f45633d0621ea0c70b366b3e4d.svn-base @@ -0,0 +1,561 @@ +/******************************************************************** + created: 2014/12/23 + author: M.Yang + purpose: UCIȫֶļ + modify: + *********************************************************************/ +#ifndef ucidef_h__ +#define ucidef_h__ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +#define _UCIAPI __stdcall +#define _UCICallBack __stdcall +#endif + +#define _in +#define _out +#define _in_out + +#ifdef __cplusplus +namespace uci { +#endif // __cplusplus + +#ifdef _CVI_ +#define u_inline static +#else +#define u_inline inline +#endif // _CVI_ + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif // !MAX_PATH + + ////////////////////////////////////////////////////////////////////////// + //{ Ͷ +#ifdef _UNICODE + //@brief : ʾһ Unicode ַ +#define u_tchar wchar_t +#else + //@brief : ʾһ ASCII ַ +#define u_tchar char +#endif // _UNICODE + +#if defined(_WIN64) + typedef unsigned __int64 u_unit_ptr; + typedef __int64 u_long_ptr; +#else + typedef unsigned int u_unit_ptr; + typedef long u_long_ptr; +#endif + + //@brief : Boolean +#define u_bool bool + //@brief : 8λ޷ +#define u_byte unsigned char + //@brief : 8λз +#define u_char char + //@brief : ָ͵Ļָ +#define u_buf void* + //@brief : ͵ij +#define u_object void + //@brief : ʾ 16 λз +#define u_short short + //@brief : ʾ 16 λ޷ +#define u_ushort unsigned short + //@brief : ʾ 16 λз +#define u_int16 u_short + //@brief : ʾ 16 λ޷ +#define u_uint16 u_ushort + //@brief : ʾ 32 λз +#define u_int32 int + //@brief : ʾ 32 λ޷ +#define u_uint32 unsigned int + //@brief : ʾUCIӿڷص״ֵ̬(32λз) +#define u_status u_int32 + //@brief : ʾС32λ޷ +#define u_size u_uint32 + //@brief : ʾỰID32λ޷ +#define u_session u_uint32 + //@brief : ʾַ +#define u_string u_tchar* + //@brief : ʾַֻ +#define u_cstring const u_tchar* + //@brief : ʾIDͣ32λ޷ +#define u_attr u_int32 + //@brief : ʾֵͣ32λ޷ +#define u_attr_v u_int32 + //@brief : ʾһ16λ޷͵ĵ +#define u_word u_ushort + //@brief : ʾһ32λ޷͵˫ +#define u_dword u_uint32 + //@brief : Ϣ +#define u_wparam u_unit_ptr + //@brief : Ϣ +#define u_lparam u_long_ptr + //} + + ////////////////////////////////////////////////////////////////////////// + //{ ӿڷ״ֵ̬ + //@brief : ɹ +#define UCI_SUCCESS (0) + //@brief : ʼֵ +#define UCI_ERR (-1000) + //@brief : жϵǰӿǷִʧ + //@brief : жϵǰӿǷִгɹ +#define UCIERR(r) (r < 0) +#define UCISUCCESS(r) (!UCIERR(r)) + + //@brief : + typedef enum _UCIErr { + NoError = 0, + + //@brief : Դʼ + InitResourceError = UCI_ERR - 20, + //@brief : ЧĻỰ + Invalid_Session, + //@brief : ʱ + Timeout, + //@brief : ʧ + Failed, + //@brief : ֵ֧IJ + Unsupported, + //@brief : ڴռ䲻 + Insufficient_Memory, + //@brief : ϵͳæ޷Ӧ + Busy, + //@brief : ͨ쳣棡 + COMExpection, + //@brief : ͨδ򿪣 + ChannelNotOpened, + + //@brief : δ֪Ĵ + Unknown = UCI_ERR - 40 - 1, + + //@brief : ӵַַʽ + Connect_InvalidAddress = UCI_ERR - 40, + //@brief : ӻδ + Connect_NotBuild, + //@brief : ѶϿ + Connect_Break, + //@brief : ֵ֧ͨŷʽ + Connect_Unsupported_COMType, + + //@brief : δָ豸 + Device_NoFound = UCI_ERR - 60, + //@brief : ֵ֧豸 + Device_Unsupported, + //@brief : Ҫִвѯ豸IJ + Device_QueryFirst, + //@brief : Ͳƥ + Device_NotMatch, + + //@brief : ѯ豸ʧ + Query_LANNodesFailed, + + //@brief : USB豸ִַֻвѯ豸Ч + //@remarks : UCI⵼USB豸ַֻһб豸ַ + AddrValid_AfterQueryDeviceOper, + + //@brief : δU̽ + UDisk_NotFound, + //@brief : Ѿ + Key_Locked, + + //@brief : ַʽ + CMD_Invalid_StringFormat = UCI_ERR - 80, + //@brief : ֵֻ֧ + CMD_OnlySupportSingle, + //@brief : һֻ֧һ + CMD_OnlySupportSingleAttr, + //@brief : ֵ֧ + CMD_Unsupported, + //@brief : ʧ + CMD_SendFailed, + //@brief : Эݸʽ + CMD_Invalid_ProtocolFormat, + //@brief : 豸дļflashʧܣ + CMD_WriteFileToFlash_Failed, + //@brief : δЧĻظ + CMD_NoFound_Valid_Reply_Data, + //@brief : Ϣ鿴ǷЭ + CMD_Error_Message, + //@brief : Чıʽ + CMD_Invalid_Expression, + + //@brief : + Args_Invalid = UCI_ERR - 100, + //@brief : ṩĿռ̫С + Args_MemoryTooSmall, + //@brief : ṩļ̫(50ֽ) + Args_FileNameTooLong, + //@brief : ݴСЭ鲻ƥ(ֹݴ) + Args_DataLenNotMatch, + + //@brief : + Data_Overflow = UCI_ERR - 120, + //@brief : Χ + Data_OutRange, + //@brief : δȫȡ + Data_NotReadEnoughLenth, + //@brief : Уʧ + Data_ECC_Failed, + //@brief : Ч + Data_Invalid, + //@brief : ѹʧ + Data_Zip_Error, + //@brief : ݽѹʧ + Data_UnZip_Error, + //@brief : ݴʧ + Data_Transfer_Error, + //@brief : ݴʧ + Data_Transfer_Break, + //@brief : Чݿɶȡ + Data_No_Data_Incoming, + + //@brief : + File_AccessDenied = UCI_ERR - 140, + //@brief : An unspecified error occurred. + File_GenericException, + //@brief : The file could not be located. + File_NotFound, + //@brief : All or part of the path is invalid. + File_BadPath, + //@brief : The permitted number of open files was exceeded. + File_TooManyOpenFiles, + //@brief : There was an attempt to use an invalid file handle + // or The file format is unsupported! + // or The file data is error! + File_InvalidFile, + //@brief : The current working directory cannot be removed + File_RemoveCurrentDir, + //@brief : There are no more directory entries + File_DirectoryFull, + //@brief : There was an error trying to set the file pointer + File_BadSeek, + //@brief : There was a hardware error + File_HardIO, + //@brief : SHARE.EXE was not loaded, or a shared region was locked + File_SharingViolation, + //@brief : There was an attempt to lock a region that was already locked + File_LockViolation, + //@brief : The disk is full + File_DiskFull, + //@brief : The end of file was reached + File_EndOfFile, + //@brief : дļʧ + File_SaveToDiskFailed, + }UErr; + //} + ////////////////////////////////////////////////////////////////////////// + + //@brief : ĻỰID +#define INVALID_SESSION ((u_uint32)(-1)) + + ////////////////////////////////////////////////////////////////////////// + //{ + //лӢģ "lang:zh-hans" or "lang:en-us" + //ʹUSB豸ƳӼ "devchange:1" +//} + + +#define CACHE_LINE 1 +#define CACHE_ALIGN __declspec(align(CACHE_LINE)) + + //@brief : ýṹĶ뷽ʽ +#define PACK_ALIGN(n) __declspec(align(n)) + + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + + //one Word is 2 bytes + u_inline u_word UCI_HIWORD(u_dword _dw) { return ((u_word)((_dw >> 16) & 0xffff)); } + u_inline u_word UCI_LOWORD(u_dword _dw) { return ((u_word)(_dw & 0xffff)); } + + //#pragma pack(show)// C4810 + //ensure byte-packed structures1ֽڶ룩 +#include //뻷ûиļ滻Ϊǰƽֽ̨ڶ䡣 + + //@brief : ݽӿڵIJ + //@remarks : ͨͨuci_CreateRParamsӿڴ + typedef struct _RParams { + //@brief : ַ'\0'β. ʽЭĵ + u_cstring CMDString; + //@brief : ҪصӾͨҪȡ\ѯǶӦģ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + //@brief : + //@remarks : ͨʹãɿ;ڲѯ豸ʱõ + //ΪQParamsĵΪ׼ + u_buf ExtraData; //reserve + //@brief : ݵij + u_size ExtraDataLen; + }RParams, *PRParams; + +#ifdef __cplusplus + inline RParams* uci_CreateRParams(RParams& _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + _p.ExtraData = _ExtraData; + _p.ExtraDataLen = _ExtraDataLen; + return &_p; + } +#else + u_inline RParams* uci_CreateRParams(RParams* _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + _p->ExtraData = _ExtraData; + _p->ExtraDataLen = _ExtraDataLen; + return _p; + } +#endif + + typedef struct _DeviceIOParams { + u_int32 Count; + u_int32* Data; + }DeviceIOParams; + + typedef struct _QParams { + //@brief : ҪѯͨŽڵ + //@remarks : enum NodeType ȡֵ ͨ־λֵ + //@eg NodeType::USB | NodeType::LAN + u_int32 Type; + //@brief : ˿ڼ˿ + u_int32 PortCount; + //@brief : ˿ڼ + u_int32* Ports; + //@brief : PVIDPVIDĸ + //@remarks : + u_int32 PVIDCount; + //@brief : PID VID + //@remarks : ʹMakePVIDGetPIDGetVIDȡ + u_int32* PVID; + //@brief : ѯַnullptrʱʾѯ豸ѯָ豸豸 + u_cstring Msg; + }QParams, *PQParams;//@brief : ѯ豸ʱò + + u_inline u_int32 MakePVID(u_ushort _pid, u_ushort _vid) { return ((_pid << 16) | (_vid)); }; + + u_inline u_ushort GetPID(u_int32 _pvid) { return UCI_HIWORD(_pvid); } + + u_inline u_ushort GetVID(u_int32 _pvid) { return UCI_LOWORD(_pvid); } + +#ifdef __cplusplus + inline QParams* UCI_CreateQParam(QParams& _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(&_qp, 0, sizeof(_qp)); + _qp.Type = _type; + _qp.Ports = _ports; + _qp.PortCount = _port_cnt; + _qp.PVID = _pvid; + _qp.PVIDCount = _pvid_cnt; + _qp.Msg = _msg; + return &_qp; + } +#else + u_inline QParams* UCI_CreateQParam(QParams* _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(_qp, 0, sizeof(*_qp)); + _qp->Type = _type; + _qp->Ports = _ports; + _qp->PortCount = _port_cnt; + _qp->PVID = _pvid; + _qp->PVIDCount = _pvid_cnt; + _qp->Msg = _msg; + return _qp; + } +#endif + //@brief : дݽӿڲ + //@remarks : ͨӿuci_CreateWParams + typedef struct _WParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : صݣӾ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + }WParams, *PWParams; + +#ifdef __cplusplus + u_inline WParams* uci_CreateWParams(WParams& _p, u_cstring _cmd, u_uint32 _timeout) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + return &_p; + } +#else + u_inline WParams* uci_CreateWParams(WParams* _p, u_cstring _cmd, u_uint32 _timeout) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + return _p; + } +#endif + typedef struct _CommandParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : 1 + u_uint32 Param1; + //@brief : 1 + u_uint32 Param2; + //@brief : ʱ + u_uint32 Timeout; + }CommandParams, *PCommandParams; + + //@brief : дļIJ + typedef struct _WFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : Ҫдļ·ļ + u_cstring FilePath; + //@brief : дʱ(λms) + u_uint32 Timeout; + }WFileParams, *PWFileParams; + + //@brief : ļӿڵIJ + typedef struct _RFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : ݵش̵ļ·ļͺ׺ + u_cstring FilePath; + //@brief : ʱ(λms) + u_uint32 Timeout; + //@brief : ļ· + u_tchar FilePathFinal[MAX_PATH]; + }RFileParams, *PRFileParams; + + //@brief : ͨŽڵ + //@remarks : QParamsǰλ룬Nodeȡenumֵ + typedef enum _NodeType{ + LAN = 0x0001, + USB = 0x0010, + }NodeType; + + //@brief : USB豸 + //@remarks : + typedef struct _USBDescriptor { + //@brief : PID + u_ushort PID; + //@brief : VID + u_ushort VID; + //@brief : ַ + u_ushort Addr; + }USBDescriptor; + + //@brief : IPַ + //@remarks : ˳Ϊ f1(192).f2(168).f3(1).f4(253) - Сģʽ + typedef union _IPAddr { + struct { u_byte f1, f2, f3, f4; } Field; + u_int32 Addr; + }u_IPAddr; + + //@brief : LANͨŵ豸 + //@remarks : + typedef struct _LANDescriptor { + //@brief : IPַַͣ + u_tchar IP[16]; + //@brief : IPַ + u_IPAddr Addr; + //@brief : ˿ + //@remarks : TCPIPõĶ˿ں + u_ushort Port; + }LANDescriptor; + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _Node { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµƣ + // ѳδͳһʱUCIڲԶƥΪUCIЭõ֣ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }Node, *PNode; + + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _NodeEx { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµơ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }NodeEx, *PNodeEx; + + typedef struct _UCIMSG { + u_session Session; + u_uint32 Message; + u_wparam wParams; + u_lparam lParams; + u_byte Reserved[240]; + }UCIMSG;//256Bytes + + ////////////////////////////////////////////////////////////////////////// + typedef enum _uci_msg { + UMSG_CONNECT_CLOSED = 1, + //@brief : ļϢ + //@remarks : + // wParams ֡ + // lParams ֡ -1 ʼ䣻 [0,wParams)У wParams + //-> UCIMSGProc return -1 ʾжϴ. + UMSG_FILE_TRANSFER = 2, + //@brief : USBϢ + //@remarks : + // wParams : ʹõ16λУ8λΪpid8λΪvid + // lParams : ¼ͣ Ƴ = 0 = 1 + UMSG_DEVICE_NOTIFY = 3, + }EUCIMSG; + + typedef int(__stdcall *UCIMSGProc)(UCIMSG* _msg); +#include + +#ifdef __cplusplus + } +#endif//__cplusplus + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ucidef_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/22/22eda3f0f788b53123c635cd22d634007025f42c.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/22/22eda3f0f788b53123c635cd22d634007025f42c.svn-base new file mode 100644 index 0000000..442935c Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/22/22eda3f0f788b53123c635cd22d634007025f42c.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/25/25407feb23bbf9c1b9156d27cdcc5c8072f438db.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/25/25407feb23bbf9c1b9156d27cdcc5c8072f438db.svn-base new file mode 100644 index 0000000..d539df9 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/25/25407feb23bbf9c1b9156d27cdcc5c8072f438db.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/27/277e89689877e93e447231160ae2bb8c3112b4f9.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/27/277e89689877e93e447231160ae2bb8c3112b4f9.svn-base new file mode 100644 index 0000000..dd42012 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/27/277e89689877e93e447231160ae2bb8c3112b4f9.svn-base @@ -0,0 +1,11 @@ +#ifndef File_h__ +#define File_h__ + +class Files { +public: + static bool ReadFile(const CString& _fileName, CString& _content); + static void WriteFile(const CString& _fileName, CString& _content); + static bool WriteAllBytes(const CString& _name, const void* _b, size_t _len, CString* _path); +}; + +#endif // File_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/27/279dea9fe324f7a0edaaa2f0ff56220646f1bd2d.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/27/279dea9fe324f7a0edaaa2f0ff56220646f1bd2d.svn-base new file mode 100644 index 0000000..d478f13 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/27/279dea9fe324f7a0edaaa2f0ff56220646f1bd2d.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2a/2ac6a2772484a0b5b648b4eef8d2e2e372dd6f90.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2a/2ac6a2772484a0b5b648b4eef8d2e2e372dd6f90.svn-base new file mode 100644 index 0000000..8c80a6d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2a/2ac6a2772484a0b5b648b4eef8d2e2e372dd6f90.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2b/2b9fc821f1a52fd3c7c20944177abcaabc507ab9.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2b/2b9fc821f1a52fd3c7c20944177abcaabc507ab9.svn-base new file mode 100644 index 0000000..83cb1d9 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2b/2b9fc821f1a52fd3c7c20944177abcaabc507ab9.svn-base @@ -0,0 +1,5 @@ +math@t:f; +trig@pos:25; +CH:0@vp:128; +CH:0@EN:1; +CH:0@SEL; diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2d/2dc5a6b385e99bbac8ecc463f0b09228eb631738.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2d/2dc5a6b385e99bbac8ecc463f0b09228eb631738.svn-base new file mode 100644 index 0000000..a59db53 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/2d/2dc5a6b385e99bbac8ecc463f0b09228eb631738.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/32/3205a5145f9ceed952b79f314d197cf736682cf3.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/32/3205a5145f9ceed952b79f314d197cf736682cf3.svn-base new file mode 100644 index 0000000..b53b36e Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/32/3205a5145f9ceed952b79f314d197cf736682cf3.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/33/334b7496d79148cfcab22918f4579a48dae2497c.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/33/334b7496d79148cfcab22918f4579a48dae2497c.svn-base new file mode 100644 index 0000000..10c7e47 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/33/334b7496d79148cfcab22918f4579a48dae2497c.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/33/33fd28054f2237c0243d881b8f377e349ea2c1de.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/33/33fd28054f2237c0243d881b8f377e349ea2c1de.svn-base new file mode 100644 index 0000000..fb7ed91 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/33/33fd28054f2237c0243d881b8f377e349ea2c1de.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/34/347aa128825b176f84c5d2ca4caf0f179f5737f0.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/34/347aa128825b176f84c5d2ca4caf0f179f5737f0.svn-base new file mode 100644 index 0000000..c32df04 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/34/347aa128825b176f84c5d2ca4caf0f179f5737f0.svn-base @@ -0,0 +1,219 @@ + + + + +ucivb + + + + + +通信接口方式。 + + + +设备名。 + + + +设备类型( 信号源 = SG, 示波器 = DSO, UPO = UPO;)。 + + + +LAN口参数。 + + + +USB口参数。 + + + +连接字符串。 + + + +序列号。 + + + +设备状态。 + + + +设备显示名称。 + + + +查询到的设备节点的参数。 + + + +命令字符串,以'\0'结尾. 具体格式见文档; + + + +文件路径 + + + +超时 + + + +最终输出文件的路径 + + + +接口ReadToFile使用的参数。 + + + +命令字符串,以'\0'结尾. 具体格式见文档; + + + +文件路径 + + + +超时 + + + +接口WriteFromFile的接口参数。 + + + +查询设备 + + 要查询的设备信息, + 接收查询结果的节点数组 + _nodes的个数 + 超时 + +小于0:错误; >=0 查询到的设备个数。 + + + + + +简单版查询设备 + + 要查询的设备信息,以逗号形式隔开每一个设备地址,{设备地址1,设备地址2,设备地址3......} + 所有设备信息总长度 + 设备接口类型,16表示USB,1表示LAN + 超时 + +小于0:错误; >=0 查询到的设备个数。 + + + + + +打开设备,建立会话。 + + + + + + + +简单版打开设备,返回会话。 + + + + session + + +关闭会话。 + + + + + +写数据。 是的非封装版本。 + + 会话ID,由获得 + 指令字符串 + 超时 + 要写入的数据 + 数据长度 + + + +简单版写字符串数据。 是的非封装版本。 + + 会话ID,由获得 + 指令字符串 + 超时 + + + +读参数(Read的参数未封装版本) + + 会话ID,由获得 + 写入的指令 + 超时 + 接收数据缓存 + 想要读的数据长度 + 读到的数据长度 + + +写文件到设备 + + 会话ID,由获得 + 文件信息 + + + +简单版写文件到设备,不需定义结构体 + + 会话ID,由获得 + 指令 + 文件路径 + 超时 + + + +读文件 + + 会话ID,由获得 + 文件信息 + + + +简单版读文件,不需定义结构体 + + 会话ID,由获得 + 指令 + 文件路径 + 超时 + 输出文件的最后全路径 + 全路径长度 + + + +得到错误描述。原始接口,不要直接使用。 请使用。 + + + + +得到错误描述字符串。接口错误码小于0 + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/36/365962d941b502fee4b8cb4e939a8933ad0c1618.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/36/365962d941b502fee4b8cb4e939a8933ad0c1618.svn-base new file mode 100644 index 0000000..187409b Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/36/365962d941b502fee4b8cb4e939a8933ad0c1618.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/36/36d55d82c58f748e719a7f85eafdb3c6b9c7c27a.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/36/36d55d82c58f748e719a7f85eafdb3c6b9c7c27a.svn-base new file mode 100644 index 0000000..587bb4c --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/36/36d55d82c58f748e719a7f85eafdb3c6b9c7c27a.svn-base @@ -0,0 +1,3 @@ +еUSBʹñװװװʽ +˫Installer.batļ԰װusb +˫UnInstaller.batļ豸Ҽж \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/37/3767e83744bf091dbd146becfc61e694949f5ee7.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/37/3767e83744bf091dbd146becfc61e694949f5ee7.svn-base new file mode 100644 index 0000000..42e56a4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/37/3767e83744bf091dbd146becfc61e694949f5ee7.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/39/392bedbaa2ed79799046ae03ebc0320c78e36a14.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/39/392bedbaa2ed79799046ae03ebc0320c78e36a14.svn-base new file mode 100644 index 0000000..7801310 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/39/392bedbaa2ed79799046ae03ebc0320c78e36a14.svn-base @@ -0,0 +1,171 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩUCIӿʹõģDSOͨö塣 + */ +#ifndef dso_base_h__ +#define dso_base_h__ + +#ifdef __cplusplus +namespace comAPICommon { +#endif + //ʱλлһ£˲ͬıԵ +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + TLEVEL_1NS = 0, + TLEVEL_2NS, + TLEVEL_5NS, + TLEVEL_10NS, + TLEVEL_20NS, + TLEVEL_50NS, + TLEVEL_100NS, + TLEVEL_200NS, + TLEVEL_500NS, + TLEVEL_1US, + TLEVEL_2US, + TLEVEL_5US, + TLEVEL_10US, + TLEVEL_20US, + TLEVEL_50US, + TLEVEL_100US, + TLEVEL_200US, + TLEVEL_500US, + TLEVEL_1MS, + TLEVEL_2MS, + TLEVEL_5MS, + TLEVEL_10MS, + TLEVEL_20MS, + TLEVEL_50MS, + TLEVEL_100MS, + TLEVEL_200MS, + TLEVEL_500MS, + TLEVEL_1S, + TLEVEL_2S, + TLEVEL_5S, + TLEVEL_10S, + TLEVEL_20S, + TLEVEL_50S, + TLEVEL_100S, + TLEVEL_200S, + }E_TIMEBASE_LEVEL; + +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + VLEVEL_1MV = 0, + VLEVEL_2MV, + VLEVEL_5MV, + + VLEVEL_10MV, + VLEVEL_20MV, + VLEVEL_50MV, + + VLEVEL_100MV, + VLEVEL_200MV, + VLEVEL_500MV, + + VLEVEL_1V, + VLEVEL_2V, + VLEVEL_5V, + + VLEVEL_10V, + VLEVEL_20V, + } E_VOLTAGEBASE_LEVEL; + + typedef struct _measure_param { + float value; + int unit; + }MeasureParam; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + + typedef struct _UnitParam { + char Type; //λͣTimeFreqȡ嶨ĵ + char Scale; //knpMȡ嶨ĵ + }UnitParam; + + //@brief : ֵ + //@remark: 4Byte align -> 8Bytes + typedef struct _MeaValue { + float Value; + UnitParam Unit; + char IsValid; //ǷЧ 0 ʾЧ 1ʾЧ + char IsExist; //Ƿڡ 0 ʾڣ 1ʾڡ + }MeaValue; + + //@brief : ݰͨö塣 + //@remark: + typedef enum _EMeaParam { + MP_MAX = 0, //ֵ + MP_MIN, //Сֵ + MP_HIGH, //High(Top)-ߵƽ(ֵ) + MP_MIDDLE, //Middle-мֵ + MP_LOW, //Low(Bottom) - ͵ƽ(׶ֵ) + + MP_PKPK, //VPP-ֵ + MP_AMP, //Сֵ + MP_MEAN, //ƽֵ + MP_CYCMEAN, // + MP_RMS, // + + MP_CYCRMS, //ھֵ + MP_AREA, // + MP_CYCAREA, // + MP_OVERSHOOT,// + MP_PRESHOOT, //Ԥ + + MP_PERIOD, // + MP_FREQ, //Ƶ + MP_RISE_TIME,//ʱ + MP_FALL_TIME,//½ʱ + MP_PWIDTH, // + + MP_NWIDTH, // + MP_PDUTY, //ռձ + MP_NDUTY, //ռձ + MP_RISEDELAY,//ʱ + MP_FALLDELAY,//ʱ + + MP_PHASE, //λ + MP_FRR, // + MP_FRF, + MP_FFR, + MP_FFF, + + MP_LRF, + MP_LRR, + MP_LFR, + MP_LFF, + + MP_BURST_WIDTH, //ͻ + + // + //reserve section + // ²׷ + // + // + //̶λ50 + MP_MAX_COUNT = 50, + }EMeaParam; + +#ifdef __cplusplus + } + namespace uci { + using namespace comAPICommon; + namespace cb = comAPICommon;//comAPICommon alias + } +#endif + +#endif // dso_base_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/3d/3d968320fdf3c624599b02a7d53b55a5496f0ab6.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/3d/3d968320fdf3c624599b02a7d53b55a5496f0ab6.svn-base new file mode 100644 index 0000000..36d7a45 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/3d/3d968320fdf3c624599b02a7d53b55a5496f0ab6.svn-base @@ -0,0 +1,7 @@ +::This is driver uninstaller for DSO USB driver +::DriverApp.exe /? for help message + +DriverApp.exe /u /d /c + +@echo off +::pause \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/40/408e37768d92eabfeb7ced0cfb73137651df3097.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/40/408e37768d92eabfeb7ced0cfb73137651df3097.svn-base new file mode 100644 index 0000000..ae41972 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/40/408e37768d92eabfeb7ced0cfb73137651df3097.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/43/43c047f83e62b7950eda5f7709db41bcbc19eb1e.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/43/43c047f83e62b7950eda5f7709db41bcbc19eb1e.svn-base new file mode 100644 index 0000000..f5f2daf --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/43/43c047f83e62b7950eda5f7709db41bcbc19eb1e.svn-base @@ -0,0 +1,15 @@ +ʹãȰװ +driver\DriverPack_Libusb\Installer.batļղ谴ռɡ + +ȻֱӴexamples\UCIDemoProjʾ̣УȻȶ +ͶӦЭĵϤ򵥵ָͨ + +鿴UCIDemoProjԴļȡ뼶Ŀʾ + +Ŀ¼˵ + ĵ + װ + ļ + VCVBC#CVILabViewʾ̡ + UCIӿڿ⣨CC#VBӿڰ汾 + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/44/4402562b304e0b0fb35a553df7ceb9f85f9cfc82.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/44/4402562b304e0b0fb35a553df7ceb9f85f9cfc82.svn-base new file mode 100644 index 0000000..24f87f1 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/44/4402562b304e0b0fb35a553df7ceb9f85f9cfc82.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/45/4597d3634e1ca9c26a16835d597df12f7ff701f1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/45/4597d3634e1ca9c26a16835d597df12f7ff701f1.svn-base new file mode 100644 index 0000000..2fca6f6 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/45/4597d3634e1ca9c26a16835d597df12f7ff701f1.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/49/49a2fd8db9f4cf5efe6bd86ddf074a6348ffd188.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/49/49a2fd8db9f4cf5efe6bd86ddf074a6348ffd188.svn-base new file mode 100644 index 0000000..9de718e Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/49/49a2fd8db9f4cf5efe6bd86ddf074a6348ffd188.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/4d/4d31ef8fc89669d8e958b3014b81b072beba43de.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/4d/4d31ef8fc89669d8e958b3014b81b072beba43de.svn-base new file mode 100644 index 0000000..8dc145c Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/4d/4d31ef8fc89669d8e958b3014b81b072beba43de.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/50/50273796eb650f8419611d50a280f00eaaf49237.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/50/50273796eb650f8419611d50a280f00eaaf49237.svn-base new file mode 100644 index 0000000..6ba6079 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/50/50273796eb650f8419611d50a280f00eaaf49237.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/50/509ea528995334feaa346575671aca78abae4f35.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/50/509ea528995334feaa346575671aca78abae4f35.svn-base new file mode 100644 index 0000000..c3389ff Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/50/509ea528995334feaa346575671aca78abae4f35.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/52/521644f9bd2fa1aa82a5998b02349489fe28ffb6.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/52/521644f9bd2fa1aa82a5998b02349489fe28ffb6.svn-base new file mode 100644 index 0000000..e17e640 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/52/521644f9bd2fa1aa82a5998b02349489fe28ffb6.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/54/54df06d9304b8b643ceb14db4e807112d1573490.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/54/54df06d9304b8b643ceb14db4e807112d1573490.svn-base new file mode 100644 index 0000000..049245f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/54/54df06d9304b8b643ceb14db4e807112d1573490.svn-base @@ -0,0 +1,6 @@ + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/55/55c27d1cdc09da9c1f0096555dc29548324e7280.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/55/55c27d1cdc09da9c1f0096555dc29548324e7280.svn-base new file mode 100644 index 0000000..8a2ab56 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/55/55c27d1cdc09da9c1f0096555dc29548324e7280.svn-base @@ -0,0 +1,102 @@ + + + + + Debug + AnyCPU + {B6ED883C-BE9E-46F0-B08D-21F09D16CFB4} + Exe + Properties + SimpleIO + SimpleIO + v4.5 + 512 + 发布\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + ..\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + lib\ucics.dll + + + + + + + True + True + Settings.settings + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + False + Microsoft .NET Framework 4.5 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/59/5976d9bc168ac06b5bbf7fba1c5ab8d7d4bff9d1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/59/5976d9bc168ac06b5bbf7fba1c5ab8d7d4bff9d1.svn-base new file mode 100644 index 0000000..0490aed Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/59/5976d9bc168ac06b5bbf7fba1c5ab8d7d4bff9d1.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5b6e5a45cc679b38ea110abcc2954353b221b6c1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5b6e5a45cc679b38ea110abcc2954353b221b6c1.svn-base new file mode 100644 index 0000000..8ac829d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5b6e5a45cc679b38ea110abcc2954353b221b6c1.svn-base @@ -0,0 +1,6 @@ +::This is driver installer for libusb +::DriverApp.exe /? for help message + +DriverApp.exe /f /c +@echo off +::pause \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5ba01b87bfcbce529b021794ee6f373120f0cbb3.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5ba01b87bfcbce529b021794ee6f373120f0cbb3.svn-base new file mode 100644 index 0000000..2608c99 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5ba01b87bfcbce529b021794ee6f373120f0cbb3.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5bb79d1d2b82ab9d9d6dd66f7e9ed28b76c26aa1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5bb79d1d2b82ab9d9d6dd66f7e9ed28b76c26aa1.svn-base new file mode 100644 index 0000000..a8eb338 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5b/5bb79d1d2b82ab9d9d6dd66f7e9ed28b76c26aa1.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5f/5fbfa7581963acef439c8318fcf7ee5a1b6252e7.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5f/5fbfa7581963acef439c8318fcf7ee5a1b6252e7.svn-base new file mode 100644 index 0000000..69aacd4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/5f/5fbfa7581963acef439c8318fcf7ee5a1b6252e7.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/60/609f8ab6dd26594fa33b27d17d45e9f04656d510.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/60/609f8ab6dd26594fa33b27d17d45e9f04656d510.svn-base new file mode 100644 index 0000000..d45b135 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/60/609f8ab6dd26594fa33b27d17d45e9f04656d510.svn-base @@ -0,0 +1,49 @@ + +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Windows ͷųʹõ +#endif + +#define _CRT_SECURE_NO_WARNINGS + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +// ر MFC ijЩɷĺԵľϢ +#define _AFX_ALL_WARNINGS + +#include // MFC ͱ׼ +#include // MFC չ + + +#include // MFC Զ + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC Internet Explorer 4 ؼ֧ +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC Windows ؼ֧ +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // Ϳؼ MFC ֧ + +#include "resource.h" + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + +#include \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/63/63001a2d084e423fee717cfc0d9166e4609b9bae.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/63/63001a2d084e423fee717cfc0d9166e4609b9bae.svn-base new file mode 100644 index 0000000..d69b471 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/63/63001a2d084e423fee717cfc0d9166e4609b9bae.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6a/6ad1d72d4907ee820475ea1ac8e7450fd7a9a9c4.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6a/6ad1d72d4907ee820475ea1ac8e7450fd7a9a9c4.svn-base new file mode 100644 index 0000000..5b80dc3 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6a/6ad1d72d4907ee820475ea1ac8e7450fd7a9a9c4.svn-base @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6b/6b94e0ae58330195aa4cdc08e5b5004f04d02386.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6b/6b94e0ae58330195aa4cdc08e5b5004f04d02386.svn-base new file mode 100644 index 0000000..140539b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6b/6b94e0ae58330195aa4cdc08e5b5004f04d02386.svn-base @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleUCI", "SimpleUCI.vcxproj", "{DA6758AD-C0D6-46D3-813B-4E83712CA7A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Debug|Win32.Build.0 = Debug|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Release|Win32.ActiveCfg = Release|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c18dd8d9e35d09420570b128a69d22e7f7c2491.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c18dd8d9e35d09420570b128a69d22e7f7c2491.svn-base new file mode 100644 index 0000000..51880cc Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c18dd8d9e35d09420570b128a69d22e7f7c2491.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c418fc6d4a6397c54332e52e29311238dc7610c.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c418fc6d4a6397c54332e52e29311238dc7610c.svn-base new file mode 100644 index 0000000..1f51829 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c418fc6d4a6397c54332e52e29311238dc7610c.svn-base @@ -0,0 +1,69 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c7f5fc14851add4e190998fa926c5cf7a8ed065.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c7f5fc14851add4e190998fa926c5cf7a8ed065.svn-base new file mode 100644 index 0000000..4ba8f86 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6c/6c7f5fc14851add4e190998fa926c5cf7a8ed065.svn-base @@ -0,0 +1,178 @@ +/******************************************************************** + created: 2015/04/08 + author: M.Yang + purpose: ṩUTG2000A&UTG7000źԴض + *********************************************************************/ + +#ifndef UTG2025Def_h__ +#define UTG2025Def_h__ + +#ifdef __cplusplus +namespace SG62_25A { +#endif + //@brief : UTG2000A&UTG7000źԴ + typedef enum _ParamNo { + Invalid_Cmd = -1, + //@brief : ǰģʽ + CurMode = 6, + //@brief : Ⲩģʽ + ArbPlayMode = 7, + //@brief : + WaveType = 8, + //@brief : Ƶ + Freq = 9, + //@brief : + Period = 10, + //@brief : -ֵ + AmpVpp = 11, + //@brief : -Чֵ + AmpVrms = 12, + //@brief : - + AmpDbm = 13, + //@brief : ֱƫ + DCOffset = 14, + //@brief : ߵƽ + High = 15, + //@brief : ͵ƽ + Low = 16, + //@brief : λ + Phase = 17, + //@brief : ռձ + DutyCycle = 18, + //@brief : Գƶ + Symmetry = 19, + //@brief : + PulseWidth = 20, + //@brief : ʱ + PulseRisingTime = 21, + //@brief : ½ʱ + PulseFallingTime = 22, + //@brief : + ArbSampleRate = 23, + //@brief : ARBļ + ArbName = 24, + //@brief : + ArbLength = 25, + + + //@brief : + ModulateType = 40, + //@brief : Ƶ + ModulateFreq = 28, + //@brief : Դ + ModulateSource = 29, + //@brief : Ʋ + ModulateShape = 30, + //@brief : + ModulateOnOff = 31, + //@brief : + ModulateAMDeepth = 32, + //@brief : Ƶƫ + ModulateFMFreqDev = 33, + //@brief : ƫ + ModulatePMPhaseDev = 34, + //@brief : ԾƵ + ModulateFSK_HopFreq = 35, + //@brief : + ModulateFSKRate = 36, + //@brief : Ƽ-λ + ModulatePSKPhase = 37, + //@brief : ƵƼ-زƵ + ModulateFSK_CarrierFreq = 38, + //@brief : -ռձƫ + ModulatePWM_DutyDev = 39, + + //@brief : ɨƵ-ʼƵ + SweepStartFreq = 47, + //@brief : ɨƵ-ֹͣƵ + SweepStopFreq = 48, + //@brief : ɨƵ-ɨʱ + SweepTime = 49, + //@brief : ɨƵ- + SweepType = 50, + + //@brief : лƵ÷ʽ-Ƶʻ + Wave_Freq_Or_Period = 51, + //@brief : л÷ʽ-Ȼ߸ߵ͵ƽ + Wave_Amp_Or_HighLow = 52, + //@brief : лͬķʾλ + Wave_Amp_Unit = 53, + + //@brief : 崮 - ʼλ + BurstStartPhase = 57, + //@brief : 崮 - ⧷ + BurstPeriod = 58, + //@brief : 崮 - ѭ + BurstCycleCount = 59, + //@brief : 崮 - ſ- + BurstPolarity = 60, + //@brief : 崮 - + BurstType = 61, + + //@brief : Դ + TriggerSource = 68, + //@brief : + SyncType = 69, + //@brief : + TriggerEdge = 70, + //@brief : + TriggerOnOff = 71, + + //@brief : CH1 ͨʹ + OutputEnable = 77, + //@brief : CH2 ͨʹ + OutputEnable2 = 78, + //@brief : + Invert = 79, + //@brief : 迹 + OutputExtRes = 80, + //@brief : + OutputLimit = 81, + //@brief : + OutputLimitHigh = 82, + //@brief : + OutputLimitLow = 83, + //@brief : ͬ + SyncOut = 84, + //@brief : + Couple = 85, + //@brief : IPַ + IPAddrType = 101, + //@brief : IPַ + IPAddr = 102, + //@brief : + IPSubnetMask = 103, + //@brief : + IPGateway = 104, + //@brief : DNS + IPDns = 105, + //@brief : MACַ + Mac = 106, + //@brief : + Language = 107, + //@brief : ʱԴ + ClkSource = 108, + //@brief : + PowerOnParam = 109, + //@brief : + BeepOnOff = 110, + //@brief : ַָ + CharDivideInt = 111, + //@brief : + LoadSettting = 112, + //@brief : + SaveSetting = 113, + //@brief : + Backlight = 114, + //@brief : + About = 115, + //@brief : ʱ + ClkOut = 116 + }ParamNo; + +#ifdef __cplusplus +} +#endif + + +#endif // UTG2025Def_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6d/6d51b3aa286b86e52fd7cb2beea54cd9910388fb.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6d/6d51b3aa286b86e52fd7cb2beea54cd9910388fb.svn-base new file mode 100644 index 0000000..ae5c5b7 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6d/6d51b3aa286b86e52fd7cb2beea54cd9910388fb.svn-base @@ -0,0 +1,26 @@ +C# + C#ƽ̨ʾ +VC\UCIDEMO\UCI_DEMO.exe + Դ빤UCIDemoProjıij + óUCIͨŽӿڵʾͲԳ ԶĵָͲĽӿӡ + +VC\SimpleUCI + Ǽ򵥵UCIӿڵʾ̣ʾCӿںC++ֽӿʹá + +VB\UCIDemoVBProj.zip + Ǽ򵥵VBӿʹõʾ̡ + +CVI + ʹCVIʾ + +UCI-Labview11.0 + LabViewƽ̨µʾ + +LabView-UCI + ǽµLabViewƽ̨µʹýӿںʾ + +Ҫѡʵƽ̨жο + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6f0a2c742f2250701f0ecc12b96a169c434b7e6e.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6f0a2c742f2250701f0ecc12b96a169c434b7e6e.svn-base new file mode 100644 index 0000000..14a30f5 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6f0a2c742f2250701f0ecc12b96a169c434b7e6e.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6fb25c24909fb333ba136698f80d0dff632688c9.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6fb25c24909fb333ba136698f80d0dff632688c9.svn-base new file mode 100644 index 0000000..9484efb --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6fb25c24909fb333ba136698f80d0dff632688c9.svn-base @@ -0,0 +1,41 @@ +// SimpleUCI.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" +#include "SimpleUCI.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// ΨһӦó + +CWinApp theApp; + +using namespace std; + +int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) +{ + int nRetCode = 0; + + setlocale(LC_ALL, "CHS"); + + // ʼ MFC ʧʱʾ + if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) + { + // TODO: ĴԷҪ + _tprintf(_T(": MFC ʼʧ\n")); + nRetCode = 1; + } + else + { + // TODO: ڴ˴ΪӦóΪд롣 + + _main(); + + system("pause"); + } + + return nRetCode; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6ff45cd58dd816a11abd7ccf06481c5a8608fa6a.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6ff45cd58dd816a11abd7ccf06481c5a8608fa6a.svn-base new file mode 100644 index 0000000..4428f0e Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/6f/6ff45cd58dd816a11abd7ccf06481c5a8608fa6a.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/71/7173460ac6901940dfedf7d6aee05ea11eb61e46.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/71/7173460ac6901940dfedf7d6aee05ea11eb61e46.svn-base new file mode 100644 index 0000000..b10912d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/71/7173460ac6901940dfedf7d6aee05ea11eb61e46.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/72/727adf094a16a1c3c3b4559e68eddac70261c677.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/72/727adf094a16a1c3c3b4559e68eddac70261c677.svn-base new file mode 100644 index 0000000..f22d631 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/72/727adf094a16a1c3c3b4559e68eddac70261c677.svn-base @@ -0,0 +1,210 @@ +#include "main.h" + +//============================================================================== +// +// Title: UCIDEMO +// Purpose: A short description of the application. +// +// Created on: 2016/10/27 at 14:20:19 by admin. +// Copyright: . All Rights Reserved. +// +//============================================================================== + +//============================================================================== +// Include files + +#include +#include +#include +#include "UCIDEMO.h" +#include "toolbox.h" +#include "include\uci.h" +#include "include\dso_base.h" +#include "include\unit.h" +//============================================================================== +// Constants + +//============================================================================== +// Types + +//============================================================================== +// Static global variables + +static int panelHandle; + +static u_session g_session = INVALID_SESSION; + +typedef struct _UCIParams{ + u_session Session; + MeaValue Params[50]; +}UCIParams; + +static UCIParams g_UCIParams; +//============================================================================== +// Static functions + +//============================================================================== +// Global variables + +//============================================================================== +// Global functions +int HandleResult(char* tips, u_status r){ + if(UCIERR(r)) + printf("%s : r = %d, %s\n", tips == NULL ? "--" : tips, r, uci_GetLastError()); + return r; +} + +int OpenDevice(){ + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 +// u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + u_status r = HandleResult( + "Open devcie", + uci_OpenX("[C:DSO][D:UPO2000CS][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x3][CFG:3]", 2000) + ); + if(UCISUCCESS(r)) + g_UCIParams.Session = (u_session)r; + return r; +} + +void InitMeasure(){ + u_status r = 0; + + if(g_UCIParams.Session == INVALID_SESSION) { + printf("please open device first!\n"); + return; + } + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + //u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + r = HandleResult( + "Enabel Measure", + uci_FormatWrite(g_UCIParams.Session, 1000, "mea@ALL:1;") + ); + + r = HandleResult( + "Switch to measure CH1", + uci_FormatWrite(g_UCIParams.Session, 1000, "mea@src:0;") + ); +} + +/// HIFN The main entry-point function. +int main (int argc, char *argv[]) +{ + int error = 0; + + + /* initialize and load resources */ + nullChk (InitCVIRTE (0, argv, 0)); + errChk (panelHandle = LoadPanel (0, "UCIDEMO.uir", PANEL)); + + g_UCIParams.Session = INVALID_SESSION; + memset(g_UCIParams.Params, 0, sizeof(g_UCIParams.Params)); + + if(OpenDevice() >= 0) + InitMeasure(); + + /* display the panel and run the user interface */ + errChk (DisplayPanel (panelHandle)); + errChk (RunUserInterface ()); +Error: + /* clean up */ + DiscardPanel (panelHandle); + return 0; +} + +//============================================================================== +// UI callback function prototypes + +/// HIFN Exit when the user dismisses the panel. +int CVICALLBACK panelCB (int panel, int event, void *callbackData, + int eventData1, int eventData2) +{ + if (event == EVENT_CLOSE) + QuitUserInterface (0); + return 0; +} + +int ReadMeaParams(void){ + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 +// u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, +// u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + return HandleResult( + "Read measure result " , + uci_ReadX(g_UCIParams.Session, "mea:all?;", 1000, (u_byte*)g_UCIParams.Params, sizeof(g_UCIParams.Params)) + ); +} + +MeaValue* GetParam(EMeaParam id){ + return &g_UCIParams.Params[id]; +} + +void ShowMeaParam(char* name, EMeaParam id){ + MeaValue* p = NULL; + if(name == NULL) + return; + + p = GetParam(id); + + if(p->IsExist == 0) + printf("%s = Not exist\n", name); + else{ + if(p->IsValid == 1){ + printf("%s = %f\n",name, p->Value); + }else{ + printf("%s = --\n", name); + } + } +} + +int CVICALLBACK _Read (int panel, int control, int event, + void *callbackData, int eventData1, int eventData2) +{ + switch (event) + { + case EVENT_COMMIT: + if(ReadMeaParams() >=0 ){ + ShowMeaParam("FREQ", MP_FREQ); + ShowMeaParam("MAX", MP_MAX); + ShowMeaParam("AMP", MP_AMP); + } + // _numFreq = g_UCIParams.Params[MP_FREQ].Value; + break; + } + return 0; +} + +int CVICALLBACK _timer (int panel, int control, int event, + void *callbackData, int eventData1, int eventData2) +{ + switch (event) + { + case EVENT_TIMER_TICK: + if(ReadMeaParams() >=0 ){ + ShowMeaParam("FREQ", MP_FREQ); + ShowMeaParam("MAX", MP_MAX); + ShowMeaParam("AMP", MP_AMP); + } + break; + } + return 0; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/74/743f48c19b64bdf03e033ad28b8189eefcc941d1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/74/743f48c19b64bdf03e033ad28b8189eefcc941d1.svn-base new file mode 100644 index 0000000..e4a7199 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/74/743f48c19b64bdf03e033ad28b8189eefcc941d1.svn-base @@ -0,0 +1,69 @@ +//Microsoft Visual C++ ɵԴű +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE 2 Դɡ +// +#include "afxres.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +LANGUAGE 4, 2 +#pragma code_page(936) + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// ַ +// + +STRINGTABLE +BEGIN + IDS_APP_TITLE "SimpleUCI" +END + +#endif +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE 3 Դɡ +// +#ifndef _AFXDLL +#include "afxres.rc" +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // APSTUDIO_INVOKED diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/77/7740d32b1386898544bf70e7e87a4f990d258542.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/77/7740d32b1386898544bf70e7e87a4f990d258542.svn-base new file mode 100644 index 0000000..8c7d324 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/77/7740d32b1386898544bf70e7e87a4f990d258542.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/7c/7c337f370bcb164e7f957eac9e091d5d9a18c7fc.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/7c/7c337f370bcb164e7f957eac9e091d5d9a18c7fc.svn-base new file mode 100644 index 0000000..06d95f4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/7c/7c337f370bcb164e7f957eac9e091d5d9a18c7fc.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/7d/7d65108ce771ab9925ff41a6d572319a96856474.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/7d/7d65108ce771ab9925ff41a6d572319a96856474.svn-base new file mode 100644 index 0000000..2e70915 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/7d/7d65108ce771ab9925ff41a6d572319a96856474.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/83/8363f2088d5c90154967f4aa2273b07a2a68a28a.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/83/8363f2088d5c90154967f4aa2273b07a2a68a28a.svn-base new file mode 100644 index 0000000..0bdd5dd Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/83/8363f2088d5c90154967f4aa2273b07a2a68a28a.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/85/85a9239a5ce55c46eb1e8f4ba9cc4c852b8f15d8.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/85/85a9239a5ce55c46eb1e8f4ba9cc4c852b8f15d8.svn-base new file mode 100644 index 0000000..5e04f7d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/85/85a9239a5ce55c46eb1e8f4ba9cc4c852b8f15d8.svn-base @@ -0,0 +1,903 @@ +#ifndef _DSOCOM_API_COMMON_DEF_H_201212281614 +#define _DSOCOM_API_COMMON_DEF_H_201212281614 + +#include "dso_base.h" + +#ifdef __cplusplus +namespace comApi +{ + using namespace comAPICommon; +#endif + //λ +#ifdef __cplusplus + namespace Units + { +#endif + const int UNIT_NULL = 0; //add by yzz + const int UNIT_PS = 1; //add by yzz + const int UNIT_NS = 2; + const int UNIT_US = 3; + const int UNIT_MS = 4; + const int UNIT_S = 5; + const int UNIT_KS = 6; + + const int UNIT_nVS = 7; + const int UNIT_uVS = 8; + const int UNIT_mVS = 9 ; + + const int UNIT_PER = 10; + + const int UNIT_UV = 11; + const int UNIT_MV = 12; + const int UNIT_V = 13; + const int UNIT_KV = 14; + + const int UNIT_pHZ = 18; + const int UNIT_nHZ = 19; + const int UNIT_uHZ =20; + const int UNIT_mHZ = 21; + const int UNIT_HZ = 22; + const int UNIT_KHZ = 23; + const int UNIT_MHZ = 24; + const int UNIT_GHZ = 25; + + //const int UNIT_VV = 52; //201452311:56:55޸ + const int UNIT_mVV = 52; + const int UNIT_VV = 53; + const int UNIT_KVV = 54; + + const int UNIT_mDB = 80; // add by yzz + const int UNIT_DB = 81; + const int UNIT_KDB = 82; // add by yzz +#ifdef __cplusplus + } +#endif + +#pragma region + enum DataCMD + { + Invalid_Data_CMD = -1, + //get data cmd + GET_DISPLAY_DATA = 150, //get ch1, ch2, math, ref a/b data + GET_CH1_DISPLAY_DATA, //get ch1 display data: + GET_CH1_ORIGIN_DATA, //get ch1 original data + GET_CH2_DISPLAY_DATA, //get ch2 display data + GET_CH2_ORIGIN_DATA, //get ch2 original data + GET_CH3_DISPLAY_DATA, + GET_CH3_ORIGIN_DATA, + GET_CH4_DISPLAY_DATA, + GET_CH4_ORIGIN_DATA, + + GET_MATH_DATA = 200, //get math data + GET_REF_A_DATA, //get ref A data + GET_REF_B_DATA, //get ref B data + + //[Notice] Get_Data_CMD_END ָ DataCMD һ + Get_Data_CMD_END = GET_REF_B_DATA, + }; + + /* Command Type */ + typedef enum _control_cmd{ + Invalid_Control_CMD = -1, + + CMD_GET_DSO_TYPE = 0, + + //special function cmd + LOCK_DSO_KEYPAD, //lock dso keypad: if set this cmd, the dso's keypad will not work + UNLOCK_DSO_KEYPAD, //unlock dso keypad: if set this cmd, the dso's keypad will work normally + SET_PROCSTATE, //PROC_STATE: control run/stop + GET_PROCSTATE, //PROC_STATE: get run/stop state + SET_AUTOSET, //set dso to do auto set + SET_TRIG_FORCE, //set dso to be force trigger state + SET_SINGLE, + SET_COARSE, + SET_PRTSC, //set dso to do print screen + GET_BITMAP_FILENAME, + GET_BITMAP_FILEDATA, + + //@brief : ָ + SET_KEY = 20, + //@brief : ѯָ + GET_KEY, + //@brief : ȡѹĻ + GET_SCREEN_SHOT, + //@brief : + GET_DEV_CONFIG, + //@brief : д + SET_DEV_CONFIG, + //@brief : ѯ豸ʾ + GET_IDN, + //@brief : ȡЭ汾 + //@remark: + GET_CVER, + + GET_SCREEN_INFO = 50, //SCREEN_INFO + GET_USB_CONNECTION_STATE, //short 1: usb connection state is ok; other: usb connection state is not ok + GET_CYMOMETER_VALUE, //SignalFreq + GET_CURRENT_ACTIVE_CHANNEL, //short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other + GET_CURRENT_ACTIVE_MENU, //short 0: CH1 menu; 1: CH2 menu; 2: MATH or FFT menu; -1: other menu + GET_CURRENT_MENU_SHOW_STATE,//x short 0: current menu is not display; 1: current menu is display + GET_SAMPLE, //get sample + + SET_TO_ZERO = 100, //set dso to zero state + SET_CH1_VPOS_TO_ZERO, + SET_CH2_VPOS_TO_ZERO, + SET_CH3_VPOS_TO_ZERO, + SET_CH4_VPOS_TO_ZERO, + SET_HPOS_TO_ZERO, + SET_TRIG_TO_ZERO, + + GET_CH1_MEASURE_PARAM = 250,//get ch1 measure parameters + GET_CH2_MEASURE_PARAM, //get ch2 measure parameters + GET_CH3_MEASURE_PARAM, + GET_CH4_MEASURE_PARAM, + GET_MATH_MEASURE_PARAM, //get math measure parameters + + //set/get channel param cmd + SET_CH1_SWITCH = 300, //ChannelSwitch + GET_CH1_SWITCH, //ChannelSwitch + SET_CH1_ATTRIBUTE, //ChannelAttribute + GET_CH1_ATTRIBUTE, //ChannelAttribute + SET_CH1_VPOS, //ChannelVPos + GET_CH1_VPOS, //ChannelVPos + SET_CH1_VLEVEL, //ChannelVLevel + GET_CH1_VLEVEL, //ChannelVLevel + SET_CH1_TIMEBASE, //ChannelTimeBaseر + GET_CH1_TIMEBASE, //ChannelTimeBase + SET_CH1_TRIG_LEVEL, //ChannelTLevel + GET_CH1_TRIG_LEVEL, //ChannelTLevel + SET_CH1_TRIG_POS, //ChannelTPos + GET_CH1_TRIG_POS, //ChannelTPos + + SET_CH2_SWITCH = 350, //ChannelSwitch + GET_CH2_SWITCH, //ChannelSwitch + SET_CH2_ATTRIBUTE, //ChannelAttribute + GET_CH2_ATTRIBUTE, //ChannelAttribute + SET_CH2_VPOS, //ChannelVPos + GET_CH2_VPOS, //ChannelVPos + SET_CH2_VLEVEL, //ChannelVLevel + GET_CH2_VLEVEL, //ChannelVLevel + SET_CH2_TIMEBASE, //ChannelTimeBase + GET_CH2_TIMEBASE, //ChannelTimeBase ر + SET_CH2_TRIG_LEVEL, //ChannelTLevel + GET_CH2_TRIG_LEVEL, //ChannelTLevel + SET_CH2_TRIG_POS, //ChannelTPos + GET_CH2_TRIG_POS, //ChannelTPos + + //math + SET_MATH_SWITCH = 800, //ChannelSwitch + GET_MATH_SWITCH, //ChannelSwitch + SET_MATH_VPOS, //ChannelVPos + GET_MATH_VPOS, //ChannelVPos + SET_MATH_VLEVEL, //ChannelVLevel + GET_MATH_VLEVEL, //ChannelVLevel + SET_FFT_FREQ, //by change timebase + GET_FFT_FREQ, //SignalFreq + SET_MATH_TYPE, //MathType + GET_MATH_TYPE, //MathType + SET_MATH_CONFIG, //MathConfig + GET_MATH_CONFIG, //MathConfig + SET_FFT_CONFIG, //FFTConfig + GET_FFT_CONFIG, //FFTConfig + SET_FILTER_CONFIG, //FilterConfig + GET_FILTER_CONFIG, //FilterConfig + + //acquire + SET_ACQUIRE_CONFIG = 850, //AcquireConfig + GET_ACQUIRE_CONFIG, //AcquireConfig + + //trig menu + SET_TRIG_EDGE_CONFIG = 900, //EdgeTrig + GET_TRIG_EDGE_CONFIG, //EdgeTrig + SET_TRIG_PULSE_CONFIG, //PulseTrig + GET_TRIG_PULSE_CONFIG, //PulseTrig + SET_TRIG_VIDEO_CONFIG, //VideoTrig + GET_TRIG_VIDEO_CONFIG, //VideoTrig + SET_TRIG_SLOPE_CONFIG, //SlopeTrig + GET_TRIG_SLOPE_CONFIG, //SlopeTrig + + //display menu + SET_DISPLAY_CONFIG = 950, //DisplayConfig + GET_DISPLAY_CONFIG, //DisplayConfig + + //measure menu + SET_MEASURE_SOURCE = 1000, //MeasureSrc + GET_MEASURE_SOURCE, //MeasureSrc + SET_MEASURE_ALL_CONFIG, //MeasureAllConfig + GET_MEASURE_ALL_CONFIG, //MeasureAllConfig + SET_MEASUER_PART_CONFIG, //MeasurePartConfig + GET_MEASURE_PART_CONFIG, //MeasurePartConfig + + //cursor menu + SET_CURSOR_CONFIG = 1050, //CursorConfig + GET_CURSOR_CONFIG, //CursorConfig + GET_CURSOR_MEASURE_RESULT, //CurSorMeasureResult + + //storage config + SET_STORAGE_SETTING = 1100, //StorageSetting + GET_STORAGE_SETTING, //StorageSetting + SET_STORAGE_WAVE, //StorageWave + GET_STORAGE_WAVE, //StorageWave + SET_STORAGE_BITMAP, + GET_STORAGE_BITMAP, + + //reference config + SET_REF_A_SWITCH = 1200, //ChannelSwitch + GET_REF_A_SWITCH, //ChannelSwitch + SET_REF_B_SWITCH, //ChannelSwitch + GET_REF_B_SWITCH, //ChannelSwitch + SET_REF_A_VPOS, //ChannelVPos + GET_REF_A_VPOS, //ChannelVPos + SET_REF_A_VLEVEL, //ChannelVLevel + GET_REF_A_VLEVEL, //ChannelVLevel + SET_REF_A_TRIG_POS, //ChannelTPos + GET_REF_A_TRIG_POS, //ChannelTPos + SET_REF_B_VPOS, //ChannelVPos + GET_REF_B_VPOS, //ChannelVPos + SET_REF_B_VLEVEL, //ChannelVLevel + GET_REF_B_VLEVEL, //ChannelVLevel + SET_REF_B_TRIG_POS, //ChannelTPos + GET_REF_B_TRIG_POS, //ChannelTPos + GET_REF_A_TIMEBASE, //ChannelTimeBase + GET_REF_B_TIMEBASE, //ChannelTimeBase + SET_REF_CONFIG, //RefConfig + GET_REF_A_CONFIG, //RefConfig + GET_REF_B_CONFIG, //RefConfig + GET_REFWAVE_EXIST, //short 0:not exist; 1:exist + GET_REFSETTING_EXIST, //short 0:not exist; 1:exist + + //horizon menu + SET_HORIZON_CONFIG = 1300, //HorizonConfig + GET_HORIZON_CONFIG, //HorizonConfig + + //utility + SET_UTILITY_CONFIG = 1400, //UtilityConfig + GET_UTILITY_CONFIG, //UtilityConfig + + //record + SET_RECORD_CONFIG = 1500, //RecordConfig + GET_RECORD_CONFIG, //RecordConfig + + //auto calibrate + SET_SELF_CALIBRATE = 1600, //set dso to be self-calibrate + //product config + SET_RESET_CONFIG = 1700, //set dso config to product config + + //select cursor +// SET_CURSOR_INDEX = 2000, +// GET_CURSOR_INDEX, + }CONTROL_CMD; +#pragma endregion + +#pragma region öֵ + //״̬Ļȡͨ֡ݰ棬ַʽȡ + typedef enum{ + PROC_STOP = 0, + PROC_RUN, + PROC_ARMED = PROC_RUN, + PROC_READY, + PROC_TRIGED, + PROC_AUTO, + PROC_SCAN, + PROC_OVER, + + PROC_RESET, // Add by yzz, for UTD2102CEX + }E_PROC_STATE; + + typedef enum{ + CH_Invalid_ID = -1, + CH_1_ID = 0, + CH_2_ID, + CH_MATH_ID, + CH_REF_A_ID, + CH_REF_B_ID, + CH_MAX_CNT, + }E_CHANNEL_ID; + + /********************************************** + ****************Channel Attribute***************** + ***********************************************/ + typedef enum{ + CH_COUPLING_DC = 0, + CH_COUPLING_AC, + CH_COUPLING_GND, + }CH_ATTR_COUPLING; + + + typedef enum{ + SWITCH_OFF = 0, + SWITCH_ON, + }SWITCH_STATE; + + typedef enum + { + CH_VOLT_SCALE_COARSE = 0, + CH_VOLT_SCALE_FINE, + }CH_VOLT_SCALE; + + + typedef enum{ + CH_PROBE_1X = 0, + CH_PROBE_10X, + CH_PROBE_100X, + CH_PROBE_1000X, + }CH_PROBE; + + //öֵ̽ͷԣ0ࣨ1 + enum ChannelPolarity + { + CH_Polar_Normal = 0, + CH_Polar_Invert, + }; + + /***********************************************/ + /********** vertical system: channel position *********/ + /***********************************************/ + typedef enum{ + CH_VPOS_TOP = 378, + CH_VPOS_BOT = -122, + }E_CH_VPOS_LIMIT; + + /***********************************************/ + /******** vertical system: channel voltage level *******/ + /***********************************************/ + typedef enum{ + ADJUST_DECREASE = -1, + ADJUST_INCREASE = 1, + }E_ADJUST_DIR; + + /*****************************************************************/ + /* horizontal system: channel horizontal position ,ie channel pre-trigger depth */ + /*****************************************************************/ + typedef enum{ + CH_TPOS_LEFT = 0, + CH_TPOS_RIGHT = 700, + }E_CH_TPOS_LIMIT; + + enum E_CH_TriggerLevel_Limit + { + CH_TriggerLevel_Min = -327, + CH_TriggerLevel_Max = 375, + }; + + /***********************************************/ + /***************** math/fft config *****************/ + /***********************************************/ + enum E_MATH_TYPE + { + MATH_TYPE_MATH = 0, + MATH_TYPE_FFT, + + MATH_TYPE_FILTER, //add by yzz + }; + + typedef enum{ + OP_SIGN_ADD = 0, + OP_SIGN_SUB, + OP_SIGN_MULTIPLY, + OP_SIGN_DIVIDE, + }E_MATH_OP_SIGN; + + typedef enum{ + FFT_WIN_RECTANGLE = 0, + FFT_WIN_HANNING, + FFT_WIN_HAMMING, + FFT_WIN_BLACKMAN, + }E_FFT_WINDOW; + + typedef enum{ + FFT_UNIT_VRMS = 0, + FFT_UNIT_DBVRMS, + }E_FFT_UNIT; + + /***********************************************/ + /***************** acquire config *****************/ + /***********************************************/ + enum E_ACQ_MODE + { + ACQ_MODE_NORMAL = 0, + ACQ_MODE_PEAK, + ACQ_MODE_AVERAGE, + }; + + enum E_SAMPLE_MODE + { + SAMPLE_REAL = 0, + SAMPLE_EQUIVALENT, + + SAMPLE_SCAN //add by yzz + }; + + /***********************************************/ + /***************** trigger config *****************/ + /***********************************************/ + typedef enum{ + TRIG_TYPE_EDGE = 0, //: + TRIG_TYPE_NTSC, //: Ƶ + TRIG_TYPE_WIDTH, //: + }E_TRIG_TYPE; + + typedef enum{ + TRIG_CH1 = CH_1_ID, + TRIG_CH2 = CH_2_ID, + TRIG_EXT, + TRIG_EXT_5, //EXT/5 + TRIG_AC_LINE = 4, + TRIG_ALTER, + }E_TRIG_SOURCE; + + typedef enum{ + TRIG_EDGE_RISE = 0, + TRIG_EDGE_FALL, + TRIG_EDGE_RISE_FALL, + }E_TRIG_SLOPE; + + typedef enum{ + TRIG_MODE_AUTO = 0, + TRIG_MODE_NORMAL, + TRIG_MODE_SINGLE, + }E_TRIG_MODE; + + typedef enum{ + TIRG_COUPLING_DC = 0, + TIRG_COUPLING_AC, + TIRG_COUPLING_H_RESTRAIN, //trigger coupling high frequency restrain + TIRG_COUPLING_L_RESTRAIN, //trigger coupling low frequency restrain + }E_TIRG_COUPLING; + + typedef enum{ + PULSE_CONDITION_GT = 0, //pulse condition greater than + PULSE_CONDITION_LT, //pulse condition less than + PULSE_CONDITION_ET, //pulse condition equal to + + PULSE_CONDITION_NO_EQUAL, //pulse not equal to , add by yzz [RESERVE] + }E_PULSE_CONDITION; + + typedef enum{ + PULSE_POLAR_P = 0, + PULSE_POLAR_N, + }E_PULSE_POLAR; + + enum TriggerType_Video_Standard + { + TRIG_Video_PAL = 0, + TRIG_Video_NTSC, + }; + + //Ƶ-ͬʽ(0)ż(1)(2)ָ(3) + enum TriggerType_Video_SyncMode + { + TRIG_Video_SyncMode_Odd = 0, + TRIG_Video_SyncMode_Even, + TRIG_Video_SyncMode_ALL, + TRIG_Video_SyncMode_Specified, + }; + + /***********************************************/ + /***************** display config *****************/ + /***********************************************/ + typedef enum{ + DISPLAY_TYPE_VECTOR = 0, + DISPLAY_TYPE_DOT, + }E_DISPLAY_TYPE; + + + typedef enum{ + FORMAT_YT = 0, + FORMAT_XY, + }E_FORMAT; + + typedef enum{ + DISPLAY_TIME_CLOSED = 0, + DISPLAY_TIME_1S, + DISPLAY_TIME_2S, + DISPLAY_TIME_5S, + DISPLAY_TIME_INFINITE, + }E_DISPLAY_TIME; + + /***********************************************/ + /***************** horizon config *****************/ + /***********************************************/ + typedef enum{ + WIN_TYPE_MAIN = 0, + WIN_TYPE_WINDOW, + }E_WIN_TYPE; + + /***********************************************/ + /***************** utility config *****************/ + /***********************************************/ + typedef enum{ + MENU_DISPLAY_T5S = 0, + MENU_DISPLAY_T10S, + MENU_DISPLAY_T15S, + MENU_DISPLAY_TMANUAL, + }E_MENU_DISPLAY_TIME; + + typedef enum{ + LANGUAGE_ZHCN, // + LANGUAGE_ZHTW, // + LANGUAGE_ENGLISH, //Ӣ + LANGUAGE_ESPANOL, // + LANGUAGE_PORTUGUESE, // + LANGUAGE_FRENCH, // + LANGUAGE_GERMAN, // + LANGUAGE_DUTCH, // + LANGUAGE_RUSSIANS, // + LANGUAGE_Korean, // + }E_LANGUAGE; + + typedef enum{ + SKIN_GREYISH_GREEN = 0, //dzɫ + SKIN_BLUE, //ɫ + SKIN_RED, //ɫ + SKIN_BOTTLE_GREEN, //ɫ + }E_SKIN; + + /***********************************************/ + /***************** storage config *****************/ + /***********************************************/ + typedef enum{ + STORAGE_TYPE_WAVE = 0, + STORAGE_TYPE_SETTING, + }E_STORAGE_TYPE; + + typedef enum{ + STORAGE_MEDIUM_DSO = 0, + STORAGE_MEDIUM_USB, + }E_STORAGE_MEDIUM; + + typedef enum{ + SAVSRC_CH1 = CH_1_ID, + SAVSRC_CH2 = CH_2_ID, + SAVSRC_ALL, + }E_STORAGE_WAVE_SRC_CH; + + typedef enum{ + STORAGE_DEPTH_NORMAL = 0, //ͨ洢 + STORAGE_DEPTH_LONG, //洢 + }E_STORAGE_DEPTH; + + /***********************************************/ + /**************** reference config *****************/ + /***********************************************/ + typedef enum{ + REF_A = 0, + REF_B, + }E_REF_SRC; + + /***********************************************/ + /***************** Cursor config *****************/ + /***********************************************/ + typedef enum{ + CURSOR_TYPE_VOLTAGE = 0, + CURSOR_TYPE_TIME, + CURSOR_TYPE_TRACK, + CURSOR_TYPE_CLOSED, + }E_CURSOR_TYPE; + + typedef enum{ + CURSOR_ID_1 = 0, + CURSOR_ID_2, + CURSOR_ID_MAX, + }E_CURSOR_ID; + + enum Cursor_Measure_Limit + { + Screen_Scale_H_Min = 50, + Screen_Scale_H_Max = 749, + + Screen_Scale_V_Min = 28, + Screen_Scale_V_Max = 228, + }; +#pragma endregion öֵ + +#pragma region ݽṹ + //Ļ + typedef struct _measure_param_packet + { + MeasureParam freq; + MeasureParam period; + MeasureParam risetime; + MeasureParam falltime; + MeasureParam pwidth; + MeasureParam nwidth; + MeasureParam overshoot; + MeasureParam preshoot; + MeasureParam pduty; + MeasureParam nduty; + MeasureParam vmean; + MeasureParam vpp; + MeasureParam vrms; + MeasureParam vtop; + MeasureParam vbase; + MeasureParam vmid; + MeasureParam vmax; + MeasureParam vmin; + MeasureParam vamp; + }MeasureParamPacket; + + // + typedef struct + { + MeasureParam freq; + MeasureParam period; + MeasureParam risetime; + MeasureParam falltime; + MeasureParam pwidth; + MeasureParam nwidth; + MeasureParam overshoot; + MeasureParam preshoot; + MeasureParam pduty; + MeasureParam nduty; + MeasureParam vmean; + MeasureParam vpp; + MeasureParam vrms; + MeasureParam vtop; + MeasureParam vbase; + MeasureParam vmid; + MeasureParam vmax; + MeasureParam vmin; + MeasureParam vamp; + + // + char Reserve[24]; + }MeasureParamPacket_UTD2000CEX; + + // + typedef struct + { + MeasureParam freq; // + MeasureParam period; // + MeasureParam risetime; // + MeasureParam falltime; // + MeasureParam pwidth; // + MeasureParam nwidth; // + MeasureParam overshoot; // + MeasureParam preshoot; // + MeasureParam pduty; // + MeasureParam nduty; // + MeasureParam vmean; // + MeasureParam vpp; // + MeasureParam vrms; // + MeasureParam vtop; // + MeasureParam vbase; // + MeasureParam vmid; // + MeasureParam vmax; // + MeasureParam vmin; // + MeasureParam vamp; // + + // + MeasureParam area; // + MeasureParam cycleArea; // + MeasureParam cycleMean; //ƽֵ + MeasureParam cycleRms; //ھֵ + MeasureParam burstWidth; //ͻ + } MeasureParamPacket_UTD2102CM; + + //cmd: GET_PROCSTATE, SET_PROCSTATE + typedef struct _proc_state{ + //0, PROC_STOP; 1, PROC_RUN; 1, PROC_ARMED; 2, PROC_READY; 3, PROC_TRIGED; 4, PROC_AUTO; 5, PROC_SCAN; 6, PROC_OVER; + short procState; + }PROC_STATE; + + ////////////////////////////////////////////////////////////////////////// + // ϵ + // ͨGET_CH1_DISPLAY_DATAGET_DISPLAY_DATAȡIJݵϵ + // X ֵ0ʼΧǵ + // Y ȡADCΧֵ[0,255] UTD2102CEX ײ28228ΧΪ200 + ////////////////////////////////////////////////////////////////////////// + //cmd: GET_SCREEN_INFO + typedef struct _screen_info{ + short screen_width; //Ļȣֵ + short screen_height; //Ļ߶ȣֵ + short x_grid_count; // + short y_grid_count; // + short x_grid_pixels; //Ԫ + short y_grid_pixels; //Ԫ + short y_min; //ϵy귶Χ[y_min y_max] + short t_min; //ϵx귶Χ[t_min t_max]0ʼ + short y_max; //ϵy귶Χ[y_min y_max] + short t_max; //ϵx귶Χ[t_min t_max]0ʼ + }ScreenInfo; + + /********************************************** + *************** Channel Switch ****************** + ***********************************************/ + typedef struct _channel_switch{ + short ch_switch; + }ChannelSwitch; + + /* channel attribute configuration : cmd = SET_CH1_ATTRIBUTE, GET_CH1_ATTRIBUTE */ + typedef struct _channel_attribute{ + short coupling; //CH_COUPLING + short bwlimited; //SWITCH_STATE + short voltscale; //CH_VOLT_SCALE + short probe; //CH_PROBE + short inverted; //SWITCH_STATE + }ChannelAttribute; + + /* channel attribute configuration : cmd = SET_CH1_ATTRIBUTE, GET_CH1_ATTRIBUTE */ + typedef struct _pre_offset_volt{ + short preOffsetSwitch; //0, STATE_CLOSED; 1, STATE_OPEN + short coarseValue; // + short fineValue; // + short toZero; //0, don't set to zero; 1, set to zero + }PreOffsetVolt; + + typedef struct _channel_vpos{ + short vpos; //[(TOP: 378), (Middle: 128), (BOTTOM: -122)] + }ChannelVPos; + + typedef struct _channel_volt_level{ + short voltLevel; //when set cmd, para: 1 or -1, when get cmd, voltage level value + float voltValue; //ȡ̽ͷΪX1ǵķֵ + short voltUnit; + short IsLimit; + }ChannelVLevel; + + /***********************************************/ + /******** horizontal system: channel time base *******/ + /***********************************************/ + typedef struct _channel_timebase{ + short timeBase; + }ChannelTimeBase; + + typedef struct _channel_tpos{ + short tpos; //[(Left: 0), (Middle: 350), (Right: 700)] + }ChannelTPos; + + /***********************************************/ + /******** tigger system: channel trigger position ******/ + /***********************************************/ + typedef struct _channel_trig_level{ + short trigLevel; //[-375, 0(middle), 375] + float trigValue; + short trigUnit; + short isLimited; + }ChannelTLevel; + + typedef struct _math_type{ + int mathType; + }MathType; + + typedef struct _fft_freq{ + float freqValue; + int freqUnit; + int IsLimit; // == 1,yes; =0, no! + }SignalFreq; + + typedef struct _math_config{ + short mathOpA; + short mathOpB; + short mathOpSign; + }MathConfig; + + typedef struct _fft_config{ + short fftSource; + short fftWindow; + short fftUnit; + }FFTConfig; + + typedef struct _acquire_config{ + short acquireMode; + short averageNum; //2^(averageNum + 1), ie: {(0: 2), (1: 4), (2: 8), (3: 16), (4: 32), (5: 64), (6: 128), (7: 256)} + short sampleMode; + short fastAcquire; + }AcquireConfig; + + typedef struct _trig_config{ + short trigType; + short trigSource; + short trigMode; + short trigCoupling; + }TriggerConfig; + + typedef struct _trig_edge_config{ + TriggerConfig trigConfig; + short trigSlope; + }TrigEdgeConfig; + + typedef struct _trig_pulse_config{ + TriggerConfig trigConfig; + short pulseCondition; + UINT pulseWidth; + short pulsePolar; + }TrigPulseConfig; + + typedef struct _display_config{ + short displayType; + short displayFormat; + short displayTime; + short displayLum; + }DisplayConfig; + + typedef struct _horizon_config{ + short windowType; //E_WIN_TYPE + unsigned int holdOff; //[10, 187500000] + }HorizonConfig; + + typedef struct _utility_config{ + short autoCalibrate; //0, not do auto calibrate; 1, do auto calibrate + short menuDisplayTime; //E_MENU_DISPLAY_TIME + short language; //E_LANGUAGE + short defaultSetting; //0, not do default setting; 1 do default setting + short skin; //E_SKIN + short gridBrightness; //[1, 100] + short sysInfo; //0, not display system info; 1, display system info; + short cymometer; //0: close; 1: open + }UtilityConfig; + + typedef struct _storage_setting{ + short saveType; //STORAGE_TYPE_SETTING + short savePos; //[1, 20] + + short save; //1, save, 0, not save + short recall; //1, recall, 0, not recall + }StorageSetting; + + typedef struct _storage_wave{ + short saveType; //STORAGE_TYPE_WAVE + short saveSource; + short savePos; + short saveMedium; + short saveDepth; + short save; + }StorageWave; + + /***********************************************/ + /***************** measure config *****************/ + /***********************************************/ + typedef struct _measure_config{ + short measureSrc; + }MeasureConfig; + + typedef struct _ref_timebase{ + float ref_TValue; + int ref_Tunit; + }RefTimeBase; + + + typedef struct _ref_config + { + short refSrc; //REF_A, REF_B + short pos; //[1, 20] + short medium; //MEDIUM_DSO, MEDIUM_USB + + short onoff; //1, on; 0, off; + }RefConfig; + + typedef struct _cursor_measure_result{ + MeasureParam Va; + MeasureParam Vb; + MeasureParam deltaV; + MeasureParam TaFa;// when ch1, ch2, Ta; when math channel, Fa; + MeasureParam TbFb;// when ch1, ch2, Tb; when math channel, Fb; + MeasureParam deltaT; + MeasureParam deltaF; + char Reserve[56]; + }CursorMeasureResult; + + typedef struct _cursor_config{ + short cursorType; + short iActiveCursor; + //Ҫӻʶ + short voltCursorPos[CURSOR_ID_MAX];//[28(top), 428(bottom)] + short timeCursorPos[CURSOR_ID_MAX];//[50(left), 749(right)] + short autoCursorPos[CURSOR_ID_MAX];//[51(left), 749(right)] + }CursorConfig; + + + /***********************************************/ + /***************** measure config *****************/ + /***********************************************/ + typedef struct _measure_src + { + short measureSrc; + }MeasureSrc; +#pragma endregion ݽṹ + +#ifdef __cplusplus +} +#endif + +#endif//end of #ifndef _DSOCOM_API_COMMON_DEF_H_201212281614 \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/86/868587e43a15cb974327ffe8b25c0f336dab28c9.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/86/868587e43a15cb974327ffe8b25c0f336dab28c9.svn-base new file mode 100644 index 0000000..10eeb62 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/86/868587e43a15cb974327ffe8b25c0f336dab28c9.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/87/8750b7b6140961d3961fc5bd33ba297fb0c1dcb5.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/87/8750b7b6140961d3961fc5bd33ba297fb0c1dcb5.svn-base new file mode 100644 index 0000000..d770683 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/87/8750b7b6140961d3961fc5bd33ba297fb0c1dcb5.svn-base @@ -0,0 +1,51 @@ +#include "stdafx.h" +#include "File.h" + +bool Files::ReadFile(const CString& _fileName, CString& _content) { + _content.Empty(); + + try { + CFile f(_fileName, CFile::modeRead); + + size_t nBytes = (UINT)f.GetLength(); + size_t nChars = nBytes / sizeof(TCHAR); + + //ļȡƵ + nBytes = f.Read(_content.GetBuffer(nChars), nBytes); + + _content.ReleaseBuffer(nChars); + + } + catch (CFileException* e) { + e->ReportError(); + e->Delete(); + return false; + } + + return true; +} + +void Files::WriteFile(const CString& _fileName, CString& _content) { + try { + CFile f(_fileName, CFile::modeWrite | CFile::modeCreate); + f.Write(_content, _content.GetLength()*sizeof(TCHAR)); + } + catch (CFileException* e) { + e->ReportError(); + e->Delete(); + } +} + +bool Files::WriteAllBytes(const CString& _name, const void* _b, size_t _len, CString* _path) { + try { + CFile f(_name, CFile::modeCreate | CFile::modeWrite); + f.Write(_b, _len); + + if (_path != nullptr) + *_path = f.GetFilePath(); + } catch (CException* e) { + e->ReportError(); + e->Delete(); + } + return true; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/88/88902325faf7546fa686cf50ddb86a6af8048384.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/88/88902325faf7546fa686cf50ddb86a6af8048384.svn-base new file mode 100644 index 0000000..574c3b9 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/88/88902325faf7546fa686cf50ddb86a6af8048384.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/8c/8c8ef10577c12959f1ec57a087fd895f5ce7c443.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/8c/8c8ef10577c12959f1ec57a087fd895f5ce7c443.svn-base new file mode 100644 index 0000000..4c03028 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/8c/8c8ef10577c12959f1ec57a087fd895f5ce7c443.svn-base @@ -0,0 +1,139 @@ + +// UCIDemoProj.cpp : ӦóΪ +// + +#include "stdafx.h" +#include "UCIDemoProj.h" +#include "UCIDemoProjDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CUCIDemoProjApp + +BEGIN_MESSAGE_MAP(CUCIDemoProjApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// CUCIDemoProjApp + +CUCIDemoProjApp::CUCIDemoProjApp() +{ + // ֧ + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: ڴ˴ӹ룬 + // Ҫijʼ InitInstance +} + + +// Ψһһ CUCIDemoProjApp + +CUCIDemoProjApp theApp; + + +// CUCIDemoProjApp ʼ + +BOOL CUCIDemoProjApp::InitInstance() +{ + // һ Windows XP ϵӦó嵥ָҪ + // ʹ ComCtl32.dll 汾 6 ߰汾ÿӻʽ + //Ҫ InitCommonControlsEx() 򣬽޷ڡ + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // ΪҪӦóʹõ + // ؼࡣ + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // shell ԷԻ + // κ shell ͼؼ shell бͼؼ + //CShellManager *pShellManager = new CShellManager; + + // Windows NativeӾԱ MFC ؼ + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // ׼ʼ + // δʹЩܲϣС + // տִļĴСӦƳ + // Ҫضʼ + // ڴ洢õע + // TODO: Ӧʵ޸ĸַ + // ޸Ϊ˾֯ + SetRegistryKey(_T("ӦóɵıӦó")); + m_SystemLange = E_LANG_CHINESE; + LANGID lid = GetSystemDefaultLangID(); + switch ((lid & 0x1ff)) { + case LANG_ENGLISH: + m_SystemLange = E_LANG_ENGLISH; + break; + default: + break; + } + + InitLanguage(m_SystemLange); + + CUCIDemoProjDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: ڴ˷ôʱ + // ȷرնԻĴ + } + else if (nResponse == IDCANCEL) + { + // TODO: ڴ˷ôʱ + // ȡرնԻĴ + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, ": Ի򴴽ʧܣӦóֹ\n"); + TRACE(traceAppMsg, 0, ": ڶԻʹ MFC ؼ޷ #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS\n"); + } + + // ɾ洴 shell +// if (pShellManager != NULL) +// { +// delete pShellManager; +// } + + // ڶԻѹرգԽ FALSE Ա˳Ӧó + // ӦóϢá + return FALSE; +} + +void CUCIDemoProjApp::InitLanguage(ELANGE _lang) { + OSVERSIONINFO ovs; + ovs.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (::GetVersionEx(&ovs)) { + m_IsNewOS = (ovs.dwPlatformId == VER_PLATFORM_WIN32_NT + && ovs.dwMajorVersion >= 6 + && ovs.dwMinorVersion >= 0); + } + + switch (_lang) { + case E_LANG_CHINESE: + if (m_IsNewOS) + SetThreadUILanguage(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED)); + else + SetThreadLocale(MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT)); + break; + case E_LANG_ENGLISH: + if (m_IsNewOS) + SetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); + else + SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); + break; + default: + break; + } +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/91/91445bce3142ad6e3b2228b9ac8d143ddfdbbe00.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/91/91445bce3142ad6e3b2228b9ac8d143ddfdbbe00.svn-base new file mode 100644 index 0000000..7b8372e --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/91/91445bce3142ad6e3b2228b9ac8d143ddfdbbe00.svn-base @@ -0,0 +1,5 @@ +#pragma once + +#include "resource.h" + +void _main(); \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/92/92bd706c6eae54c1d3ad54553b2cd8768021f516.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/92/92bd706c6eae54c1d3ad54553b2cd8768021f516.svn-base new file mode 100644 index 0000000..0ce9639 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/92/92bd706c6eae54c1d3ad54553b2cd8768021f516.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/95/95135db97e27e63168b04e79d4b052fa43aee0e0.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/95/95135db97e27e63168b04e79d4b052fa43aee0e0.svn-base new file mode 100644 index 0000000..3751bc2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/95/95135db97e27e63168b04e79d4b052fa43aee0e0.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/96/960229ddfd52511f270bbe756fa729a05e6158a8.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/96/960229ddfd52511f270bbe756fa729a05e6158a8.svn-base new file mode 100644 index 0000000..7188f01 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/96/960229ddfd52511f270bbe756fa729a05e6158a8.svn-base @@ -0,0 +1,33 @@ +/**************************************************************************/ +/* LabWindows/CVI User Interface Resource (UIR) Include File */ +/* Copyright (c) National Instruments 2016. All Rights Reserved. */ +/* */ +/* WARNING: Do not add to, delete from, or otherwise modify the contents */ +/* of this include file. */ +/**************************************************************************/ + +#include + +#ifdef __cplusplus + extern "C" { +#endif + + /* Panels and Controls: */ + +#define PANEL 1 +#define PANEL_COMMANDBUTTON 2 /* callback function: _Read */ + + + /* Menu Bars, Menus, and Menu Items: */ + + /* (no menu bars in the resource file) */ + + + /* Callback Prototypes: */ + +int CVICALLBACK _Read(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); + + +#ifdef __cplusplus + } +#endif diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/96/96fb770d65491c3c3bb0fc6eb68b5ec8c70bc84e.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/96/96fb770d65491c3c3bb0fc6eb68b5ec8c70bc84e.svn-base new file mode 100644 index 0000000..7caf537 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/96/96fb770d65491c3c3bb0fc6eb68b5ec8c70bc84e.svn-base @@ -0,0 +1,1011 @@ +#include "stdafx.h" +#include "UCIDemoProj.h" +#include "UCIDemoProjDlg.h" +#include "afxdialogex.h" + +#include "File.h" +#include "lib\UPO.h" +#include "lib\UTG4162.h" + +using namespace uci; + +#pragma comment(lib, "lib\\uci.lib") + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#define WM_TCPIP_DISCONNECT (WM_USER+2) +u_session g_curSession = -1; + +// CUCIDemoProjDlg Ի + +DWORD g_di = GetTickCount(); + +void ResetTimer() { + g_di = GetTickCount(); +} + +DWORD GetTimeSpan() { + return GetTickCount() - g_di; +} + +CUCIDemoProjDlg::CUCIDemoProjDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(CUCIDemoProjDlg::IDD, pParent) + , m_Val_Timeout(1000) + , m_IsConnect(false) + , m_Val_BytesToRead(4) + , m_MaxCMDHistoryCount(20) + , m_nConnectAddrPort(0) + , m_cbBoxText(_T("")) { +} + +void CUCIDemoProjDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Control(pDX, IDC_EDIT_MSG, m_Ctrl_Edit_Msg); + DDX_Text(pDX, IDC_EDIT_TIMEOUT, m_Val_Timeout); + DDX_Text(pDX, IDC_EDIT_READ_BYTES, m_Val_BytesToRead); + DDX_Control(pDX, IDC_MFCEDITBROWSE1, m_CtrlFileChoose); + DDX_Control(pDX, IDC_COMBO_CMD, m_cbxCMD); + DDX_Control(pDX, IDC_BTN_WRITE_IN_FILE, m_btnWriteParam_File); + DDX_Control(pDX, IDC_COMBO_DEV_ADDR, m_cbxDevAddr); + DDX_CBString(pDX, IDC_COMBO_CMD, m_cbBoxText); + DDV_MaxChars(pDX, m_cbBoxText, 500); +} + +CUCIDemoProjDlg* CUCIDemoProjDlg::c_object = nullptr; + +BEGIN_MESSAGE_MAP(CUCIDemoProjDlg, CDialogEx) + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_BUTTON_QUERY_NODES, &CUCIDemoProjDlg::OnBnClickedButtonQueryNodes) + ON_BN_CLICKED(IDC_BUTTON_CLEAR, &CUCIDemoProjDlg::OnBnClickedButtonClear) + ON_BN_CLICKED(IDC_BUTTON_OPEN, &CUCIDemoProjDlg::OnBnClickedButtonOpen) + ON_BN_CLICKED(IDC_BTN_WRITE, &CUCIDemoProjDlg::OnBnClickedBtnWrite) + ON_BN_CLICKED(IDC_BTN_READ, &CUCIDemoProjDlg::OnBnClickedBtnRead) + ON_BN_CLICKED(IDC_BUTTON_WRITE_FILE, &CUCIDemoProjDlg::OnBnClickedButtonWriteFile) + ON_BN_CLICKED(IDC_BUTTON_READ_FILE, &CUCIDemoProjDlg::OnBnClickedButtonReadFile) + ON_WM_DESTROY() + ON_BN_CLICKED(IDC_BTN_WRITE_IN_FILE, &CUCIDemoProjDlg::OnBnClickedBtnWriteInFile) + ON_BN_SETFOCUS(IDC_BTN_WRITE_IN_FILE, &CUCIDemoProjDlg::OnBnSetfocusBtnWriteInFile) + ON_MESSAGE(WM_TCPIP_DISCONNECT, &CUCIDemoProjDlg::OnLANDisconnect) +END_MESSAGE_MAP() + +BOOL CUCIDemoProjDlg::OnInitDialog() + +{ + auto r = CDialogEx::OnInitDialog(); + SetIcon(m_hIcon, TRUE); + SetIcon(m_hIcon, FALSE); + + //{{initialize for The tips of widgets; + m_tips.Create(this); + m_tips.SetDelayTime(500); + m_tips.SetTipTextColor(RGB(0, 0, 255)); + m_tips.SetTipBkColor(RGB(255, 255, 255)); + m_tips.Activate(true); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_OPEN), IDC_BUTTON_OPEN); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_QUERY_NODES), IDC_BUTTON_QUERY_NODES); + m_tips.AddTool(GetDlgItem(IDC_EDIT_TIMEOUT), IDC_EDIT_TIMEOUT); + //m_tips.AddTool(GetDlgItem(IDC_EDIT_DEV_ADDR), IDC_EDIT_DEV_ADDR); + //m_tips.AddTool(GetDlgItem(IDC_EDIT_DEV_ADDR), IDC_EDIT_DEV_ADDR); + m_tips.AddTool(GetDlgItem(IDC_COMBO_CMD), IDC_COMBO_CMD); + m_tips.AddTool(GetDlgItem(IDC_MFCEDITBROWSE1), IDC_MFCEDITBROWSE1); + m_tips.AddTool(GetDlgItem(IDC_EDIT_READ_BYTES), IDC_EDIT_READ_BYTES); + m_tips.AddTool(GetDlgItem(IDC_BTN_READ), IDC_BTN_READ); + m_tips.AddTool(GetDlgItem(IDC_BTN_WRITE), IDC_BTN_WRITE); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_WRITE_FILE), IDC_BUTTON_WRITE_FILE); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_READ_FILE), IDC_BUTTON_READ_FILE); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_CLEAR), IDC_BUTTON_CLEAR); + //}} + + //{{Get the file path of saved the history of command + GetAppFolderPath(m_strCMDListPath); + m_strCMDListPath += _T("\\cmd.txt"); + //}} + + //{{Get app configuration + m_Val_Timeout = theApp.GetProfileInt(_T("Params"), _T("Timeout"), 1000); + m_Val_BytesToRead = theApp.GetProfileInt(_T("RParams"), _T("BYTES"), 50); + CString addr = _T("[C:UPO][D:UPO2000CS][T:TCPIP][IP:192.168.1.172][Port:0x1388]"); + addr = theApp.GetProfileString(_T("Connect"), _T("Addr"), addr); + m_COMType = theApp.GetProfileInt(_T("RParams"), _T("COMTYPE"), 50); + //}} + + m_cbxDevAddr.AddString(addr); + m_cbxDevAddr.SetCurSel(0); + + InitUI(); + + LoadCMDList(); + + c_object = this; + + //{{ Config for UCI + ELANGE lang = theApp.GetSystemLange(); + switch (lang) { + case E_LANG_CHINESE: + uci_SetAttribute(INVALID_SESSION, _T("lang:zh-Hans;devchange:1;"), nullptr, 0); + break; + case E_LANG_ENGLISH: + uci_SetAttribute(INVALID_SESSION, _T("lang:en-US;devchange:1;"), nullptr, 0); + break; + default: + break; + } + uci_SetNotify(UCI_MessageProc); + +// m_cbxCMD.ModifyStyle(0, CBS_AUTOHSCROLL); +// auto dwStyle = m_cbxCMD.GetStyle(); +// dwStyle |= CBS_AUTOHSCROLL; +// m_cbxCMD.ModifyStyle(0, dwStyle); +// m_cbxCMD.LimitText(0); + + + //}} + return r; + //return TRUE; // ǽõؼ򷵻 TRUE +} + +void CUCIDemoProjDlg::InitUI() { + //{{UI initialization + CheckDlgButton(IDC_CHECK_LAN, m_COMType & uci::NodeType::LAN); + CheckDlgButton(IDC_CHECK_USB, m_COMType & uci::NodeType::USB); + EnableWidgets(FALSE); + m_btnWriteParam_File.SetDelayFullTextTooltipSet(FALSE); + UpdateData(FALSE); + //} +} + +void CUCIDemoProjDlg::LoadCMDList() { + try { + CStdioFile f(m_strCMDListPath, CFile::modeRead | CFile::typeText); + + CString s; + while (f.ReadString(s) && m_cbxCMD.GetCount() <= m_MaxCMDHistoryCount) { + if (m_cbxCMD.GetCount() == 0) { + m_cbxCMD.AddString(s); + } else { + m_cbxCMD.InsertString(0, s); + } + } + } catch (CException* e) { + m_cbxCMD.AddString(_T("CH:0@SEL;")); + m_cbxCMD.AddString(_T("CH:0@EN:1;")); + m_cbxCMD.AddString(_T("CH:0@vp:128;")); + m_cbxCMD.AddString(_T("trig@pos:25;")); + m_cbxCMD.AddString(_T("math@t:f;")); + e->Delete(); + } +} + +bool CUCIDemoProjDlg::GetAppFolderPath(CString& _strPath) { + TCHAR path[MAX_PATH]; + ZeroMemory(path, sizeof(path)); + auto r = GetModuleFileName(AfxGetInstanceHandle(), path, MAX_PATH); + if (r == 0) { + ASSERT(false); + return false; + } + + CString strAppPath(path); + auto i = strAppPath.ReverseFind(_T('\\')); + if (i == -1) { + ASSERT(false); + return false; + } + + _strPath = strAppPath.Left(i); + //AfxMessageBox(_strPath); + return true; +} + +void CUCIDemoProjDlg::EnableWidgets(BOOL _isConnect) { + GetDlgItem(IDC_BTN_WRITE)->EnableWindow(_isConnect); + GetDlgItem(IDC_BTN_READ)->EnableWindow(_isConnect); + GetDlgItem(IDC_BUTTON_WRITE_FILE)->EnableWindow(_isConnect); + GetDlgItem(IDC_BUTTON_READ_FILE)->EnableWindow(_isConnect); + GetDlgItem(IDC_BTN_WRITE_IN_FILE)->EnableWindow(_isConnect); + //GetDlgItem(IDC_CHECK_WITE_FILE)->EnableWindow(_isConnect); +} + +void CUCIDemoProjDlg::OnPaint() { + if (IsIconic()) { + CPaintDC dc(this); + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + dc.DrawIcon(x, y, m_hIcon); + } else { + CDialogEx::OnPaint(); + } +} + +HCURSOR CUCIDemoProjDlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + +void CUCIDemoProjDlg::GetCMDString(CString& _msg) { + GetDlgItemText(IDC_COMBO_CMD, _msg); +} + +int CUCIDemoProjDlg::UCIWrite(const TCHAR* _cmd, UINT _timeOut) { + WParams wp; + ZeroMemory(&wp, sizeof(wp)); + //You can also use the simple interface "uci_WriteX", defined in uci.h + auto r = uci_Write(g_curSession, uci_CreateWParams(wp, _cmd, _timeOut), nullptr, 0); + if (r >= 0) + RecordCMD(_cmd); + return r; +} + +int CUCIDemoProjDlg::UCIRead(const TCHAR* _cmd, u_byte* _data, u_size _dataLen, UINT _timeOut) { +#if 0 + //You can also use the simple interface "uci_ReadX", defined in uci.h + RParams rp; + auto r = uci_Read(g_curSession, uci_CreateRParams(rp, _cmd, _timeOut, NULL, 0), _data, _dataLen); +#else + auto r = uci_ReadX(g_curSession, _cmd, _timeOut, _data, _dataLen); +#endif + if (r >= 0) + RecordCMD(_cmd); + return r; +} + +int __stdcall CUCIDemoProjDlg::UCI_MessageProc(UCIMSG* _msg) { + if (_msg == nullptr) { + ASSERT(FALSE); + return 0; + } + + switch (_msg->Message) { + case uci::EUCIMSG::UMSG_DEVICE_NOTIFY: + { +#if 1 + //if (c_object->m_DevName.CompareNoCase(CString(_msg->Reserved)) == 0) { + if (c_object->m_IsConnect && g_curSession != Invalid_Session) { + c_object->ShowResult(uci_Close(g_curSession), IDS_TIPS_CLOSE_CONNECT); + c_object->SetWidgetText(IDC_BUTTON_OPEN, IDS_BTN_CONNECT); + c_object->m_IsConnect = false; + } + //} +#endif + } + break; + case uci::EUCIMSG::UMSG_CONNECT_CLOSED: + //TCIPIPӵĶϿ¼ʱ̵߳øýӿڣڴ˽ӿвܸUI + //This event can been invoked when the disconnection of tcpip, and it been call in thread, you can not update UI here; + break; + default: + break; + } + + return 1; +} + +void CUCIDemoProjDlg::Disconnect() { + if (m_IsConnect && g_curSession != Invalid_Session) { + ShowResult(uci_Close(g_curSession), IDS_TIPS_CLOSE_CONNECT); + SetWidgetText(IDC_BUTTON_OPEN, IDS_BTN_CONNECT); + m_IsConnect = false; + } +} + + +//@brief : recode cmd for input history +//@param _msg : +//@return : +//@remarks : +void CUCIDemoProjDlg::RecordCMD(const CString& _msg) { + // Delete all items that begin with the specified string. + int nItem = 0; + while ((nItem = m_cbxCMD.FindString(nItem, _msg)) != CB_ERR) { + m_cbxCMD.DeleteString(nItem); + } + + while (m_cbxCMD.GetCount() > m_MaxCMDHistoryCount) { + m_cbxCMD.DeleteString(m_cbxCMD.GetCount() - 1); + } + + m_cbxCMD.InsertString(0, _msg); + m_cbxCMD.SetWindowText(_msg); +} + +void CUCIDemoProjDlg::ShowResult(int _r, int _idsSOerationString, const TCHAR* _format, ...) +{ + CString msg; + if (_format != nullptr) + { + va_list argptr; + va_start(argptr, _format); + msg.FormatV(_format, argptr); + va_end(argptr); + + } + if (_idsSOerationString != -1) + msg = LoadString(_idsSOerationString) + msg; + + CString str; + if (_r < 0) { + str.Format(_T("\r\n[%s], Error id = 0x%x(hex) , %d(dec);\r\n\t->%s;"), msg, _r, _r, uci_GetLastError()); + } else { + str.Format(_T("\r\n[%s], return = %d, Succeed!, use time = %d ms;\r\n"), msg, _r, GetTimeSpan()); + } + + ASSERT(IsWindow(m_Ctrl_Edit_Msg.GetSafeHwnd())); + int indexEnd = m_Ctrl_Edit_Msg.GetWindowTextLength(), index = indexEnd; + m_Ctrl_Edit_Msg.SetSel(index, indexEnd); + m_Ctrl_Edit_Msg.ReplaceSel(str); +} + +void CUCIDemoProjDlg::AppendTraceMsg(const u_tchar *format, ...) { + CString msg; + va_list argptr; + va_start(argptr, format); + msg.FormatV(format, argptr); + va_end(argptr); + + int indexEnd = m_Ctrl_Edit_Msg.GetWindowTextLength(), index = indexEnd; + m_Ctrl_Edit_Msg.SetSel(index, indexEnd); + m_Ctrl_Edit_Msg.ReplaceSel(msg); +} + +void CUCIDemoProjDlg::OnBnClickedButtonClear() { + m_Ctrl_Edit_Msg.SetWindowText(_T("")); +} + +void CUCIDemoProjDlg::OnBnClickedButtonQueryNodes() { + UpdateData(); + if (m_Val_Timeout == 0) { + AfxMessageBox(IDS_TIPS_TIMEOUT_ZERO); + return; + } + + CWaitCursor wc; + + //*******************************delete device addr list:************************** + ResetTimer(); + while (m_cbxDevAddr.GetCount() > 0) { + m_cbxDevAddr.DeleteString(m_cbxDevAddr.GetCount() - 1); + } + + CString strResult; + //*******************************query devices:************************** + //example1: uci_QueryNodes +#if 0 + QParams qp; + + int pvids[] = { + MakePVID(0x1234, 0x5345), + MakePVID(0x7777, 0x5345), + MakePVID(0x0834, 0x5656), + MakePVID(0x5537, 0x4348), + MakePVID(0xE008, 0x1A86), + MakePVID(0xEA80, 0x10C4), + }; + + int ports[] = { + 4162, + 5000, + }; + + //int type = NodeType::LAN | NodeType::USB; + int type = 0; + if (IsDlgButtonChecked (IDC_CHECK_USB)) + type |= NodeType::USB; + + if (IsDlgButtonChecked(IDC_CHECK_LAN)) + type |= NodeType::LAN; + + if (type == 0) + { + AfxMessageBox(_T("ѡҪѯͨŽӿͣ")); + return; + } + UCI_CreateQParam(qp, type, ports, sizeof(ports) / sizeof(int), pvids, sizeof(pvids) / sizeof(int), nullptr); + + Node nodes[10]; + ZeroMemory(nodes, sizeof(nodes)); + u_size notesCNT = sizeof(nodes) / sizeof(nodes[0]); + + int r = uci_QueryNodes(&qp, nodes, ¬esCNT, m_Val_Timeout); +#else + //example2: uci_QueryNodesX + // + CString strQuery; + + //int type = NodeType::LAN | NodeType::USB; + int type = 0; + if (IsDlgButtonChecked(IDC_CHECK_USB)) { + type |= NodeType::USB; + //+ DSO,SG,POWER + strQuery.AppendFormat(_T("USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348")); + //+ DM(HID) + strQuery.AppendFormat(_T(",0xE008&0x1A86,0xEA80&0x10C4;")); + } + + if (IsDlgButtonChecked(IDC_CHECK_LAN)) { + type |= NodeType::LAN; + //8000:UTG2000A series; 5000: UPO2000S/UPO7000Z series; 4162 : UTG4000A series + strQuery.AppendFormat(_T("LAN:5000,4162,8000,18191;")); + } + m_COMType = type; + + ZeroMemory(m_Nodes, sizeof(m_Nodes)); + u_size notesCNT = sizeof(m_Nodes) / sizeof(m_Nodes[0]); + + int r = uci_QueryNodesX(strQuery, m_Nodes, notesCNT, m_Val_Timeout); +#endif + + if (r < 0) { + ShowResult(r, IDS_QUERY_DEVICES_FAILED);// Error to query nodes + return; + } + + if (notesCNT == 0) { + AfxMessageBox(IDS_TIPS_NOT_FOUND_ANY_DEVICES); + return; + } + + //*******************************show result:************************** + notesCNT = r; + for (size_t i = 0; i < notesCNT; i++) { + switch (m_Nodes[i].Type) { + case NodeType::LAN: + { + auto n = &m_Nodes[i].LAN; + TRACE(_T("\r\nIP : %s, Port : %d"), CString(n->IP), n->Port); + strResult.AppendFormat(_T("\r\nIP : %s, Port : %d"), CString(n->IP), n->Port); + break; + } + case NodeType::USB: + { + auto n = &m_Nodes[i].USB; + TRACE(_T("\r\nPID : 0x%x, VID : 0x%x, Addr : %d"), n->PID, n->VID, n->Addr); + strResult.AppendFormat(_T("\r\nPID : %d, VID : %d, Addr : %d"), n->PID, n->VID, n->Addr); + break; + } + default: + ASSERT(FALSE); + break; + } + + strResult.AppendFormat(_T(",%s,SN:%s, status = %d, IDN = %s"), + m_Nodes[i].Name, m_Nodes[i].SN, m_Nodes[i].Status, m_Nodes[i].IDN); + strResult.AppendFormat(_T("\r\n\t->UCI Addr: %s"), m_Nodes[i].UCIAddr); + + m_cbxDevAddr.AddString(m_Nodes[i].UCIAddr); + } + + if (!strResult.IsEmpty ()) + AppendTraceMsg(_T("\r\n--------QUERY Result------------%s"), strResult); + ShowResult(r, -1, _T("Query")); + + AppendTraceMsg(_T("\r\n--------------------")); + AppendTraceMsg(LoadString (IDS_TIPS_COPY_UCI_ADDR)); + AppendTraceMsg(_T("\r\n--------------------\r\n")); + + //SetDlgItemText(IDC_EDIT_DEV_ADDR, nodes[0].UCIAddr); + m_cbxDevAddr.SetWindowText(m_Nodes[0].UCIAddr); +} + +LRESULT AFX_MSG_CALL CUCIDemoProjDlg::OnLANDisconnect(WPARAM wParam, LPARAM lParam) { + Disconnect(); + return 1; +} + +void CUCIDemoProjDlg::OnBnClickedButtonOpen() { + ResetTimer(); + + //{UI + if (m_IsConnect && g_curSession != INVALID_SESSION) { + ShowResult(uci_Close(g_curSession), IDS_TIPS_CLOSE_CONNECT); + SetWidgetText(IDC_BUTTON_OPEN, IDS_BTN_CONNECT); + m_IsConnect = false; + EnableWidgets(FALSE); + return; + } + //} + + CString msg; + m_cbxDevAddr.GetWindowText(msg); + if (msg == _T("")) { + AfxMessageBox(LoadString(IDS_CMD_MSG_EMPTY)); + return; + } + + auto r = uci_Open(msg, &g_curSession, 2000); + ShowResult(r, IDS_TIPS_BUILD_COONNECTION); + m_IsConnect = UCISUCCESS(r); + + if (m_IsConnect) { + //{UI + SetWidgetText(IDC_BUTTON_OPEN, IDS_BTN_DISCONNECT); + EnableWidgets(TRUE); + //} + + //{record the IDN string + m_IDN.Empty(); + for (int count = 0; count < sizeof(m_Nodes) / sizeof(m_Nodes[0]); count++) { + if (msg.CompareNoCase(m_Nodes[count].UCIAddr) == 0) + m_IDN = m_Nodes[count].IDN; + } + //} + + //{parse Fields of UCI Address + m_DevName = FindConnectAddrField(msg, _T("[D:"), _T("]")); + auto comType = FindConnectAddrField(msg, _T("[T:"), _T("]")); + if (comType.CompareNoCase(_T("TCPIP")) == 0) { + m_ConnectAddrIP = FindConnectAddrField(msg, _T("[IP:"), _T("]")); + m_ConnectAddrPort = FindConnectAddrField(msg, _T("[PORT:"), _T("]")); + m_nConnectAddrPort = _tcstol(m_ConnectAddrPort, nullptr, m_ConnectAddrPort.Find(_T("0x")) == -1 ? 10 : 16); + } + //} + + CString tips; + tips.Format(_T("winmsg:0x%x@closed:%d;"), GetSafeHwnd(), WM_TCPIP_DISCONNECT); + uci_SetAttribute(g_curSession, tips, nullptr, 0); + } + + //save the UCI Address for next startup + theApp.WriteProfileString(_T("Connect"), _T("Addr"), msg); +} + +CString CUCIDemoProjDlg::FindConnectAddrField(const CString& _addr, + const CString& _fieldBegin, const CString&_fieldEnd) { + CString addr(_addr), begin(_fieldBegin), end(_fieldEnd); + addr.MakeUpper(); + begin.MakeUpper(); + end.MakeUpper(); + auto i = addr.Find(_fieldBegin); + auto iEnd = addr.Find(_fieldEnd, i); + return addr.Mid(i + _fieldBegin.GetLength(), iEnd - i - _fieldBegin.GetLength()); +} + +void CUCIDemoProjDlg::OnBnClickedBtnWrite() { + if (!CheckConnectiion()) + return; + + UpdateData(); + + CString msg; + GetCMDString(msg); + if (msg.IsEmpty()) { + AfxMessageBox(IDS_CMD_MSG_EMPTY); + return; + } + + ResetTimer(); + + ShowResult(UCIWrite(msg, m_Val_Timeout), IDS_TIPS_CMD_WRITE, msg); +} + +void CUCIDemoProjDlg::OnBnClickedBtnWriteInFile() { + if (!CheckConnectiion()) + return; + + UpdateData(); + + if (!GetCommandString ()) + return; + + CString strPath; + m_CtrlFileChoose.GetWindowText(strPath); + if (strPath.IsEmpty()) { + AfxMessageBox(_T("ļ·Ϊգ")); + return; + } + + strPath.Trim(_T(" ")); + + if (!::PathFileExists(strPath)) { + AfxMessageBox(_T("ļ·")); + return; + } + + ResetTimer(); + + try { + CFile f(strPath, CFile::modeRead); + + std::vector buf((size_t)f.GetLength(), 0); + + f.Read(buf.data(), buf.size()); + + WParams wp; + ZeroMemory(&wp, sizeof(wp)); + auto r = uci_Write(g_curSession, uci_CreateWParams(wp, m_CommandString, m_Val_Timeout), buf.data(), buf.size()); + if (UCISUCCESS(r)) + RecordCMD(m_CommandString); + + ShowResult(r, IDS_TIPS_CMD_WRITE_FILE_AS_WRITE_PARAMS, m_CommandString); + } catch (CException* e) { + e->ReportError(); + e->Delete(); + } +} + +bool CUCIDemoProjDlg::CheckConnectiion() { + if (g_curSession == Invalid_Session || !m_IsConnect) { + AfxMessageBox(IDS_TIPS_NOT_CONNECT); + return false; + } + return true; +} + +void CUCIDemoProjDlg::OnBnClickedBtnRead() { + SetDlgItemText(IDC_EDIT_MSG, _T("")); + + UpdateData(TRUE); + + auto sz = sizeof(upo2k::CellBaseValue); + + if (m_Val_BytesToRead < 2) { + AfxMessageBox(_T("Ҫȡֽ2Bytes, 4Bytes")); + return; + } + + if (m_Val_Timeout == 0) { + AfxMessageBox(_T("ʱʱ䲻Ϊ0")); + return; + } + + theApp.WriteProfileInt(_T("RParams"), _T("BYTES"), m_Val_BytesToRead); + theApp.WriteProfileInt(_T("Params"), _T("Timeout"), m_Val_Timeout); + + if (g_curSession == Invalid_Session || !m_IsConnect) { + AfxMessageBox(_T("Ƚӣ")); + return; + } + + //"USB BIN"ͨŷʽmsgҪ + CString msg; + GetCMDString(msg); + if (msg == _T("")) { + AfxMessageBox(_T("ַΪգ")); + return; + } + + std::vector buf; + try { + buf.resize(m_Val_BytesToRead, 0); + } catch (CException* e) { + e->ReportError(); + e->Delete(); + return; + } + + ResetTimer(); + + //ȡ + auto r = UCIRead(msg, &buf[0], buf.size(), m_Val_Timeout); + ShowResult(r, IDS_TIPS_CMD_READ); + if (UCIERR(r)) + return; + + //ԽͼָõĽͼļ + CString path, fileName = _T("RData.dat"); + fileName = CreateBmpFileName(msg, fileName); + if (r > m_Val_BytesToRead) + r = m_Val_BytesToRead; + + //ԭʼݵļ + Files::WriteAllBytes(fileName, &buf[0], r, &path); + AppendTraceMsg(_T("The received data had been stored in file\r\n -> %s"), path); + + //һ + auto pBin = reinterpret_cast(&buf[0]); + size_t szBin = buf.size() > 100 ? 100 : buf.size(); + CString s, str; + size_t line_count = 10; + for (size_t i = 0; i < szBin; i++) { + if (i > 0 && i % line_count == 0) { + s += _T("| ") + str; + str.Empty(); + s.AppendFormat(_T("\r\n")); + } + s.AppendFormat(_T("%02x\t"), pBin[i]); + str.AppendFormat(_T("%c"), pBin[i] == 0 ? '.' : pBin[i]); + } + //if (szBin < line_count) { + s += _T("| ") + str; + //} + + AppendTraceMsg(_T("\r\n----------------------------")); + AppendTraceMsg(_T("\r\nBinary Data(%dBytes) : \r\n%s"), szBin, s); + + AppendTraceMsg(_T("\r\n----------------------------")); + AppendTraceMsg(_T("\r\nTry parse build-in struct")); + + //Գݽнʾ + auto szV = buf.size(); + switch (szV) { + case 2: + { + auto pb_short = reinterpret_cast(&buf[0]); + auto pb_ushort = reinterpret_cast(&buf[0]); + auto pb_byte = reinterpret_cast(pb_ushort); + AppendTraceMsg(_T("\r\nShort = 0x%x(%d), UShort = 0x%x(%d) -> L-Word(%d) H-Word(%d)"), + *pb_short, *pb_short, *pb_ushort, *pb_ushort, pb_ushort[0], pb_ushort[1]); + break; + } + case 4: + { + auto pb = reinterpret_cast(&buf[0]); + auto pb_uint = reinterpret_cast(&buf[0]); + auto pb_short = reinterpret_cast(pb); + AppendTraceMsg(_T("\r\nInt = 0x%x(%d), UInt = 0x%x(%d) -> L-Word(%d) H-Word(%d)"), + *pb, *pb, *pb_uint, *pb_uint, pb_short[0], pb_short[1]); + + auto pf = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nfloat = %f"), *pf); + break; + } + + case 8:{ + auto pb = reinterpret_cast(&buf[0]); + auto pb_int_64 = reinterpret_cast(&buf[0]); + auto pb_uint_64 = reinterpret_cast(pb); + auto pb_double = reinterpret_cast(pb); + double v = *pb_double; + AppendTraceMsg(_T("\r\nInt64 = 0x%x(%d), UInt64 = 0x%x(%u)"), + *pb_int_64, *pb_int_64, *pb_uint_64, *pb_uint_64); + AppendTraceMsg(_T("\r\ndouble = %f"), *pb_double); + break; + } + default: + break; + } + + AppendTraceMsg(_T("\r\n----------------------------")); + AppendTraceMsg(_T("\r\nTry parse")); + if (buf.size() == sizeof(upo2k::CellBaseValue)) { + upo2k::CellBaseValue * pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nV = %f\r\nU = %d(type = %d, code = %d)\r\nIsLimit = %d"), + pb->Value, pb->Unit, upo2k::GetUnitType(pb->Unit), upo2k::GetUnitCode(pb->Unit), pb->IsLimit); + if (buf.size() == sizeof(double)) { + AppendTraceMsg(_T("\r\n----")); + AppendTraceMsg(_T("\r\nV = %f, %d"), *(reinterpret_cast(&buf[0])), *(reinterpret_cast(&buf[0]))); + } + } else if (buf.size() == sizeof(upo2k::CellBaseValue) * 2) { + upo2k::CellBaseValue * pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\n[Low]V = %f,U = %d,IsLimit = %d;\r\n[High]V = %f,U = %d,IsLimit = %d"), + pb->Value, pb->Unit, pb->IsLimit, pb[1].Value, pb[1].Unit, pb[1].IsLimit); + }else if (buf.size() == sizeof(utg4162::LEDStatus)) { + auto pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\n[LED] CH1 = %d, CH2 = %d, Sine = %d"), pb->CH1, pb->CH2, pb->SINE); + } else if (buf.size() == sizeof(upo2k::UValue)) { + upo2k::UValue * pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nV = %f\r\nU = %d(0x%x)"), pb->value, pb->unit, pb->unit); + } else if (buf.size() == sizeof(upo2k::CursorMeasurePack)) { + auto pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nAx : V = %f,U = %d[0x%x t(0x%x) c(%d)]"), + pb->Ax.value, pb->Ax.unit, pb->Ax.unit, upo2k::GetUnitType(pb->Ax.unit), upo2k::GetUnitCode(pb->Ax.unit)); + AppendTraceMsg(_T("\r\nAy : V = %f,U = %d[0x%x t(0x%x) c(%d)]"), + pb->Ay.value, pb->Ay.unit, pb->Ay.unit, upo2k::GetUnitType(pb->Ay.unit), upo2k::GetUnitCode(pb->Ay.unit)); + } else if (buf.size() == sizeof(upo2k::Time)) { + auto pt = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nTime: %d-%d-%d, %d:%d:%d"), + pt->Year, pt->Month, pt->Day, pt->Hour, pt->Minute, pt->Second); + } + + if (msg.Find(_T("mea:all?")) != -1) { + ParseParamsMeasure(buf.data(), buf.size()); + } else if (msg.Compare(_T(":MEA:All?")) == 0) { + ParseParamsMeasure(buf.data() + 8 , buf.size() - 8); + } else if (msg.Find(_T("mea:user?")) != -1) { + ParseParamsMeasure_User(buf.data(), buf.size()); + } +} + +const CString& CUCIDemoProjDlg::CreateBmpFileName(CString &msg, CString& fileName) { + if (msg.CompareNoCase(_T("PrtScn:bmp;")) == 0 || msg.CompareNoCase(_T("PrtScn:.bmp;")) == 0) { + if (!m_IDN.IsEmpty()) + fileName = m_IDN; + else + fileName = m_DevName; + fileName += _T("_"); + fileName += GetCurrentTime(); + fileName += ".bmp"; + Sleep(300); + } + return fileName; +} + +void CUCIDemoProjDlg::ParseParamsMeasure(byte* _data, int _data_len) { + float v = 12.0; + float * pv = &v; + cb::MeaValue* pmv = reinterpret_cast(_data); + AppendTraceMsg(_T("\r\n")); + PrintMeaParam(_T("MAX"), pmv[cb::MP_MAX]); + PrintMeaParam(_T("MIN"), pmv[cb::MP_MIN]); + PrintMeaParam(_T("HIGH"), pmv[cb::MP_HIGH]); + PrintMeaParam(_T("MIDDLE"), pmv[cb::MP_MIDDLE]); + PrintMeaParam(_T("LOW"), pmv[cb::MP_LOW]); + PrintMeaParam(_T("PKPK"), pmv[cb::MP_PKPK]); + PrintMeaParam(_T("AMP"), pmv[cb::MP_AMP]); + PrintMeaParam(_T("MEAN"), pmv[cb::MP_MEAN]); + PrintMeaParam(_T("CYCMEAN"), pmv[cb::MP_CYCMEAN]); + PrintMeaParam(_T("RMS"), pmv[cb::MP_RMS]); + + PrintMeaParam(_T("CYCRMS"), pmv[cb::MP_CYCRMS]); + PrintMeaParam(_T("AREA"), pmv[cb::MP_AREA]); + PrintMeaParam(_T("CYCAREA"), pmv[cb::MP_CYCAREA]); + PrintMeaParam(_T("OVERSHOOT"), pmv[cb::MP_OVERSHOOT]); + PrintMeaParam(_T("PRESHOOT"), pmv[cb::MP_PRESHOOT]); + PrintMeaParam(_T("PERIOD"), pmv[cb::MP_PERIOD]); + PrintMeaParam(_T("FREQ"), pmv[cb::MP_FREQ]); + + PrintMeaParam(_T("RISE_TIME"), pmv[cb::MP_RISE_TIME]); + PrintMeaParam(_T("FALL_TIME"), pmv[cb::MP_FALL_TIME]); + PrintMeaParam(_T("PWIDTH"), pmv[cb::MP_PWIDTH]); + PrintMeaParam(_T("NWIDTH"), pmv[cb::MP_NWIDTH]); + PrintMeaParam(_T("PDUTY"), pmv[cb::MP_PDUTY]); + PrintMeaParam(_T("NDUTY"), pmv[cb::MP_NDUTY]); + PrintMeaParam(_T("RISEDELAY"), pmv[cb::MP_RISEDELAY]); + + PrintMeaParam(_T("FALLDELAY"), pmv[cb::MP_FALLDELAY]); + PrintMeaParam(_T("PHASE"), pmv[cb::MP_PHASE]); + PrintMeaParam(_T("FRR"), pmv[cb::MP_FRR]); + PrintMeaParam(_T("FRF"), pmv[cb::MP_FRF]); + + PrintMeaParam(_T("FFR"), pmv[cb::MP_FFR]); + PrintMeaParam(_T("FFF"), pmv[cb::MP_FFF]); + PrintMeaParam(_T("LRF"), pmv[cb::MP_LRF]); + PrintMeaParam(_T("LRR"), pmv[cb::MP_LRR]); + PrintMeaParam(_T("LFR"), pmv[cb::MP_LFR]); + PrintMeaParam(_T("LFF"), pmv[cb::MP_LFF]); + + PrintMeaParam(_T("BURST_WIDTH"), pmv[cb::MP_BURST_WIDTH]); +} + +void CUCIDemoProjDlg::ParseParamsMeasure_User(byte* _data, int _data_len) { + if (_data_len != (sizeof(cb::MeaValue) * 5)) + return; + + cb::MeaValue* pmv = reinterpret_cast(_data); + + for (size_t i = 0; i < 5; i++) { + AppendTraceMsg(_T("\r\nIsExist=%d,IsValid=%d,Value=%f, Unit(Type=%d,Scale=%d)"), + pmv->IsExist, pmv->IsValid, pmv->Value, pmv->Unit.Type, pmv->Unit.Scale); + pmv++; + } +} + +void CUCIDemoProjDlg::PrintMeaParam(const TCHAR * _name, const comAPICommon::MeaValue& _p) { + AppendTraceMsg(_T("%s\t\t\t=\t"), _name); + if (_p.IsExist) { + if (_p.IsValid) + AppendTraceMsg(_T("%f "), _p.Value); + else + AppendTraceMsg(_T("--")); + } else { + AppendTraceMsg(_T("NotExit")); + } + + AppendTraceMsg(_T(" %s%s\n"), unit::uci_UnitFindScaleName(_p.Unit.Scale), + CString(unit::uci_UnitFindTypeName(_p.Unit.Type))); +} + +bool CUCIDemoProjDlg::GetCommandString() { + m_CommandString.Empty(); + GetCMDString(m_CommandString); + if (m_CommandString.IsEmpty()) { + AfxMessageBox(IDS_CMD_MSG_EMPTY);//_T("The command string cannot be empty!") + return false; + } + return true; +} + +bool CUCIDemoProjDlg::GetFilePath() { + m_Path.Empty(); + m_CtrlFileChoose.GetWindowText(m_Path); + if (m_Path.IsEmpty()) { + AfxMessageBox(IDS_TIPS_PATH_EMPTY);//The path cannot be empty + return false; + } + return true; +} + +void CUCIDemoProjDlg::OnBnClickedButtonWriteFile() { + UpdateData(); + + ResetTimer(); + + if (!GetCommandString()) + return; + + if (!GetFilePath()) + return; + + if (!::PathFileExists(m_Path)) { + AfxMessageBox(IDS_TIPS_FILE_NOT_EXIST); + return; + } + + //////////////////////////////////////дļʾ/////////////////////////// + uci::WFileParams wf; + wf.CMDString = m_CommandString; + wf.FilePath = m_Path; + wf.Timeout = m_Val_Timeout; + + auto r = uci_WriteFromFile(g_curSession, &wf); + ShowResult(r, IDS_TIPS_CMD_WRITE_FILE, m_CommandString); + if (UCISUCCESS(r)) + RecordCMD(m_CommandString); +} + + +void CUCIDemoProjDlg::OnBnClickedButtonReadFile() { + if (!GetCommandString()) + return; + + UpdateData(); + ResetTimer(); + + //////////////////////////////////////read file example/////////////////////////// + CString fileName("RFile.bin"); + RFileParams rfp; + ZeroMemory(&rfp, sizeof(rfp)); + rfp.CMDString = m_CommandString; + rfp.FilePath = CreateBmpFileName(m_CommandString, fileName); + //msg.CompareNoCase(_T("prtscn:bmp;")) == 0 ? _T("screen_short.bmp") : _T("RFile.bin"); + rfp.Timeout = m_Val_Timeout; + + auto r = uci_ReadToFile(g_curSession, &rfp); + ShowResult(r, IDS_TIPS_CMD_READFILE, m_CommandString); + + if (UCISUCCESS(r)) { + if (fileName.Right(4).CompareNoCase(_T(".bmp")) == 0) { + AppendTraceMsg(_T("Save path%s"), rfp.FilePathFinal); + } else { + AppendTraceMsg(_T("Save path%s,\r\nIf you want view the file,please change file extention, and use appropriate Viewer to view!"), + rfp.FilePathFinal); + } + RecordCMD(rfp.CMDString); + } +} + +void CUCIDemoProjDlg::OnDestroy() { + CDialogEx::OnDestroy(); + + //////////////////////////////////////remember app data//////////////////////////// + UpdateData(); + + theApp.WriteProfileInt(_T("Params"), _T("Timeout"), m_Val_Timeout); + theApp.WriteProfileInt(_T("RParams"), _T("BYTES"), m_Val_BytesToRead); + theApp.WriteProfileInt(_T("RParams"), _T("COMTYPE"), m_COMType); + + try { + CStdioFile f(m_strCMDListPath, CFile::modeCreate| CFile::modeWrite | CFile::typeText); + + CString str1, str2; + int n; + for (int i = m_cbxCMD.GetCount() - 1; i >= 0; i--) { + n = m_cbxCMD.GetLBTextLen(i); + m_cbxCMD.GetLBText(i, str1.GetBuffer(n)); + str1.ReleaseBuffer(); + + f.WriteString(str1 + _T("\n")); + } + } catch (CException* e) { + e->ReportError(); + e->Delete(); + } +} + +void CUCIDemoProjDlg::OnBnSetfocusBtnWriteInFile() { + m_btnWriteParam_File.SetTooltip(_T("hello")); +} + +BOOL CUCIDemoProjDlg::PreTranslateMessage(MSG* pMsg) { + if (pMsg->message == WM_MOUSEMOVE) + m_tips.RelayEvent(pMsg); + return CDialogEx::PreTranslateMessage(pMsg); +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/97/970f1423d5cf03e9af7926682af18c5ea2f173a1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/97/970f1423d5cf03e9af7926682af18c5ea2f173a1.svn-base new file mode 100644 index 0000000..e14f9ee Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/97/970f1423d5cf03e9af7926682af18c5ea2f173a1.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/97/97a46c2e0c823cc857b9ab41e120d7dd430ac74b.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/97/97a46c2e0c823cc857b9ab41e120d7dd430ac74b.svn-base new file mode 100644 index 0000000..44b4fbe --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/97/97a46c2e0c823cc857b9ab41e120d7dd430ac74b.svn-base @@ -0,0 +1,3 @@ +[ҵĵ] +ҵĵ = "192.168.1.145" + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/98/98d32a97e8d38a9b1ba8cfc313410546f3f44d12.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/98/98d32a97e8d38a9b1ba8cfc313410546f3f44d12.svn-base new file mode 100644 index 0000000..b9d9a59 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/98/98d32a97e8d38a9b1ba8cfc313410546f3f44d12.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/9b/9b0e44b677088187bc872699e9d7df52deb5f978.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/9b/9b0e44b677088187bc872699e9d7df52deb5f978.svn-base new file mode 100644 index 0000000..c958649 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/9b/9b0e44b677088187bc872699e9d7df52deb5f978.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/9c/9c998f4a047bc82558ae85eb0cc0d442e4e1df52.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/9c/9c998f4a047bc82558ae85eb0cc0d442e4e1df52.svn-base new file mode 100644 index 0000000..7d91c59 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/9c/9c998f4a047bc82558ae85eb0cc0d442e4e1df52.svn-base @@ -0,0 +1,15 @@ +ʹãȰװ +driver\DriverPack_Libusb\Installer.batļղ谴ռɡ + +ȻֱӴexamples\UCIDemoProjʾ̣УȻȶ +ͶӦЭĵϤ򵥵ָͨ + +鿴UCIDemoProjԴļȡ뼶Ŀʾ + +Ŀ¼˵ + ĵ + װ + ļ + VCVBCVILabViewʾ̡ + UCIӿڿ⣨CC#VBӿڰ汾 + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a0/a0c64ac5d278a04f4030fe7e0a0c0331d9d09e85.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a0/a0c64ac5d278a04f4030fe7e0a0c0331d9d09e85.svn-base new file mode 100644 index 0000000..ef5ff2a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a0/a0c64ac5d278a04f4030fe7e0a0c0331d9d09e85.svn-base @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a0/a0dc680041f62cad08c8fa7b93d643f6e313fdd7.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a0/a0dc680041f62cad08c8fa7b93d643f6e313fdd7.svn-base new file mode 100644 index 0000000..3d4aaf8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a0/a0dc680041f62cad08c8fa7b93d643f6e313fdd7.svn-base @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace SimpleIO.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a1/a1836787c621e4d1f55c8fb1e043ec729595a0b5.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a1/a1836787c621e4d1f55c8fb1e043ec729595a0b5.svn-base new file mode 100644 index 0000000..639e9e5 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a1/a1836787c621e4d1f55c8fb1e043ec729595a0b5.svn-base @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SimpleIO")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SimpleIO")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("6f1614c4-8639-4bf3-954e-d562095a557d")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a5/a51f4161ba039291cbfb34982ff8c939c44a841e.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a5/a51f4161ba039291cbfb34982ff8c939c44a841e.svn-base new file mode 100644 index 0000000..bf2e8bf Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a5/a51f4161ba039291cbfb34982ff8c939c44a841e.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a5/a5b7574c6b611fff8b3072d32a406e7a4eda00d7.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a5/a5b7574c6b611fff8b3072d32a406e7a4eda00d7.svn-base new file mode 100644 index 0000000..3eaa221 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a5/a5b7574c6b611fff8b3072d32a406e7a4eda00d7.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a6/a644b66f3d19c98fcab587b988489f6c7f6b036e.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a6/a644b66f3d19c98fcab587b988489f6c7f6b036e.svn-base new file mode 100644 index 0000000..89a1f01 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a6/a644b66f3d19c98fcab587b988489f6c7f6b036e.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a9/a975a950819a660598088ea3bebafc136f2a524f.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a9/a975a950819a660598088ea3bebafc136f2a524f.svn-base new file mode 100644 index 0000000..32ce446 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/a9/a975a950819a660598088ea3bebafc136f2a524f.svn-base @@ -0,0 +1,136 @@ +[Project Header] +Version = 850 +Pathname = "/e/Documents/National Instruments/CVI85/UCIDEMO.prj" +CVI Dir = "/c/program files (x86)/national instruments/cvi85" +CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI" +CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI85" +CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI" +IVI Standard Root Dir = "/C/Program Files (x86)/IVI Foundation/IVI" +VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt" +Number of Files = 3 +Target Type = "Executable" +Flags = 16 + +[File 0001] +File Type = "CSource" +Res Id = 1 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "UCIDEMO.c" +Path = "/e/Documents/National Instruments/CVI85/UCIDEMO.c" +Exclude = False +Compile Into Object File = False +Project Flags = 0 +Folder = "Source Files" + +[File 0002] +File Type = "User Interface Resource" +Res Id = 2 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "UCIDEMO.uir" +Path = "/e/Documents/National Instruments/CVI85/UCIDEMO.uir" +Exclude = False +Project Flags = 0 +Folder = "User Interface Files" + +[File 0003] +File Type = "Library" +Res Id = 3 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "lib/C/ASCII/uci.lib" +Path = "/e/Documents/National Instruments/CVI85/lib/C/ASCII/uci.lib" +Exclude = False +Project Flags = 0 +Folder = "Not In A Folder" + +[Folders] +Include Files Folder Not Added Yet = True +Instrument Files Folder Not Added Yet = True +Folder 0 = "User Interface Files" +Folder 1 = "Source Files" + +[Compiler Options] +Default Calling Convention = "cdecl" +Require Prototypes = True +Require Return Values = True +Enable Pointer Mismatch Warning = False +Enable Unreachable Code Warning = False +Enable Unreferenced Identifiers Warning = False +Enable Assignment In Conditional Warning = False +O Option Compatible With 5.0 = False +Uninitialized Locals Compile Warning = "Conservative" + +[Run Options] +Stack Size = 250000 +Image Base Address = 4194304 + +[Compiler Defines] +Compiler Defines = "/DWIN32_LEAN_AND_MEAN" + +[Create Executable] +Executable File_Debug Is Rel = True +Executable File_Debug Rel To = "Project" +Executable File_Debug Rel Path = "UCIDEMO.exe" +Executable File_Debug = "/e/Documents/National Instruments/CVI85/UCIDEMO.exe" +Executable File_Release Is Rel = True +Executable File_Release Rel To = "Project" +Executable File_Release Rel Path = "UCIDEMO.exe" +Executable File_Release = "/e/Documents/National Instruments/CVI85/UCIDEMO.exe" +Icon File Is Rel = False +Icon File = "" +Application Title = "" +DLL Exports = "Include File Symbols" +DLL Import Library Choice = "Gen Lib For Current Mode" +Use IVI Subdirectories for Import Libraries = False +Use VXIPNP Subdirectories for Import Libraries = False +Use Dflt Import Lib Base Name = True +Where to Copy DLL = "Do not copy" +Add Type Lib To DLL = False +Include Type Lib Help Links = False +Type Lib FP File Is Rel = False +Type Lib FP File = "" +Type Lib Guid = "" +Runtime Support = "Full Runtime Support" +Instrument Driver Support Only = False +Embed Project .UIRs = False +Generate Map File = False + +[External Compiler Support] +UIR Callbacks File Option = 0 +Using LoadExternalModule = False +Create Project Symbols File = True +UIR Callbacks Obj File Is Rel = False +UIR Callbacks Obj File = "" +Project Symbols H File Is Rel = False +Project Symbols H File = "" +Project Symbols Obj File Is Rel = False +Project Symbols Obj File = "" + +[ActiveX Server Options] +Specification File Is Rel = False +Specification File = "" +Source File Is Rel = False +Source File = "" +Include File Is Rel = False +Include File = "" +IDL File Is Rel = False +IDL File = "" +Register ActiveX Server = False + +[Signing Info] +Sign = False +Sign Debug Build = False +Store = "" +Certificate = "" +Timestamp URL = "" +URL = "" + +[Manifest Info] +Embed = False + +[tpcSection] +tpcEnabled = 0 +tpcOverrideEnvironment = 0 + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/aa/aac809242be2874aeab3ff7278b218c248254c2b.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/aa/aac809242be2874aeab3ff7278b218c248254c2b.svn-base new file mode 100644 index 0000000..cdc2ffe Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/aa/aac809242be2874aeab3ff7278b218c248254c2b.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ab/ab1e4614ba10a5a67ea460a9c8429a9ce7fe3ace.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ab/ab1e4614ba10a5a67ea460a9c8429a9ce7fe3ace.svn-base new file mode 100644 index 0000000..26481f0 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ab/ab1e4614ba10a5a67ea460a9c8429a9ce7fe3ace.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ab/abf52138bf009a0d23378dc190e7180a50386605.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ab/abf52138bf009a0d23378dc190e7180a50386605.svn-base new file mode 100644 index 0000000..178f088 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ab/abf52138bf009a0d23378dc190e7180a50386605.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ac/acc7d5ed0c7972534fa4fc7a68dc0ab07f1720e7.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ac/acc7d5ed0c7972534fa4fc7a68dc0ab07f1720e7.svn-base new file mode 100644 index 0000000..f9d7764 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ac/acc7d5ed0c7972534fa4fc7a68dc0ab07f1720e7.svn-base @@ -0,0 +1,117 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1} + SimpleUCI + Win32Proj + + + + Application + v120 + Dynamic + Static + Unicode + true + + + Application + v120 + Dynamic + Static + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>12.0.30501.0 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + + + + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + EditAndContinue + + + true + Console + MachineX86 + + + + + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + Use + Level3 + ProgramDatabase + + + true + Console + true + true + MachineX86 + + + + + + + Create + Create + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/af/af7831bc8ef2250d2a14b2229eafabd33add36c9.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/af/af7831bc8ef2250d2a14b2229eafabd33add36c9.svn-base new file mode 100644 index 0000000..005c0af Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/af/af7831bc8ef2250d2a14b2229eafabd33add36c9.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/af/afb18a8915e42a0991c87c8cbefff1ea942fb4f5.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/af/afb18a8915e42a0991c87c8cbefff1ea942fb4f5.svn-base new file mode 100644 index 0000000..2d4906d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/af/afb18a8915e42a0991c87c8cbefff1ea942fb4f5.svn-base @@ -0,0 +1,44 @@ + +// UCIDemoProj.h : PROJECT_NAME Ӧóͷļ +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "ڰļ֮ǰstdafx.h PCH ļ" +#endif + +#include "resource.h" // + + +// CUCIDemoProjApp: +// йشʵ֣ UCIDemoProj.cpp +// + +enum ELANGE { + E_LANG_CHINESE = 0, + E_LANG_ENGLISH, +}; + +class CUCIDemoProjApp : public CWinApp +{ +public: + CUCIDemoProjApp(); + + + ELANGE GetSystemLange() const { return m_SystemLange; } + // д +public: + virtual BOOL InitInstance(); + // ʵ + + DECLARE_MESSAGE_MAP() + +protected: + void InitLanguage(ELANGE _lang); +private: + ELANGE m_SystemLange; + bool m_IsNewOS; +}; + +extern CUCIDemoProjApp theApp; \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b0/b0d7d9a2698efdce4f722dd0ea6f403d3a321e98.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b0/b0d7d9a2698efdce4f722dd0ea6f403d3a321e98.svn-base new file mode 100644 index 0000000..fc9d73f Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b0/b0d7d9a2698efdce4f722dd0ea6f403d3a321e98.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b4/b4c9cd3a25f6fbeb963b5dddbaf0278bd7ca9e13.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b4/b4c9cd3a25f6fbeb963b5dddbaf0278bd7ca9e13.svn-base new file mode 100644 index 0000000..09648fe --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b4/b4c9cd3a25f6fbeb963b5dddbaf0278bd7ca9e13.svn-base @@ -0,0 +1,8 @@ + +// stdafx.cpp : ֻ׼ļԴļ +// UCIDemoProj.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b5/b5cd9526df1b232353ac66f7b118ed0dfd8edba1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b5/b5cd9526df1b232353ac66f7b118ed0dfd8edba1.svn-base new file mode 100644 index 0000000..210ec81 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b5/b5cd9526df1b232353ac66f7b118ed0dfd8edba1.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b6/b66926a017684cbba615f143e3049580a1a5cd2a.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b6/b66926a017684cbba615f143e3049580a1a5cd2a.svn-base new file mode 100644 index 0000000..79751d8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b6/b66926a017684cbba615f143e3049580a1a5cd2a.svn-base @@ -0,0 +1,60 @@ +/*! + * \created : 2017/3/17 + * \author : M.Yang + * \purpose : ṩUCIC++汾ӿ + */ +#ifndef uci_cpp_h__ +#define uci_cpp_h__ +#include "uci.h" + +namespace uci { + class Session; +} + +//@brief : UCI Ự +//@remark: uci_ǰ׺CԹ淶Ľӿ򵥷װĺôǣ +// 1SessionʱԶرջỰǣʹõʹʱעʹ߼Ǵ߼ +// 2ÿһӿϣʡȥһSession IDΣҿ趨βεĬֵijЩCԱ֧֣ʹýӿڸ򵥣 +// ע⣺ +// ಻ȫӿڵ䣬Ҫ䡣 +class uci::Session { +public: + Session() : m_Session(INVALID_SESSION) {} + virtual ~Session() { + if (m_Session != INVALID_SESSION) { + uci_Close(m_Session); + m_Session = INVALID_SESSION; + } + } + + u_status Open(u_cstring _addr, u_uint32 _timeout = 2000) { + u_status r = uci_OpenX(_addr, _timeout); + if (UCISUCCESS(r)) + m_Session = (u_session)r; + return r; + } + + u_status Write(u_cstring _msg,u_uint32 _timeout = 1000, const u_byte* _data = NULL, u_size _len = 0) { + return uci_WriteX(m_Session, _msg, _timeout, _data, _len); + } + + u_status Read(u_cstring _msg,u_uint32 _timeout, u_byte* _data, u_size _dataLen) { + return uci_ReadX(m_Session, _msg, _timeout, _data, _dataLen); + } + + u_status WriteFromFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout) { + return uci_WriteFromFileX(m_Session, _msg, _filePath, _timeout); + } + + u_status ReadToFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength) { + return uci_ReadToFileX(m_Session, _msg, _filePath, _timeout, _filePathFinal, _filePathFinalLength); + } + + u_status Close() { return uci_Close(m_Session); } + u_session GetSession() const { return m_Session; } +protected: + u_session m_Session; +}; + +#endif // uci_cpp_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b7/b79005db9a5d4a9c87a14cbd2798c3bbd27fab13.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b7/b79005db9a5d4a9c87a14cbd2798c3bbd27fab13.svn-base new file mode 100644 index 0000000..f713d50 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b7/b79005db9a5d4a9c87a14cbd2798c3bbd27fab13.svn-base @@ -0,0 +1,28 @@ + + + + 3 + true + true + false + 0 + 我的电脑/VI服务器 + 我的电脑/VI服务器 + true + true + false + + + + + + + + + + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b7/b7c0011cbf7fd0008a8943e8f829782648da79ea.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b7/b7c0011cbf7fd0008a8943e8f829782648da79ea.svn-base new file mode 100644 index 0000000..6aa5c5f Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/b7/b7c0011cbf7fd0008a8943e8f829782648da79ea.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c2/c2da79e670d130fdf12803f7b0dfff838bac3032.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c2/c2da79e670d130fdf12803f7b0dfff838bac3032.svn-base new file mode 100644 index 0000000..45ffec1 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c2/c2da79e670d130fdf12803f7b0dfff838bac3032.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c5/c56f440d7fe1279441340425ba14473f8db98739.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c5/c56f440d7fe1279441340425ba14473f8db98739.svn-base new file mode 100644 index 0000000..817fe3d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c5/c56f440d7fe1279441340425ba14473f8db98739.svn-base @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleUCI", "SimpleUCI.vcproj", "{DA6758AD-C0D6-46D3-813B-4E83712CA7A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Debug|Win32.Build.0 = Debug|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Release|Win32.ActiveCfg = Release|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c5/c5b431774e8a4349cd874d3dde66474e2d34039d.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c5/c5b431774e8a4349cd874d3dde66474e2d34039d.svn-base new file mode 100644 index 0000000..36391bd --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c5/c5b431774e8a4349cd874d3dde66474e2d34039d.svn-base @@ -0,0 +1,7 @@ +汾V2.2 +ڣ20181228 +޸ģ +1uci.dll UTD2000CEX\UTD7000BGϵʾеBUG +2x64汾uci.dll.\lib\C\x64 +3x64汾UCI_DEMO (.\examples\VC\UCIDEMO\x64\UNICODE +4޸UTP3000C&\UTP8000MϵеԴĵʾ룻 \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c6/c632db7163f499fda8c9dc4d7ecd93fa61a9a6c9.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c6/c632db7163f499fda8c9dc4d7ecd93fa61a9a6c9.svn-base new file mode 100644 index 0000000..cc58b46 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c6/c632db7163f499fda8c9dc4d7ecd93fa61a9a6c9.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c6/c6d51899e9dc935abe97b735029565e0d22e6f02.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c6/c6d51899e9dc935abe97b735029565e0d22e6f02.svn-base new file mode 100644 index 0000000..3446546 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c6/c6d51899e9dc935abe97b735029565e0d22e6f02.svn-base @@ -0,0 +1,551 @@ +/*! + * \created : 2016/12/28 + * \author : M.Yang + * \purpose : ʹUTD2000M\UTD4000M\UTD2000CEX-EDUϵлʹõָ塣 + * ʹã鿴Ӧ͵Эĵ + */ +#ifndef CMD_COMVer2_h__ +#define CMD_COMVer2_h__ + +#ifdef __cplusplus +namespace comApiEx { +#endif + static const int Invalid_CMD = -1; + +#ifdef __cplusplus + static bool IsCMDValid(short cmd) { + return (cmd != Invalid_CMD); + } +#else + static int IsCMDValid(short cmd) + { + return (cmd == Invalid_CMD) ? 0 : 1; + } +#endif + + //@brief : ͨ + //@remarks : ӿڲCHΪ-1ΪEnumݣӦĶshot(2Bytes)ͽжд. + typedef enum _commom_cmd { + //@brief : ȡ豸ͱ + //@remarks : {IO:R}{DATA:comAPICommon::E_DSO_TYPE} + CMD_GET_DSO_TYPE = 0, + //@brief : ü + //@remarks : {IO:W}{DATA:null} + CMD_LOCK_KEYPAD, + //@brief : ü̽ + //@remarks : {IO:W}{DATA:null} + CMD_UNLOCK_KEYPAD, + //@brief : ȡ豸״̬ + //@remarks : {IO:R}{DATA:comApi::E_PROC_STATE from } + CMD_PROCSTATE, + //@brief : ִAUTOSET + //@remarks : {IO:W}{DATA:null} + CMD_AUTOSET, + //@brief : ִǿƴFORCE + //@remarks : {IO:W}{DATA:null} + CMD_TRIG_FORCE, + //@brief : ִеδSINGLE + //@remarks : {IO:W}{DATA:null} + CMD_SINGLE, + //@brief : ִCOARSE + //@remarks : {IO:W}{DATA:null} + CMD_COARSE, + //@brief : ִаPRTSC + //@remarks : {IO:W}{DATA:null} + CMD_PRTSC, + //@brief : + CMD_GET_BITMAP_FILENAME, + //@brief : ȡͼ + //@remarks : {IO:R}{DATA: 2000M/4000M768512Bytes} + CMD_GET_BITMAP_FILEDATA, + + //@brief : ָ + //@remarks : {IO:WR}{DATA<8Bytes>:comAPICommon::Key from } + CMD_KEY, + //@brief : ȡѹĻ + CMD_CAPTURE_SCREEN, + //@brief : д + CMD_DEV_CONFIG, + //@brief : ѯ豸ʾ + CMD_IDN, + //@brief : ѯЭ汾š + CMD_CVER, + + //@brief : ȡĻϢ + //@remarks : {IO:R}{DATA<20Bytes>:comApiEx::SCREEN_INFO from } + CMD_GET_SCREEN_INFO = 50, //SCREEN_INFO + //@brief : short 1: usb connection state is ok; other: usb connection state is not ok (ok) + //@remarks : + CMD_GET_USB_CONNECTION_STATE, + //@brief : õǰƵʼֵ + //@remarks : {IO:R}{DATA:comApiEx::SignalFreq from } + CMD_GET_CYMOMETER_VALUE, + //@brief : õǰѡеͨ + //@remarks : short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other (ok) + CMD_GET_CURRENT_ACTIVE_CHANNEL, //short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other (ok) + //@brief : õ豸˵ǰвIJ˵ + //@remarks : short 0: CH1 menu; 1: CH2 menu; 2: MATH or FFT menu; -1: other menu (ok) + CMD_GET_CURRENT_ACTIVE_MENU, + //@brief : ȡǰ˵Ƿʾ + //@remarks : short 0: current menu is not display; 1: current menu is display (ok) + CMD_GET_CURRENT_MENU_SHOW_STATE, + CMD_GET_SAMPLE, + //@brief : UǷ + //@remarks : {IO:R}{DATA: 0 δ룻 1 } + CMD_GET_USBDISK_STATE, + + //{acquire + //@brief : ɼģʽ + //@remarks : {IO:WR}{DATA:comApiEx::E_ACQ_MODE from } + CMD_ACQ_MODE = 400, + //@brief : ƽ + //@remarks : {IO:WR}{DATA: averageNum} + //ʵʴùʽ<2^(averageNum + 1)>, : {(0: 2), (1: 4), (2: 8), (3: 16), (4: 32), (5: 64), (6: 128), (7: 256)} + CMD_ACQ_AVERAGE_NUM, + //@brief : ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_SAMPLE_MODE from } + CMD_ACQ_SAMPLING, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_ACQ_SAV_DEPTH from } + CMD_ACQ_DEPTH, + //@brief : ٲɼ + //@remarks : {IO:WR}{DATA: 0 ر 1 } + CMD_ACQ_FAST, + //} + + //{trigger + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_TYPE from } + CMD_TRIG_TYPE = 500, + //@brief : Դ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_SOURCE from } + CMD_TRIG_SOURCE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_TIRG_COUPLING from } + CMD_TRIG_COUPLING, + //@brief : ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_MODE from } + CMD_TRIG_METHOD, + //@brief : شбʴ-б + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_EDGE_SLOPE(ء) E_SLOP_POLARITY(б) from } + CMD_TRIG_SLOPE_TYPE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_PULSE_POLAR from } + CMD_TRIG_PULSE_POLAR, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_PULSE_CONDITION from } + CMD_TRIG_PULSE_COND, + //@brief : ʱ + //@remarks : {IO:WR}{DATA: ֵstep, 㹫ʽ(t = K * step), һK = 4} + CMD_TRIG_PULSE_TIME, + //@brief : Ƶ-Ƶʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_VIDEO_STANDARD from } + CMD_TRIG_VIDEO_STD, + //@brief : Ƶ-ͬ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_VIDEO_SYNC_MODE from } + CMD_TRIG_VIDEO_SYNC, + //@brief : Ƶ-ָ + //@remarks : {IO:WR}{DATA: } + CMD_TRIG_VIDEO_LINE_NUMBER, + //@brief : бʴ-б + //@remarks : {IO:WR}{DATA: comApiEx::E_SLOP_WHEN from } + CMD_TRIG_SLOPE_COND, + //@brief : бʴ-ʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_SLOPE_TIME, + //@brief : бʴ-ֵ(Ƿ/µֵ) + //@remarks : {IO:WR}{DATA: comApiEx::E_SLOP_THRESHOLD from } + CMD_TRIG_SLOPE_THRESHOLD, + //@brief : бʴ-ѹ + //@remarks : {IO:R}{DATA: ַʽȡ} + CMD_TRIG_SLOPE_VT, + + //@brief : ʱ1 CEM""><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵstep, 㹫ʽ(t = K * step), һK = 4} + CMD_TRIG_PULSE_LT_TIME, + //@brief : бʴ-ʱ2 CEM"б"><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_SLOPE_LT_TIME, + + //@brief : - + //@remarks : {IO:WR}{DATA: comApiEx::E_WINDOE_WHEN from } + CMD_TRIG_WINDOW_COND, + //@brief : -ʱ + //@remarks :{IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_WINDOW_TIME, + //@brief : Ƿ- + //@remarks : {IO:WR}{DATA: comApiEx::E_RUNT_WHEN from } + CMD_TRIG_RUNT_COND, + //@brief : Ƿ-ʱ + //@remarks :{IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_RUNT_TIME, + //@brief : Ƿ-ʱ1 CEM""><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_RUNT_LT_TIME, + //} + + + //{display + //@brief : DISPLAY + //@remarks : {IO:WR}{DATA: comApiEx::E_DISPLAY_TYPE from } + CMD_DISPLAY_TYPE = 600, + //@brief : DISPLAY ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_DISPLAY_FORMAT from } + CMD_DISPLAY_FORMAT, + //@brief : DISPLAY դ + //@remarks : {IO:WR}{DATA: comApiEx::E_Display_Graticule from } + CMD_DISPLAY_GRID, + //@brief : DISPLAY ʱ + //@remarks : {IO:WR}{DATA: comApiEx::E_Dislay_PersistTime from } + CMD_DISPLAY_PERSIST, + //@brief : DISPLAY + //@remarks : {IO:WR}{DATA: һ 1 - 100 2000M4000M step[0,49] = curStep * 2 + 2} + CMD_DISPLAY_WAVE_LUM, + //} + + //{cursor + //@brief : Cursor + //@remarks : {IO:WR}{DATA: comApiEx::E_CURSOR_TYPE from } + CMD_CURSOR_TYPE, + //@brief : Cursor ģʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_CURSOR_MODE from } + CMD_CURSOR_MODE, + //@brief : Cursor ģʽ + //@remarks : {IO:WR}{DATA: ʱ comApiEx::E_CURSOR_V_UNIT ѹ : comApiEx::E_CURSOR_H_UNIT from } + CMD_CURSOR_UNIT, + //@brief : Cursor ׼ + //@remarks : {IO:WR}{DATA: E_CURSOR_POS from } + CMD_CURSOR_BASE, + //@brief : Cursor Aλõ + //@remarks : {IO:WR}{DATA : ˮƽߣΪ0һΪ25ֱߣΪ350һΪ50} + CMD_CURSOR_A_POS, + //@brief : Cursor Bλõ + //@remarks : {IO:WR}{DATA : ˮƽߣΪ0һΪ25ֱߣΪ350һΪ50 } + CMD_CURSOR_B_POS, + //} + + //{windows + CMD_WIN_TYPE, // (ok) + CMD_WIN_HOLDOFF, // + //} + + //{storage + //@brief : Storage + //@remarks : {IO:WR}{DATA: comApiEx::E_STORAGE_TYPE from } + CMD_STORAGE_TYPE = 700, + //@brief : Storage ļ + //@remarks : {IO:WR}{DATA: } + CMD_STORAGE_FILE_NAME, + //@brief : Storage ο-Դ + //@remarks : {IO:WR}{DATA: comApiEx::E_CHANNEL_ID from } + CMD_STORAGE_REFWAVE_SOURCE, + //@brief : Storage ο-ļʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_STORAGE_REFWAVE_FILE_FORMAT from } + CMD_STORAGE_REFWAVE_FILE_FORMAT, + //@brief : ȡô洢ļб + //@remarks :{IO:WR}{DATA: comApiEx::FileList_Flash from } + CMD_STORAGE_GET_FILE_LIST_FLASH, // (ok) + //@brief : ȡô洢ļб + //@remarks :{IO:WR}{DATA: comApiEx::FileList_USB from } + CMD_STORAGE_GET_FILE_LIST_USB, + //@brief : ִSAVE浽Flash. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_SAVE, + //@brief : ִLOADFlash. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_LOAD, + //@brief : ִImportU̼. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_IMPORT, + //@brief : ִExport + //@remarks : {IO:W}{DATA} + CMD_STORAGE_EXPORT, + //@brief : ѯǷѱ + //@remarks : {IO:R}{DATA : 0 ڣ 1 } + CMD_STORAGE_REFSETTING_EXIST, + //@brief : 洢λ + //@remarks : {IO:WR}{DATA : λ} + CMD_STORAGE_POS, + //} + + //{measure + MEASURE_ALL = 800, + MEASURE_CLEAR, + MEASURE_CUSTOMIZE, + MEASURE_INDICATOR, + MEASURE_DELAY_FROM, + MEASURE_DELAY_FEDGE, + MEASURE_DELAY_TO, + MEASURE_DELAY_TEGDE, + MEASURE_DELAY_OK, + MEASURE_PHASE_FROM, + + MEASURE_PHASE_TO, + MEASURE_PHASE_OK, + //} + + //for UTD2102CEX + CMD_MEASURE_SOURCE, + CMD_MEASURE_STATISTICS, + + //{utility + //@brief : ִУ + //@remarks : {IO:W}{DATA} + CMD_UTILITY_SELF_CALIBRATE = 1000, + CMD_UTILITY_SYSTEM_INFO, //(ok) + //@brief : ִClear + //@remarks : {IO:W}{DATA} + CMD_UTILITY_CLEAR_INFO, + //@brief : ִлָ + //@remarks : {IO:W}{DATA} + CMD_UTILITY_RESET_TO_FACTORY, + //@brief : Աȶ + //@remarks : {IO:WR}{DATA} + CMD_UTILITY_CONTRAST, + //@brief : л + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Language from } + CMD_UTILITY_LANGUAGE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Skin from } + CMD_UTILITY_SKIN, + //@brief : ˵ʾʱ + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Menu_Display_Time from } + CMD_UTILITY_MENU_DISP, + //@brief : + //@remarks : {IO:WR}{DATA} + CMD_UTILITY_GRID_LUM, + //@brief : Ƶʼƿ + //@remarks : {IO:WR}{DATA:comApiEx:: E_SWITCH_STATE from } + CMD_UTILITY_CYMOMETER, + + CMD_UTILITY_AUTOSET_CHANNEL, + CMD_UTILITY_AUTOSET_ACQUIRE, + CMD_UTILITY_AUTOSET_TRIG, + CMD_UTILITY_AUTOSET_SIGNAL, + //} + + //{record + CMD_DSO_RECORD_START, + CMD_DSO_RECORD_STOP, + CMD_DSO_RECORD_REPLAY, + CMD_DSO_RECORD_CLEAR, + //} + + //{ + CMD_UTILITY_SQUARE_WAVE, + CMD_UTILITY_SLEEP_TIME, + CMD_UTILITY_MEASURE_UNIT, + //} + + //{ + CMD_SYS_TIME_SWITCH = 1100, + CMD_SYS_TIME, + //} + + //{pass fail + CMD_PASS_FAIL_ALLOW_TEST, + CMD_PASS_FAIL_OUTPUT, + CMD_PASS_FAIL_SOURCE, + CMD_PASS_FAIL_DISP_INFO, + CMD_PASS_FAIL_OPERATION, + CMD_PASS_FAIL_STOP_TYPE, + CMD_PASS_FAIL_STOP_COND, + CMD_PASS_FAIL_STOP_THRESHOLD, + CMD_PASS_FAIL_TEMPLATE_WAVEREF, + CMD_PASS_FAIL_TEMPLATE_REFLOAD, + CMD_PASS_FAIL_TEMPLATE_HRANGE, + CMD_PASS_FAIL_TEMPLATE_VRANGE, + CMD_PASS_FAIL_TEMPLATE_CREATE, + //} + + //@brief : ȡͨݰʽĵ + //@remarks : + CMD_GET_DISPLAY_DATA = 1200, //get ch1, ch2, math, ref a/b data ok + //ͬDSO״̬ͣDSOAttrStateͿͶͬ + CMD_SYNC_DSO, + + //ʱDSOݡ + CMD_PERIOD_MSG2DSO, + + //{CEX-EDUʹ + //CEX-EDUʹãͽҪȡRECݵͷ׼ + CMD_DSO_RECORD_HEADER_READY = 1400, + //CEX-EDUʹãȡRECͷ + CMD_DSO_RECORD_HEADER, + //CEX-EDUʹãͽҪȡREC׼ + CMD_DSO_RECORD_DATA_READY, + //CEX-EDUʹãȡRECݿ顣 + CMD_DSO_RECORD_DATA, + //CEX-EDUʹãжϵǰRECǷЧ + CMD_DSO_RECORD_DATA_VALID, + //} + + //{2000M-special + CMD_VARDEPTH_SAMPLE_RATE = 1420, + CMD_VARDEPTH_SAVE_DEPTH, + CMD_VARDEPTH_PRE_TRIG_TIME, + CMD_VARDEPTH_AUTO_TRIG_TIME, + //} + + // + CMD_MESSAGE = 1430, + // + CMD_DUMP_BEGIN = 1440, + CMD_DUMP_ID = CMD_DUMP_BEGIN, + CMD_DUMP_END = 1500, //#TODO:Ҫṩ룬ͽCEX2000Mıôṩͳһ롣 + }COMMON_CMD; + + //@brief : ͨ + //@remarks : + typedef enum _channel_cmd + { + CH_Invalid_CMD = -1, + //@brief : ͨ + //@remarks : {IO:WR}{DATA:E_CH_COUPLING_TYPE} + CH_ATTR_COUPLING = 0, + //@brief : + //@remarks : {IO:WR}{DATA:E_CH_BANDLIMIT} + CH_ATTR_BAND_WIDTH, + //@brief : + //@remarks : + CH_ATTR_VOLT_SCALE, + //@brief : Ŵ + //@remarks : {IO:WR}{DATA:CH_PROBE} + CH_ATTR_PROBE, + //@brief : + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_INVERT, + //@brief : ƫõѹ + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_PRE_BIAS_VOLT_SWITCH, + //@brief : ƫõѹֵ + //@remarks : {IO:W}{DATA: +1 increase; -1 decrease;} + CH_ATTR_PRE_BIAS_VOLT_VALUE, + //@brief : ƫõѹ + //@remarks : {IO:W}{DATA:null} + CH_ATTR_PRE_BIAS_VOLT_TOZERO, + + //@brief : ͨ + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_CHANNEL_SWITCH = 100, + //@brief : ֱλ + //@remarks : {IO:WR}{DATA: UTD2000M -> ϵΪ [-100 , 100], CEX -> µ[28,128]} + CH_ATTR_VERTICAL_POS, + //@brief : ֱλù + //@remarks : {IO:W}{DATA:null} + CH_ATTR_VERTICAL_POS_TOZERO, + //@brief : Ԥλ + //@remarks : {IO:WR}{DATA: UTD2000M -> ĻмΪ350һΪ50} + CH_ATTR_TRIG_DEPTH, + //@brief : Ԥȹ + //@remarks : {IO:W}{DATA:null} + CH_ATTR_TRIG_DEPTH_TOZERO, + //@brief : ƽϢ + //@remarks : {IO:R}{DATA:comApiEx::CellBaseValue} + // ֻͨһƽ Ϊ comApiEx::CellBaseValues TrigVolt; + // бʴƽ Ϊ comApiEx::CellBaseValues TrigVolt[2]; + CH_ATTR_TRIG_LEVEL, + //@brief : ƽλ + //@remarks : {IO:WR}{DATA: ͨΪ0㣬¸ÿ25} + CH_ATTR_TRIG_LEVEL_POS, + //@brief : ƽλù + //@remarks : {IO:WR}{DATA: ͨΪ0㣬¸ÿ25} + CH_ATTR_TRIG_LEVEL_TOZERO, + //@brief : Ϣ + //@remarks : {IO:R}{DATA: CellBaseValue} + CH_ATTR_VOLT_AMPLITUDE, + //񵲵λΪshort + //@brief : 񵲵λ + //@remarks : {IO:WR}{DATA: +1 increase; -1 decrease; other : code } + CH_ATTR_VOLT_AMPLITUDE_LEVEL, + //ʱλΪshortֻã + //@brief : ʱλ + //@remarks : {IO:W}{DATA: E_TIMEBASE_LEVEL } + CH_ATTR_TIME_BASE, + //@brief : ȡʱʱ + //@remarks : {IO:R}{DATA: CellBaseValue} + CH_ATTR_TIME_BASE_VALUE, + + //@brief : MATH + //@remarks : {IO:WR}{DATA: E_MATH_TYPE } + CH_MATH_TYPE = 200, + //@brief : MATHԴ1 + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_MATH_OP1, + //MATHͣͣshort + //@brief : MATH + //@remarks : {IO:WR}{DATA: E_MATH_OP_SIGN } + CH_MATH_OP, + //@brief : MATHԴ2 + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_MATH_OP2, + //@brief : FFTԴ + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_FFT_SRC, + //@brief : FFT + //@remarks : {IO:WR}{DATA: E_FFT_WINDOW } + CH_FFT_WINDOW, + //@brief : FFTֱλ + //@remarks : {IO:WR}{DATA: E_FFT_UNIT } + CH_FFT_VSCALE, + //@brief : ȡFFTƵֵ + //@remarks : {IO:R}{DATA: SignalFreq } + CH_FFT_FREQ, + //@brief : ˲ + //@remarks : {IO:WR}{DATA: E_FILTER_TYPE } + CH_FILTER_TYPE, + //@brief : Ƶ + //@remarks : {IO:WR}{DATA: ֵƵֵҪм} + CH_FILTER_FREQ_LOW, + //@brief : Ƶ + //@remarks : {IO:WR}{DATA: ֵƵֵҪм} + CH_FILTER_FREQ_HIGH, + //@brief : ˲Դ + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_FILTER_SRC, + + //@brief : REFص() + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_LOAD_FROM_FLASH = 300, + //@brief : REF벨(USB) + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_LOAD_FROM_USB, + //@brief : REF洢λõ + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_POS, + //@brief : жijһλòǷڣλCH_REF_POSõģ + //@remarks : {IO:R}{DATA: Ϊ洢λֵ } + CH_REF_POS_WAVE_EXIST, + //@brief : д洢 + //@remarks : {IO:W}{DATA : null } + CH_REF_CLEAR, + + //[] + CH_DISPLAY_DATA = 400, + //[]ȡԭʼݣCH_GET_SAV_DATA + CH_ORIGIN_DATA, + + //@brief : ȡSAVļݣݸʽ [4Bytes ļ] + [ļ] + //@remarks : ʹ÷ʽĵʾ + // UTD2102CMUTD4000M ӦСΪ32768Bytes UTD2102CEX-EDUӦ32000Bytes + CH_GET_SAV_DATA, + + //{2102CM-x + CH_VARDEPTH_ENABLE = 500, + CH_VARDEPTH_SAMPLE_RATE, + + CH_VARDEPTH_DATA_READY = 510, + CH_VARDEPTH_DATA, + + CH_VOLT_AMPLITUDE_LEVEL, //ѹֵãֱӽ0~15λ + CH_PRE_BIAS_VOLT_VALUE, //ƫõѹãֱõѹȸֵ + + CH_VARDEPTH_TRIG_READY, //ͨDSO׽źŵĻ + //} + }CHAN_CMD; + +#ifdef __cplusplus +} +#endif + +#endif // CMD_COMVer2_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c7/c751756c27820dd2115c05cf93adb6de0d939be0.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c7/c751756c27820dd2115c05cf93adb6de0d939be0.svn-base new file mode 100644 index 0000000..7f329f4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c7/c751756c27820dd2115c05cf93adb6de0d939be0.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c9/c92aa522d2f63eafe8747df11f77957991adb518.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c9/c92aa522d2f63eafe8747df11f77957991adb518.svn-base new file mode 100644 index 0000000..9be5b1b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/c9/c92aa522d2f63eafe8747df11f77957991adb518.svn-base @@ -0,0 +1,222 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩʹUCIӿڵģDSOض + */ + +#ifndef DSO_UPO_h__ +#define DSO_UPO_h__ + +#ifdef __cplusplus +namespace upo2k { +#endif // __cplusplus + ////////////////////////////////////////////////////////////////////////// + // UPOλ壺 + // 16bit8λΪλͣ8λΪλ! + // ȡʽ short unit + // char unit_code = unit & 0xff; + // if((unit & UT_Time) == UT_Time) unit_code is ETime + // else if((unit & UT_Freq) == UT_Freq) unit_code is EFreq + ////////////////////////////////////////////////////////////////////////// + + //@brief : λ + //@remarks : 8λΪλͣ8λΪλ! +#ifdef __cplusplus + typedef enum _UnitType : unsigned short { +#else + typedef enum _UnitType { +#endif // __cplusplus + UT_Voltage = (0x0000), + UT_Time = (0x0100), + UT_Freq = (0x0200), + UT_Percent = (0x0300), + UT_Degree = (0x0400), + UT_DB = (0x0500), + UT_SamplePoint = (0x0600), + //@brief : + UT_Current = (0x0700), + //@brief : + UT_Watt = (0x0800), + //@brief : δ֪λ + UT_Unknown = (0x0900), + + UT_Invalid = (0x8000), + }UnitType; + + enum EFreq { + Hz = 0, + KHz, + MHz, + GHz, + THz, + }; + + enum ETime { + s = 0, + ms, + s, + ns, + ps, + }; + + enum EVoltage { + V = 0, + mV, + V, + KV + }; + + enum ECurrent { + A = 0, + mA, + A, + KA + }; + + enum EWatt { + W = 0, + mW, + W, + KW + }; + + enum EUnknown { + U = 0, + mU, + U, + KU + }; + + enum EDB { + mdB = 0, + dB, + kdB + }; + + enum EPoint { + Sa = 0, + KSa, + MSa, + GSa, + }; + + enum EPercent { + Percent = 0 + }; + + enum EDegree { + Degree = 0, + }; + + static inline char GetUnitType(short _v) { return (char)(_v >> 8); } + static inline char GetUnitCode(short _v) { return _v & 0xff; } + + //@brief : λ + //@remark: ָͨLock?ȡ64bitλǡ + typedef enum _KeyFlagsPos { + IKEY_F1, + IKEY_F2, + IKEY_F3, + IKEY_F4, + IKEY_F5, + + IKEY_CH1, + IKEY_CH2, + IKEY_CH3, + IKEY_CH4, + + IKEY_MATH, + IKEY_REF, + IKEY_HORIZON, + IKEY_TRIGGER, + IKEY_FORCE, + IKEY_HELP, + IKEY_MEASURE, + IKEY_CURSOR, + IKEY_ACQUIRE, + IKEY_DISPLAY, + IKEY_STORAGE, + IKEY_UTILITY, + IKEY_DECODE, + IKEY_DEFAULT, + IKEY_AUTOSET, + IKEY_RUNSTOP, + IKEY_SINGLE, + IKEY_CLEAR, + IKEY_PRINTSCREEN, + IKEY_MENU, + + IKEY_OFFSET_LEFT, + IKEY_OFFSET_RIGHT, + IKEY_OFFSET_OK, + + IKEY_PRETRIG_LEFT, + IKEY_PRETRIG_RIGHT, + IKEY_PRETRIG_OK, + + IKEY_TRIGLEVEL_LEFT, + IKEY_TRIGLEVEL_RIGHT, + IKEY_TRIGLEVEL_OK, + + IKEY_VOLTS_LEFT, + IKEY_VOLTS_RIGHT, + IKEY_VOLTS_OK, + + IKEY_TIMEBASE_LEFT, + IKEY_TIMEBASE_RIGHT, + IKEY_TIMEBASE_OK, + + IKEY_SELECT_LEFT, + IKEY_SELECT_RIGHT, + IKEY_SELECT, + }KeyFlagsPos; + + typedef struct _CellBaseValue { + float Value; + short Unit; + short IsLimit; // == 1,yes; =0, no! + }CellBaseValue; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + +#include //1ֽڶ + //@brief : λ + //@remark: + typedef struct _measure_param { + float value; //ЧʱֵΪ FLT_MAX + //@brief : λ + //@remark: λUnitType + short unit; //ЧʱֵΪ UT_Invalid = (0x8000) + }UValue; + + //@brief : ȡLED״̬ + //@remark: 1 - 0 δ ָLED? ȡ + typedef struct _KeyLedStat { + char CH1, CH2, CH3, CH4, MATH, REF, RUN_STOP, Single; + }KeyLedStat; + + //@brief : ݰ + typedef struct _CursorMeasurePack { + UValue Ax; + UValue Bx; + UValue Bx_Ax; + UValue Hz_Bx_Ax; + UValue Ay; + UValue By; + UValue By_Ay; + char Reserver[8]; + }CursorMeasurePack; +#include + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // DSO_UPO_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ca/ca012731124bc7df24ee5741124c65a017ff514c.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ca/ca012731124bc7df24ee5741124c65a017ff514c.svn-base new file mode 100644 index 0000000..85f1b3a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ca/ca012731124bc7df24ee5741124c65a017ff514c.svn-base @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// SimpleUCI.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cb/cbe1a5969f35f505fcb33c17036b12dff31a6e7d.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cb/cbe1a5969f35f505fcb33c17036b12dff31a6e7d.svn-base new file mode 100644 index 0000000..ca316b2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cb/cbe1a5969f35f505fcb33c17036b12dff31a6e7d.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cb/cbef5a06d98cb80907fc08ec9d67d07bbf08cd64.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cb/cbef5a06d98cb80907fc08ec9d67d07bbf08cd64.svn-base new file mode 100644 index 0000000..0505307 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cb/cbef5a06d98cb80907fc08ec9d67d07bbf08cd64.svn-base @@ -0,0 +1,13 @@ + + + + 发布\ + + + + + + zh-CN + false + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cf/cf4699cb2970073e364fbab15244e6755c7908a8.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cf/cf4699cb2970073e364fbab15244e6755c7908a8.svn-base new file mode 100644 index 0000000..0afac5b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/cf/cf4699cb2970073e364fbab15244e6755c7908a8.svn-base @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h ߰汾Ŀ Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d2/d252754fc59cd1f995e99d538a7028419980161b.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d2/d252754fc59cd1f995e99d538a7028419980161b.svn-base new file mode 100644 index 0000000..60f3044 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d2/d252754fc59cd1f995e99d538a7028419980161b.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d3/d301925379206905ce4a6f73c370d0a66c67617c.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d3/d301925379206905ce4a6f73c370d0a66c67617c.svn-base new file mode 100644 index 0000000..85b8787 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d3/d301925379206905ce4a6f73c370d0a66c67617c.svn-base @@ -0,0 +1,7001 @@ +CH_1 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0400 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0400 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0400 +0.0800 +0.0400 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0400 +0.0800 +0.0400 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0400 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.1200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.8400 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +1.7200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0400 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0400 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0400 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0400 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1600 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0400 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.8400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.1200 +3.1200 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.1200 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.1200 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.1200 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.1200 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0400 +3.0800 +1.7200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0400 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0400 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0400 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0400 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0400 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1600 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.1200 +0.1200 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.1200 +0.0800 +0.0800 +0.1200 +0.1200 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.1200 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.0800 +0.8400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0400 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.1200 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.1200 +3.0800 +3.1200 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.1200 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0400 +3.0800 +3.0800 +3.0800 +3.0400 +3.0400 +3.0800 +3.0400 +3.0800 +3.0800 +3.0800 +3.0800 +3.0800 diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d3/d33f7155d4020bca946927f6db89a5efbd5537ce.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d3/d33f7155d4020bca946927f6db89a5efbd5537ce.svn-base new file mode 100644 index 0000000..797c1c2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d3/d33f7155d4020bca946927f6db89a5efbd5537ce.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d5/d5a23fe83028d80da05f0b1ec4797a00ebf8b335.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d5/d5a23fe83028d80da05f0b1ec4797a00ebf8b335.svn-base new file mode 100644 index 0000000..05be8ba --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d5/d5a23fe83028d80da05f0b1ec4797a00ebf8b335.svn-base @@ -0,0 +1,105 @@ +#include "stdafx.h" +#include "SimpleUCI.h" +#include + +#include "uci.h" +#include "dso_base.h" +#include "unit.h" + +#include "uci_cpp.h" + +#pragma comment(lib, "uci.lib") + +using namespace uci; + +int HandleResult(const TCHAR* _msg, int _r) { + if (UCISUCCESS(_r)) { + _tprintf(_T("%s: OK, r = %d;\n"), _msg, _r); + } else { + _tprintf(_T("%s: Error, r = %d; msg = %s\n"), _msg, _r, uci_GetLastError()); + } + return _r; +} + +void ParseParamsMeasure(byte* _data, int _data_len) { + if (_data_len != (sizeof(cb::MeaValue) * EMeaParam::MP_MAX_COUNT)) + return; + + cb::MeaValue* pmv = reinterpret_cast(_data); + + for (size_t i = 0; i < EMeaParam::MP_MAX_COUNT; i++) { + _tprintf(_T("\r\nIsExist=%d,IsValid=%d,Value=%f, Unit(Type=%d,Scale=%d)"), + pmv->IsExist, pmv->IsValid, pmv->Value, pmv->Unit.Type, pmv->Unit.Scale); + + if (pmv->IsExist && pmv->IsValid) + { + printf("- %s%s", unit::uci_UnitFindScaleName(pmv->Unit.Scale), + unit::uci_UnitFindTypeName(pmv->Unit.Type)); + + printf("- ׼λ %f", unit::uci_UnitConvertTo(pmv->Value, pmv->Unit.Scale, unit::SCALE_STD, 1000.0)); + } + + pmv++; + } +} + +namespace dat { + struct MeaUserParams { + char ID; //-1 : ޲ + char CH; //0 ʼͨţ ID == -1 CHЧ + }; + + enum ECH { + CH1, + CH2, + CH3, + CH4, + }; +} +void _main_c(); +void _main_cpp(); + +void _main() { + //_main_c(); + _main_cpp(); +} + +void _main_c() { + u_session session = INVALID_SESSION; + //u_cstring addr = _T("[C:UPO][D:UPO][T:TCPIP][IP:192.168.1.113][Port:0x1388]"); + u_cstring addr = _T("[C:UPO][D:UPO][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x3][CFG:3][I:0]"); + + try { + u_status r = uci_Open(addr, &session, 1000); + if (UCIERR(r)) { + _tprintf(_T(": 豸ʧܣ ַ%s, Ϣ %s\n"), addr, uci_GetLastError()); + throw r; + } + + } catch (u_status r) { + + if (UCIERR(r)) + _tprintf(_T("Ϣ %s\n"), uci_GetLastError()); + } + + if (session != INVALID_SESSION) { + uci_Close(session); + } +} + +void _main_cpp() { + uci::Session ses; + + u_cstring addr = _T("[C:UPO][D:UPO][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x3][CFG:3][I:0]"); + u_status r = ses.Open(addr); + if (UCIERR(r)) { + _tprintf(_T(": 豸ʧܣ ַ%s, Ϣ %s\n"), addr, uci_GetLastError()); + return; + } + + std::vector buf(400, 0); + r = ses.Read(_T("mea:all?;"), 1000, buf.data(), buf.size()); + HandleResult(_T("mea:all?"), r); + if (UCISUCCESS(r)) + ParseParamsMeasure(buf.data(), buf.size()); +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d6/d65088535eee90a45d34f8c31912a1d6242c18ea.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d6/d65088535eee90a45d34f8c31912a1d6242c18ea.svn-base new file mode 100644 index 0000000..d95d2fb Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d6/d65088535eee90a45d34f8c31912a1d6242c18ea.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d8/d8e4c76a129d0ccd7a8df9da451a8ca3317d8890.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d8/d8e4c76a129d0ccd7a8df9da451a8ca3317d8890.svn-base new file mode 100644 index 0000000..275955b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d8/d8e4c76a129d0ccd7a8df9da451a8ca3317d8890.svn-base @@ -0,0 +1,245 @@ +[Workspace Header] +Version = 850 +Pathname = "/e/Documents/National Instruments/CVI85/UCIDEMO.cws" +CVI Dir = "/c/program files (x86)/national instruments/cvi85" +CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI" +CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI85" +CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI" +IVI Standard Root Dir = "/C/Program Files (x86)/IVI Foundation/IVI" +VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt" +Number of Projects = 3 +Active Project = 3 +Project 0001 = "" +Project 0002 = "" +Project 0003 = "UCIDEMO.prj" +Drag Bar Left = 198 +Window Top = 95 +Window Left = 78 +Window Bottom = 1018 +Window Right = 1778 +Maximized = True +Maximized Children = True +Max Number Of Errors = 20 +Track Include File Dependencies = True +Prompt For Missing Includes = True +Stop On First Error File = False +Bring Up Err Win For Warnings = True +Show Build Dialog = False +Save Changes Before Running = "Always" +Hide Windows = False +Global Hot Key = False +Break At First Statement = False +Sort Type = "File Name" +Number of Opened Files = 7 +Window Confinement Region Enabled = True +MainColumnWidth = 179 +FileDateColumnWidth = 70 +FileSizeColumnWidth = 70 +StatusColumnWidth = 70 + +[Project Header 0001] +Version = 850 +Don't Update DistKit = False +Platform Code = 4 +Build Configuration = "Debug" +Warn User If Debugging Release = 1 +Batch Build Release = False +Batch Build Debug = False +Force Rebuild = False + +[Project Header 0002] +Version = 850 +Don't Update DistKit = False +Platform Code = 4 +Build Configuration = "Debug" +Warn User If Debugging Release = 1 +Batch Build Release = False +Batch Build Debug = False +Force Rebuild = False + +[Project Header 0003] +Version = 850 +Don't Update DistKit = False +Platform Code = 4 +Build Configuration = "Debug" +Warn User If Debugging Release = 1 +Batch Build Release = False +Batch Build Debug = False +Force Rebuild = False + +[File 0001] +Path = "/e/Documents/National Instruments/CVI85/UCIDEMO.c" +File Type = "CSource" +Disk Date = 3560402216 +In Projects = "3," +Window Top = 98 +Window Left = 44 +Window Z-Order = 1 +Source Window State = "1,112,114,112,35,36,35,0,0,209,0,0,0,0,0,40,141,0,63,4,505,757,1,0," + +[File 0002] +Path = "/e/Documents/National Instruments/CVI85/UCIDEMO.uir" +File Type = "User Interface Resource" +Disk Date = 3560402075 +In Projects = "3," +Window Top = 66 +Window Left = 27 +Window Height = 334 +Window Width = 757 +Window Z-Order = 2 + +[File 0003] +Path = "/c/Program Files (x86)/National Instruments/CVI85/include/ansi_c.h" +File Type = "Include" +Disk Date = 3275949600 +In Projects = "" +Window Top = 130 +Window Left = 61 +Window Z-Order = 7 +Source Window State = "1,21,21,21,13,18,18,0,3,88,0,0,0,0,0,16,11,0,21,13,334,757,1,0," + +[File 0004] +Path = "/e/Documents/National Instruments/CVI85/lib/C/ASCII/uci.lib" +File Type = "Library" +Disk Date = 3560397350 +In Projects = "3," + +[File 0005] +Path = "/e/Documents/National Instruments/CVI85/include/uci.h" +File Type = "Include" +Disk Date = 3560397554 +In Projects = "" +Window Top = 162 +Window Left = 78 +Window Z-Order = 5 +Source Window State = "1,127,135,135,0,107,107,0,0,88,0,0,0,0,0,16,121,0,134,51,334,757,1,0," + +[File 0006] +Path = "/e/Documents/National Instruments/CVI85/include/ucidef.h" +File Type = "Include" +Disk Date = 3560397476 +In Projects = "" +Window Top = 130 +Window Left = 61 +Window Z-Order = 6 +Source Window State = "1,251,251,251,8,23,23,0,3,88,0,0,0,0,0,20,236,0,251,8,410,757,1,0," + +[File 0007] +Path = "/e/Documents/National Instruments/CVI85/include/unit.h" +File Type = "Include" +Disk Date = 3560397608 +In Projects = "" +Window Top = 98 +Window Left = 44 +Window Z-Order = 4 +Source Window State = "1,53,53,53,23,26,23,0,0,88,0,0,0,0,0,16,0,0,23,33,334,757,1,0," + +[File 0008] +Path = "/e/Documents/National Instruments/CVI85/include/comApiCommon.h" +File Type = "Include" +Disk Date = 3560396673 +In Projects = "" +Window Top = 98 +Window Left = 44 +Window Z-Order = 3 +Source Window State = "1,197,197,197,8,14,14,0,0,88,0,0,0,0,0,16,189,0,199,17,334,757,1,0," + +[Build Options 0001] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Execution Trace = "Disabled" +Debugging Level = "Standard" +Break On Library Errors = True +Break On First Chance Exceptions = False +Execution Target Address = "Local desktop computer" +Execution Target Port = 0 +Execution Target Type = 0 + +[SCC Options 0001] +Use global settings = True +SCC Provider = "" +SCC Project = "" +Local Path = "" +Auxiliary Path = "" +Perform Same Action For .h File As For .uir File = "Ask" +Perform Same Action For .cds File As For .prj File = "Ask" +Username = "" +Comment = "" +Use Default Username = False +Use Default Comment = False +Suppress CVI Error Messages = False +Always show confirmation dialog = True + +[DLL Debugging Support 0001] +External Process Path = "" + +[Command Line Args 0001] +Command Line Args = "" + +[Build Options 0002] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Execution Trace = "Disabled" +Debugging Level = "Standard" +Break On Library Errors = True +Break On First Chance Exceptions = False +Execution Target Address = "Local desktop computer" +Execution Target Port = 0 +Execution Target Type = 0 + +[SCC Options 0002] +Use global settings = True +SCC Provider = "" +SCC Project = "" +Local Path = "" +Auxiliary Path = "" +Perform Same Action For .h File As For .uir File = "Ask" +Perform Same Action For .cds File As For .prj File = "Ask" +Username = "" +Comment = "" +Use Default Username = False +Use Default Comment = False +Suppress CVI Error Messages = False +Always show confirmation dialog = True + +[DLL Debugging Support 0002] +External Process Path = "" + +[Command Line Args 0002] +Command Line Args = "" + +[Build Options 0003] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Execution Trace = "Disabled" +Debugging Level = "Standard" +Break On Library Errors = True +Break On First Chance Exceptions = False +Execution Target Address = "Local desktop computer" +Execution Target Port = 0 +Execution Target Type = 0 + +[SCC Options 0003] +Use global settings = True +SCC Provider = "" +SCC Project = "" +Local Path = "" +Auxiliary Path = "" +Perform Same Action For .h File As For .uir File = "Ask" +Perform Same Action For .cds File As For .prj File = "Ask" +Username = "" +Comment = "" +Use Default Username = False +Use Default Comment = False +Suppress CVI Error Messages = False +Always show confirmation dialog = True + +[DLL Debugging Support 0003] +External Process Path = "" + +[DLLs Used By Executable 0003] +DLL 0001 = "/e/Documents/National Instruments/CVI85/uci.dll" + +[Command Line Args 0003] +Command Line Args = "" + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d8/d8f9f014c4f80623517a14d50b1e1cc08d1f39ba.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d8/d8f9f014c4f80623517a14d50b1e1cc08d1f39ba.svn-base new file mode 100644 index 0000000..9451322 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/d8/d8f9f014c4f80623517a14d50b1e1cc08d1f39ba.svn-base @@ -0,0 +1,145 @@ + +// UCIDemoProjDlg.h : ͷļ +// + +#pragma once + +#include "lib\uci.h" +#include +#include "afxwin.h" +#include "lib\dso_base.h"//ʹ +#include "lib\unit.h"//ʹ + +class CMyMFCButton : public CMFCButton { +public: + void SetDelayFullTextTooltipSet(bool DelayFullTextTooltipSet) { + m_bDelayFullTextTooltipSet = DelayFullTextTooltipSet; + } +}; + +// CUCIDemoProjDlg Ի +class CUCIDemoProjDlg : public CDialogEx +{ +// +public: + CUCIDemoProjDlg(CWnd* pParent = NULL); // ׼캯 + +// Ի + enum { IDD = IDD_UCIDEMOPROJ_DIALOG }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + +public: + static CUCIDemoProjDlg* c_object; +// ʵ +protected: + HICON m_hIcon; + CEdit m_Ctrl_Edit_Msg; + UINT m_Val_Timeout; + int m_Val_BytesToRead; + CMFCEditBrowseCtrl m_CtrlFileChoose; + CComboBox m_cbxCMD; + CMyMFCButton m_btnWriteParam_File; + +protected: + CToolTipCtrl m_tips; +protected: + bool m_IsConnect; + int m_MaxCMDHistoryCount; + CString m_strCMDListPath; + CString m_DevName, m_IDN; + CString m_ConnectAddrIP; + CString m_ConnectAddrPort; + int m_nConnectAddrPort; + int m_COMType; + + uci::Node m_Nodes[100]; + + CString m_CommandString, m_Path; + +protected: + void GetCMDString(CString& _msg); + int UCIWrite(const TCHAR* _cmd, UINT _timeOut); + int UCIRead(const TCHAR* _cmd, u_byte* _data, u_size _dataLen, UINT _timeOut); + + static int __stdcall UCI_MessageProc(uci::UCIMSG* _msg); + + void Disconnect(); + void RecordCMD(const CString& _msg); + + void ShowResult(int _r, int _idsSOerationString, const TCHAR* _format = NULL, ...); + + // @brief : ׷ϢıϢʾ + // @param : const u_tchar * _format + // @param : ... + // @return : void + // @remarks : + void AppendTraceMsg(const u_tchar * _format, ...); + // ɵϢӳ亯 + virtual BOOL OnInitDialog(); + + void InitUI(); + void LoadCMDList(); + bool GetAppFolderPath(CString& _strPath); + void EnableWidgets(BOOL _isConnect); + + CString FindConnectAddrField(const CString& _addr, const CString& _fieldBegin, const CString&_fieldEnd); + + // + void ParseParamsMeasure(byte* _data, int _data_len); + void ParseParamsMeasure_User(byte* _data, int _data_len); + void PrintMeaParam(const TCHAR * _name, const comAPICommon::MeaValue& _p); + + bool GetCommandString(); + bool GetFilePath(); +protected: + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() + afx_msg void OnBnClickedButtonQueryNodes(); + afx_msg LRESULT AFX_MSG_CALL OnLANDisconnect(WPARAM wParam, LPARAM lParam); + +public: + afx_msg void OnBnClickedButtonClear(); + afx_msg void OnBnClickedButtonOpen(); + afx_msg void OnBnClickedBtnWrite(); + afx_msg void OnBnClickedBtnRead(); + + const CString& CreateBmpFileName(CString &msg, CString& fileName); + + afx_msg void OnBnClickedButtonWriteFile(); + afx_msg void OnBnClickedButtonReadFile(); + afx_msg void OnDestroy(); + afx_msg void OnBnClickedBtnWriteInFile(); + + bool CheckConnectiion(); + + afx_msg void OnBnSetfocusBtnWriteInFile(); + virtual BOOL PreTranslateMessage(MSG* pMsg); + + // ʾ豸ַб + CComboBox m_cbxDevAddr; + + inline CString GetCurrentTime() { + SYSTEMTIME t = { 0 }; + GetLocalTime(&t); + + CString s; + s.Format(_T("%02d-%02d-%02d"), t.wHour, t.wMinute, t.wSecond); + return s; + } + + + inline CString LoadString(UINT idRes) { + CString str; + BOOL bNameValid = str.LoadString(idRes); + ASSERT(bNameValid); + return str; + } + + inline void SetWidgetText(UINT _idWidget, UINT _idString) { + SetDlgItemText(_idWidget, LoadString(_idString)); + } + CString m_cbBoxText; +}; diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/db/db5065a26825cd88353bdbc406f916ce6d06c136.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/db/db5065a26825cd88353bdbc406f916ce6d06c136.svn-base new file mode 100644 index 0000000..6aa74a7 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/db/db5065a26825cd88353bdbc406f916ce6d06c136.svn-base @@ -0,0 +1,38 @@ +======================================================================== +̨ӦóSimpleUCI Ŀ +======================================================================== + +ӦóΪ˴ SimpleUCI Ӧó + +ļҪ SimpleUCI Ӧóÿļݡ + + +SimpleUCI.vcproj +ʹӦóɵ VC++ ĿĿļ +ɸļ Visual C++ İ汾ϢԼйʹӦóѡƽ̨úĿܵϢ + +SimpleUCI.cpp +ӦóԴļ + +///////////////////////////////////////////////////////////////////////////// +Ӧó򵼴Դ + +SimpleUCI.rc +dzʹõ Microsoft Windows Դб RES Ŀ¼д洢ͼꡢλͼ͹ꡣļֱ Microsoft Visual C++ нб༭ + +Resource.h +DZ׼ͷļµԴ ID +Microsoft Visual C++ ȡ´ļ + +///////////////////////////////////////////////////////////////////////////// +׼ļ + +StdAfx.h, StdAfx.cpp +ЩļΪ SimpleUCI.pch Ԥͷ (PCH) ļΪ StdAfx.obj Ԥļ + +///////////////////////////////////////////////////////////////////////////// +עͣ + +ӦóʹáTODO:ָʾӦӻԶԴ벿֡ + +///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/db/dbb658b17ca10db1b6cc94d760d744902f2a7688.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/db/dbb658b17ca10db1b6cc94d760d744902f2a7688.svn-base new file mode 100644 index 0000000..77b14b0 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/db/dbb658b17ca10db1b6cc94d760d744902f2a7688.svn-base @@ -0,0 +1,53 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +// 뽫λָƽ̨֮ǰƽ̨ΪĿ꣬޸ж塣 +// йزͬƽ̨ӦֵϢο MSDN +#ifndef WINVER // ʹض Windows XP ߰汾Ĺܡ +#define WINVER 0x0501 // ֵΪӦֵ Windows 汾 +#endif + +#ifndef _WIN32_WINNT // ʹض Windows XP ߰汾Ĺܡ +#define _WIN32_WINNT 0x0501 // ֵΪӦֵ Windows 汾 +#endif + +#ifndef _WIN32_WINDOWS // ʹض Windows 98 ߰汾Ĺܡ +#define _WIN32_WINDOWS 0x0410 // ֵΪʵֵָ Windows Me ߰汾ΪĿꡣ +#endif + +#ifndef _WIN32_IE // ʹض IE 6.0 ߰汾Ĺܡ +#define _WIN32_IE 0x0600 // ֵΪӦֵ IE 汾 +#endif + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +#include +#include +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Windows ͷųʹõ +#endif + +#include +#include // MFC ͱ׼ +#include // MFC չ +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC Internet Explorer 4 ؼ֧ +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC Windows ؼ֧ +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include + + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +#include +#include + +// TODO: ڴ˴óҪͷļ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/dd/dd0c9ba1235e7fae85781ab8c81582e7bd1b8c3e.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/dd/dd0c9ba1235e7fae85781ab8c81582e7bd1b8c3e.svn-base new file mode 100644 index 0000000..6c73e78 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/dd/dd0c9ba1235e7fae85781ab8c81582e7bd1b8c3e.svn-base @@ -0,0 +1,228 @@ +/******************************************************************** + created: 2014/12/22 + author: M.Yang + purpose: UCI(united communicate interface) +*********************************************************************/ + +#ifndef uci_h__ +#define uci_h__ + +#include "ucidef.h" + +////////////////////////////////////////////////////////////////////////// +// ڽӿڷص״ֵ̬ +// < 0 : ʾ +// ӦĴϢͨuci_GetLastErrorȡ,Ķucidef.hļС +// < UCI_ERRĴΪlibusbĴ롣 +////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +namespace uci { +extern "C"{ +#endif + //@brief : ִỰ޹صIJѯ + //@param PRParams _params : ѯIJ + //@param u_byte * _data : ݵĻַ + //@param u_size _dataCount : ݵĻСBytes + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_Query(_in_out PRParams _params, _in_out u_byte* _data, _in u_size _dataCount); + + //@brief : ѯͨŽڵ + //@param _in const QParams * _params : ѯ + //@param _out Node * _outBuf : ŲѯĽڵ + //@param _in_out u_size * _nodeCnt : ΪҪȡĽڵΪʵʶȡĽڵ + //@param _in u_size _timeOut : ѯʱ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_QueryNodes(_in const QParams* _params, _out Node* _outBuf, + _in_out u_size* _nodeCnt, _in u_size _timeOut); + + //@brief : ѯͨŽڵ + //@param _msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _nodes : ŲѯĽڵ + //@param _node_count : ҪѯĽڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX(u_cstring _msg, Node* _nodes, u_size _node_count, _in u_size _timeout); + + /*21-7-2017 15:51 by M.J Created <򻯰汾ѯͨѶڵ㲢ͨŵַ>*/ + //@brief : ѯͨŽڵ + //@param _addr_msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _addr_msg_len : յַַbufferij + //@param _node_type : ڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX_Simple(u_tchar* _addr_msg, u_size _addr_msg_len, u_size _node_type, _in u_size _timeout); + + //@brief : 豸 + //@param u_cstring _addr : 豸ַ '\0'β + //@param u_session * _session : ѽĻỰID. + //@param u_uint32 _timeOut : ӳʱʱ ms + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + // UCI_SUCCESS + // UCI_ERR_ARGS_WRONG; + // UCI_ERR_RES_INIT_ERROR; + // UCI_ERR_CONNECT_ADDR_WRONG; + // UCI_ERR_CONNECT_FAILED; + // UCI_ERR_CONNECT_TIMEOUT] + //@remarks : ĵ + u_status _UCIAPI uci_Open(u_cstring _addr, u_session* _session, u_uint32 _timeOut); + + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 + u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + //@brief : ִ + //@param u_session _session : ỰID + //@param PCommandParams _params : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SendCommand(u_session _session, PCommandParams _params); + + //@brief : UCI¼ + //@param uciNotify _pNotify : ӦUCI¼Ļص + //@return u_status _UCIAPI : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SetNotify(UCIMSGProc _pNotify); + + //@brief : + //@param _msg : ַ + //@param _obj : ݻַ + //@param _objSize : ݻС + //@return : 鿴ļеġڽӿڷص״ֵ̬˵s + //@remarks : Ŀǰֻ֧л԰汾Ͷ豸ͷĵ¼鿴ĵ + u_status _UCIAPI uci_SetAttribute(u_session _sesn, u_cstring _msg, const u_object* _obj, u_size _objSize); + + //@brief : ѯ + //@param u_session _sesn : + //@param u_attr _name : + //@param u_attr_v * _value : + //@return u_status _UCIAPI : + //@remarks : + u_status _UCIAPI uci_GetAttribute(u_session _sesn, u_cstring _msg, u_object* _obj, u_size _objSize); + + //@brief : д + //@param u_session _session : ỰID + //@param PWParam _params : д + //@param const u_byte * _data : Ҫдݻַ ΪNULL + //@param u_size _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_params.CMDStringѾҪдֶˣʹuci_FormatWriteӿڣ + // _data != NULLַ_params.CMDStringֻܰһ䡣 + u_status _UCIAPI uci_Write(u_session _session, PWParams _params, const u_byte* _data, u_size _len); + + //@brief : д + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@param _data : Ҫдݻַ ΪNULL + //@param _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_msgѾҪдֶˣ + // _data != NULLַ_msgֻܰһ䡣 + u_status _UCIAPI uci_WriteX(u_session _session, u_cstring _msg, + u_uint32 _timeout, const u_byte* _data, u_size _len); + + //@brief : ֻдַָдָӿ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteSimple(u_session _session, u_cstring _msg, u_uint32 _timeout); + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + //@brief : ȡ + //@param u_session _session : ỰID + //@param PRParams _params : + //@param u_byte * _data : ݵĻ + //@param u_size _dataLen : ݵĻССЭ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ʹuci_ReadX汾 + u_status _UCIAPI uci_Read(u_session _session, PRParams _params, u_byte* _data, u_size _dataLen); + + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 + u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, + u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + //@brief : дļ + //@param u_session _session : ỰID + //@param WFileParams * _info : ļϢ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteFromFile(u_session _session, WFileParams* _info); + + //@brief : дļ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : Ҫдļ·ļ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_WriteFromFileļ򻯰汾 + u_status _UCIAPI uci_WriteFromFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout); + + //@brief : Read data synchronously and store the transferred data in a file. + //@param u_session _session : ỰID + //@param RFileParams _params : Ҫݵļ· + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_ReadToFile(u_session _session, RFileParams* _params); + + //@brief : ȡļ + //@param _session : ỰID. + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : ݵش̵ļ·ļͺ׺ + //Ǿ·Ҳ··ͨ_filePathFinalȡ· + //@param _timeout : ʱ + //@param _filePathFinal : 嵽صļľ· + //@param _filePathFinalLength : _filePathFinalijȣַ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_ReadToFileķǷװ汾 + u_status _UCIAPI uci_ReadToFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength); + + //@brief : رջỰ + //@param u_session _session : ҪرյĻỰID + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + u_status _UCIAPI uci_Close(u_session _session); + + //@brief : һβӦĴ״̬Ϣ + //@return u_cstring : Ϣ + //@remarks : ͨuci_SetAttributeôϢ԰汾 + u_cstring _UCIAPI uci_GetLastError(void); + + //@brief : ˳UCIʵʱá + //@remarks : ˳ʱãͷڲԴ + // ӿڲһҪʹá ֻ.NETйܻ£ + // ͨuci_SetAttribute uci_SetNotifyӿ + // 豸Ƴ¼ʱ˳ʱʹá + void _UCIAPI uci_ExInstance(void); +#ifdef __cplusplus +} + +} +#endif +#endif // uci_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/de/ded4335a2d8bb74f3f0973c39c97eb328cdca495.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/de/ded4335a2d8bb74f3f0973c39c97eb328cdca495.svn-base new file mode 100644 index 0000000..e304835 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/de/ded4335a2d8bb74f3f0973c39c97eb328cdca495.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e1/e1c9295a8980486fec38b4af2186a577a591ce46.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e1/e1c9295a8980486fec38b4af2186a577a591ce46.svn-base new file mode 100644 index 0000000..50bce8d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e1/e1c9295a8980486fec38b4af2186a577a591ce46.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e2/e2104f52e577a72406c058027d70babd30a715bf.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e2/e2104f52e577a72406c058027d70babd30a715bf.svn-base new file mode 100644 index 0000000..a2aa80e --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e2/e2104f52e577a72406c058027d70babd30a715bf.svn-base @@ -0,0 +1,24 @@ +VC\UCIDEMO\UCI_DEMO.exe + Դ빤UCIDemoProjıij + óUCIͨŽӿڵʾͲԳ ԶĵָͲĽӿӡ + +VC\SimpleUCI + Ǽ򵥵UCIӿڵʾ̣ʾCӿںC++ֽӿʹá + +VB\UCIDemoVBProj.zip + Ǽ򵥵VBӿʹõʾ̡ + +CVI + ʹCVIʾ + +UCI-Labview11.0 + LabViewƽ̨µʾ + +LabView-UCI + ǽµLabViewƽ̨µʹýӿںʾ + +Ҫѡʵƽ̨жο + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e4/e4a3b6129dddb21cf17ff77f8b6d82f5927f7a8c.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e4/e4a3b6129dddb21cf17ff77f8b6d82f5927f7a8c.svn-base new file mode 100644 index 0000000..3e60937 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e4/e4a3b6129dddb21cf17ff77f8b6d82f5927f7a8c.svn-base @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uci; + +/* + * 本工程演示基本的设备访问接口,如查询、打开、读、写、关闭等等。 + * 以示波器为演示机型。 + */ +namespace SimpleIO +{ + class Program + { + /// + /// 会话类,也可以使用UCIInterop的适配接口,但最终都是调用的uci.dll中的接口 + /// + static Session _com = new Session(true); + + static void Main(string[] args) + { + //{全局配置 + //切换所有打印输出为中文; + UCIInterop.SetAttribute(UCIInterop.InvalidSession,"lang:zh-Hans;", null, 0); + //切换所有打印输出为英文; + //UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:en-US;", null, 0); + //} + + //{查询设备示例 + string queryMsg = "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348"; //查询USB设备 + //queryMsg += ";LAN:4162,5000";//查询网络设备 + queryMsg += ";"; + uci.Node[] nodes = new uci.Node[10]; + int count = UCIInterop.QueryNodesX(queryMsg, nodes, nodes.Length, 2000); + if (count > 0) + { + Console.WriteLine("查询到的满足条件的USB设备数量:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("[{0}]\t:\t{1}", i, nodes[i].UCIAddr); + } + } + else + { + OutputResult(count, "查询设备"); + } + //} + + //{查询串口设备 + // 此查询不包括任何的协议,只是查询串口。如果要查询指定协议的设备,请遍历打开串口 + // 并使用指定协议进行验证。 + uci.COMPort[] comPorts = new uci.COMPort[10]; + count = UCIInterop.QueryCOMPort(comPorts, comPorts.Length); + if (count > 0) + { + Console.WriteLine("Ports:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("{0} - COM{1} : {2}", i, comPorts[i].Port, comPorts[i].FriendlyName); + } + } + else if (count == 0) + { + Console.WriteLine("未查询到任何串口设备"); + } + else + { + OutputResult(count, "查询串口设备"); + } + //* Ports:1 + //* 0 - COM3 : Silicon Labs CP210x USB to UART Bridge (COM3) + //} + + + //打开设备,设备地址获取方式: + //1 可以从文档中获取; + //2 使用UCIInterop.QueryNodesX查询获取; + //3 使用“SDK\examples\VC\UCIDEMO\Unicode\UCI_DEMO.exe"程序,查询获取。 + string addr = "[C:DSO][D:DSO-E][T:USB][PID:0x5537][VID:0x4348][EI:0x82][EO:0x2][CFG:1][I:0][addr:0]"; + //addr = "[C:UPO][D:UPO][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x3][CFG:3][I:0]"; + var r = _com.Open(addr); + if (!OutputResult(r, "打开设备")) + {//error : r < 0; + //特别的,如果返回-1040(建立连接的字符串地址格式错误),说明当前工程 + //和调用的uci.dll的字符编码不一致,一般C#的工程都是UNICODE的版本, + //请拷贝“SDK\lib\C\Unicode\uci.dll”到当前工程的执行程序的运行目录下。 + return; + } + + //写参数 + r = _com.Write("CH:0@sel;"); + OutputResult(r, "写参数"); + + //读参数测量结果 + //{打包读取所有参数测量结果--适用于所有示波器 + byte[] allMeaBytes = new byte[50 * 8]; //固定的50个参数,一个参数8Bytes + r = _com.Read("mea:all?;", allMeaBytes); + if (OutputResult(r, "读参数测量")) + { + //转换为结构体 + uci.Model.mea.MeaValue[] allMea = new uci.Model.mea.MeaValue[50]; + uci.Utility.ByteArrayToStructArray(allMeaBytes, ref allMea, 50); + //打印输出 + ParseParamsMeasure(allMea); + } + //} + + //读取单个参数 - 请参照文档查看是否支持。 +#if false + double v = 0.0; + r = _com.Read("mea:freq;", out v); +#endif + + //{读取波形文件 + // 指令格式(capture wave:.csv@CH:0@DT:vol;)请参照具体的文档,个别机型有差异。 + uci.RFileParams rfp = new RFileParams() + { + CMDString = "capture wave:.csv@CH:0@DT:vol;", + FilePath = "waveform.csv", + TimeOut = 2000, + }; + r = _com.ReadToFile(ref rfp); + OutputResult(r, "读波形文件"); + //} + + //Session析构时自动关闭 + } + + /// + /// 输出UCI API的接口返回的结果 + /// + /// + /// + /// + static bool OutputResult(int r, string msg) + { + string s = "[" + msg + "]"; + if (Session.Error(r)) + { + s += string.Format("失败,错误码:{0},错误信息:{1}", + r, _com.GetLastError()); + } + else + { + s += "成功!"; + } + Console.WriteLine(s); + return r >= 0; + } + + /// + /// 得到物理单位量级 + /// + /// + /// + static string GetUnitScaleName(uci.Model.unit.Scale s) + { + if (s == uci.Model.unit.Scale.STD) + return string.Empty; + return s.ToString(); + } + + /// + /// 打印参数测量的所有结果 + /// + /// + static void ParseParamsMeasure(uci.Model.mea.MeaValue[] m) + { + for(int i = 0; i < m.Length; i++) + { + Console.WriteLine("{0}:IsExist={1},IsValid={2}, Value={3}, Unit(Type={4},Scale={5}) --> {6}{7}{8}", + (uci.Model.mea.MeaParam)(i), + m[i].IsExist, m[i].IsValid, m[i].Value, m[i].Unit.Type, m[i].Unit.Scale, + m[i].Value, + GetUnitScaleName((uci.Model.unit.Scale)m[i].Unit.Scale), + //获取物理量单位,可以使用uci API : UCIInterop.GetUnitTypeName + //也可以自己建表 + UCIInterop.GetUnitTypeName((char)m[i].Unit.Type)); + } + } + } +} diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e7/e7c5509f940ddb10e005816e0c47e4088cab03cd.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e7/e7c5509f940ddb10e005816e0c47e4088cab03cd.svn-base new file mode 100644 index 0000000..f00d8d1 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e7/e7c5509f940ddb10e005816e0c47e4088cab03cd.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e7/e7cb06cb9bbdbab8646d1f69c5911f3a583058b8.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e7/e7cb06cb9bbdbab8646d1f69c5911f3a583058b8.svn-base new file mode 100644 index 0000000..7b546ef Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e7/e7cb06cb9bbdbab8646d1f69c5911f3a583058b8.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e9/e91fdb2cd72603544db74d8174bcb6348c65d9a4.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e9/e91fdb2cd72603544db74d8174bcb6348c65d9a4.svn-base new file mode 100644 index 0000000..7d1f0cb Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/e9/e91fdb2cd72603544db74d8174bcb6348c65d9a4.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ea/ea6db44a262e63dc419321ebe2ad4db234ee0aa1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ea/ea6db44a262e63dc419321ebe2ad4db234ee0aa1.svn-base new file mode 100644 index 0000000..37e1158 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ea/ea6db44a262e63dc419321ebe2ad4db234ee0aa1.svn-base @@ -0,0 +1,3 @@ +[Ŀ(_D)] +ProjectExplorer.ClassicPosition[String] = "221,845,1094,1217" + diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ea/eaaa3d5567efec4500153fc029aaf365b22cc7f4.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ea/eaaa3d5567efec4500153fc029aaf365b22cc7f4.svn-base new file mode 100644 index 0000000..9a2620f Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ea/eaaa3d5567efec4500153fc029aaf365b22cc7f4.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb0473d7b54b639166f0365440f6da213e99c59e.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb0473d7b54b639166f0365440f6da213e99c59e.svn-base new file mode 100644 index 0000000..f7557fa Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb0473d7b54b639166f0365440f6da213e99c59e.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb1e3fb0f2eab044242e36fa19588c073bba2dcb.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb1e3fb0f2eab044242e36fa19588c073bba2dcb.svn-base new file mode 100644 index 0000000..2f9212c Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb1e3fb0f2eab044242e36fa19588c073bba2dcb.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb299023f86abd48e13855b9ac0f63e70c38020d.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb299023f86abd48e13855b9ac0f63e70c38020d.svn-base new file mode 100644 index 0000000..f5bf38d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb299023f86abd48e13855b9ac0f63e70c38020d.svn-base @@ -0,0 +1,571 @@ +/******************************************************************** + created: 2014/12/23 + author: M.Yang + purpose: UCIȫֶļ + modify: + *********************************************************************/ +#ifndef ucidef_h__ +#define ucidef_h__ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +#define _UCIAPI __stdcall +#define _UCICallBack __stdcall +#endif + +#define _in +#define _out +#define _in_out + +#ifdef __cplusplus +namespace uci { +#endif // __cplusplus + +#ifdef _CVI_ +#define u_inline static +#else +#define u_inline inline +#endif // _CVI_ + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif // !MAX_PATH + + ////////////////////////////////////////////////////////////////////////// + //{ Ͷ +#ifdef _UNICODE + //@brief : ʾһ Unicode ַ +#define u_tchar wchar_t +#else + //@brief : ʾһ ASCII ַ +#define u_tchar char +#endif // _UNICODE + +#if defined(_WIN64) + typedef unsigned __int64 u_unit_ptr; + typedef __int64 u_long_ptr; +#else + typedef unsigned int u_unit_ptr; + typedef long u_long_ptr; +#endif + + //@brief : Boolean +#define u_bool bool + //@brief : 8λ޷ +#define u_byte unsigned char + //@brief : 8λз +#define u_char char + //@brief : ָ͵Ļָ +#define u_buf void* + //@brief : ͵ij +#define u_object void + //@brief : ʾ 16 λз +#define u_short short + //@brief : ʾ 16 λ޷ +#define u_ushort unsigned short + //@brief : ʾ 16 λз +#define u_int16 u_short + //@brief : ʾ 16 λ޷ +#define u_uint16 u_ushort + //@brief : ʾ 32 λз +#define u_int32 int + //@brief : ʾ 32 λ޷ +#define u_uint32 unsigned int + //@brief : ʾUCIӿڷص״ֵ̬(32λз) +#define u_status u_int32 + //@brief : ʾС32λ޷ +#define u_size u_uint32 + //@brief : ʾỰID32λ޷ +#define u_session u_uint32 + //@brief : ʾַ +#define u_string u_tchar* + //@brief : ʾַֻ +#define u_cstring const u_tchar* + //@brief : ʾIDͣ32λ޷ +#define u_attr u_int32 + //@brief : ʾֵͣ32λ޷ +#define u_attr_v u_int32 + //@brief : ʾһ16λ޷͵ĵ +#define u_word u_ushort + //@brief : ʾһ32λ޷͵˫ +#define u_dword u_uint32 + //@brief : Ϣ +#define u_wparam u_unit_ptr + //@brief : Ϣ +#define u_lparam u_long_ptr + //} + + ////////////////////////////////////////////////////////////////////////// + //{ ӿڷ״ֵ̬ + //@brief : ɹ +#define UCI_SUCCESS (0) + //@brief : ʼֵ +#define UCI_ERR (-1000) + //@brief : жϵǰӿǷִʧ + //@brief : жϵǰӿǷִгɹ +#define UCIERR(r) (r < 0) +#define UCISUCCESS(r) (!UCIERR(r)) + + //@brief : + typedef enum _UCIErr { + NoError = 0, + + //@brief : Դʼ + InitResourceError = UCI_ERR - 20, + //@brief : ЧĻỰ + Invalid_Session, + //@brief : ʱ + Timeout, + //@brief : ʧ + Failed, + //@brief : ֵ֧IJ + Unsupported, + //@brief : ڴռ䲻 + Insufficient_Memory, + //@brief : ϵͳæ޷Ӧ + Busy, + //@brief : ͨ쳣棡 + COMExpection, + //@brief : ͨδ򿪣 + ChannelNotOpened, + //@brief : WinAPI + API_Failed, + + //@brief : δ֪Ĵ + Unknown = UCI_ERR - 40 - 1, + + //@brief : ӵַַʽ + Connect_InvalidAddress = UCI_ERR - 40, + //@brief : ӻδ + Connect_NotBuild, + //@brief : ѶϿ + Connect_Break, + //@brief : ֵ֧ͨŷʽ + Connect_Unsupported_COMType, + + //@brief : δָ豸 + Device_NoFound = UCI_ERR - 60, + //@brief : ֵ֧豸 + Device_Unsupported, + //@brief : Ҫִвѯ豸IJ + Device_QueryFirst, + //@brief : Ͳƥ + Device_NotMatch, + + //@brief : ѯ豸ʧ + Query_LANNodesFailed, + + //@brief : USB豸ִַֻвѯ豸Ч + //@remarks : UCI⵼USB豸ַֻһб豸ַ + AddrValid_AfterQueryDeviceOper, + + //@brief : δU̽ + UDisk_NotFound, + //@brief : Ѿ + Key_Locked, + + //@brief : ַʽ + CMD_Invalid_StringFormat = UCI_ERR - 80, + //@brief : ֵֻ֧ + CMD_OnlySupportSingle, + //@brief : һֻ֧һ + CMD_OnlySupportSingleAttr, + //@brief : ֵ֧ + CMD_Unsupported, + //@brief : ʧ + CMD_SendFailed, + //@brief : Эݸʽ + CMD_Invalid_ProtocolFormat, + //@brief : 豸дļflashʧܣ + CMD_WriteFileToFlash_Failed, + //@brief : δЧĻظ + CMD_NoFound_Valid_Reply_Data, + //@brief : Ϣ鿴ǷЭ + CMD_Error_Message, + //@brief : Чıʽ + CMD_Invalid_Expression, + //@brief : ڵǰģʽ²ԼⲨļ + CMD_Cannot_LoadARB_InCurrent_MOD_Mode, + + //@brief : + Args_Invalid = UCI_ERR - 100, + //@brief : ṩĿռ̫С + Args_MemoryTooSmall, + //@brief : ṩļ̫(50ֽ) + Args_FileNameTooLong, + //@brief : ݴСЭ鲻ƥ(ֹݴ) + Args_DataLenNotMatch, + + //@brief : + Data_Overflow = UCI_ERR - 120, + //@brief : Χ + Data_OutRange, + //@brief : δȫȡ + Data_NotReadEnoughLenth, + //@brief : Уʧ + Data_ECC_Failed, + //@brief : Ч + Data_Invalid, + //@brief : ѹʧ + Data_Zip_Error, + //@brief : ݽѹʧ + Data_UnZip_Error, + //@brief : ݴʧ + Data_Transfer_Error, + //@brief : ݴʧ + Data_Transfer_Break, + //@brief : Чݿɶȡ + Data_No_Data_Incoming, + + //@brief : + File_AccessDenied = UCI_ERR - 140, + //@brief : An unspecified error occurred. + File_GenericException, + //@brief : The file could not be located. + File_NotFound, + //@brief : All or part of the path is invalid. + File_BadPath, + //@brief : The permitted number of open files was exceeded. + File_TooManyOpenFiles, + //@brief : There was an attempt to use an invalid file handle + // or The file format is unsupported! + // or The file data is error! + File_InvalidFile, + //@brief : The current working directory cannot be removed + File_RemoveCurrentDir, + //@brief : There are no more directory entries + File_DirectoryFull, + //@brief : There was an error trying to set the file pointer + File_BadSeek, + //@brief : There was a hardware error + File_HardIO, + //@brief : SHARE.EXE was not loaded, or a shared region was locked + File_SharingViolation, + //@brief : There was an attempt to lock a region that was already locked + File_LockViolation, + //@brief : The disk is full + File_DiskFull, + //@brief : The end of file was reached + File_EndOfFile, + //@brief : дļʧ + File_SaveToDiskFailed, + //@brief : ļȳΧ + File_Length_OutOfRange, + }UErr; + //} + ////////////////////////////////////////////////////////////////////////// + + //@brief : ĻỰID +#define INVALID_SESSION ((u_uint32)(-1)) + + ////////////////////////////////////////////////////////////////////////// + //{ + //лӢģ "lang:zh-hans" or "lang:en-us" + //ʹUSB豸ƳӼ "devchange:1" +//} + + +#define CACHE_LINE 1 +#define CACHE_ALIGN __declspec(align(CACHE_LINE)) + + //@brief : ýṹĶ뷽ʽ +#define PACK_ALIGN(n) __declspec(align(n)) + + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + + //one Word is 2 bytes + u_inline u_word UCI_HIWORD(u_dword _dw) { return ((u_word)((_dw >> 16) & 0xffff)); } + u_inline u_word UCI_LOWORD(u_dword _dw) { return ((u_word)(_dw & 0xffff)); } + + //#pragma pack(show)// C4810 + //ensure byte-packed structures1ֽڶ룩 +#include //뻷ûиļ滻Ϊǰƽֽ̨ڶ䡣 + + //@brief : ݽӿڵIJ + //@remarks : ͨͨuci_CreateRParamsӿڴ + typedef struct _RParams { + //@brief : ַ'\0'β. ʽЭĵ + u_cstring CMDString; + //@brief : ҪصӾͨҪȡ\ѯǶӦģ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + //@brief : + //@remarks : ͨʹãɿ;ڲѯ豸ʱõ + //ΪQParamsĵΪ׼ + u_buf ExtraData; //reserve + //@brief : ݵij + u_size ExtraDataLen; + }RParams, *PRParams; + +#ifdef __cplusplus + inline RParams* uci_CreateRParams(RParams& _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + _p.ExtraData = _ExtraData; + _p.ExtraDataLen = _ExtraDataLen; + return &_p; + } +#else + u_inline RParams* uci_CreateRParams(RParams* _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + _p->ExtraData = _ExtraData; + _p->ExtraDataLen = _ExtraDataLen; + return _p; + } +#endif + + typedef struct _DeviceIOParams { + u_int32 Count; + u_int32* Data; + }DeviceIOParams; + + typedef struct _QParams { + //@brief : ҪѯͨŽڵ + //@remarks : enum NodeType ȡֵ ͨ־λֵ + //@eg NodeType::USB | NodeType::LAN + u_int32 Type; + //@brief : ˿ڼ˿ + u_int32 PortCount; + //@brief : ˿ڼ + u_int32* Ports; + //@brief : PVIDPVIDĸ + //@remarks : + u_int32 PVIDCount; + //@brief : PID VID + //@remarks : ʹMakePVIDGetPIDGetVIDȡ + u_int32* PVID; + //@brief : ѯַnullptrʱʾѯ豸ѯָ豸豸 + u_cstring Msg; + }QParams, *PQParams;//@brief : ѯ豸ʱò + + u_inline u_int32 MakePVID(u_ushort _pid, u_ushort _vid) { return ((_pid << 16) | (_vid)); }; + + u_inline u_ushort GetPID(u_int32 _pvid) { return UCI_HIWORD(_pvid); } + + u_inline u_ushort GetVID(u_int32 _pvid) { return UCI_LOWORD(_pvid); } + +#ifdef __cplusplus + inline QParams* UCI_CreateQParam(QParams& _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(&_qp, 0, sizeof(_qp)); + _qp.Type = _type; + _qp.Ports = _ports; + _qp.PortCount = _port_cnt; + _qp.PVID = _pvid; + _qp.PVIDCount = _pvid_cnt; + _qp.Msg = _msg; + return &_qp; + } +#else + u_inline QParams* UCI_CreateQParam(QParams* _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(_qp, 0, sizeof(*_qp)); + _qp->Type = _type; + _qp->Ports = _ports; + _qp->PortCount = _port_cnt; + _qp->PVID = _pvid; + _qp->PVIDCount = _pvid_cnt; + _qp->Msg = _msg; + return _qp; + } +#endif + //@brief : дݽӿڲ + //@remarks : ͨӿuci_CreateWParams + typedef struct _WParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : صݣӾ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + }WParams, *PWParams; + +#ifdef __cplusplus + u_inline WParams* uci_CreateWParams(WParams& _p, u_cstring _cmd, u_uint32 _timeout) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + return &_p; + } +#else + u_inline WParams* uci_CreateWParams(WParams* _p, u_cstring _cmd, u_uint32 _timeout) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + return _p; + } +#endif + typedef struct _CommandParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : 1 + u_uint32 Param1; + //@brief : 1 + u_uint32 Param2; + //@brief : ʱ + u_uint32 Timeout; + }CommandParams, *PCommandParams; + + //@brief : дļIJ + typedef struct _WFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : Ҫдļ·ļ + u_cstring FilePath; + //@brief : дʱ(λms) + u_uint32 Timeout; + }WFileParams, *PWFileParams; + + //@brief : ļӿڵIJ + typedef struct _RFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : ݵش̵ļ·ļͺ׺ + u_cstring FilePath; + //@brief : ʱ(λms) + u_uint32 Timeout; + //@brief : ļ· + u_tchar FilePathFinal[MAX_PATH]; + }RFileParams, *PRFileParams; + + //@brief : ͨŽڵ + //@remarks : QParamsǰλ룬Nodeȡenumֵ + typedef enum _NodeType{ + LAN = 0x0001, + USB = 0x0010, + }NodeType; + + //@brief : USB豸 + //@remarks : + typedef struct _USBDescriptor { + //@brief : PID + u_ushort PID; + //@brief : VID + u_ushort VID; + //@brief : ַ + u_ushort Addr; + }USBDescriptor; + + //@brief : IPַ + //@remarks : ˳Ϊ f1(192).f2(168).f3(1).f4(253) - Сģʽ + typedef union _IPAddr { + struct { u_byte f1, f2, f3, f4; } Field; + u_int32 Addr; + }u_IPAddr; + + //@brief : LANͨŵ豸 + //@remarks : + typedef struct _LANDescriptor { + //@brief : IPַַͣ + u_tchar IP[16]; + //@brief : IPַ + u_IPAddr Addr; + //@brief : ˿ + //@remarks : TCPIPõĶ˿ں + u_ushort Port; + }LANDescriptor; + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _Node { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµƣ + // ѳδͳһʱUCIڲԶƥΪUCIЭõ֣ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }Node, *PNode; + + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _NodeEx { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµơ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }NodeEx, *PNodeEx; + + typedef struct _UCIMSG { + u_session Session; + u_uint32 Message; + u_wparam wParams; + u_lparam lParams; + u_byte Reserved[240]; + }UCIMSG;//256Bytes + + ////////////////////////////////////////////////////////////////////////// + typedef enum _uci_msg { + //@brief : 豸ѾϿ + //@remarks : Ŀǰֻ֧LANڷʵӵ + // wParams LAN : ˿ں(ʮ) + // Reserved LAN : IP ַ + UMSG_CONNECT_CLOSED = 1, + //@brief : ļϢ + //@remarks : + // wParams ֡ + // lParams ֡ -1 ʼ䣻 [0,wParams)У wParams + //-> UCIMSGProc return -1 ʾжϴ. + UMSG_FILE_TRANSFER = 2, + //@brief : USBϢ + //@remarks : + // wParams : ʹõ16λУ8λΪpid8λΪvid + // lParams : ¼ͣ Ƴ = 0 = 1 + UMSG_DEVICE_NOTIFY = 3, + }EUCIMSG; + + typedef int(__stdcall *UCIMSGProc)(UCIMSG* _msg); +#include + +#ifdef __cplusplus + } +#endif//__cplusplus + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ucidef_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb8defadf08fb4778db5968e829844e99ea185e1.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb8defadf08fb4778db5968e829844e99ea185e1.svn-base new file mode 100644 index 0000000..94b0a85 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/eb/eb8defadf08fb4778db5968e829844e99ea185e1.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ec/ece2773f02c00583b6805e512644c3396e0ce9e5.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ec/ece2773f02c00583b6805e512644c3396e0ce9e5.svn-base new file mode 100644 index 0000000..7abe977 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ec/ece2773f02c00583b6805e512644c3396e0ce9e5.svn-base @@ -0,0 +1,37 @@ +/**************************************************************************/ +/* LabWindows/CVI User Interface Resource (UIR) Include File */ +/* Copyright (c) National Instruments 2016. All Rights Reserved. */ +/* */ +/* WARNING: Do not add to, delete from, or otherwise modify the contents */ +/* of this include file. */ +/**************************************************************************/ + +#include + +#ifdef __cplusplus + extern "C" { +#endif + + /* Panels and Controls: */ + +#define PANEL 1 /* callback function: panelCB */ +#define PANEL_COMMANDBUTTON 2 /* callback function: _Read */ +#define PANEL__numFreq 3 +#define PANEL_TIMER 4 /* callback function: _timer */ + + + /* Menu Bars, Menus, and Menu Items: */ + + /* (no menu bars in the resource file) */ + + + /* Callback Prototypes: */ + +int CVICALLBACK _Read(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); +int CVICALLBACK _timer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); +int CVICALLBACK panelCB(int panel, int event, void *callbackData, int eventData1, int eventData2); + + +#ifdef __cplusplus + } +#endif diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ed/ed26e70b6433039dfb8d775464408d7f477e1617.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ed/ed26e70b6433039dfb8d775464408d7f477e1617.svn-base new file mode 100644 index 0000000..75a99f2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/ed/ed26e70b6433039dfb8d775464408d7f477e1617.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f1/f16a18bac46f300a9dbde275ddc068b767d826df.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f1/f16a18bac46f300a9dbde275ddc068b767d826df.svn-base new file mode 100644 index 0000000..5f9ceff --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f1/f16a18bac46f300a9dbde275ddc068b767d826df.svn-base @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by SimpleUCI.rc +// + +#define IDS_APP_TITLE 103 + +// ¶һĬֵ +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f4/f416b3d39063d9da24322791646ae5f38c0386c7.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f4/f416b3d39063d9da24322791646ae5f38c0386c7.svn-base new file mode 100644 index 0000000..5112955 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f4/f416b3d39063d9da24322791646ae5f38c0386c7.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f5/f53ec4b320747238aed8465f2f020eea8b50f8ad.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f5/f53ec4b320747238aed8465f2f020eea8b50f8ad.svn-base new file mode 100644 index 0000000..b4ea617 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f5/f53ec4b320747238aed8465f2f020eea8b50f8ad.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f8/f8f76819d6e1884f058194d11db3a58bdee5f063.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f8/f8f76819d6e1884f058194d11db3a58bdee5f063.svn-base new file mode 100644 index 0000000..3294196 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/f8/f8f76819d6e1884f058194d11db3a58bdee5f063.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/fb/fb89e79b7da0b36fc8d6bbe77a1c5af643fac8d8.svn-base b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/fb/fb89e79b7da0b36fc8d6bbe77a1c5af643fac8d8.svn-base new file mode 100644 index 0000000..40bde63 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/pristine/fb/fb89e79b7da0b36fc8d6bbe77a1c5af643fac8d8.svn-base differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/wc.db b/Driver/UDP5080-100/UNI-T SDK/.svn/wc.db new file mode 100644 index 0000000..6fbf7c3 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/.svn/wc.db differ diff --git a/Driver/UDP5080-100/UNI-T SDK/.svn/wc.db-journal b/Driver/UDP5080-100/UNI-T SDK/.svn/wc.db-journal new file mode 100644 index 0000000..e69de29 diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/MSO3000CS_ProgrammingGuide.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/MSO3000CS_ProgrammingGuide.pdf new file mode 100644 index 0000000..512d39c Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/MSO3000CS_ProgrammingGuide.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UCI API 帮助文档.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UCI API 帮助文档.pdf new file mode 100644 index 0000000..ff42b84 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UCI API 帮助文档.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UPO2000CS&UPO7000Z系列示波器编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UPO2000CS&UPO7000Z系列示波器编程手册.pdf new file mode 100644 index 0000000..4da502c Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UPO2000CS&UPO7000Z系列示波器编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UPO3000CS&UPO2000CS_SW4.0编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UPO3000CS&UPO2000CS_SW4.0编程手册.pdf new file mode 100644 index 0000000..214f4ea Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UPO3000CS&UPO2000CS_SW4.0编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UPO3000CS编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UPO3000CS编程手册.pdf new file mode 100644 index 0000000..214f4ea Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UPO3000CS编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTD2000CEX&UTD7000B系列示波器编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTD2000CEX&UTD7000B系列示波器编程手册.pdf new file mode 100644 index 0000000..4ad1815 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTD2000CEX&UTD7000B系列示波器编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTD2000CM&UTD4000CM&UTD8000W系列示波器编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTD2000CM&UTD4000CM&UTD8000W系列示波器编程手册.pdf new file mode 100644 index 0000000..8f8cd7a Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTD2000CM&UTD4000CM&UTD8000W系列示波器编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTG1000A&UTG6000B系列信号源编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTG1000A&UTG6000B系列信号源编程手册.pdf new file mode 100644 index 0000000..a98cba7 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTG1000A&UTG6000B系列信号源编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTG1000L&UTG9000C系列信号源编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTG1000L&UTG9000C系列信号源编程手册.pdf new file mode 100644 index 0000000..fa3317a Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTG1000L&UTG9000C系列信号源编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTG2000A&UTG7000B系列信号源编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTG2000A&UTG7000B系列信号源编程手册.pdf new file mode 100644 index 0000000..5769c6d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTG2000A&UTG7000B系列信号源编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTG4000A&UTG8000D系列信号源编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTG4000A&UTG8000D系列信号源编程手册.pdf new file mode 100644 index 0000000..9acf151 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTG4000A&UTG8000D系列信号源编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTG4000系列信号源编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTG4000系列信号源编程手册.pdf new file mode 100644 index 0000000..4cc468d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTG4000系列信号源编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTG9000T系列信号源编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTG9000T系列信号源编程手册.pdf new file mode 100644 index 0000000..6e9c12d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTG9000T系列信号源编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTG900_ProgrammingGuide.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTG900_ProgrammingGuide.pdf new file mode 100644 index 0000000..dbb2e69 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTG900_ProgrammingGuide.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTP3000C&UTP8000M系列电源编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTP3000C&UTP8000M系列电源编程手册.pdf new file mode 100644 index 0000000..8f293b6 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTP3000C&UTP8000M系列电源编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTP3305S编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTP3305S编程手册.pdf new file mode 100644 index 0000000..0515919 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTP3305S编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/doc/UTx系列万用表&毫伏表编程手册.pdf b/Driver/UDP5080-100/UNI-T SDK/doc/UTx系列万用表&毫伏表编程手册.pdf new file mode 100644 index 0000000..11ae894 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/doc/UTx系列万用表&毫伏表编程手册.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver.zip b/Driver/UDP5080-100/UNI-T SDK/driver.zip new file mode 100644 index 0000000..85845a7 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver.zip differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/DriverApp.exe b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/DriverApp.exe new file mode 100644 index 0000000..10eeb62 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/DriverApp.exe differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/DPInst32.exe b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/DPInst32.exe new file mode 100644 index 0000000..26481f0 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/DPInst32.exe differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/amd64/libusb0.dll b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/amd64/libusb0.dll new file mode 100644 index 0000000..a8eb338 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/amd64/libusb0.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/amd64/libusb0.sys b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/amd64/libusb0.sys new file mode 100644 index 0000000..50bce8d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/amd64/libusb0.sys differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.cat b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.cat new file mode 100644 index 0000000..c958649 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.cat differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.dll b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.dll new file mode 100644 index 0000000..3294196 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.inf b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.inf new file mode 100644 index 0000000..f7557fa Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/libusb0.inf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/usb_device.cat b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/usb_device.cat new file mode 100644 index 0000000..c958649 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS32Bit/usb_device.cat differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/DPInst64.exe b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/DPInst64.exe new file mode 100644 index 0000000..7d1f0cb Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/DPInst64.exe differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/amd64/libusb0.dll b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/amd64/libusb0.dll new file mode 100644 index 0000000..a8eb338 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/amd64/libusb0.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/amd64/libusb0.sys b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/amd64/libusb0.sys new file mode 100644 index 0000000..50bce8d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/amd64/libusb0.sys differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.cat b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.cat new file mode 100644 index 0000000..c958649 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.cat differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.dll b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.dll new file mode 100644 index 0000000..3294196 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.inf b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.inf new file mode 100644 index 0000000..f7557fa Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/libusb0.inf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/usb_device.cat b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/usb_device.cat new file mode 100644 index 0000000..c958649 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/OS64Bit/usb_device.cat differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/Readme.txt b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/Readme.txt new file mode 100644 index 0000000..587bb4c --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/Readme.txt @@ -0,0 +1,3 @@ +еUSBʹñװװװʽ +˫Installer.batļ԰װusb +˫UnInstaller.batļ豸Ҽж \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/点击卸载(UnInstaller).bat b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/点击卸载(UnInstaller).bat new file mode 100644 index 0000000..36d7a45 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/点击卸载(UnInstaller).bat @@ -0,0 +1,7 @@ +::This is driver uninstaller for DSO USB driver +::DriverApp.exe /? for help message + +DriverApp.exe /u /d /c + +@echo off +::pause \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/点击安装(Installer).bat b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/点击安装(Installer).bat new file mode 100644 index 0000000..8ac829d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/driver/DriverPack_Libusb/点击安装(Installer).bat @@ -0,0 +1,6 @@ +::This is driver installer for libusb +::DriverApp.exe /? for help message + +DriverApp.exe /f /c +@echo off +::pause \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/USB转串口驱动/PL2303_Prolific_DriverInstaller_v130.exe b/Driver/UDP5080-100/UNI-T SDK/driver/USB转串口驱动/PL2303_Prolific_DriverInstaller_v130.exe new file mode 100644 index 0000000..1f6e542 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/driver/USB转串口驱动/PL2303_Prolific_DriverInstaller_v130.exe differ diff --git a/Driver/UDP5080-100/UNI-T SDK/driver/USB转串口驱动/readme.txt.txt b/Driver/UDP5080-100/UNI-T SDK/driver/USB转串口驱动/readme.txt.txt new file mode 100644 index 0000000..1c33fb6 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/driver/USB转串口驱动/readme.txt.txt @@ -0,0 +1 @@ +רUTP3305Sϵл \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/App.config b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Program.cs b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Program.cs new file mode 100644 index 0000000..3e60937 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Program.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using uci; + +/* + * 本工程演示基本的设备访问接口,如查询、打开、读、写、关闭等等。 + * 以示波器为演示机型。 + */ +namespace SimpleIO +{ + class Program + { + /// + /// 会话类,也可以使用UCIInterop的适配接口,但最终都是调用的uci.dll中的接口 + /// + static Session _com = new Session(true); + + static void Main(string[] args) + { + //{全局配置 + //切换所有打印输出为中文; + UCIInterop.SetAttribute(UCIInterop.InvalidSession,"lang:zh-Hans;", null, 0); + //切换所有打印输出为英文; + //UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:en-US;", null, 0); + //} + + //{查询设备示例 + string queryMsg = "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348"; //查询USB设备 + //queryMsg += ";LAN:4162,5000";//查询网络设备 + queryMsg += ";"; + uci.Node[] nodes = new uci.Node[10]; + int count = UCIInterop.QueryNodesX(queryMsg, nodes, nodes.Length, 2000); + if (count > 0) + { + Console.WriteLine("查询到的满足条件的USB设备数量:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("[{0}]\t:\t{1}", i, nodes[i].UCIAddr); + } + } + else + { + OutputResult(count, "查询设备"); + } + //} + + //{查询串口设备 + // 此查询不包括任何的协议,只是查询串口。如果要查询指定协议的设备,请遍历打开串口 + // 并使用指定协议进行验证。 + uci.COMPort[] comPorts = new uci.COMPort[10]; + count = UCIInterop.QueryCOMPort(comPorts, comPorts.Length); + if (count > 0) + { + Console.WriteLine("Ports:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("{0} - COM{1} : {2}", i, comPorts[i].Port, comPorts[i].FriendlyName); + } + } + else if (count == 0) + { + Console.WriteLine("未查询到任何串口设备"); + } + else + { + OutputResult(count, "查询串口设备"); + } + //* Ports:1 + //* 0 - COM3 : Silicon Labs CP210x USB to UART Bridge (COM3) + //} + + + //打开设备,设备地址获取方式: + //1 可以从文档中获取; + //2 使用UCIInterop.QueryNodesX查询获取; + //3 使用“SDK\examples\VC\UCIDEMO\Unicode\UCI_DEMO.exe"程序,查询获取。 + string addr = "[C:DSO][D:DSO-E][T:USB][PID:0x5537][VID:0x4348][EI:0x82][EO:0x2][CFG:1][I:0][addr:0]"; + //addr = "[C:UPO][D:UPO][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x3][CFG:3][I:0]"; + var r = _com.Open(addr); + if (!OutputResult(r, "打开设备")) + {//error : r < 0; + //特别的,如果返回-1040(建立连接的字符串地址格式错误),说明当前工程 + //和调用的uci.dll的字符编码不一致,一般C#的工程都是UNICODE的版本, + //请拷贝“SDK\lib\C\Unicode\uci.dll”到当前工程的执行程序的运行目录下。 + return; + } + + //写参数 + r = _com.Write("CH:0@sel;"); + OutputResult(r, "写参数"); + + //读参数测量结果 + //{打包读取所有参数测量结果--适用于所有示波器 + byte[] allMeaBytes = new byte[50 * 8]; //固定的50个参数,一个参数8Bytes + r = _com.Read("mea:all?;", allMeaBytes); + if (OutputResult(r, "读参数测量")) + { + //转换为结构体 + uci.Model.mea.MeaValue[] allMea = new uci.Model.mea.MeaValue[50]; + uci.Utility.ByteArrayToStructArray(allMeaBytes, ref allMea, 50); + //打印输出 + ParseParamsMeasure(allMea); + } + //} + + //读取单个参数 - 请参照文档查看是否支持。 +#if false + double v = 0.0; + r = _com.Read("mea:freq;", out v); +#endif + + //{读取波形文件 + // 指令格式(capture wave:.csv@CH:0@DT:vol;)请参照具体的文档,个别机型有差异。 + uci.RFileParams rfp = new RFileParams() + { + CMDString = "capture wave:.csv@CH:0@DT:vol;", + FilePath = "waveform.csv", + TimeOut = 2000, + }; + r = _com.ReadToFile(ref rfp); + OutputResult(r, "读波形文件"); + //} + + //Session析构时自动关闭 + } + + /// + /// 输出UCI API的接口返回的结果 + /// + /// + /// + /// + static bool OutputResult(int r, string msg) + { + string s = "[" + msg + "]"; + if (Session.Error(r)) + { + s += string.Format("失败,错误码:{0},错误信息:{1}", + r, _com.GetLastError()); + } + else + { + s += "成功!"; + } + Console.WriteLine(s); + return r >= 0; + } + + /// + /// 得到物理单位量级 + /// + /// + /// + static string GetUnitScaleName(uci.Model.unit.Scale s) + { + if (s == uci.Model.unit.Scale.STD) + return string.Empty; + return s.ToString(); + } + + /// + /// 打印参数测量的所有结果 + /// + /// + static void ParseParamsMeasure(uci.Model.mea.MeaValue[] m) + { + for(int i = 0; i < m.Length; i++) + { + Console.WriteLine("{0}:IsExist={1},IsValid={2}, Value={3}, Unit(Type={4},Scale={5}) --> {6}{7}{8}", + (uci.Model.mea.MeaParam)(i), + m[i].IsExist, m[i].IsValid, m[i].Value, m[i].Unit.Type, m[i].Unit.Scale, + m[i].Value, + GetUnitScaleName((uci.Model.unit.Scale)m[i].Unit.Scale), + //获取物理量单位,可以使用uci API : UCIInterop.GetUnitTypeName + //也可以自己建表 + UCIInterop.GetUnitTypeName((char)m[i].Unit.Type)); + } + } + } +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/AssemblyInfo.cs b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..639e9e5 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的常规信息通过以下 +// 特性集控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("SimpleIO")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SimpleIO")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 使此程序集中的类型 +// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +// 则将该类型上的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("6f1614c4-8639-4bf3-954e-d562095a557d")] + +// 程序集的版本信息由下面四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/Settings.Designer.cs b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/Settings.Designer.cs new file mode 100644 index 0000000..3d4aaf8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace SimpleIO.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/Settings.settings b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/Settings.settings new file mode 100644 index 0000000..049245f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/Properties/Settings.settings @@ -0,0 +1,6 @@ + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/SimpleIO.csproj b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/SimpleIO.csproj new file mode 100644 index 0000000..6ce87ff --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/SimpleIO.csproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {B6ED883C-BE9E-46F0-B08D-21F09D16CFB4} + Exe + Properties + SimpleIO + SimpleIO + v4.5 + 512 + 发布\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + lib\ucics.dll + + + + + + + True + True + Settings.settings + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + False + Microsoft .NET Framework 4.5 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/uci.dll b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/uci.dll new file mode 100644 index 0000000..178f088 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/uci.lib b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/uci.lib new file mode 100644 index 0000000..a59db53 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/uci.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/ucics.XML b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/ucics.XML new file mode 100644 index 0000000..26824f3 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/ucics.XML @@ -0,0 +1,2253 @@ + + + + ucics + + + + + 物理单位信息 + + + + + 单位类型,比如Time、Freq等。具体定义见文档。 + + + + + 量级,比如k、n,p,M等。具体定义见文档。 + + + + + 物理单位量级 + + + + + + + + + + / + + + + + + + + + + + + + + + 标准单位 + + + + + K + + + + + + + + + + + + + + + + + + + + 物理单位类型 + + + + + 无效的类型 + + + + + 频率(Hz) + + + + + 时间(s) + + + + + 面积(Vs) + + + + + 采样率(Sa/s) + + + + + 点数(Sa) + + + + + 峰峰值(V) + + + + + 电压 + + + + + 电流(A) + + + + + db(dB) + + + + + VV (VV) + + + + + 百分比(%) + + + + + 度数(°) + + + + + 瓦特,功率(W) + + + + + 未知单位(U) + + + + + 物理量数值 + + + 4Byte align -> 8Bytes, + 所有示波器都通过指令"mea:all?;"读取参数测量数据。 + 读取到的就是 MeaValue v[50] (固定长度), + 各参数的位置索引由定义。 + + + + + 测量值 + + + + + 物理单位 + + + + + 是否有效。 0 表示无效; 1表示有效。 + + + + + 是否存在。 0 表示存在; 1表示不存在。 + + + + + 参数测量数据包的通用定义。 + + + + + 最大值 + + + + + 最小值 + + + + + High(Top)-高电平(顶端值) + + + + + Middle-中间值 + + + + + Low(Bottom) - 低电平(底端值) + + + + + VPP-峰峰值 + + + + + 幅度值 + + + + + 平均值 + + + + + 周期平均值 + + + + + 均方根 + + + + + 周期均方值 + + + + + 面积 + + + + + 周期面积 + + + + + 过冲 + + + + + 预冲 + + + + + 周期 + + + + + 频率 + + + + + 上升时间 + + + + + 下降时间 + + + + + 正脉宽 + + + + + 负脉宽 + + + + + 正占空比 + + + + + 负占空比 + + + + + 上升延时 + + + + + 下升延时 + + + + + 相位 + + + + + FRR + + + + + FRF + + + + + FFR + + + + + FFF + + + + + LRF + + + + + LRR + + + + + LFR + + + + + LFF + + + + + 突发脉冲 + + + + + 固定位50个参数 + + + + + b0 : SYNC; b1 : channel(CH1); b2 : Trigger + + + + + SYNC Key + + + + + Channel Key + + + + + Trigger Key + + + + + 模拟C/C++的堆内存的操作:申请、释放、转换 + + + + + 创建指定大小(bytes)的非托管内存空间 + + + + + + 创建基于所给字节数组的非托管内存空间。默认数据会被拷贝到非托管内存空间。 + + 托管字节数组 + + + + 创建基于所给整形数据的非托管内存空间。默认数据会被拷贝到非托管内存空间。 + + 托管整形数组 + 起始拷贝位置 needCopy = true 时有效 + 拷贝数量 + + + + allocate storage for count elements of type ty + + + + + + + 创建基于所给对象数据的非托管内存空间 + + 托管对象数据 + true : 拷贝托管字节数组的数据到非托管内存空间; false : 不拷贝 + + + + 提供Pointer到IntPtr的运算符。 + + Pointer类型对象 + IntPtr + + + + 析构器 + + + + + 将内存数据转换所给的结构体类型数据。 + + 要转换的结构体 + 要转换的结构体 + + + + 指向非托管内存的指针 + + + + + 非托管内存空间的地址 + + + + + 非托管内存空间的大小(bytes) + + + + + 通信方式 + + + + + USB通信 + + + + + LAN通信 + + + + + 串口通信 + + + + + 信号源的通道号 + + + + + 通道1的编号 + + + + + 通道2的编号 + + + + + 代表所有通道的编号 + + + + + 非通道编号 + + + + + 开关状态,占用1个字节。 + + + + + 关闭状态 + + + + + 打开状态 + + + + + UCI所有接口返回的状态编码。如果小于0,则代表发生错误;反之,代表正确。 + #TODO:检查完整性 + + + + + 没有任何错误 + + + + + 错误(基础编码,所有错误码都在这个编码基础上定义) + + + + + 资源初始化错误 + + + + + 无效的会话 + + + + + 操作超时 + + + + + 操作失败 + + + + + 不支持的操作 + + + + + 内存空间不足 + + + + + 系统繁忙,无法响应 + + + + + 通信异常,不可逆! + + + + + 未知的错误 + + + + + 建立连接的字符串地址格式错误 + + + + + 连接还未建立 + + + + + 连接已断开 + + + + + 不支持的通信方式 + + + + + 未发现指定的设备 + + + + + 不支持的设备 + + + + + 需要先执行查询设备的操作 + + + + + 查询网络设备失败 + + + + + USB设备地址只在执行查询设备操作后才有效, + + + 从UCI库导出的USB设备地址,只是一个列表索引,不是真正的设备地址。 + + + + + 未发现U盘接入 + + + + + 按键已经锁定 + + + + + 命令格式错误 + + + + + 只支持单条命令 + + + + + 一条命令只支持一个属性 + + + + + 不支持的命令 + + + + + 发送命令失败 + + + + + 协议数据格式错误 + + + + + 设备端写文件到flash失败! + + + + + 未发现有效数据 + + + + + 命令消息错误,请命令参数是否符合协议 + + + + + 无效的表达式 + + + + + 参数错误 + + + + + 参数提供的空间太小 + + + + + 所提供的文件名太长(最长50个字节) + + + + + 参数所给的数据大小与协议不匹配(防止数据错误) + + + + + 数字溢出 + + + + + 超出范围 + + + + + 数据未全部读取完 + + + + + 数据校验失败 + + + + + 无效的数据 + + + + + 数据压缩失败 + + + + + 数据解压缩失败 + + + + + 数据传输失败 + + + + + 数据传输失败 + + + + + 拒绝访问 + + + + + An unspecified error occurred. + + + + + The file could not be located. + + + + + All or part of the path is invalid + + + + + The permitted number of open files was exceeded. + + + + + There was an attempt to use an invalid file handle + + + + + The current working directory cannot be removed + + + + + There are no more directory entries + + + + + There was an error trying to set the file pointer + + + + + There was a hardware error + + + + + SHARE.EXE was not loaded, or a shared region was locked + + + + + There was an attempt to lock a region that was already locked + + + + + The disk is full + + + + + The end of file was reached + + + + + 写文件到磁盘失败 + + + + + 信号源任意波下载方式 + + + + + 以载波方式加载 + + + + + 以调制波方式加载 + + + + + 将ARB文件写到Flash. + + + + + UCI读接口()用的读参数。 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + (废弃)返回的数据量数据,具体意义视具体命令而定; + 返回的数据量由接口的返回值确定。 + + + + + 读超时,单位ms,1000 = 1s + + + + + 附加数据,大多数情况下是不需要的,可设置为IntPtr.Zero. + + + + + 附加数据大小 + + + + + UCI写接口的写参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 返回的数据量数据,具体意义视具体命令而定; + + + + + 超时 + + + + + 接口SendCommand使用的参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 命令参数1 + + + + + 命令参数2 + + + + + 超时 + + + + + 写任意波文件的参数 + + + + + 通道号,一般CH1=0,依次类推 + + + + + 任意波(ARB)加载方式 + + + + + 写文件的参数,2个Bytes.(模拟C中的联合体) + + + + + 预留的数据段 + + + + + 任意波(ARB)文件参数 + + + + + 接口WriteFromFile的接口参数。 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 文件路径 + + + + + 指令执行超时,在该时间内指令为完成,就返回! + + + + + 接口ReadToFile使用的参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 文件路径 + + + + + 指令执行超时,在该时间内指令为完成,就返回! + + + + + 最终输出文件的路径 + + + + + 设备按键LED状态数据 + + + + + Noise按键LED开关状态 + + + + + UTILTY按键LED开关状态 + + + + + STORGE按键LED开关状态 + + + + + RAMP按键LED开关状态 + + + + + PULSE按键LED开关状态 + + + + + COUNTER按键LED开关状态 + + + + + USER按键LED开关状态 + + + + + DIGTAL按键LED开关状态 + + + + + HARMONIC按键LED开关状态 + + + + + DC按键LED开关状态 + + + + + TRGGER按键LED开关状态 + + + + + CH2按键LED开关状态 + + + + + SWAPCH按键LED开关状态 + + + + + ARB按键LED开关状态 + + + + + CH1按键LED开关状态 + + + + + SINE按键LED开关状态 + + + + + SQUARE按键LED开关状态 + + + + + 通信节点类型 + + + 在QParams中是按位与,在Node中取的是enum值。 + + + + + 网络设备类型 + + + + + USB设备类型 + + + + + USB设备的描述符 + + + + + PID + + + + + VID + + + + + 地址 + + + + + 4字段数据类型 + + + + + 字段1 + + + + + 字段2 + + + + + 字段3 + + + + + 字段4 + + + + + IP地址 + + + 填充顺序为 f1(192).f2(168).f3(1).f4(253) - 小端模式 + + + + + 分字段存取 + + + + + 32为整数表示的IP地址 + + + + + LAN口通信的设备描述符 + + + + + IP地址(字符串类型) + + + + + IP地址 + + + + + 网络端口(TCPIP连接用的端口号) + + + + + 查询到的设备节点的参数 + + + + + 通信接口方式 + + + + + 设备名 + + + + + 设备类型( 信号源 = SG, 示波器 = DSO, UPO = UPO;) + + + + + LAN口参数 + + + + + USB接口参数 + + + + + 连接字符串 + + + + + 序列号 + + + + + 设备状态 + + + + + 设备显示名称 + + + + + 串口描述 + + + + + 友好名称 + + + + + 端口号 + + + + + 查询参数 + + + + + 要查询的节点类型,按位与,数据取自QueryNodeType定义 + eg: QueryNodeType.USB | QueryNodeType.LAN + + + + + Ports的长度 + + + + + 端口集,指向int类型; + + + + + PVID数据的长度 + + + + + 存放PID和VID信息的指向INT类型的缓冲区地址, + int 类型对应的格式 :PID(高16bit) + VID(低16bit) + + + + + 查询字符串,nullptr时表示查询所有设备,否则查询指定设备名的设备。 + + + + + UCI使用的消息类型 + + + + + 与设备建立的连接已经断开 + + + 目前只支持LAN口访问的连接的侦测 + wParams LAN : 端口号(十进制); + Reserved LAN : IP 地址 + + + + + 文件传输消息 + + + wParams 总帧数; + lParams 帧计数; -1 : 开始传输; [0,wParams)传输中, 等于wParams传输结束-> + UCIMSGProc return -1 : 表示中断传输. + + + + + USB插拔消息 + + + wParams : 使用低16位,其中,高8位为pid,低8位为vid; + lParams : 事件类型, 移除 = 0, 插入 = 1; + Reserved : USB插入移除事件的设备的设备名 + + + + + USB设备事件 + + + + + USB 设备移除事件 + + + + + USB 设备接入事件 + + + + + UCI 消息数据 + + + + + 发送消息的会话ID + + + + + UCI消息,按解析 + + + + + 消息参数,每个消息的使用意义不一样 + + + + + 消息参数,每个消息的使用意义不一样 + + + + + 保留字段,每个消息的使用意义不一样 + + + + + 带单位的数值 + + + + + 数值 + + + + + 单位量级 + + + + + 带单位的数值 + + + + + 数值 + + + + + 单位量级 + + + + + 万用表和毫伏表数据帧 + + + + + 主显字符串(20个字符) + + + + + 副显字符串或(20个字符) + + + + + 主显数值(8Bytes) + + + + + 副显数值(8Bytes) + + + + + 标记位(8Bytes) + + + + + UCI会话(与设备建立会话) + 本接口是的面向对象封装版本。 + 会在UCISession对象释放时自动关闭会话,并做所有资源清理,且提供若干 + 实用接口。 + + + + + 构造器 + + 一般设置为true,在程序退出时会调用 + UCIInterop.ExInstance()进行资源清除。 + + + + + 析构器 + + + + + 打开设备,建立会话。 + + + 设备地址。获取方式:
+ 1、可以通过查询接口获取;
+ 2、也可以通过查看文档获取。
+ 3、使用提供的示例程序查询获取
+ + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + + static Session _com = new Session(true); + //... + var r = _com.Open("[C:DSO][D:DSO-E][T:USB][PID:0x5537][VID:0x4348][EI:0x82][EO:0x2][CFG:1][I:0][addr:0]"); + if (!OutputResult(r, "打开设备")){return false;} + //... + static bool OutputResult(int r, string msg) + { + string s = "[" + msg + "]"; + if (Session.Error(r)) + { + s += string.Format("失败,错误码:{0},错误信息:{1}", + r, _com.GetLastError()); + } + else + { + s += "成功!"; + } + Console.WriteLine(s); + return r >= 0; + } + + +
+ + + 打开交换机 + + 交换机地址 + 超时。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 内部使用接口 + + + + + 关闭会话 + + + 在设备未打开时调用不会执行任何操作。 + + + + + 获取最近一次调用UCI接口后的反馈信息。 + + + 反馈的文本字符串,与此描述对应的状态码可以查看。 + + + 返回的描述信息,可以设置中文和英文两个版本,设置方式如下: + + //设置为中文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession,"lang:zh-Hans;", null, 0); + + + //设置为英文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:en-US;", null, 0); + + 示例代码参见 + + + + + 写数据(字节流,基础接口) + + + 指令字符串,请查阅各机型编程手册获取 + + 要写到设备的字节流数据,如果是内置类型(如int等), + 可以使用转换: + + int v = 10; + byte[] arrayV = BitConverter.GetBytes(v); + + + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(纯指令文本) + + + 指令字符串,请查阅各机型编程手册获取 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(short类型) + + + 指令字符串,请查阅各机型编程手册获取 + short 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(double类型) + + + 指令字符串,请查阅各机型编程手册获取 + double 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(int类型) + + + 指令字符串,请查阅各机型编程手册获取 + int 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(任何类型) + + + 数据类型,struct 或者内置类型 + 指令字符串,请查阅各机型编程手册获取 + 写入的数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + 适用于结构体等类型数据的写操作。 + 也可以使用,但必须先使用 + 将结构体转换为Byte[] + + + + + 读数据(基础接口) + + 指令字符串,请查阅各机型编程手册获取 + 接收数据的缓冲区 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 如果需要将读取到的字节流转换为其它常见的数据类型,请使用 + 类提供的方法进行转换。 + + + + //打包读取所有参数测量结果--适用于所有示波器 + //... + static Session _com = new Session(true); + //... + //固定的50个参数,一个参数8Bytes,共400Bytes + byte[] allMeaBytes = new byte[50 * 8]; + r = _com.Read("mea:all?;", allMeaBytes); + if (r > 0) + { + //转换为结构体 + uci.Model.mea.MeaValue[] allMea = new uci.Model.mea.MeaValue[50]; + uci.Utility.ByteArrayToStructArray(allMeaBytes, ref allMea, 50); + } + + + + + + 读数据(dobule类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的double类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToDouble(byte[], 0) 将Byte[]转换为double + + + + + 读数据(int类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的int类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToInt32(byte[], 0) 将Byte[]转换为int + + + + + 读数据(short类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的short类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToInt16(byte[], 0) 将Byte[]转换为short + + + + + 读取数据(泛型版本,支持内置类型、结构体数据)(结构体大小必须是确定的) + + + 内置类型或结构体类型,必须是确定的已经序列化的结构体(大小是确定的)。 + 指令字符串,请查阅各机型编程手册获取 + 要读取的数据 + 超时。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 适用于读取结构体数据,比如的大小就是确定的。 + + + + + 写文件 + + 指令字符串 + 要发送的文件路径 + 指令执行超时(ms),在该时间内指令为完成,就返回! + 具体描述,请查看说明。 + + + + 读文件 + + 读文件参数 + 具体描述,请查看说明。 + + + + 判断接口返回值是否错误 + + 接口返回值 + true : 正确; false : 错误 + + + + 判断接口返回值是否正确 + + 接口返回值 + true : 正确; false : 错误 + + + + (内部)制作远程访问指令文本 + + 通用UCI指令文本,与具体机型对应。 + 远程访问的类型 + 超时。在该时间内指令未完成,就返回超时错误! + 数据长度 + 返回制作好的指令文本 + + + + 获取会话ID + + + + + 设备地址,只有设备被打开时,才会存在。 + + + + + 当前设备是否已经打开 + + + + + 是否时交换机通信模式(普通设备通信无需理会) + + + + + UCIInterop类是对uci.dll导出的C语言接口的适配。
+ 基本会话接口请结合 使用
+ +
+
+ + + 无效的会话ID + + + + + 打开设备,建立会话。 + + 设备地址。获取方式:
+ 1、可以通过查询接口获取;
+ 2、也可以通过查看文档获取。
+ 3、使用提供的示例程序查询获取
+ + 返回的会话ID + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 请参考 + +
+ + + 查询设备(私有,不公开,因为参数类型对于CS环境而言过于抽象,此即可与C接口直接对应) + + 查询操作的参数 + 输出数据的缓冲区地址 + 输出数据的缓冲区大小(Bytes) + 具体描述,请查看说明。 + + + + 查询设备 + + + + 要查询的设备信息 + 接收查询结果的节点数组 + _nodes的个数 + 超时 + + 小于0:错误; >=0 查询到的设备个数。 + + + 查询文本串的格式是:“{通信类型名称 : 设备参数 ;}”
+ 每个通信类型数据以';'结尾;':'之前是节点名,节点名是内置的,网络通信是"LAN",USB通信是"USB"。
+ LAN通信的参数是端口号,以','分割.
+ USB通信的参数是PID(第一个)和VID(第二个),每组数据以','号分割,PID和VID以'&'分割。
+ 示例:
+ + string msg = "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + + UCI接口查询是要指定要查询的设备信息后,才可查询!
+ 目前支持的全部USB设备:
+ 示波器、信号源和电源:
+ "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348;"
+ 万用表(HID)
+ "USB:0xE008&0x1A86,0xEA80&0x10C4;"
+ 目前支持的LAN口设备:
+ 8000 : UTG2000A&UTG7000B 系列;
+ 5000 : UPO2000S&UPO7000Z 系列;
+ 4162 : UTG4000A&UTG8000D 系列
+ 18191: UTP3000C&UTP8000M 系列
+ "LAN:5000,4162,8000,18191;"
+ 请注意:串口需要使用接口: 单独查询。
+
+ + + string queryMsg = "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348"; //查询USB设备 + //queryMsg += ";LAN:4162,5000";//查询网络设备 + queryMsg += ";"; + uci.Node[] nodes = new uci.Node[10]; + int count = UCIInterop.QueryNodesX(queryMsg, nodes, nodes.Length, 2000); + if (count > 0) + { + Console.WriteLine("查询到的满足条件的USB设备数量:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("[{0}]:{1}", i, nodes[i].UCIAddr); + } + } + else + { + OutputResult(count, "查询设备"); + } + + +
+ + + 查找串口 + + 接收端口描述的数据地址,调用者只需要做初始化即可。 + _nodes的个数 + 具体描述,请查看说明。 + + 此查询不包括任何的协议,只是查询串口。如果要查询指定协议的设备,请遍历打开串口 + 并使用指定协议进行验证。 + + uci.COMPort[] comPorts = new uci.COMPort[10]; + count = UCIInterop.QueryCOMPort(comPorts, comPorts.Length); + if (count > 0) + { + Console.WriteLine("Ports:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("{0} - COM{1} : {2}", i, comPorts[i].Port, comPorts[i].FriendlyName); + } + } + else if (count == 0) + { + Console.WriteLine("未查询到任何串口设备"); + } + else + { + OutputResult(count, "查询串口设备"); + } + //* Ports:1 + //* 0 - COM3 : Silicon Labs CP210x USB to UART Bridge (COM3) + + + + + + + 写数据。 可以使用简化版本的接口: + + 会话ID,由获得 + 接口参数 + 要写入的数据 + 数据长度 + 具体描述,请查看说明。 + + + + 写数据。 是的非封装版本。 + + 会话ID,由获得 + 指令字符串 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 要写入的数据 + 数据长度 + 具体描述,请查看说明。 + + + + 发送指令 + + 会话ID,由获得 + 指令参数 + 具体描述,请查看说明。 + + 具体哪些指令支持此接口,请参考各机型文档。 + + + + + 读参数。请使用 + + 会话ID,由获得 + 读接口参数 + 接收数据的缓冲区 + 接收数据的缓冲区的长度 + 具体描述,请查看说明。 + + + + 读参数(的参数未封装版本) + + 会话ID,由获得 + 读指令文本 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 接收数据的缓冲区 + 接收数据的缓冲区的长度 + 具体描述,请查看说明。 + + 可参考 + + + + + 关闭会话 + + 会话ID,由获得 + 具体描述,请查看说明。 + + + + 写文件到设备 + + 会话ID,由获得 + 写文件参数 + 具体描述,请查看说明。 + + + + 写文件到设备,是参数非封装接口 + + 会话ID,由获得 + 指令字符串 + 要发送的文件路径 + 指令执行超时(ms),在该时间内指令为完成,就返回! + 具体描述,请查看说明。 + + + + 读文件 + + 会话ID,由获得 + 读文件参数 + 具体描述,请查看说明。 + + + + 写属性。 + + 会话ID,由获得, + 如果使用表示写的是全局属性。 + 属性指令文本 + 属性参数数据 + 属性参数数据长度(字节) + 具体描述,请查看说明。 + + 返回的描述信息,可以设置中文和英文两个版本,设置方式如下: + + //设置为中文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession,"lang:zh-Hans;", null, 0); + //设置为英文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:en-US;", null, 0); + + 订阅设备更改通知。设备在接入和移除时会触发改通知。 + + uci_SetAttribute(UCIInterop.InvalidSession, "devchange:1;", null, 0); + + 注意:需要使用 订阅通知。 + + + + + 添加事件订阅 + + 委托签名请见 + 目前默认返回0. + + + + 获取最近一次调用UCI接口后的反馈信息。 + 详细描述请参考: + + + 反馈的文本字符串,与此描述对应的状态码可以查看。 + + + + + (内部使用) 得到错误描述。原始接口,不要直接使用。 请使用。 + + + + + + (内部)获取单位类型编码对应的单位名 + + 单位类型编码,编码定义见 + 物理单位名,也可以参考的定义自己建表查找。 + + + + 将当前单位的数值自动转换到合适的单位类型,以使数值小于进制。比如2300Hz,转换后就是2.3kHz + + 当前值 + 当前单位编码 + 进制,一般为1000,比如频率的进制是1000 + 返回物理量(数值+单位量级) + + + + 将当前单位的数值转换到指定的单位。 + + 当前数值 + 当前单位编码 + 要转换到的单位编码 + 进制,一般为1000,比如频率的进制是1000 + 返回转换后的数值,比如2.3KHz 转换为Hz就是2300Hz + 注意单位编码必须如EScale定义的,连续递增的量。 + + + + 获取单位类型编码对应的单位名 + + 单位类型编码,编码定义见 + 物理单位名,也可以参考的定义自己建表查找。 + + + + 在主程序退出之前调用本接口以清除uci.dll内部资源。 + 本接口只是针对C#接口使用。否则在退出时会有异常出现。 + + + + + 转换PID和VID为32位整数。 + + USB PID + USB VID + 转换好的PVID : 高16位为pid,低16位为vid. + + + + 判断接口返回值是否代表错误,辅助接口。 + 内部代码: return (r < 0); + + 接口返回值 + false :接口返回的状态码代表发生错误,反正,执行成功! + + + + 判断接口返回值是否代表正确,辅助接口 + 内部代码: return (r >= 0); + + 接口返回值 + false :接口返回的状态码代表发生错误,反正,执行成功! + + + + 查询在线的设备(建议不再使用该接口,可用代替) + + 查询参数 + 输出设备信息的缓冲区 + 入参是要查询的设备数量,出参是已经查询到的设备数量 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + + + 对压缩像素数据进行解压缩(适用于UTG4000A系列\UTG2025A NEW) + + 压缩之后的数据地址(按32bit寻址) + 压缩的数据大小,注意是int类型。 + 存放解压缩后的像素数据缓冲区 + 像素点数 + 小于0 错误,错误码见UnZipError, >=0解压缩后的大小(像素数) + + _dst缓冲区大小是屏幕宽度 * 屏幕高度, 比如800*480的屏幕, + 解压缩后就是 800*480 = 384000.即_dst_size = 384000. + + + + + alg_UnCompressPixels 接口的另一版本, 缓冲区全部是字节流 + + 压缩之后的数据地址,字节流 + 字节流长度 + 接收解压缩后的数据的字节流缓冲区 + _dst缓冲区的长度(Bytes) + 参考 + + + + 对压缩像素数据进行解压缩(适用于UTG2025A和UTG2062A) + + 压缩之后的数据地址 + 压缩的数据大小,字节数 + 存放解压缩后的像素数据缓冲区 + 像素点数*3, 24bit + 小于 0 错误,错误码见UnZipError, >=0解压缩后的大小(字节数) + + _des缓冲区大小应该是480*272*3 + + + + + 1000A信号源使用的图像数据的解压算法 + + 从设备端读取到的完整数据包 + _src 指向的数据大小Bytes + 输出的32bit的像素数据的缓冲区 + 图像的宽度 + 图像的高度 + 小于 0 错误,错误码见UnZipError, >=0解压缩后的像素个数 + + + + 使用ZBMP算法压缩的位图数据的解压缩算法 + + 原始数据 + 原始数据长度 + 接收解压后数据的缓冲区 + _des的长度 + 小于0 : 错误,请查看 + + + + 通知事件的委托函数,由使用。 + + 通知附带的消息参数 + 视消息协议而定 + + + + 解压缩返回算法返回的错误码 + + + + + 参数错误 + + + + + 接收非压缩数据的缓冲区大小不够 + + + + + alg_UnZipBMP接口返回的错误码 + + + + + 参数错误 + 地址不能为空,长度不能为0,接收解压缩的缓冲区不能被存放压缩数据的缓冲区小 + + + + + 存储空间不足 + + + + + 错误的窗大小 + + + + + 压缩数据格式错误 + + + + + 压缩数据有误 + + + + + 提供一些做跨平台数据转换时的常用接口 + + + + + 将字节数组转换为结构体数组 + + 结构体类型 + 被转换的字节数组 + 用于数据的结构体数组 + 要转换的结构体数量 + + + + + + byte数组转结构体 + + byte数组 + 结构体类型 + 转换后的结构体, 转换失败返回null + + + + 结构体转byte数组 + + 要转换的结构体 + 转换后的byte数组 + +
+
diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/ucics.dll b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/ucics.dll new file mode 100644 index 0000000..005c0af Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/C#/SimpleIO/lib/ucics.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.c b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.c new file mode 100644 index 0000000..f22d631 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.c @@ -0,0 +1,210 @@ +#include "main.h" + +//============================================================================== +// +// Title: UCIDEMO +// Purpose: A short description of the application. +// +// Created on: 2016/10/27 at 14:20:19 by admin. +// Copyright: . All Rights Reserved. +// +//============================================================================== + +//============================================================================== +// Include files + +#include +#include +#include +#include "UCIDEMO.h" +#include "toolbox.h" +#include "include\uci.h" +#include "include\dso_base.h" +#include "include\unit.h" +//============================================================================== +// Constants + +//============================================================================== +// Types + +//============================================================================== +// Static global variables + +static int panelHandle; + +static u_session g_session = INVALID_SESSION; + +typedef struct _UCIParams{ + u_session Session; + MeaValue Params[50]; +}UCIParams; + +static UCIParams g_UCIParams; +//============================================================================== +// Static functions + +//============================================================================== +// Global variables + +//============================================================================== +// Global functions +int HandleResult(char* tips, u_status r){ + if(UCIERR(r)) + printf("%s : r = %d, %s\n", tips == NULL ? "--" : tips, r, uci_GetLastError()); + return r; +} + +int OpenDevice(){ + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 +// u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + u_status r = HandleResult( + "Open devcie", + uci_OpenX("[C:DSO][D:UPO2000CS][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x3][CFG:3]", 2000) + ); + if(UCISUCCESS(r)) + g_UCIParams.Session = (u_session)r; + return r; +} + +void InitMeasure(){ + u_status r = 0; + + if(g_UCIParams.Session == INVALID_SESSION) { + printf("please open device first!\n"); + return; + } + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + //u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + r = HandleResult( + "Enabel Measure", + uci_FormatWrite(g_UCIParams.Session, 1000, "mea@ALL:1;") + ); + + r = HandleResult( + "Switch to measure CH1", + uci_FormatWrite(g_UCIParams.Session, 1000, "mea@src:0;") + ); +} + +/// HIFN The main entry-point function. +int main (int argc, char *argv[]) +{ + int error = 0; + + + /* initialize and load resources */ + nullChk (InitCVIRTE (0, argv, 0)); + errChk (panelHandle = LoadPanel (0, "UCIDEMO.uir", PANEL)); + + g_UCIParams.Session = INVALID_SESSION; + memset(g_UCIParams.Params, 0, sizeof(g_UCIParams.Params)); + + if(OpenDevice() >= 0) + InitMeasure(); + + /* display the panel and run the user interface */ + errChk (DisplayPanel (panelHandle)); + errChk (RunUserInterface ()); +Error: + /* clean up */ + DiscardPanel (panelHandle); + return 0; +} + +//============================================================================== +// UI callback function prototypes + +/// HIFN Exit when the user dismisses the panel. +int CVICALLBACK panelCB (int panel, int event, void *callbackData, + int eventData1, int eventData2) +{ + if (event == EVENT_CLOSE) + QuitUserInterface (0); + return 0; +} + +int ReadMeaParams(void){ + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 +// u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, +// u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + return HandleResult( + "Read measure result " , + uci_ReadX(g_UCIParams.Session, "mea:all?;", 1000, (u_byte*)g_UCIParams.Params, sizeof(g_UCIParams.Params)) + ); +} + +MeaValue* GetParam(EMeaParam id){ + return &g_UCIParams.Params[id]; +} + +void ShowMeaParam(char* name, EMeaParam id){ + MeaValue* p = NULL; + if(name == NULL) + return; + + p = GetParam(id); + + if(p->IsExist == 0) + printf("%s = Not exist\n", name); + else{ + if(p->IsValid == 1){ + printf("%s = %f\n",name, p->Value); + }else{ + printf("%s = --\n", name); + } + } +} + +int CVICALLBACK _Read (int panel, int control, int event, + void *callbackData, int eventData1, int eventData2) +{ + switch (event) + { + case EVENT_COMMIT: + if(ReadMeaParams() >=0 ){ + ShowMeaParam("FREQ", MP_FREQ); + ShowMeaParam("MAX", MP_MAX); + ShowMeaParam("AMP", MP_AMP); + } + // _numFreq = g_UCIParams.Params[MP_FREQ].Value; + break; + } + return 0; +} + +int CVICALLBACK _timer (int panel, int control, int event, + void *callbackData, int eventData1, int eventData2) +{ + switch (event) + { + case EVENT_TIMER_TICK: + if(ReadMeaParams() >=0 ){ + ShowMeaParam("FREQ", MP_FREQ); + ShowMeaParam("MAX", MP_MAX); + ShowMeaParam("AMP", MP_AMP); + } + break; + } + return 0; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.cdb b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.cdb new file mode 100644 index 0000000..8c7d324 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.cdb differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.cws b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.cws new file mode 100644 index 0000000..275955b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.cws @@ -0,0 +1,245 @@ +[Workspace Header] +Version = 850 +Pathname = "/e/Documents/National Instruments/CVI85/UCIDEMO.cws" +CVI Dir = "/c/program files (x86)/national instruments/cvi85" +CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI" +CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI85" +CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI" +IVI Standard Root Dir = "/C/Program Files (x86)/IVI Foundation/IVI" +VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt" +Number of Projects = 3 +Active Project = 3 +Project 0001 = "" +Project 0002 = "" +Project 0003 = "UCIDEMO.prj" +Drag Bar Left = 198 +Window Top = 95 +Window Left = 78 +Window Bottom = 1018 +Window Right = 1778 +Maximized = True +Maximized Children = True +Max Number Of Errors = 20 +Track Include File Dependencies = True +Prompt For Missing Includes = True +Stop On First Error File = False +Bring Up Err Win For Warnings = True +Show Build Dialog = False +Save Changes Before Running = "Always" +Hide Windows = False +Global Hot Key = False +Break At First Statement = False +Sort Type = "File Name" +Number of Opened Files = 7 +Window Confinement Region Enabled = True +MainColumnWidth = 179 +FileDateColumnWidth = 70 +FileSizeColumnWidth = 70 +StatusColumnWidth = 70 + +[Project Header 0001] +Version = 850 +Don't Update DistKit = False +Platform Code = 4 +Build Configuration = "Debug" +Warn User If Debugging Release = 1 +Batch Build Release = False +Batch Build Debug = False +Force Rebuild = False + +[Project Header 0002] +Version = 850 +Don't Update DistKit = False +Platform Code = 4 +Build Configuration = "Debug" +Warn User If Debugging Release = 1 +Batch Build Release = False +Batch Build Debug = False +Force Rebuild = False + +[Project Header 0003] +Version = 850 +Don't Update DistKit = False +Platform Code = 4 +Build Configuration = "Debug" +Warn User If Debugging Release = 1 +Batch Build Release = False +Batch Build Debug = False +Force Rebuild = False + +[File 0001] +Path = "/e/Documents/National Instruments/CVI85/UCIDEMO.c" +File Type = "CSource" +Disk Date = 3560402216 +In Projects = "3," +Window Top = 98 +Window Left = 44 +Window Z-Order = 1 +Source Window State = "1,112,114,112,35,36,35,0,0,209,0,0,0,0,0,40,141,0,63,4,505,757,1,0," + +[File 0002] +Path = "/e/Documents/National Instruments/CVI85/UCIDEMO.uir" +File Type = "User Interface Resource" +Disk Date = 3560402075 +In Projects = "3," +Window Top = 66 +Window Left = 27 +Window Height = 334 +Window Width = 757 +Window Z-Order = 2 + +[File 0003] +Path = "/c/Program Files (x86)/National Instruments/CVI85/include/ansi_c.h" +File Type = "Include" +Disk Date = 3275949600 +In Projects = "" +Window Top = 130 +Window Left = 61 +Window Z-Order = 7 +Source Window State = "1,21,21,21,13,18,18,0,3,88,0,0,0,0,0,16,11,0,21,13,334,757,1,0," + +[File 0004] +Path = "/e/Documents/National Instruments/CVI85/lib/C/ASCII/uci.lib" +File Type = "Library" +Disk Date = 3560397350 +In Projects = "3," + +[File 0005] +Path = "/e/Documents/National Instruments/CVI85/include/uci.h" +File Type = "Include" +Disk Date = 3560397554 +In Projects = "" +Window Top = 162 +Window Left = 78 +Window Z-Order = 5 +Source Window State = "1,127,135,135,0,107,107,0,0,88,0,0,0,0,0,16,121,0,134,51,334,757,1,0," + +[File 0006] +Path = "/e/Documents/National Instruments/CVI85/include/ucidef.h" +File Type = "Include" +Disk Date = 3560397476 +In Projects = "" +Window Top = 130 +Window Left = 61 +Window Z-Order = 6 +Source Window State = "1,251,251,251,8,23,23,0,3,88,0,0,0,0,0,20,236,0,251,8,410,757,1,0," + +[File 0007] +Path = "/e/Documents/National Instruments/CVI85/include/unit.h" +File Type = "Include" +Disk Date = 3560397608 +In Projects = "" +Window Top = 98 +Window Left = 44 +Window Z-Order = 4 +Source Window State = "1,53,53,53,23,26,23,0,0,88,0,0,0,0,0,16,0,0,23,33,334,757,1,0," + +[File 0008] +Path = "/e/Documents/National Instruments/CVI85/include/comApiCommon.h" +File Type = "Include" +Disk Date = 3560396673 +In Projects = "" +Window Top = 98 +Window Left = 44 +Window Z-Order = 3 +Source Window State = "1,197,197,197,8,14,14,0,0,88,0,0,0,0,0,16,189,0,199,17,334,757,1,0," + +[Build Options 0001] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Execution Trace = "Disabled" +Debugging Level = "Standard" +Break On Library Errors = True +Break On First Chance Exceptions = False +Execution Target Address = "Local desktop computer" +Execution Target Port = 0 +Execution Target Type = 0 + +[SCC Options 0001] +Use global settings = True +SCC Provider = "" +SCC Project = "" +Local Path = "" +Auxiliary Path = "" +Perform Same Action For .h File As For .uir File = "Ask" +Perform Same Action For .cds File As For .prj File = "Ask" +Username = "" +Comment = "" +Use Default Username = False +Use Default Comment = False +Suppress CVI Error Messages = False +Always show confirmation dialog = True + +[DLL Debugging Support 0001] +External Process Path = "" + +[Command Line Args 0001] +Command Line Args = "" + +[Build Options 0002] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Execution Trace = "Disabled" +Debugging Level = "Standard" +Break On Library Errors = True +Break On First Chance Exceptions = False +Execution Target Address = "Local desktop computer" +Execution Target Port = 0 +Execution Target Type = 0 + +[SCC Options 0002] +Use global settings = True +SCC Provider = "" +SCC Project = "" +Local Path = "" +Auxiliary Path = "" +Perform Same Action For .h File As For .uir File = "Ask" +Perform Same Action For .cds File As For .prj File = "Ask" +Username = "" +Comment = "" +Use Default Username = False +Use Default Comment = False +Suppress CVI Error Messages = False +Always show confirmation dialog = True + +[DLL Debugging Support 0002] +External Process Path = "" + +[Command Line Args 0002] +Command Line Args = "" + +[Build Options 0003] +Generate Browse Info = True +Enable Uninitialized Locals Runtime Warning = True +Execution Trace = "Disabled" +Debugging Level = "Standard" +Break On Library Errors = True +Break On First Chance Exceptions = False +Execution Target Address = "Local desktop computer" +Execution Target Port = 0 +Execution Target Type = 0 + +[SCC Options 0003] +Use global settings = True +SCC Provider = "" +SCC Project = "" +Local Path = "" +Auxiliary Path = "" +Perform Same Action For .h File As For .uir File = "Ask" +Perform Same Action For .cds File As For .prj File = "Ask" +Username = "" +Comment = "" +Use Default Username = False +Use Default Comment = False +Suppress CVI Error Messages = False +Always show confirmation dialog = True + +[DLL Debugging Support 0003] +External Process Path = "" + +[DLLs Used By Executable 0003] +DLL 0001 = "/e/Documents/National Instruments/CVI85/uci.dll" + +[Command Line Args 0003] +Command Line Args = "" + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.exe b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.exe new file mode 100644 index 0000000..24f87f1 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.exe differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.h new file mode 100644 index 0000000..7abe977 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.h @@ -0,0 +1,37 @@ +/**************************************************************************/ +/* LabWindows/CVI User Interface Resource (UIR) Include File */ +/* Copyright (c) National Instruments 2016. All Rights Reserved. */ +/* */ +/* WARNING: Do not add to, delete from, or otherwise modify the contents */ +/* of this include file. */ +/**************************************************************************/ + +#include + +#ifdef __cplusplus + extern "C" { +#endif + + /* Panels and Controls: */ + +#define PANEL 1 /* callback function: panelCB */ +#define PANEL_COMMANDBUTTON 2 /* callback function: _Read */ +#define PANEL__numFreq 3 +#define PANEL_TIMER 4 /* callback function: _timer */ + + + /* Menu Bars, Menus, and Menu Items: */ + + /* (no menu bars in the resource file) */ + + + /* Callback Prototypes: */ + +int CVICALLBACK _Read(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); +int CVICALLBACK _timer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); +int CVICALLBACK panelCB(int panel, int event, void *callbackData, int eventData1, int eventData2); + + +#ifdef __cplusplus + } +#endif diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.prj b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.prj new file mode 100644 index 0000000..32ce446 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.prj @@ -0,0 +1,136 @@ +[Project Header] +Version = 850 +Pathname = "/e/Documents/National Instruments/CVI85/UCIDEMO.prj" +CVI Dir = "/c/program files (x86)/national instruments/cvi85" +CVI Shared Dir = "/C/Program Files (x86)/National Instruments/Shared/CVI" +CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI85" +CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI" +IVI Standard Root Dir = "/C/Program Files (x86)/IVI Foundation/IVI" +VXIplug&play Framework Dir = "/C/Program Files (x86)/IVI Foundation/VISA/winnt" +Number of Files = 3 +Target Type = "Executable" +Flags = 16 + +[File 0001] +File Type = "CSource" +Res Id = 1 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "UCIDEMO.c" +Path = "/e/Documents/National Instruments/CVI85/UCIDEMO.c" +Exclude = False +Compile Into Object File = False +Project Flags = 0 +Folder = "Source Files" + +[File 0002] +File Type = "User Interface Resource" +Res Id = 2 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "UCIDEMO.uir" +Path = "/e/Documents/National Instruments/CVI85/UCIDEMO.uir" +Exclude = False +Project Flags = 0 +Folder = "User Interface Files" + +[File 0003] +File Type = "Library" +Res Id = 3 +Path Is Rel = True +Path Rel To = "Project" +Path Rel Path = "lib/C/ASCII/uci.lib" +Path = "/e/Documents/National Instruments/CVI85/lib/C/ASCII/uci.lib" +Exclude = False +Project Flags = 0 +Folder = "Not In A Folder" + +[Folders] +Include Files Folder Not Added Yet = True +Instrument Files Folder Not Added Yet = True +Folder 0 = "User Interface Files" +Folder 1 = "Source Files" + +[Compiler Options] +Default Calling Convention = "cdecl" +Require Prototypes = True +Require Return Values = True +Enable Pointer Mismatch Warning = False +Enable Unreachable Code Warning = False +Enable Unreferenced Identifiers Warning = False +Enable Assignment In Conditional Warning = False +O Option Compatible With 5.0 = False +Uninitialized Locals Compile Warning = "Conservative" + +[Run Options] +Stack Size = 250000 +Image Base Address = 4194304 + +[Compiler Defines] +Compiler Defines = "/DWIN32_LEAN_AND_MEAN" + +[Create Executable] +Executable File_Debug Is Rel = True +Executable File_Debug Rel To = "Project" +Executable File_Debug Rel Path = "UCIDEMO.exe" +Executable File_Debug = "/e/Documents/National Instruments/CVI85/UCIDEMO.exe" +Executable File_Release Is Rel = True +Executable File_Release Rel To = "Project" +Executable File_Release Rel Path = "UCIDEMO.exe" +Executable File_Release = "/e/Documents/National Instruments/CVI85/UCIDEMO.exe" +Icon File Is Rel = False +Icon File = "" +Application Title = "" +DLL Exports = "Include File Symbols" +DLL Import Library Choice = "Gen Lib For Current Mode" +Use IVI Subdirectories for Import Libraries = False +Use VXIPNP Subdirectories for Import Libraries = False +Use Dflt Import Lib Base Name = True +Where to Copy DLL = "Do not copy" +Add Type Lib To DLL = False +Include Type Lib Help Links = False +Type Lib FP File Is Rel = False +Type Lib FP File = "" +Type Lib Guid = "" +Runtime Support = "Full Runtime Support" +Instrument Driver Support Only = False +Embed Project .UIRs = False +Generate Map File = False + +[External Compiler Support] +UIR Callbacks File Option = 0 +Using LoadExternalModule = False +Create Project Symbols File = True +UIR Callbacks Obj File Is Rel = False +UIR Callbacks Obj File = "" +Project Symbols H File Is Rel = False +Project Symbols H File = "" +Project Symbols Obj File Is Rel = False +Project Symbols Obj File = "" + +[ActiveX Server Options] +Specification File Is Rel = False +Specification File = "" +Source File Is Rel = False +Source File = "" +Include File Is Rel = False +Include File = "" +IDL File Is Rel = False +IDL File = "" +Register ActiveX Server = False + +[Signing Info] +Sign = False +Sign Debug Build = False +Store = "" +Certificate = "" +Timestamp URL = "" +URL = "" + +[Manifest Info] +Embed = False + +[tpcSection] +tpcEnabled = 0 +tpcOverrideEnvironment = 0 + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.uir b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.uir new file mode 100644 index 0000000..2f9212c Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/UCIDEMO.uir differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/CMD_COMVer2.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/CMD_COMVer2.h new file mode 100644 index 0000000..3446546 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/CMD_COMVer2.h @@ -0,0 +1,551 @@ +/*! + * \created : 2016/12/28 + * \author : M.Yang + * \purpose : ʹUTD2000M\UTD4000M\UTD2000CEX-EDUϵлʹõָ塣 + * ʹã鿴Ӧ͵Эĵ + */ +#ifndef CMD_COMVer2_h__ +#define CMD_COMVer2_h__ + +#ifdef __cplusplus +namespace comApiEx { +#endif + static const int Invalid_CMD = -1; + +#ifdef __cplusplus + static bool IsCMDValid(short cmd) { + return (cmd != Invalid_CMD); + } +#else + static int IsCMDValid(short cmd) + { + return (cmd == Invalid_CMD) ? 0 : 1; + } +#endif + + //@brief : ͨ + //@remarks : ӿڲCHΪ-1ΪEnumݣӦĶshot(2Bytes)ͽжд. + typedef enum _commom_cmd { + //@brief : ȡ豸ͱ + //@remarks : {IO:R}{DATA:comAPICommon::E_DSO_TYPE} + CMD_GET_DSO_TYPE = 0, + //@brief : ü + //@remarks : {IO:W}{DATA:null} + CMD_LOCK_KEYPAD, + //@brief : ü̽ + //@remarks : {IO:W}{DATA:null} + CMD_UNLOCK_KEYPAD, + //@brief : ȡ豸״̬ + //@remarks : {IO:R}{DATA:comApi::E_PROC_STATE from } + CMD_PROCSTATE, + //@brief : ִAUTOSET + //@remarks : {IO:W}{DATA:null} + CMD_AUTOSET, + //@brief : ִǿƴFORCE + //@remarks : {IO:W}{DATA:null} + CMD_TRIG_FORCE, + //@brief : ִеδSINGLE + //@remarks : {IO:W}{DATA:null} + CMD_SINGLE, + //@brief : ִCOARSE + //@remarks : {IO:W}{DATA:null} + CMD_COARSE, + //@brief : ִаPRTSC + //@remarks : {IO:W}{DATA:null} + CMD_PRTSC, + //@brief : + CMD_GET_BITMAP_FILENAME, + //@brief : ȡͼ + //@remarks : {IO:R}{DATA: 2000M/4000M768512Bytes} + CMD_GET_BITMAP_FILEDATA, + + //@brief : ָ + //@remarks : {IO:WR}{DATA<8Bytes>:comAPICommon::Key from } + CMD_KEY, + //@brief : ȡѹĻ + CMD_CAPTURE_SCREEN, + //@brief : д + CMD_DEV_CONFIG, + //@brief : ѯ豸ʾ + CMD_IDN, + //@brief : ѯЭ汾š + CMD_CVER, + + //@brief : ȡĻϢ + //@remarks : {IO:R}{DATA<20Bytes>:comApiEx::SCREEN_INFO from } + CMD_GET_SCREEN_INFO = 50, //SCREEN_INFO + //@brief : short 1: usb connection state is ok; other: usb connection state is not ok (ok) + //@remarks : + CMD_GET_USB_CONNECTION_STATE, + //@brief : õǰƵʼֵ + //@remarks : {IO:R}{DATA:comApiEx::SignalFreq from } + CMD_GET_CYMOMETER_VALUE, + //@brief : õǰѡеͨ + //@remarks : short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other (ok) + CMD_GET_CURRENT_ACTIVE_CHANNEL, //short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other (ok) + //@brief : õ豸˵ǰвIJ˵ + //@remarks : short 0: CH1 menu; 1: CH2 menu; 2: MATH or FFT menu; -1: other menu (ok) + CMD_GET_CURRENT_ACTIVE_MENU, + //@brief : ȡǰ˵Ƿʾ + //@remarks : short 0: current menu is not display; 1: current menu is display (ok) + CMD_GET_CURRENT_MENU_SHOW_STATE, + CMD_GET_SAMPLE, + //@brief : UǷ + //@remarks : {IO:R}{DATA: 0 δ룻 1 } + CMD_GET_USBDISK_STATE, + + //{acquire + //@brief : ɼģʽ + //@remarks : {IO:WR}{DATA:comApiEx::E_ACQ_MODE from } + CMD_ACQ_MODE = 400, + //@brief : ƽ + //@remarks : {IO:WR}{DATA: averageNum} + //ʵʴùʽ<2^(averageNum + 1)>, : {(0: 2), (1: 4), (2: 8), (3: 16), (4: 32), (5: 64), (6: 128), (7: 256)} + CMD_ACQ_AVERAGE_NUM, + //@brief : ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_SAMPLE_MODE from } + CMD_ACQ_SAMPLING, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_ACQ_SAV_DEPTH from } + CMD_ACQ_DEPTH, + //@brief : ٲɼ + //@remarks : {IO:WR}{DATA: 0 ر 1 } + CMD_ACQ_FAST, + //} + + //{trigger + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_TYPE from } + CMD_TRIG_TYPE = 500, + //@brief : Դ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_SOURCE from } + CMD_TRIG_SOURCE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_TIRG_COUPLING from } + CMD_TRIG_COUPLING, + //@brief : ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_MODE from } + CMD_TRIG_METHOD, + //@brief : شбʴ-б + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_EDGE_SLOPE(ء) E_SLOP_POLARITY(б) from } + CMD_TRIG_SLOPE_TYPE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_PULSE_POLAR from } + CMD_TRIG_PULSE_POLAR, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_PULSE_CONDITION from } + CMD_TRIG_PULSE_COND, + //@brief : ʱ + //@remarks : {IO:WR}{DATA: ֵstep, 㹫ʽ(t = K * step), һK = 4} + CMD_TRIG_PULSE_TIME, + //@brief : Ƶ-Ƶʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_VIDEO_STANDARD from } + CMD_TRIG_VIDEO_STD, + //@brief : Ƶ-ͬ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_VIDEO_SYNC_MODE from } + CMD_TRIG_VIDEO_SYNC, + //@brief : Ƶ-ָ + //@remarks : {IO:WR}{DATA: } + CMD_TRIG_VIDEO_LINE_NUMBER, + //@brief : бʴ-б + //@remarks : {IO:WR}{DATA: comApiEx::E_SLOP_WHEN from } + CMD_TRIG_SLOPE_COND, + //@brief : бʴ-ʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_SLOPE_TIME, + //@brief : бʴ-ֵ(Ƿ/µֵ) + //@remarks : {IO:WR}{DATA: comApiEx::E_SLOP_THRESHOLD from } + CMD_TRIG_SLOPE_THRESHOLD, + //@brief : бʴ-ѹ + //@remarks : {IO:R}{DATA: ַʽȡ} + CMD_TRIG_SLOPE_VT, + + //@brief : ʱ1 CEM""><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵstep, 㹫ʽ(t = K * step), һK = 4} + CMD_TRIG_PULSE_LT_TIME, + //@brief : бʴ-ʱ2 CEM"б"><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_SLOPE_LT_TIME, + + //@brief : - + //@remarks : {IO:WR}{DATA: comApiEx::E_WINDOE_WHEN from } + CMD_TRIG_WINDOW_COND, + //@brief : -ʱ + //@remarks :{IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_WINDOW_TIME, + //@brief : Ƿ- + //@remarks : {IO:WR}{DATA: comApiEx::E_RUNT_WHEN from } + CMD_TRIG_RUNT_COND, + //@brief : Ƿ-ʱ + //@remarks :{IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_RUNT_TIME, + //@brief : Ƿ-ʱ1 CEM""><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_RUNT_LT_TIME, + //} + + + //{display + //@brief : DISPLAY + //@remarks : {IO:WR}{DATA: comApiEx::E_DISPLAY_TYPE from } + CMD_DISPLAY_TYPE = 600, + //@brief : DISPLAY ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_DISPLAY_FORMAT from } + CMD_DISPLAY_FORMAT, + //@brief : DISPLAY դ + //@remarks : {IO:WR}{DATA: comApiEx::E_Display_Graticule from } + CMD_DISPLAY_GRID, + //@brief : DISPLAY ʱ + //@remarks : {IO:WR}{DATA: comApiEx::E_Dislay_PersistTime from } + CMD_DISPLAY_PERSIST, + //@brief : DISPLAY + //@remarks : {IO:WR}{DATA: һ 1 - 100 2000M4000M step[0,49] = curStep * 2 + 2} + CMD_DISPLAY_WAVE_LUM, + //} + + //{cursor + //@brief : Cursor + //@remarks : {IO:WR}{DATA: comApiEx::E_CURSOR_TYPE from } + CMD_CURSOR_TYPE, + //@brief : Cursor ģʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_CURSOR_MODE from } + CMD_CURSOR_MODE, + //@brief : Cursor ģʽ + //@remarks : {IO:WR}{DATA: ʱ comApiEx::E_CURSOR_V_UNIT ѹ : comApiEx::E_CURSOR_H_UNIT from } + CMD_CURSOR_UNIT, + //@brief : Cursor ׼ + //@remarks : {IO:WR}{DATA: E_CURSOR_POS from } + CMD_CURSOR_BASE, + //@brief : Cursor Aλõ + //@remarks : {IO:WR}{DATA : ˮƽߣΪ0һΪ25ֱߣΪ350һΪ50} + CMD_CURSOR_A_POS, + //@brief : Cursor Bλõ + //@remarks : {IO:WR}{DATA : ˮƽߣΪ0һΪ25ֱߣΪ350һΪ50 } + CMD_CURSOR_B_POS, + //} + + //{windows + CMD_WIN_TYPE, // (ok) + CMD_WIN_HOLDOFF, // + //} + + //{storage + //@brief : Storage + //@remarks : {IO:WR}{DATA: comApiEx::E_STORAGE_TYPE from } + CMD_STORAGE_TYPE = 700, + //@brief : Storage ļ + //@remarks : {IO:WR}{DATA: } + CMD_STORAGE_FILE_NAME, + //@brief : Storage ο-Դ + //@remarks : {IO:WR}{DATA: comApiEx::E_CHANNEL_ID from } + CMD_STORAGE_REFWAVE_SOURCE, + //@brief : Storage ο-ļʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_STORAGE_REFWAVE_FILE_FORMAT from } + CMD_STORAGE_REFWAVE_FILE_FORMAT, + //@brief : ȡô洢ļб + //@remarks :{IO:WR}{DATA: comApiEx::FileList_Flash from } + CMD_STORAGE_GET_FILE_LIST_FLASH, // (ok) + //@brief : ȡô洢ļб + //@remarks :{IO:WR}{DATA: comApiEx::FileList_USB from } + CMD_STORAGE_GET_FILE_LIST_USB, + //@brief : ִSAVE浽Flash. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_SAVE, + //@brief : ִLOADFlash. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_LOAD, + //@brief : ִImportU̼. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_IMPORT, + //@brief : ִExport + //@remarks : {IO:W}{DATA} + CMD_STORAGE_EXPORT, + //@brief : ѯǷѱ + //@remarks : {IO:R}{DATA : 0 ڣ 1 } + CMD_STORAGE_REFSETTING_EXIST, + //@brief : 洢λ + //@remarks : {IO:WR}{DATA : λ} + CMD_STORAGE_POS, + //} + + //{measure + MEASURE_ALL = 800, + MEASURE_CLEAR, + MEASURE_CUSTOMIZE, + MEASURE_INDICATOR, + MEASURE_DELAY_FROM, + MEASURE_DELAY_FEDGE, + MEASURE_DELAY_TO, + MEASURE_DELAY_TEGDE, + MEASURE_DELAY_OK, + MEASURE_PHASE_FROM, + + MEASURE_PHASE_TO, + MEASURE_PHASE_OK, + //} + + //for UTD2102CEX + CMD_MEASURE_SOURCE, + CMD_MEASURE_STATISTICS, + + //{utility + //@brief : ִУ + //@remarks : {IO:W}{DATA} + CMD_UTILITY_SELF_CALIBRATE = 1000, + CMD_UTILITY_SYSTEM_INFO, //(ok) + //@brief : ִClear + //@remarks : {IO:W}{DATA} + CMD_UTILITY_CLEAR_INFO, + //@brief : ִлָ + //@remarks : {IO:W}{DATA} + CMD_UTILITY_RESET_TO_FACTORY, + //@brief : Աȶ + //@remarks : {IO:WR}{DATA} + CMD_UTILITY_CONTRAST, + //@brief : л + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Language from } + CMD_UTILITY_LANGUAGE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Skin from } + CMD_UTILITY_SKIN, + //@brief : ˵ʾʱ + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Menu_Display_Time from } + CMD_UTILITY_MENU_DISP, + //@brief : + //@remarks : {IO:WR}{DATA} + CMD_UTILITY_GRID_LUM, + //@brief : Ƶʼƿ + //@remarks : {IO:WR}{DATA:comApiEx:: E_SWITCH_STATE from } + CMD_UTILITY_CYMOMETER, + + CMD_UTILITY_AUTOSET_CHANNEL, + CMD_UTILITY_AUTOSET_ACQUIRE, + CMD_UTILITY_AUTOSET_TRIG, + CMD_UTILITY_AUTOSET_SIGNAL, + //} + + //{record + CMD_DSO_RECORD_START, + CMD_DSO_RECORD_STOP, + CMD_DSO_RECORD_REPLAY, + CMD_DSO_RECORD_CLEAR, + //} + + //{ + CMD_UTILITY_SQUARE_WAVE, + CMD_UTILITY_SLEEP_TIME, + CMD_UTILITY_MEASURE_UNIT, + //} + + //{ + CMD_SYS_TIME_SWITCH = 1100, + CMD_SYS_TIME, + //} + + //{pass fail + CMD_PASS_FAIL_ALLOW_TEST, + CMD_PASS_FAIL_OUTPUT, + CMD_PASS_FAIL_SOURCE, + CMD_PASS_FAIL_DISP_INFO, + CMD_PASS_FAIL_OPERATION, + CMD_PASS_FAIL_STOP_TYPE, + CMD_PASS_FAIL_STOP_COND, + CMD_PASS_FAIL_STOP_THRESHOLD, + CMD_PASS_FAIL_TEMPLATE_WAVEREF, + CMD_PASS_FAIL_TEMPLATE_REFLOAD, + CMD_PASS_FAIL_TEMPLATE_HRANGE, + CMD_PASS_FAIL_TEMPLATE_VRANGE, + CMD_PASS_FAIL_TEMPLATE_CREATE, + //} + + //@brief : ȡͨݰʽĵ + //@remarks : + CMD_GET_DISPLAY_DATA = 1200, //get ch1, ch2, math, ref a/b data ok + //ͬDSO״̬ͣDSOAttrStateͿͶͬ + CMD_SYNC_DSO, + + //ʱDSOݡ + CMD_PERIOD_MSG2DSO, + + //{CEX-EDUʹ + //CEX-EDUʹãͽҪȡRECݵͷ׼ + CMD_DSO_RECORD_HEADER_READY = 1400, + //CEX-EDUʹãȡRECͷ + CMD_DSO_RECORD_HEADER, + //CEX-EDUʹãͽҪȡREC׼ + CMD_DSO_RECORD_DATA_READY, + //CEX-EDUʹãȡRECݿ顣 + CMD_DSO_RECORD_DATA, + //CEX-EDUʹãжϵǰRECǷЧ + CMD_DSO_RECORD_DATA_VALID, + //} + + //{2000M-special + CMD_VARDEPTH_SAMPLE_RATE = 1420, + CMD_VARDEPTH_SAVE_DEPTH, + CMD_VARDEPTH_PRE_TRIG_TIME, + CMD_VARDEPTH_AUTO_TRIG_TIME, + //} + + // + CMD_MESSAGE = 1430, + // + CMD_DUMP_BEGIN = 1440, + CMD_DUMP_ID = CMD_DUMP_BEGIN, + CMD_DUMP_END = 1500, //#TODO:Ҫṩ룬ͽCEX2000Mıôṩͳһ롣 + }COMMON_CMD; + + //@brief : ͨ + //@remarks : + typedef enum _channel_cmd + { + CH_Invalid_CMD = -1, + //@brief : ͨ + //@remarks : {IO:WR}{DATA:E_CH_COUPLING_TYPE} + CH_ATTR_COUPLING = 0, + //@brief : + //@remarks : {IO:WR}{DATA:E_CH_BANDLIMIT} + CH_ATTR_BAND_WIDTH, + //@brief : + //@remarks : + CH_ATTR_VOLT_SCALE, + //@brief : Ŵ + //@remarks : {IO:WR}{DATA:CH_PROBE} + CH_ATTR_PROBE, + //@brief : + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_INVERT, + //@brief : ƫõѹ + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_PRE_BIAS_VOLT_SWITCH, + //@brief : ƫõѹֵ + //@remarks : {IO:W}{DATA: +1 increase; -1 decrease;} + CH_ATTR_PRE_BIAS_VOLT_VALUE, + //@brief : ƫõѹ + //@remarks : {IO:W}{DATA:null} + CH_ATTR_PRE_BIAS_VOLT_TOZERO, + + //@brief : ͨ + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_CHANNEL_SWITCH = 100, + //@brief : ֱλ + //@remarks : {IO:WR}{DATA: UTD2000M -> ϵΪ [-100 , 100], CEX -> µ[28,128]} + CH_ATTR_VERTICAL_POS, + //@brief : ֱλù + //@remarks : {IO:W}{DATA:null} + CH_ATTR_VERTICAL_POS_TOZERO, + //@brief : Ԥλ + //@remarks : {IO:WR}{DATA: UTD2000M -> ĻмΪ350һΪ50} + CH_ATTR_TRIG_DEPTH, + //@brief : Ԥȹ + //@remarks : {IO:W}{DATA:null} + CH_ATTR_TRIG_DEPTH_TOZERO, + //@brief : ƽϢ + //@remarks : {IO:R}{DATA:comApiEx::CellBaseValue} + // ֻͨһƽ Ϊ comApiEx::CellBaseValues TrigVolt; + // бʴƽ Ϊ comApiEx::CellBaseValues TrigVolt[2]; + CH_ATTR_TRIG_LEVEL, + //@brief : ƽλ + //@remarks : {IO:WR}{DATA: ͨΪ0㣬¸ÿ25} + CH_ATTR_TRIG_LEVEL_POS, + //@brief : ƽλù + //@remarks : {IO:WR}{DATA: ͨΪ0㣬¸ÿ25} + CH_ATTR_TRIG_LEVEL_TOZERO, + //@brief : Ϣ + //@remarks : {IO:R}{DATA: CellBaseValue} + CH_ATTR_VOLT_AMPLITUDE, + //񵲵λΪshort + //@brief : 񵲵λ + //@remarks : {IO:WR}{DATA: +1 increase; -1 decrease; other : code } + CH_ATTR_VOLT_AMPLITUDE_LEVEL, + //ʱλΪshortֻã + //@brief : ʱλ + //@remarks : {IO:W}{DATA: E_TIMEBASE_LEVEL } + CH_ATTR_TIME_BASE, + //@brief : ȡʱʱ + //@remarks : {IO:R}{DATA: CellBaseValue} + CH_ATTR_TIME_BASE_VALUE, + + //@brief : MATH + //@remarks : {IO:WR}{DATA: E_MATH_TYPE } + CH_MATH_TYPE = 200, + //@brief : MATHԴ1 + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_MATH_OP1, + //MATHͣͣshort + //@brief : MATH + //@remarks : {IO:WR}{DATA: E_MATH_OP_SIGN } + CH_MATH_OP, + //@brief : MATHԴ2 + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_MATH_OP2, + //@brief : FFTԴ + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_FFT_SRC, + //@brief : FFT + //@remarks : {IO:WR}{DATA: E_FFT_WINDOW } + CH_FFT_WINDOW, + //@brief : FFTֱλ + //@remarks : {IO:WR}{DATA: E_FFT_UNIT } + CH_FFT_VSCALE, + //@brief : ȡFFTƵֵ + //@remarks : {IO:R}{DATA: SignalFreq } + CH_FFT_FREQ, + //@brief : ˲ + //@remarks : {IO:WR}{DATA: E_FILTER_TYPE } + CH_FILTER_TYPE, + //@brief : Ƶ + //@remarks : {IO:WR}{DATA: ֵƵֵҪм} + CH_FILTER_FREQ_LOW, + //@brief : Ƶ + //@remarks : {IO:WR}{DATA: ֵƵֵҪм} + CH_FILTER_FREQ_HIGH, + //@brief : ˲Դ + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_FILTER_SRC, + + //@brief : REFص() + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_LOAD_FROM_FLASH = 300, + //@brief : REF벨(USB) + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_LOAD_FROM_USB, + //@brief : REF洢λõ + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_POS, + //@brief : жijһλòǷڣλCH_REF_POSõģ + //@remarks : {IO:R}{DATA: Ϊ洢λֵ } + CH_REF_POS_WAVE_EXIST, + //@brief : д洢 + //@remarks : {IO:W}{DATA : null } + CH_REF_CLEAR, + + //[] + CH_DISPLAY_DATA = 400, + //[]ȡԭʼݣCH_GET_SAV_DATA + CH_ORIGIN_DATA, + + //@brief : ȡSAVļݣݸʽ [4Bytes ļ] + [ļ] + //@remarks : ʹ÷ʽĵʾ + // UTD2102CMUTD4000M ӦСΪ32768Bytes UTD2102CEX-EDUӦ32000Bytes + CH_GET_SAV_DATA, + + //{2102CM-x + CH_VARDEPTH_ENABLE = 500, + CH_VARDEPTH_SAMPLE_RATE, + + CH_VARDEPTH_DATA_READY = 510, + CH_VARDEPTH_DATA, + + CH_VOLT_AMPLITUDE_LEVEL, //ѹֵãֱӽ0~15λ + CH_PRE_BIAS_VOLT_VALUE, //ƫõѹãֱõѹȸֵ + + CH_VARDEPTH_TRIG_READY, //ͨDSO׽źŵĻ + //} + }CHAN_CMD; + +#ifdef __cplusplus +} +#endif + +#endif // CMD_COMVer2_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/ItemCode_COMVer2.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/ItemCode_COMVer2.h new file mode 100644 index 0000000..e5b817a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/ItemCode_COMVer2.h @@ -0,0 +1,449 @@ +/*! + * \created : 2016/12/28 + * \author : M.Yang + * \purpose : ģUTD2000M\UTD4000M\UTD2000CEX-EDUϵлʹõѡͲѡ붨塣 + */ +#ifndef ItemCode_COMVer2_h__ +#define ItemCode_COMVer2_h__ + +#ifdef __cplusplus +namespace comApiEx +{ +#endif + +enum E_SWITCH_STATE +{ + SWITCH_OFF, + SWITCH_ON, +}; + +#pragma region Channel +typedef enum{ + CH_Invalid_ID = -1, + CH_1_ID = 0, + CH_2_ID, + CH_MATH_ID, + CH_REF_A_ID, + CH_REF_B_ID, + CH_MAX_CNT, +}E_CHANNEL_ID; + +enum E_REF_SRC +{ + REF_A = 0, + REF_B, +}; + +enum E_CH_COUPLING_TYPE +{ + CH_COUPLING_DC = 0, + CH_COUPLING_AC, + CH_COUPLING_GND, +}; + +enum E_CH_BANDLIMIT +{ + CH_BANDLIMIT_FULL, + CH_BANDLIMIT_HALF, + CH_BANDLIMIT_20MHZ, +}; + +// +typedef enum { + CH_PROBE_1X = 0, + CH_PROBE_10X, + CH_PROBE_100X, + CH_PROBE_1000X, + + //2017-3-13CEM + CH_PROBE_2X, + CH_PROBE_5X, + CH_PROBE_20X, + CH_PROBE_50X, + CH_PROBE_200X, + CH_PROBE_500X, + CH_PROBE_1MX, + CH_PROBE_2MX, + CH_PROBE_5MX, + CH_PROBE_10MX, + CH_PROBE_20MX, + CH_PROBE_50MX, + CH_PROBE_100MX, + CH_PROBE_200MX, + CH_PROBE_500MX, +}CH_PROBE; + +#pragma endregion Channel + +#pragma region Trigger +////////////////////////////Trigger/////////////////////////////////// +//2017-3-13ӴںǷ +enum E_TRIG_TYPE +{ + TRIG_TYPE_EDGE = 0, //: + TRIG_TYPE_PLUSE_WIDTH, //: + TRIG_TYPE_VIDEO, //: Ƶ + TRIG_TYPE_SLOPE, //: б + TRIG_TYPE_WINDOW, //: ڣ + TRIG_TYPE_RUNT, //: Ƿ +}; + +enum E_TRIG_SOURCE +{ + TRIG_CH1 = CH_1_ID, + TRIG_CH2 = CH_2_ID, + TRIG_EXT, + TRIG_EXT_5, //EXT/5 + TRIG_AC_LINE = 4, + TRIG_ALTER, +}; + +enum E_TIRG_COUPLING +{ + TIRG_COUPLING_DC = 0, + TIRG_COUPLING_AC, + TIRG_COUPLING_L_RESTRAIN, //trigger coupling low frequency restrain + TIRG_COUPLING_H_RESTRAIN, //trigger coupling high frequency restrain + TIRG_COUPLING_NOISE_REJ, // +}; + +enum E_TRIG_MODE +{ + TRIG_MODE_AUTO = 0, + TRIG_MODE_NORMAL, + TRIG_MODE_SINGLE, +}; + +enum E_TRIG_EDGE_SLOPE +{ + TRIG_EDGE_SLOP_RISE = 0, + TRIG_EDGE_SLOP_FALL, + TRIG_EDGE_SLOP_RISE_FALL, +}; + +enum E_PULSE_POLAR +{ + PULSE_POLAR_N = 0, + PULSE_POLAR_P , +}; + +//2017-3-13PULSE_CONDITION_GT_LT +enum E_PULSE_CONDITION +{ + PULSE_CONDITION_LT = 0, //pulse condition less than + PULSE_CONDITION_GT, //pulse condition greater than + PULSE_CONDITION_ET, //pulse condition equal to + + PULSE_CONDITION_NO_EQUAL, //pulse not equal to , add by yzz [RESERVE] + PULSE_CONDITION_GT_LT, +}; + +enum E_TRIG_VIDEO_STANDARD +{ + TRIG_Video_NTSC = 0, + TRIG_Video_PAL, +}; + +//Ƶ-ͬʽ(0)ż(1)(2)ָ(3) +enum E_TRIG_VIDEO_SYNC_MODE +{ + TRIG_Video_SyncMode_Odd = 0, + TRIG_Video_SyncMode_Even, + TRIG_Video_SyncMode_ALL, + TRIG_Video_SyncMode_Specified, +}; + +enum E_SLOP_POLARITY +{ + SLOP_POLAR_FALL = 0, + SLOP_POLAR_RISE, +}; + +//2017-3-13SLOP_WHEN_GT_LT +enum E_SLOP_WHEN +{ + SLOP_WHEN_LT = 0, + SLOP_WHEN_GT, + SLOP_WHEN_Equal, + SLOP_WHEN_GT_LT, +}; + +enum E_SLOP_THRESHOLD +{ + SLOP_THRESHOLD_LOW = 0, + SLOP_THRESHOLD_HIGH, + SLOP_THRESHOLD_LOW_HIGH, +}; + +// +enum E_WINDOE_WHEN +{ + TRIG_SCOPE_WHEN_ENTER = 0, + TRIG_SCOPE_WHEN_EXIT, + TRIG_SCOPE_WHEN_TIME, +}; +// Ƿ +enum E_RUNT_WHEN +{ + TRIG_RUNT_WHEN_NO = 0, + TRIG_RUNT_WHEN_GT, + TRIG_RUNT_WHEN_LT, + TRIG_RUNT_WHEN_GT_LT, +}; + +#pragma endregion Trigger + +#pragma region Math +/////////////////////////////Math////////////////////////////////////// +enum E_MATH_TYPE +{ + MATH_TYPE_MATH = 0, + MATH_TYPE_FFT, + MATH_TYPE_FILTER, +}; + +enum E_MATH_OP_SIGN +{ + OP_SIGN_ADD = 0, + OP_SIGN_SUB, + OP_SIGN_MULTIPLY, + OP_SIGN_DIVIDE, +}; + +enum E_FFT_WINDOW +{ + FFT_WIN_HAMMING = 0, + FFT_WIN_BLACKMAN, + FFT_WIN_RECTANGLE, + FFT_WIN_HANNING +}; + +enum E_FFT_UNIT +{ + FFT_UNIT_VRMS = 0, + FFT_UNIT_DBVRMS, +}; + +enum E_FILTER_TYPE +{ + FILTER_LOW = 0, + FILTER_HIGH, + FILTER_BAND, + FILTER_BAND_STOP, //Ӵ +}; + +enum E_MATH_ZOOM_RATE +{ + ZOOM_RATE_DIV_1, + ZOOM_RATE_DIV_10, + ZOOM_RATE_DIV_100, + ZOOM_RATE_DIV_1000, +}; +#pragma endregion Math + +#pragma region Acquire +////////////////////////////Acquire////////////////////////////////// +//2017-3-13Ӹ߷ֱ +enum E_ACQ_MODE +{ + ACQ_MODE_NORMAL = 0, + ACQ_MODE_PEAK, + ACQ_MODE_AVERAGE, + ACQ_MODE_HIGHRESOLUTION, +}; + +enum E_SAMPLE_MODE +{ + ACQ_SAMPLE_EQUIVALENT = 0, + ACQ_SAMPLE_REAL, + ACQ_SAMPLE_SCAN, +}; +//32m,3.2m,32k,3.2k +enum E_ACQ_SAV_DEPTH +{ + ACQ_DEPTH_NORMAL = 0, + ACQ_DEPTH_DEPTH, + ACQ_DEPTH_32M, + ACQ_DEPTH_3POINT2M, + ACQ_DEPTH_32K, + ACQ_DEPTH_3POINT2K, + +}; +#pragma endregion Acquire + +#pragma region Display +////////////////////////////Display////////////////////////////////// +enum E_DISPLAY_TYPE +{ + DISPLAY_TYPE_YT = 0, + DISPLAY_TYPE_XY, +}; + +enum E_DISPLAY_FORMAT +{ + DISPLAY_FORMAT_VECTOR = 0, + DISPLAY_FORMAT_DOT, +}; + +enum E_Display_Graticule +{ + Display_Graticule_Full, + Display_Graticule_Grid, + Display_Graticule_CrossHair, + Display_Graticule_Frame, +}; + +enum E_Dislay_PersistTime +{ + Display_PersistTime_Auto, + Display_PersistTime_Short, + Display_PersistTime_Long, + Display_PersistTime_Unlimited, +}; +#pragma endregion Display + +#pragma region Utility +////////////////////////////Utility////////////////////////////////// +enum E_Utility_Skin +{ + UTILITY_SKIN_CLASSIC, + UTILITY_SKIN_TRADITIONAL, + UTILITY_SKIN_MODERN, +}; + +enum E_Utility_Menu_Display_Time +{ + UTILITY_MENU_DISPLAY_T5S, + UTILITY_MENU_DISPLAY_T10S, + UTILITY_MENU_DISPLAY_T20S, + UTILITY_MENU_DISPLAY_TMANUAL, + + UTILITY_MENU_DISPLAY_T1S, + UTILITY_MENU_DISPLAY_T2S, +}; + +enum E_Utility_Language +{ + UTILITY_LANG_ZHCN, // + UTILITY_LANG_ZHTW, // + UTILITY_LANG_ENGLISH, //Ӣ + UTILITY_LANG_GERMAN, // + UTILITY_LANG_RUSSIANS, // + + UTILITY_LANG_ESPANOL, // + UTILITY_LANG_PORTUGUESE, // + UTILITY_LANG_FRENCH, // + UTILITY_LANG_DUTCH, // +}; + +enum E_Utility_AutoSet +{ + UTILITY_AUTOSET_LOCK_ON, + UTILITY_AUTOSET_LOCK_OFF, +}; + +enum E_Utility_PassFail_AllowTesting +{ + UTILITY_PF_ALLOWTEST_COLSE, + UTILITY_PF_ALLOWTEST_OPEN, +}; + +enum E_Utility_PassFail_Output +{ + UTILITY_PF_OUTPUT_PASS, + UTILITY_PF_OUTPUT_FAIL, +}; + +enum E_Utility_PassFail_DisplayInfo +{ + UTILITY_PF_DISPLAYINFO_OPEN, + UTILITY_PF_DISPLAYINFO_CLOSE, +}; + +enum E_Utility_PassFail_Operation +{ + UTILITY_PF_OPERATION_PLAY, + UTILITY_PF_OPERATION_STOP, +}; + +enum E_Utility_PassFail_StopSet_Type +{ + UTILITY_PF_STOPSET_TYPE_PASSTIMES, + UTILITY_PF_STOPSET_TYPE_FAILTIME, +}; + +enum E_Utility_PassFail_StopSet_Condition +{ + UTILITY_PF_STOPSET_CONDITION_GT_EQU, + UTILITY_PF_STOPSET_CONDITION_LT_EQU, +}; +#pragma endregion Utility + +#pragma region Storage +////////////////////////////Storage////////////////////////////////// +enum E_STORAGE_TYPE +{ + STORAGE_TYPE_SETTING, + STORAGE_TYPE_WAVE, + STORAGE_TYPE_BITMAP, +}; + + +enum E_STORAGE_REFWAVE_FILE_FORMAT +{ + STORAGE_REFWAVE_FILE_FMT_CSV, + STORAGE_REFWAVE_FILE_FMT_INNER, +}; + +#pragma endregion Storage + +#pragma region Cursor +enum E_CURSOR_TYPE +{ + CURSOR_TYPE_TIME, + CURSOR_TYPE_VOLTAGE, + CURSOR_TYPE_TRACK, + CURSOR_TYPE_DUMP, + CURSOR_TYPE_CLOSED, +}; + +enum E_CURSOR_MODE +{ + CURSOR_MODE_INDEPENDENT, + CURSOR_MODE_TRACK, +}; + +enum E_CURSOR_H_UNIT +{ + CURSOR_UNIT_H_BASE, + CURSOR_UNIT_H_PERCENT, +}; + +enum E_CURSOR_V_UNIT +{ + CURSOR_UNIT_V_SECOND, + CURSOR_UNIT_V_HERTZ, + CURSOR_UNIT_V_PERCENT, + CURSOR_UNIT_V_DEGREE, +}; + +enum E_CURSOR_POS +{ + CURSOR_POS_CURRENT = 3, + CURSOR_POS_6DIV, +}; +#pragma endregion Cursor + +enum E_Measure_Edge +{ + Measure_Edge_Fall, + Measure_Edge_Rise, +}; + + +#ifdef __cplusplus +} +#endif + + +#endif // ItemCode_COMVer2_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UPO.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UPO.h new file mode 100644 index 0000000..9be5b1b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UPO.h @@ -0,0 +1,222 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩʹUCIӿڵģDSOض + */ + +#ifndef DSO_UPO_h__ +#define DSO_UPO_h__ + +#ifdef __cplusplus +namespace upo2k { +#endif // __cplusplus + ////////////////////////////////////////////////////////////////////////// + // UPOλ壺 + // 16bit8λΪλͣ8λΪλ! + // ȡʽ short unit + // char unit_code = unit & 0xff; + // if((unit & UT_Time) == UT_Time) unit_code is ETime + // else if((unit & UT_Freq) == UT_Freq) unit_code is EFreq + ////////////////////////////////////////////////////////////////////////// + + //@brief : λ + //@remarks : 8λΪλͣ8λΪλ! +#ifdef __cplusplus + typedef enum _UnitType : unsigned short { +#else + typedef enum _UnitType { +#endif // __cplusplus + UT_Voltage = (0x0000), + UT_Time = (0x0100), + UT_Freq = (0x0200), + UT_Percent = (0x0300), + UT_Degree = (0x0400), + UT_DB = (0x0500), + UT_SamplePoint = (0x0600), + //@brief : + UT_Current = (0x0700), + //@brief : + UT_Watt = (0x0800), + //@brief : δ֪λ + UT_Unknown = (0x0900), + + UT_Invalid = (0x8000), + }UnitType; + + enum EFreq { + Hz = 0, + KHz, + MHz, + GHz, + THz, + }; + + enum ETime { + s = 0, + ms, + s, + ns, + ps, + }; + + enum EVoltage { + V = 0, + mV, + V, + KV + }; + + enum ECurrent { + A = 0, + mA, + A, + KA + }; + + enum EWatt { + W = 0, + mW, + W, + KW + }; + + enum EUnknown { + U = 0, + mU, + U, + KU + }; + + enum EDB { + mdB = 0, + dB, + kdB + }; + + enum EPoint { + Sa = 0, + KSa, + MSa, + GSa, + }; + + enum EPercent { + Percent = 0 + }; + + enum EDegree { + Degree = 0, + }; + + static inline char GetUnitType(short _v) { return (char)(_v >> 8); } + static inline char GetUnitCode(short _v) { return _v & 0xff; } + + //@brief : λ + //@remark: ָͨLock?ȡ64bitλǡ + typedef enum _KeyFlagsPos { + IKEY_F1, + IKEY_F2, + IKEY_F3, + IKEY_F4, + IKEY_F5, + + IKEY_CH1, + IKEY_CH2, + IKEY_CH3, + IKEY_CH4, + + IKEY_MATH, + IKEY_REF, + IKEY_HORIZON, + IKEY_TRIGGER, + IKEY_FORCE, + IKEY_HELP, + IKEY_MEASURE, + IKEY_CURSOR, + IKEY_ACQUIRE, + IKEY_DISPLAY, + IKEY_STORAGE, + IKEY_UTILITY, + IKEY_DECODE, + IKEY_DEFAULT, + IKEY_AUTOSET, + IKEY_RUNSTOP, + IKEY_SINGLE, + IKEY_CLEAR, + IKEY_PRINTSCREEN, + IKEY_MENU, + + IKEY_OFFSET_LEFT, + IKEY_OFFSET_RIGHT, + IKEY_OFFSET_OK, + + IKEY_PRETRIG_LEFT, + IKEY_PRETRIG_RIGHT, + IKEY_PRETRIG_OK, + + IKEY_TRIGLEVEL_LEFT, + IKEY_TRIGLEVEL_RIGHT, + IKEY_TRIGLEVEL_OK, + + IKEY_VOLTS_LEFT, + IKEY_VOLTS_RIGHT, + IKEY_VOLTS_OK, + + IKEY_TIMEBASE_LEFT, + IKEY_TIMEBASE_RIGHT, + IKEY_TIMEBASE_OK, + + IKEY_SELECT_LEFT, + IKEY_SELECT_RIGHT, + IKEY_SELECT, + }KeyFlagsPos; + + typedef struct _CellBaseValue { + float Value; + short Unit; + short IsLimit; // == 1,yes; =0, no! + }CellBaseValue; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + +#include //1ֽڶ + //@brief : λ + //@remark: + typedef struct _measure_param { + float value; //ЧʱֵΪ FLT_MAX + //@brief : λ + //@remark: λUnitType + short unit; //ЧʱֵΪ UT_Invalid = (0x8000) + }UValue; + + //@brief : ȡLED״̬ + //@remark: 1 - 0 δ ָLED? ȡ + typedef struct _KeyLedStat { + char CH1, CH2, CH3, CH4, MATH, REF, RUN_STOP, Single; + }KeyLedStat; + + //@brief : ݰ + typedef struct _CursorMeasurePack { + UValue Ax; + UValue Bx; + UValue Bx_Ax; + UValue Hz_Bx_Ax; + UValue Ay; + UValue By; + UValue By_Ay; + char Reserver[8]; + }CursorMeasurePack; +#include + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // DSO_UPO_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UTG2025Def.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UTG2025Def.h new file mode 100644 index 0000000..4ba8f86 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UTG2025Def.h @@ -0,0 +1,178 @@ +/******************************************************************** + created: 2015/04/08 + author: M.Yang + purpose: ṩUTG2000A&UTG7000źԴض + *********************************************************************/ + +#ifndef UTG2025Def_h__ +#define UTG2025Def_h__ + +#ifdef __cplusplus +namespace SG62_25A { +#endif + //@brief : UTG2000A&UTG7000źԴ + typedef enum _ParamNo { + Invalid_Cmd = -1, + //@brief : ǰģʽ + CurMode = 6, + //@brief : Ⲩģʽ + ArbPlayMode = 7, + //@brief : + WaveType = 8, + //@brief : Ƶ + Freq = 9, + //@brief : + Period = 10, + //@brief : -ֵ + AmpVpp = 11, + //@brief : -Чֵ + AmpVrms = 12, + //@brief : - + AmpDbm = 13, + //@brief : ֱƫ + DCOffset = 14, + //@brief : ߵƽ + High = 15, + //@brief : ͵ƽ + Low = 16, + //@brief : λ + Phase = 17, + //@brief : ռձ + DutyCycle = 18, + //@brief : Գƶ + Symmetry = 19, + //@brief : + PulseWidth = 20, + //@brief : ʱ + PulseRisingTime = 21, + //@brief : ½ʱ + PulseFallingTime = 22, + //@brief : + ArbSampleRate = 23, + //@brief : ARBļ + ArbName = 24, + //@brief : + ArbLength = 25, + + + //@brief : + ModulateType = 40, + //@brief : Ƶ + ModulateFreq = 28, + //@brief : Դ + ModulateSource = 29, + //@brief : Ʋ + ModulateShape = 30, + //@brief : + ModulateOnOff = 31, + //@brief : + ModulateAMDeepth = 32, + //@brief : Ƶƫ + ModulateFMFreqDev = 33, + //@brief : ƫ + ModulatePMPhaseDev = 34, + //@brief : ԾƵ + ModulateFSK_HopFreq = 35, + //@brief : + ModulateFSKRate = 36, + //@brief : Ƽ-λ + ModulatePSKPhase = 37, + //@brief : ƵƼ-زƵ + ModulateFSK_CarrierFreq = 38, + //@brief : -ռձƫ + ModulatePWM_DutyDev = 39, + + //@brief : ɨƵ-ʼƵ + SweepStartFreq = 47, + //@brief : ɨƵ-ֹͣƵ + SweepStopFreq = 48, + //@brief : ɨƵ-ɨʱ + SweepTime = 49, + //@brief : ɨƵ- + SweepType = 50, + + //@brief : лƵ÷ʽ-Ƶʻ + Wave_Freq_Or_Period = 51, + //@brief : л÷ʽ-Ȼ߸ߵ͵ƽ + Wave_Amp_Or_HighLow = 52, + //@brief : лͬķʾλ + Wave_Amp_Unit = 53, + + //@brief : 崮 - ʼλ + BurstStartPhase = 57, + //@brief : 崮 - ⧷ + BurstPeriod = 58, + //@brief : 崮 - ѭ + BurstCycleCount = 59, + //@brief : 崮 - ſ- + BurstPolarity = 60, + //@brief : 崮 - + BurstType = 61, + + //@brief : Դ + TriggerSource = 68, + //@brief : + SyncType = 69, + //@brief : + TriggerEdge = 70, + //@brief : + TriggerOnOff = 71, + + //@brief : CH1 ͨʹ + OutputEnable = 77, + //@brief : CH2 ͨʹ + OutputEnable2 = 78, + //@brief : + Invert = 79, + //@brief : 迹 + OutputExtRes = 80, + //@brief : + OutputLimit = 81, + //@brief : + OutputLimitHigh = 82, + //@brief : + OutputLimitLow = 83, + //@brief : ͬ + SyncOut = 84, + //@brief : + Couple = 85, + //@brief : IPַ + IPAddrType = 101, + //@brief : IPַ + IPAddr = 102, + //@brief : + IPSubnetMask = 103, + //@brief : + IPGateway = 104, + //@brief : DNS + IPDns = 105, + //@brief : MACַ + Mac = 106, + //@brief : + Language = 107, + //@brief : ʱԴ + ClkSource = 108, + //@brief : + PowerOnParam = 109, + //@brief : + BeepOnOff = 110, + //@brief : ַָ + CharDivideInt = 111, + //@brief : + LoadSettting = 112, + //@brief : + SaveSetting = 113, + //@brief : + Backlight = 114, + //@brief : + About = 115, + //@brief : ʱ + ClkOut = 116 + }ParamNo; + +#ifdef __cplusplus +} +#endif + + +#endif // UTG2025Def_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UTG4162.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UTG4162.h new file mode 100644 index 0000000..a629417 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/UTG4162.h @@ -0,0 +1,449 @@ +/******************************************************************** + created: 2015/01/14 + author: M.Yang + purpose: UCIʹõйUTG4000&UTG8000Ķ + *********************************************************************/ +#ifndef UTG4162_h__ +#define UTG4162_h__ + +#ifdef __cplusplus +namespace uci { + namespace utg4162 { +#endif // __cplusplus + + /////////////////////////////////Key Define///////////////////////////// + + //@brief : UTG4000&UTG8000ϵл͵尴ֵ塣 + //@remark: + typedef enum _SGKeys { + Key_F1 = 0, + Key_F2, + Key_F3, + Key_F4, + Key_F5, + Key_F6, + Key_0 = '0', + Key_1, + Key_2, + Key_3, + Key_4, + Key_5, + Key_6, + Key_7, + Key_8, + Key_9, + Key_Dot, + Key_Symbol, + Key_Right, + Key_Left, + Key_Ok, + Key_Up, + Key_Down, + // + Key_User, + Key_Digital, + Key_Counter, + Key_Mod, + Key_Sweep, + Key_Bst, + Key_Sine, + Key_Noise, + Key_Square, + Key_Ramp, + Key_Pulse, + Key_Arb, + Key_Harmonic, + Key_DC, + Key_Ch1, + Key_Ch2, + Key_Trigger, + Key_SwapCh, + Key_OtherPage, + Key_Preset, + Key_Storge, + Key_StorgeL, + Key_Utility, + Key_Help, + Key_HelpL, + Key_Esc, + Key_PrScreen, + Key_Null = 0xff + }SGKeys; + + inline int GetKeyIndex(SGKeys _code) { + return (_code >= Key_F1 && _code < Key_F6) ? _code : _code - '0' + 6; + }; + + + //@brief : жϰǷ + //@param _code : ֵ + //@param _v : ǰ״̬64bitʹָ"lock?"ȡ + //@return : == 0 δ + //@remarks : + inline int IsKeyLocked(SGKeys _code, long long _v) { + return _v & ((long long)1 << GetKeyIndex(_code)); + }; + + //@brief : LED״̬ + //@remarks : 0 ʾ 1 ʾ + typedef struct _LEDStatus { + char Noise; + char UTILTY; + char STORGE; + char RAMP; + char PULSE; + char COUNTER; + char USER; + char DIGTAL; + char HARMONIC; + char DC; + char TRGGER; + char CH2; + char SWAPCH; + char ARB; + char CH1; + char SINE; + char SQUARE; + }LEDStatus; + + + /////////////////////////////////File Load///////////////////////////// + //@brief : Ⲩļطʽ + typedef enum _ARBWriteMode { + //@brief : زʽ + ARB_MODE_CARRIER = 0, + //@brief : ԵƲʽ + ARB_MODE_MOD, + }ARBWriteMode; + + //@brief : صļŽ + typedef enum _FileMedium { + //@brief : ŵRAM + FM_RAM = 0, + //@brief : ŵROM + FM_ROM, + //@brief : ŵTF + FM_TF, + //@brief : ŵU + FM_UDISK + }FileMedium; + + + /////////////////////////////////Parameters Address Define///////////////////////////// + //ģʽ + typedef enum _EWorkMode : long long { + //@brief : ģʽ + WM_BASE = 0, + //@brief : Ʋģʽ + WM_MODE, + //@brief : ɨƵģʽ + WM_SWEEP, + //@brief : ⧷ + WM_BURST, + }EWorkMode; + + // + typedef enum _EBaseWave : long long { + //@brief : Ҳ + BASE_SINE = 0, + //@brief : + BASE_SQUARE = 1, + //@brief : б + BASE_RAMP = 3, + //@brief : 岨 + BASE_PULSE = 4, + //@brief : + BASE_NOISE = 5, + //@brief : Ⲩ + BASE_ARB = 6, + //@brief : г + BASE_HARMONIC = 7, + //@brief : ֱ + BASE_DC = 8 + }EBaseWave; + + typedef enum _EModeType : long long { + MT_AM = 0, + MT_FM = 1, + MT_PM = 2, + MT_ASK = 3, + MT_FSK = 4, + MT_PSK = 5, + MT_BPSK = 6, + MT_QPSK = 7, + MT_OSK = 8, + MT_QAM = 9, + MT_PWM = 10, + MT_SUM = 11, + }EModeType; + + //Ʋ + typedef enum _EModeWaveType : long long { + MOD_WAVE_SINE = 0, + MOD_WAVE_SQUARE = 1, + MOD_WAVE_UPRAMP = 2, + MOD_WAVE_DNRAMP = 3, + MOD_WAVE_NOISE = 4, + MOD_WAVE_ARB = 5, + }EModeWaveType; + + //@brief : źԴ + //@remark: ʹrpָдʹwpָ + //@example: wp@ch:0@addr:0x8000@v:0; + // rp@ch:0@addr:0x8000; + // вĶӦ8bytesdouble + typedef enum _enumRemoteMessage { + //@brief : ģʽ + //@remark: {IO:WR}{DATA:EWorkMode} + RM_WORK_MODE = 0x8000, + + //{ + //@brief : ͨ + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_CH_SW = 0x8001, + //@brief : ͬ + //@remark: {IO:WR}{DATA: 0-OFF1-ON2-reverse} + RM_CH_SYNC_SW, + //@brief : ͨ + //@remark: {IO:WR}{DATA: 0OFF1ON} + RM_CH_REVERTSE, + //@brief : ͨ迹 + //@remark: {IO:WR}{DATA: 1~1000} + RM_CH_LOAD, + //@brief : ͨʹ + //@remark: {IO:WR}{DATA: 0OFF1ON} + RM_CH_OUTPUT_LIMIT_ENABLE, + //@brief : ͨ͵ƽ + //@remark: {IO:WR}{DATA: -10V~MAX_LEVEL} + RM_CH_OUTPUT_LIMIT_MIN_LEVEL, + //@brief : ͨߵƽ + //@remark: {IO:WR}{DATA: MIN_LEVEL~10V} + RM_CH_OUTPUT_LIMIT_MAX_LEVEL, + + //@brief : + //@remark: {IO:WR}{DATA:EBaseWave} + RM_BASE_WAVE_TYPE = 0x8008, + //@brief : Ƶ(λHz) + //@remark: {IO:WR}{DATA: 1uHz~ǰƵ} + RM_BASE_FREQ, + //@brief : λ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_BASE_PHASE = 0x800A, + //@brief : (λVPP) + //@remark: {IO:WR}{DATA: 1mVpp~10Vpp50ŷķ} + RM_BASE_AMP_VPP, + //@brief : (λVRMS) + //@remark: {IO:WR}{DATA: 1mVRMS~5Vpp50ŷķ} + RM_BASE_AMP_VRMS, + //@brief : (λVDBM) + //@remark: {IO:WR}{DATA: -53.010VDBM~26.99VDBM50ŷķ} + RM_BASE_AMP_VDBM, + //@brief : ƫ(λV) + //@remark: {IO:WR}{DATA: -5VRMS~5Vpp50ŷķ} + RM_BASE_OFFSET, + //@brief : ߵƽ(λV) + //@remark: {IO:WR}{DATA: BASE_LOW~5Vpp50ŷķ} + RM_BASE_HIGHT = 0x800F, + //@brief : ͵ƽ(λV) + //@remark: {IO:WR}{DATA: -5VRMS~BASE_HIGHT50ŷķ} + RM_BASE_LOW = 0x8010, + //@brief : ռձȶԷռձȡ岨ռձȡDzԳƶȹ + //@remark: {IO:WR}{DATA: 0~100} + RM_BASE_DUTY, + //@brief : 岨ʱ(λs) + //@remark: {IO:WR}{DATA: min ~ *0.4} + RM_BASE_RISETIME, + //@brief : 岨½ʱ(λs) + //@remark: {IO:WR}{DATA: min ~ *0.4} + RM_BASE_FALLTIME, + //@brief : Ⲩģʽ + //@remark: {IO:WR}{DATA:0OFF1ON} + RM_BASE_ARB_PLAY_ENABLE, + //@brief : г - ģʽ + //@remark: {IO:WR} + //{DATA: + //0: , + //1: ż, + //2: ȫ, + //3: USER,Զ + // } + RM_BASE_HARMOIC_TYPE = 0x8080, + //@brief :г,RM_BASE_HARMOIC_TYPE=USERʱЧ + //@remark: {IO:WR}{DATA:BIT14BIT0ֱӦ2~16гأBIT15Ӧǿƿ} + RM_BASE_HARMONIC_ONOFF, + //N(2~16)г,Կַ: + //EG:N=3(г),AMP = 1Vpp, PHASE = 90 + //1: + //1ָгRM_HARMONIC_NUM = N(2~16), + //2趨гķȺλ, + // RM_HARMONIC_SN_AMP_N = 1.0; RM_HARMONIC_SN_PHASE_N = 90.0; + //1:ֱõгķȺλ + //RM_HARMONIC_SN_AMP_3 = 1.0, RM_HARMONIC_SN_PHASE_3 = 90.0, + + //@brief : г + //@remark: {IO:WR}{DATA:1~15} + RM_HARMONIC_NUM, + //@brief : гVpp + //@remark: {IO:WR}{DATA:0~} + RM_HARMONIC_SN_AMP_N, + //@brief : гλ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_HARMONIC_SN_PHASE_N = 0x8084, + //@brief : г ͬRM_HARMONIC_SN_AMP_N + RM_HARMONIC_SN_AMP_2, + RM_HARMONIC_SN_AMP_3, + RM_HARMONIC_SN_AMP_4, + RM_HARMONIC_SN_AMP_5, + RM_HARMONIC_SN_AMP_6, + RM_HARMONIC_SN_AMP_7 = 0x808A , + RM_HARMONIC_SN_AMP_8, + RM_HARMONIC_SN_AMP_9, + RM_HARMONIC_SN_AMP_10, + RM_HARMONIC_SN_AMP_11, + RM_HARMONIC_SN_AMP_12 = 0x808F, + RM_HARMONIC_SN_AMP_13 = 0x8090, + RM_HARMONIC_SN_AMP_14, + RM_HARMONIC_SN_AMP_15, + RM_HARMONIC_SN_AMP_16, + //@brief : гλ RM_HARMONIC_SN_PHASE_N + RM_HARMONIC_SN_PHASE_2, + RM_HARMONIC_SN_PHASE_3, + RM_HARMONIC_SN_PHASE_4, + RM_HARMONIC_SN_PHASE_5, + RM_HARMONIC_SN_PHASE_6, + RM_HARMONIC_SN_PHASE_7, + RM_HARMONIC_SN_PHASE_8 = 0x809A, + RM_HARMONIC_SN_PHASE_9, + RM_HARMONIC_SN_PHASE_10, + RM_HARMONIC_SN_PHASE_11, + RM_HARMONIC_SN_PHASE_12, + RM_HARMONIC_SN_PHASE_13 = 0x809F, + RM_HARMONIC_SN_PHASE_14 = 0x80A0, + RM_HARMONIC_SN_PHASE_15, + RM_HARMONIC_SN_PHASE_16, + //} + + //{MOD + //@brief : ģʽ + //@remark: {IO:WR}{DATA:EModeType} + RM_MOD_TYPE = 0x8100, + //Ʋ + //0: MOD_SINE, + //1: MOD_SQUARE, + //2: MOD_UPRAMP, + //3: MOD_DNRAMP, + //4: MOD_NOISE, + //5: MOD_ARB, + //@brief : Ʋ + //@remark: {IO:WR}{DATA:EModeWaveType} + RM_MOD_WAVE, + //@brief : ƲƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~200KHz} + RM_MOD_FREQ, + //@brief : Ʋʣλs + //@remark: {IO:WR}{DATA: 2ms~1Ms} + RM_MOD_RATE, + //@brief : ȣλ% + //@remark: {IO:WR}{DATA: 0~120} + RM_MOD_SCOPE, + //@brief : Դ + //@remark: {IO:WR}{DATA: 0-Internal,1-External} + RM_MOD_SOURCE, + //@brief : FMƵλHz + //@remark: {IO:WR}{DATA: 0~زǰƵ} + RM_MOD_FRE_DEV, + //@brief : PM (λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_MOD_PHASE_DEV, + //@brief : FSKƵλHz + //@remark: {IO:WR}{DATA: 0~زƵ} + RM_MOD_HOP_FREQ, + //@brief : BPSKԴ + //@remark: {IO:WR} + //{DATA: + //0: PN7, + //1: PN9, + //2: PN15, + //3: PN21, + //} + RM_MOD_DATA_SOURCE = 0x8109, + //@brief : BPSKλQPSKλ1,(λ) + //@remark: {IO:WR}{DATA: -360~360}} + RM_MOD_PSK_PHASE1, + //@brief : QPSKλ2(λ) + //@remark: {IO:WR}{DATA:-360~360}} + RM_MOD_PSK_PHASE2, + //@brief : QPSKλ3(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_MOD_PSK_PHASE3, + //@brief : OSKʱ(λs) + //@remark: {IO:WR}{DATA: 8ns~200s} + RM_MOD_OSC_TIME, + //@brief : QAMIQ MAM + //@remark: {IO:WR}{DATA: 0-4QAM,1-8QAM,2-16QAM,3-32QAM,4-64QAM,5-128QAM,6-256QAM,} + RM_MOD_IQ_MAP, + //@brief : PWMռձȲֵ + //@remark: {IO:WR}{DATA: 0~PULS DUTY} + RM_MOD_DUTY_DEV, + //} + + //{SWEEP + //@brief : ɨƵ + //@remark: {IO:WR}{DATA: 0ԣ1} + RM_SWEEP_TYPE = 0x8200, + //@brief : ɨƵԴ + //@remark: {IO:WR}{DATA: 0ڲ1ⲿ2ֶ} + RM_SWEEP_SOURCE, + //@brief : ɨƵʱ(λs) + //@remark: {IO:WR}{DATA: 1ms~500s} + RM_SWEEP_TIME, + //@brief : ɨƵʼƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~زƵ} + RM_SWEEP_START_FREQ, + //@brief : ɨƵֹͣƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~زƵ} + RM_SWEEP_STOP_FREQ, + //@brief : ͬƵʣλHz + //@remark: {IO:WR}{DATA: RM_SWEEP_START_FREQ~RM_SWEEP_STOP_FREQ} + RM_SWEEP_SYNC_FREQ, + //@brief : ɨƵ + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_SWEEP_TIRG_OUT, + //} + + //{BURST + //@brief : ⧷ + //@remark: {IO:WR}{DATA: + //0: N, + //1: , + //2: ſ + //} + RM_BURST_TYPE = 0x8300, + //@brief : ⧷Դ + //@remark: {IO:WR}{DATA: 0ڲ1ⲿ2ֶ} + RM_BURST_SOURCE, + //@brief : + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_BURST_TIRG_OUT, + //@brief : ⧷ڣλs + //@remark: {IO:WR}{DATA: 1~500} + RM_BURST_PERIOD, + //@brief : ⧷λ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_BURST_PHASE, + //@brief : ⧷λ + //@remark: {IO:WR}{DATA: 1~50000} + RM_BURST_CYCLES, + //@brief : + //@remark: {IO:WR}{DATA: 0-Rise1-Fall} + RM_BURST_TIRG_EDGE, + //} + }ERemoteMessage; + + +#ifdef __cplusplus + } +} +#endif // __cplusplus + +#endif // UTG4162_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/comApiDef.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/comApiDef.h new file mode 100644 index 0000000..5e04f7d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/comApiDef.h @@ -0,0 +1,903 @@ +#ifndef _DSOCOM_API_COMMON_DEF_H_201212281614 +#define _DSOCOM_API_COMMON_DEF_H_201212281614 + +#include "dso_base.h" + +#ifdef __cplusplus +namespace comApi +{ + using namespace comAPICommon; +#endif + //λ +#ifdef __cplusplus + namespace Units + { +#endif + const int UNIT_NULL = 0; //add by yzz + const int UNIT_PS = 1; //add by yzz + const int UNIT_NS = 2; + const int UNIT_US = 3; + const int UNIT_MS = 4; + const int UNIT_S = 5; + const int UNIT_KS = 6; + + const int UNIT_nVS = 7; + const int UNIT_uVS = 8; + const int UNIT_mVS = 9 ; + + const int UNIT_PER = 10; + + const int UNIT_UV = 11; + const int UNIT_MV = 12; + const int UNIT_V = 13; + const int UNIT_KV = 14; + + const int UNIT_pHZ = 18; + const int UNIT_nHZ = 19; + const int UNIT_uHZ =20; + const int UNIT_mHZ = 21; + const int UNIT_HZ = 22; + const int UNIT_KHZ = 23; + const int UNIT_MHZ = 24; + const int UNIT_GHZ = 25; + + //const int UNIT_VV = 52; //201452311:56:55޸ + const int UNIT_mVV = 52; + const int UNIT_VV = 53; + const int UNIT_KVV = 54; + + const int UNIT_mDB = 80; // add by yzz + const int UNIT_DB = 81; + const int UNIT_KDB = 82; // add by yzz +#ifdef __cplusplus + } +#endif + +#pragma region + enum DataCMD + { + Invalid_Data_CMD = -1, + //get data cmd + GET_DISPLAY_DATA = 150, //get ch1, ch2, math, ref a/b data + GET_CH1_DISPLAY_DATA, //get ch1 display data: + GET_CH1_ORIGIN_DATA, //get ch1 original data + GET_CH2_DISPLAY_DATA, //get ch2 display data + GET_CH2_ORIGIN_DATA, //get ch2 original data + GET_CH3_DISPLAY_DATA, + GET_CH3_ORIGIN_DATA, + GET_CH4_DISPLAY_DATA, + GET_CH4_ORIGIN_DATA, + + GET_MATH_DATA = 200, //get math data + GET_REF_A_DATA, //get ref A data + GET_REF_B_DATA, //get ref B data + + //[Notice] Get_Data_CMD_END ָ DataCMD һ + Get_Data_CMD_END = GET_REF_B_DATA, + }; + + /* Command Type */ + typedef enum _control_cmd{ + Invalid_Control_CMD = -1, + + CMD_GET_DSO_TYPE = 0, + + //special function cmd + LOCK_DSO_KEYPAD, //lock dso keypad: if set this cmd, the dso's keypad will not work + UNLOCK_DSO_KEYPAD, //unlock dso keypad: if set this cmd, the dso's keypad will work normally + SET_PROCSTATE, //PROC_STATE: control run/stop + GET_PROCSTATE, //PROC_STATE: get run/stop state + SET_AUTOSET, //set dso to do auto set + SET_TRIG_FORCE, //set dso to be force trigger state + SET_SINGLE, + SET_COARSE, + SET_PRTSC, //set dso to do print screen + GET_BITMAP_FILENAME, + GET_BITMAP_FILEDATA, + + //@brief : ָ + SET_KEY = 20, + //@brief : ѯָ + GET_KEY, + //@brief : ȡѹĻ + GET_SCREEN_SHOT, + //@brief : + GET_DEV_CONFIG, + //@brief : д + SET_DEV_CONFIG, + //@brief : ѯ豸ʾ + GET_IDN, + //@brief : ȡЭ汾 + //@remark: + GET_CVER, + + GET_SCREEN_INFO = 50, //SCREEN_INFO + GET_USB_CONNECTION_STATE, //short 1: usb connection state is ok; other: usb connection state is not ok + GET_CYMOMETER_VALUE, //SignalFreq + GET_CURRENT_ACTIVE_CHANNEL, //short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other + GET_CURRENT_ACTIVE_MENU, //short 0: CH1 menu; 1: CH2 menu; 2: MATH or FFT menu; -1: other menu + GET_CURRENT_MENU_SHOW_STATE,//x short 0: current menu is not display; 1: current menu is display + GET_SAMPLE, //get sample + + SET_TO_ZERO = 100, //set dso to zero state + SET_CH1_VPOS_TO_ZERO, + SET_CH2_VPOS_TO_ZERO, + SET_CH3_VPOS_TO_ZERO, + SET_CH4_VPOS_TO_ZERO, + SET_HPOS_TO_ZERO, + SET_TRIG_TO_ZERO, + + GET_CH1_MEASURE_PARAM = 250,//get ch1 measure parameters + GET_CH2_MEASURE_PARAM, //get ch2 measure parameters + GET_CH3_MEASURE_PARAM, + GET_CH4_MEASURE_PARAM, + GET_MATH_MEASURE_PARAM, //get math measure parameters + + //set/get channel param cmd + SET_CH1_SWITCH = 300, //ChannelSwitch + GET_CH1_SWITCH, //ChannelSwitch + SET_CH1_ATTRIBUTE, //ChannelAttribute + GET_CH1_ATTRIBUTE, //ChannelAttribute + SET_CH1_VPOS, //ChannelVPos + GET_CH1_VPOS, //ChannelVPos + SET_CH1_VLEVEL, //ChannelVLevel + GET_CH1_VLEVEL, //ChannelVLevel + SET_CH1_TIMEBASE, //ChannelTimeBaseر + GET_CH1_TIMEBASE, //ChannelTimeBase + SET_CH1_TRIG_LEVEL, //ChannelTLevel + GET_CH1_TRIG_LEVEL, //ChannelTLevel + SET_CH1_TRIG_POS, //ChannelTPos + GET_CH1_TRIG_POS, //ChannelTPos + + SET_CH2_SWITCH = 350, //ChannelSwitch + GET_CH2_SWITCH, //ChannelSwitch + SET_CH2_ATTRIBUTE, //ChannelAttribute + GET_CH2_ATTRIBUTE, //ChannelAttribute + SET_CH2_VPOS, //ChannelVPos + GET_CH2_VPOS, //ChannelVPos + SET_CH2_VLEVEL, //ChannelVLevel + GET_CH2_VLEVEL, //ChannelVLevel + SET_CH2_TIMEBASE, //ChannelTimeBase + GET_CH2_TIMEBASE, //ChannelTimeBase ر + SET_CH2_TRIG_LEVEL, //ChannelTLevel + GET_CH2_TRIG_LEVEL, //ChannelTLevel + SET_CH2_TRIG_POS, //ChannelTPos + GET_CH2_TRIG_POS, //ChannelTPos + + //math + SET_MATH_SWITCH = 800, //ChannelSwitch + GET_MATH_SWITCH, //ChannelSwitch + SET_MATH_VPOS, //ChannelVPos + GET_MATH_VPOS, //ChannelVPos + SET_MATH_VLEVEL, //ChannelVLevel + GET_MATH_VLEVEL, //ChannelVLevel + SET_FFT_FREQ, //by change timebase + GET_FFT_FREQ, //SignalFreq + SET_MATH_TYPE, //MathType + GET_MATH_TYPE, //MathType + SET_MATH_CONFIG, //MathConfig + GET_MATH_CONFIG, //MathConfig + SET_FFT_CONFIG, //FFTConfig + GET_FFT_CONFIG, //FFTConfig + SET_FILTER_CONFIG, //FilterConfig + GET_FILTER_CONFIG, //FilterConfig + + //acquire + SET_ACQUIRE_CONFIG = 850, //AcquireConfig + GET_ACQUIRE_CONFIG, //AcquireConfig + + //trig menu + SET_TRIG_EDGE_CONFIG = 900, //EdgeTrig + GET_TRIG_EDGE_CONFIG, //EdgeTrig + SET_TRIG_PULSE_CONFIG, //PulseTrig + GET_TRIG_PULSE_CONFIG, //PulseTrig + SET_TRIG_VIDEO_CONFIG, //VideoTrig + GET_TRIG_VIDEO_CONFIG, //VideoTrig + SET_TRIG_SLOPE_CONFIG, //SlopeTrig + GET_TRIG_SLOPE_CONFIG, //SlopeTrig + + //display menu + SET_DISPLAY_CONFIG = 950, //DisplayConfig + GET_DISPLAY_CONFIG, //DisplayConfig + + //measure menu + SET_MEASURE_SOURCE = 1000, //MeasureSrc + GET_MEASURE_SOURCE, //MeasureSrc + SET_MEASURE_ALL_CONFIG, //MeasureAllConfig + GET_MEASURE_ALL_CONFIG, //MeasureAllConfig + SET_MEASUER_PART_CONFIG, //MeasurePartConfig + GET_MEASURE_PART_CONFIG, //MeasurePartConfig + + //cursor menu + SET_CURSOR_CONFIG = 1050, //CursorConfig + GET_CURSOR_CONFIG, //CursorConfig + GET_CURSOR_MEASURE_RESULT, //CurSorMeasureResult + + //storage config + SET_STORAGE_SETTING = 1100, //StorageSetting + GET_STORAGE_SETTING, //StorageSetting + SET_STORAGE_WAVE, //StorageWave + GET_STORAGE_WAVE, //StorageWave + SET_STORAGE_BITMAP, + GET_STORAGE_BITMAP, + + //reference config + SET_REF_A_SWITCH = 1200, //ChannelSwitch + GET_REF_A_SWITCH, //ChannelSwitch + SET_REF_B_SWITCH, //ChannelSwitch + GET_REF_B_SWITCH, //ChannelSwitch + SET_REF_A_VPOS, //ChannelVPos + GET_REF_A_VPOS, //ChannelVPos + SET_REF_A_VLEVEL, //ChannelVLevel + GET_REF_A_VLEVEL, //ChannelVLevel + SET_REF_A_TRIG_POS, //ChannelTPos + GET_REF_A_TRIG_POS, //ChannelTPos + SET_REF_B_VPOS, //ChannelVPos + GET_REF_B_VPOS, //ChannelVPos + SET_REF_B_VLEVEL, //ChannelVLevel + GET_REF_B_VLEVEL, //ChannelVLevel + SET_REF_B_TRIG_POS, //ChannelTPos + GET_REF_B_TRIG_POS, //ChannelTPos + GET_REF_A_TIMEBASE, //ChannelTimeBase + GET_REF_B_TIMEBASE, //ChannelTimeBase + SET_REF_CONFIG, //RefConfig + GET_REF_A_CONFIG, //RefConfig + GET_REF_B_CONFIG, //RefConfig + GET_REFWAVE_EXIST, //short 0:not exist; 1:exist + GET_REFSETTING_EXIST, //short 0:not exist; 1:exist + + //horizon menu + SET_HORIZON_CONFIG = 1300, //HorizonConfig + GET_HORIZON_CONFIG, //HorizonConfig + + //utility + SET_UTILITY_CONFIG = 1400, //UtilityConfig + GET_UTILITY_CONFIG, //UtilityConfig + + //record + SET_RECORD_CONFIG = 1500, //RecordConfig + GET_RECORD_CONFIG, //RecordConfig + + //auto calibrate + SET_SELF_CALIBRATE = 1600, //set dso to be self-calibrate + //product config + SET_RESET_CONFIG = 1700, //set dso config to product config + + //select cursor +// SET_CURSOR_INDEX = 2000, +// GET_CURSOR_INDEX, + }CONTROL_CMD; +#pragma endregion + +#pragma region öֵ + //״̬Ļȡͨ֡ݰ棬ַʽȡ + typedef enum{ + PROC_STOP = 0, + PROC_RUN, + PROC_ARMED = PROC_RUN, + PROC_READY, + PROC_TRIGED, + PROC_AUTO, + PROC_SCAN, + PROC_OVER, + + PROC_RESET, // Add by yzz, for UTD2102CEX + }E_PROC_STATE; + + typedef enum{ + CH_Invalid_ID = -1, + CH_1_ID = 0, + CH_2_ID, + CH_MATH_ID, + CH_REF_A_ID, + CH_REF_B_ID, + CH_MAX_CNT, + }E_CHANNEL_ID; + + /********************************************** + ****************Channel Attribute***************** + ***********************************************/ + typedef enum{ + CH_COUPLING_DC = 0, + CH_COUPLING_AC, + CH_COUPLING_GND, + }CH_ATTR_COUPLING; + + + typedef enum{ + SWITCH_OFF = 0, + SWITCH_ON, + }SWITCH_STATE; + + typedef enum + { + CH_VOLT_SCALE_COARSE = 0, + CH_VOLT_SCALE_FINE, + }CH_VOLT_SCALE; + + + typedef enum{ + CH_PROBE_1X = 0, + CH_PROBE_10X, + CH_PROBE_100X, + CH_PROBE_1000X, + }CH_PROBE; + + //öֵ̽ͷԣ0ࣨ1 + enum ChannelPolarity + { + CH_Polar_Normal = 0, + CH_Polar_Invert, + }; + + /***********************************************/ + /********** vertical system: channel position *********/ + /***********************************************/ + typedef enum{ + CH_VPOS_TOP = 378, + CH_VPOS_BOT = -122, + }E_CH_VPOS_LIMIT; + + /***********************************************/ + /******** vertical system: channel voltage level *******/ + /***********************************************/ + typedef enum{ + ADJUST_DECREASE = -1, + ADJUST_INCREASE = 1, + }E_ADJUST_DIR; + + /*****************************************************************/ + /* horizontal system: channel horizontal position ,ie channel pre-trigger depth */ + /*****************************************************************/ + typedef enum{ + CH_TPOS_LEFT = 0, + CH_TPOS_RIGHT = 700, + }E_CH_TPOS_LIMIT; + + enum E_CH_TriggerLevel_Limit + { + CH_TriggerLevel_Min = -327, + CH_TriggerLevel_Max = 375, + }; + + /***********************************************/ + /***************** math/fft config *****************/ + /***********************************************/ + enum E_MATH_TYPE + { + MATH_TYPE_MATH = 0, + MATH_TYPE_FFT, + + MATH_TYPE_FILTER, //add by yzz + }; + + typedef enum{ + OP_SIGN_ADD = 0, + OP_SIGN_SUB, + OP_SIGN_MULTIPLY, + OP_SIGN_DIVIDE, + }E_MATH_OP_SIGN; + + typedef enum{ + FFT_WIN_RECTANGLE = 0, + FFT_WIN_HANNING, + FFT_WIN_HAMMING, + FFT_WIN_BLACKMAN, + }E_FFT_WINDOW; + + typedef enum{ + FFT_UNIT_VRMS = 0, + FFT_UNIT_DBVRMS, + }E_FFT_UNIT; + + /***********************************************/ + /***************** acquire config *****************/ + /***********************************************/ + enum E_ACQ_MODE + { + ACQ_MODE_NORMAL = 0, + ACQ_MODE_PEAK, + ACQ_MODE_AVERAGE, + }; + + enum E_SAMPLE_MODE + { + SAMPLE_REAL = 0, + SAMPLE_EQUIVALENT, + + SAMPLE_SCAN //add by yzz + }; + + /***********************************************/ + /***************** trigger config *****************/ + /***********************************************/ + typedef enum{ + TRIG_TYPE_EDGE = 0, //: + TRIG_TYPE_NTSC, //: Ƶ + TRIG_TYPE_WIDTH, //: + }E_TRIG_TYPE; + + typedef enum{ + TRIG_CH1 = CH_1_ID, + TRIG_CH2 = CH_2_ID, + TRIG_EXT, + TRIG_EXT_5, //EXT/5 + TRIG_AC_LINE = 4, + TRIG_ALTER, + }E_TRIG_SOURCE; + + typedef enum{ + TRIG_EDGE_RISE = 0, + TRIG_EDGE_FALL, + TRIG_EDGE_RISE_FALL, + }E_TRIG_SLOPE; + + typedef enum{ + TRIG_MODE_AUTO = 0, + TRIG_MODE_NORMAL, + TRIG_MODE_SINGLE, + }E_TRIG_MODE; + + typedef enum{ + TIRG_COUPLING_DC = 0, + TIRG_COUPLING_AC, + TIRG_COUPLING_H_RESTRAIN, //trigger coupling high frequency restrain + TIRG_COUPLING_L_RESTRAIN, //trigger coupling low frequency restrain + }E_TIRG_COUPLING; + + typedef enum{ + PULSE_CONDITION_GT = 0, //pulse condition greater than + PULSE_CONDITION_LT, //pulse condition less than + PULSE_CONDITION_ET, //pulse condition equal to + + PULSE_CONDITION_NO_EQUAL, //pulse not equal to , add by yzz [RESERVE] + }E_PULSE_CONDITION; + + typedef enum{ + PULSE_POLAR_P = 0, + PULSE_POLAR_N, + }E_PULSE_POLAR; + + enum TriggerType_Video_Standard + { + TRIG_Video_PAL = 0, + TRIG_Video_NTSC, + }; + + //Ƶ-ͬʽ(0)ż(1)(2)ָ(3) + enum TriggerType_Video_SyncMode + { + TRIG_Video_SyncMode_Odd = 0, + TRIG_Video_SyncMode_Even, + TRIG_Video_SyncMode_ALL, + TRIG_Video_SyncMode_Specified, + }; + + /***********************************************/ + /***************** display config *****************/ + /***********************************************/ + typedef enum{ + DISPLAY_TYPE_VECTOR = 0, + DISPLAY_TYPE_DOT, + }E_DISPLAY_TYPE; + + + typedef enum{ + FORMAT_YT = 0, + FORMAT_XY, + }E_FORMAT; + + typedef enum{ + DISPLAY_TIME_CLOSED = 0, + DISPLAY_TIME_1S, + DISPLAY_TIME_2S, + DISPLAY_TIME_5S, + DISPLAY_TIME_INFINITE, + }E_DISPLAY_TIME; + + /***********************************************/ + /***************** horizon config *****************/ + /***********************************************/ + typedef enum{ + WIN_TYPE_MAIN = 0, + WIN_TYPE_WINDOW, + }E_WIN_TYPE; + + /***********************************************/ + /***************** utility config *****************/ + /***********************************************/ + typedef enum{ + MENU_DISPLAY_T5S = 0, + MENU_DISPLAY_T10S, + MENU_DISPLAY_T15S, + MENU_DISPLAY_TMANUAL, + }E_MENU_DISPLAY_TIME; + + typedef enum{ + LANGUAGE_ZHCN, // + LANGUAGE_ZHTW, // + LANGUAGE_ENGLISH, //Ӣ + LANGUAGE_ESPANOL, // + LANGUAGE_PORTUGUESE, // + LANGUAGE_FRENCH, // + LANGUAGE_GERMAN, // + LANGUAGE_DUTCH, // + LANGUAGE_RUSSIANS, // + LANGUAGE_Korean, // + }E_LANGUAGE; + + typedef enum{ + SKIN_GREYISH_GREEN = 0, //dzɫ + SKIN_BLUE, //ɫ + SKIN_RED, //ɫ + SKIN_BOTTLE_GREEN, //ɫ + }E_SKIN; + + /***********************************************/ + /***************** storage config *****************/ + /***********************************************/ + typedef enum{ + STORAGE_TYPE_WAVE = 0, + STORAGE_TYPE_SETTING, + }E_STORAGE_TYPE; + + typedef enum{ + STORAGE_MEDIUM_DSO = 0, + STORAGE_MEDIUM_USB, + }E_STORAGE_MEDIUM; + + typedef enum{ + SAVSRC_CH1 = CH_1_ID, + SAVSRC_CH2 = CH_2_ID, + SAVSRC_ALL, + }E_STORAGE_WAVE_SRC_CH; + + typedef enum{ + STORAGE_DEPTH_NORMAL = 0, //ͨ洢 + STORAGE_DEPTH_LONG, //洢 + }E_STORAGE_DEPTH; + + /***********************************************/ + /**************** reference config *****************/ + /***********************************************/ + typedef enum{ + REF_A = 0, + REF_B, + }E_REF_SRC; + + /***********************************************/ + /***************** Cursor config *****************/ + /***********************************************/ + typedef enum{ + CURSOR_TYPE_VOLTAGE = 0, + CURSOR_TYPE_TIME, + CURSOR_TYPE_TRACK, + CURSOR_TYPE_CLOSED, + }E_CURSOR_TYPE; + + typedef enum{ + CURSOR_ID_1 = 0, + CURSOR_ID_2, + CURSOR_ID_MAX, + }E_CURSOR_ID; + + enum Cursor_Measure_Limit + { + Screen_Scale_H_Min = 50, + Screen_Scale_H_Max = 749, + + Screen_Scale_V_Min = 28, + Screen_Scale_V_Max = 228, + }; +#pragma endregion öֵ + +#pragma region ݽṹ + //Ļ + typedef struct _measure_param_packet + { + MeasureParam freq; + MeasureParam period; + MeasureParam risetime; + MeasureParam falltime; + MeasureParam pwidth; + MeasureParam nwidth; + MeasureParam overshoot; + MeasureParam preshoot; + MeasureParam pduty; + MeasureParam nduty; + MeasureParam vmean; + MeasureParam vpp; + MeasureParam vrms; + MeasureParam vtop; + MeasureParam vbase; + MeasureParam vmid; + MeasureParam vmax; + MeasureParam vmin; + MeasureParam vamp; + }MeasureParamPacket; + + // + typedef struct + { + MeasureParam freq; + MeasureParam period; + MeasureParam risetime; + MeasureParam falltime; + MeasureParam pwidth; + MeasureParam nwidth; + MeasureParam overshoot; + MeasureParam preshoot; + MeasureParam pduty; + MeasureParam nduty; + MeasureParam vmean; + MeasureParam vpp; + MeasureParam vrms; + MeasureParam vtop; + MeasureParam vbase; + MeasureParam vmid; + MeasureParam vmax; + MeasureParam vmin; + MeasureParam vamp; + + // + char Reserve[24]; + }MeasureParamPacket_UTD2000CEX; + + // + typedef struct + { + MeasureParam freq; // + MeasureParam period; // + MeasureParam risetime; // + MeasureParam falltime; // + MeasureParam pwidth; // + MeasureParam nwidth; // + MeasureParam overshoot; // + MeasureParam preshoot; // + MeasureParam pduty; // + MeasureParam nduty; // + MeasureParam vmean; // + MeasureParam vpp; // + MeasureParam vrms; // + MeasureParam vtop; // + MeasureParam vbase; // + MeasureParam vmid; // + MeasureParam vmax; // + MeasureParam vmin; // + MeasureParam vamp; // + + // + MeasureParam area; // + MeasureParam cycleArea; // + MeasureParam cycleMean; //ƽֵ + MeasureParam cycleRms; //ھֵ + MeasureParam burstWidth; //ͻ + } MeasureParamPacket_UTD2102CM; + + //cmd: GET_PROCSTATE, SET_PROCSTATE + typedef struct _proc_state{ + //0, PROC_STOP; 1, PROC_RUN; 1, PROC_ARMED; 2, PROC_READY; 3, PROC_TRIGED; 4, PROC_AUTO; 5, PROC_SCAN; 6, PROC_OVER; + short procState; + }PROC_STATE; + + ////////////////////////////////////////////////////////////////////////// + // ϵ + // ͨGET_CH1_DISPLAY_DATAGET_DISPLAY_DATAȡIJݵϵ + // X ֵ0ʼΧǵ + // Y ȡADCΧֵ[0,255] UTD2102CEX ײ28228ΧΪ200 + ////////////////////////////////////////////////////////////////////////// + //cmd: GET_SCREEN_INFO + typedef struct _screen_info{ + short screen_width; //Ļȣֵ + short screen_height; //Ļ߶ȣֵ + short x_grid_count; // + short y_grid_count; // + short x_grid_pixels; //Ԫ + short y_grid_pixels; //Ԫ + short y_min; //ϵy귶Χ[y_min y_max] + short t_min; //ϵx귶Χ[t_min t_max]0ʼ + short y_max; //ϵy귶Χ[y_min y_max] + short t_max; //ϵx귶Χ[t_min t_max]0ʼ + }ScreenInfo; + + /********************************************** + *************** Channel Switch ****************** + ***********************************************/ + typedef struct _channel_switch{ + short ch_switch; + }ChannelSwitch; + + /* channel attribute configuration : cmd = SET_CH1_ATTRIBUTE, GET_CH1_ATTRIBUTE */ + typedef struct _channel_attribute{ + short coupling; //CH_COUPLING + short bwlimited; //SWITCH_STATE + short voltscale; //CH_VOLT_SCALE + short probe; //CH_PROBE + short inverted; //SWITCH_STATE + }ChannelAttribute; + + /* channel attribute configuration : cmd = SET_CH1_ATTRIBUTE, GET_CH1_ATTRIBUTE */ + typedef struct _pre_offset_volt{ + short preOffsetSwitch; //0, STATE_CLOSED; 1, STATE_OPEN + short coarseValue; // + short fineValue; // + short toZero; //0, don't set to zero; 1, set to zero + }PreOffsetVolt; + + typedef struct _channel_vpos{ + short vpos; //[(TOP: 378), (Middle: 128), (BOTTOM: -122)] + }ChannelVPos; + + typedef struct _channel_volt_level{ + short voltLevel; //when set cmd, para: 1 or -1, when get cmd, voltage level value + float voltValue; //ȡ̽ͷΪX1ǵķֵ + short voltUnit; + short IsLimit; + }ChannelVLevel; + + /***********************************************/ + /******** horizontal system: channel time base *******/ + /***********************************************/ + typedef struct _channel_timebase{ + short timeBase; + }ChannelTimeBase; + + typedef struct _channel_tpos{ + short tpos; //[(Left: 0), (Middle: 350), (Right: 700)] + }ChannelTPos; + + /***********************************************/ + /******** tigger system: channel trigger position ******/ + /***********************************************/ + typedef struct _channel_trig_level{ + short trigLevel; //[-375, 0(middle), 375] + float trigValue; + short trigUnit; + short isLimited; + }ChannelTLevel; + + typedef struct _math_type{ + int mathType; + }MathType; + + typedef struct _fft_freq{ + float freqValue; + int freqUnit; + int IsLimit; // == 1,yes; =0, no! + }SignalFreq; + + typedef struct _math_config{ + short mathOpA; + short mathOpB; + short mathOpSign; + }MathConfig; + + typedef struct _fft_config{ + short fftSource; + short fftWindow; + short fftUnit; + }FFTConfig; + + typedef struct _acquire_config{ + short acquireMode; + short averageNum; //2^(averageNum + 1), ie: {(0: 2), (1: 4), (2: 8), (3: 16), (4: 32), (5: 64), (6: 128), (7: 256)} + short sampleMode; + short fastAcquire; + }AcquireConfig; + + typedef struct _trig_config{ + short trigType; + short trigSource; + short trigMode; + short trigCoupling; + }TriggerConfig; + + typedef struct _trig_edge_config{ + TriggerConfig trigConfig; + short trigSlope; + }TrigEdgeConfig; + + typedef struct _trig_pulse_config{ + TriggerConfig trigConfig; + short pulseCondition; + UINT pulseWidth; + short pulsePolar; + }TrigPulseConfig; + + typedef struct _display_config{ + short displayType; + short displayFormat; + short displayTime; + short displayLum; + }DisplayConfig; + + typedef struct _horizon_config{ + short windowType; //E_WIN_TYPE + unsigned int holdOff; //[10, 187500000] + }HorizonConfig; + + typedef struct _utility_config{ + short autoCalibrate; //0, not do auto calibrate; 1, do auto calibrate + short menuDisplayTime; //E_MENU_DISPLAY_TIME + short language; //E_LANGUAGE + short defaultSetting; //0, not do default setting; 1 do default setting + short skin; //E_SKIN + short gridBrightness; //[1, 100] + short sysInfo; //0, not display system info; 1, display system info; + short cymometer; //0: close; 1: open + }UtilityConfig; + + typedef struct _storage_setting{ + short saveType; //STORAGE_TYPE_SETTING + short savePos; //[1, 20] + + short save; //1, save, 0, not save + short recall; //1, recall, 0, not recall + }StorageSetting; + + typedef struct _storage_wave{ + short saveType; //STORAGE_TYPE_WAVE + short saveSource; + short savePos; + short saveMedium; + short saveDepth; + short save; + }StorageWave; + + /***********************************************/ + /***************** measure config *****************/ + /***********************************************/ + typedef struct _measure_config{ + short measureSrc; + }MeasureConfig; + + typedef struct _ref_timebase{ + float ref_TValue; + int ref_Tunit; + }RefTimeBase; + + + typedef struct _ref_config + { + short refSrc; //REF_A, REF_B + short pos; //[1, 20] + short medium; //MEDIUM_DSO, MEDIUM_USB + + short onoff; //1, on; 0, off; + }RefConfig; + + typedef struct _cursor_measure_result{ + MeasureParam Va; + MeasureParam Vb; + MeasureParam deltaV; + MeasureParam TaFa;// when ch1, ch2, Ta; when math channel, Fa; + MeasureParam TbFb;// when ch1, ch2, Tb; when math channel, Fb; + MeasureParam deltaT; + MeasureParam deltaF; + char Reserve[56]; + }CursorMeasureResult; + + typedef struct _cursor_config{ + short cursorType; + short iActiveCursor; + //Ҫӻʶ + short voltCursorPos[CURSOR_ID_MAX];//[28(top), 428(bottom)] + short timeCursorPos[CURSOR_ID_MAX];//[50(left), 749(right)] + short autoCursorPos[CURSOR_ID_MAX];//[51(left), 749(right)] + }CursorConfig; + + + /***********************************************/ + /***************** measure config *****************/ + /***********************************************/ + typedef struct _measure_src + { + short measureSrc; + }MeasureSrc; +#pragma endregion ݽṹ + +#ifdef __cplusplus +} +#endif + +#endif//end of #ifndef _DSOCOM_API_COMMON_DEF_H_201212281614 \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/dso_base.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/dso_base.h new file mode 100644 index 0000000..7801310 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/dso_base.h @@ -0,0 +1,171 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩUCIӿʹõģDSOͨö塣 + */ +#ifndef dso_base_h__ +#define dso_base_h__ + +#ifdef __cplusplus +namespace comAPICommon { +#endif + //ʱλлһ£˲ͬıԵ +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + TLEVEL_1NS = 0, + TLEVEL_2NS, + TLEVEL_5NS, + TLEVEL_10NS, + TLEVEL_20NS, + TLEVEL_50NS, + TLEVEL_100NS, + TLEVEL_200NS, + TLEVEL_500NS, + TLEVEL_1US, + TLEVEL_2US, + TLEVEL_5US, + TLEVEL_10US, + TLEVEL_20US, + TLEVEL_50US, + TLEVEL_100US, + TLEVEL_200US, + TLEVEL_500US, + TLEVEL_1MS, + TLEVEL_2MS, + TLEVEL_5MS, + TLEVEL_10MS, + TLEVEL_20MS, + TLEVEL_50MS, + TLEVEL_100MS, + TLEVEL_200MS, + TLEVEL_500MS, + TLEVEL_1S, + TLEVEL_2S, + TLEVEL_5S, + TLEVEL_10S, + TLEVEL_20S, + TLEVEL_50S, + TLEVEL_100S, + TLEVEL_200S, + }E_TIMEBASE_LEVEL; + +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + VLEVEL_1MV = 0, + VLEVEL_2MV, + VLEVEL_5MV, + + VLEVEL_10MV, + VLEVEL_20MV, + VLEVEL_50MV, + + VLEVEL_100MV, + VLEVEL_200MV, + VLEVEL_500MV, + + VLEVEL_1V, + VLEVEL_2V, + VLEVEL_5V, + + VLEVEL_10V, + VLEVEL_20V, + } E_VOLTAGEBASE_LEVEL; + + typedef struct _measure_param { + float value; + int unit; + }MeasureParam; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + + typedef struct _UnitParam { + char Type; //λͣTimeFreqȡ嶨ĵ + char Scale; //knpMȡ嶨ĵ + }UnitParam; + + //@brief : ֵ + //@remark: 4Byte align -> 8Bytes + typedef struct _MeaValue { + float Value; + UnitParam Unit; + char IsValid; //ǷЧ 0 ʾЧ 1ʾЧ + char IsExist; //Ƿڡ 0 ʾڣ 1ʾڡ + }MeaValue; + + //@brief : ݰͨö塣 + //@remark: + typedef enum _EMeaParam { + MP_MAX = 0, //ֵ + MP_MIN, //Сֵ + MP_HIGH, //High(Top)-ߵƽ(ֵ) + MP_MIDDLE, //Middle-мֵ + MP_LOW, //Low(Bottom) - ͵ƽ(׶ֵ) + + MP_PKPK, //VPP-ֵ + MP_AMP, //Сֵ + MP_MEAN, //ƽֵ + MP_CYCMEAN, // + MP_RMS, // + + MP_CYCRMS, //ھֵ + MP_AREA, // + MP_CYCAREA, // + MP_OVERSHOOT,// + MP_PRESHOOT, //Ԥ + + MP_PERIOD, // + MP_FREQ, //Ƶ + MP_RISE_TIME,//ʱ + MP_FALL_TIME,//½ʱ + MP_PWIDTH, // + + MP_NWIDTH, // + MP_PDUTY, //ռձ + MP_NDUTY, //ռձ + MP_RISEDELAY,//ʱ + MP_FALLDELAY,//ʱ + + MP_PHASE, //λ + MP_FRR, // + MP_FRF, + MP_FFR, + MP_FFF, + + MP_LRF, + MP_LRR, + MP_LFR, + MP_LFF, + + MP_BURST_WIDTH, //ͻ + + // + //reserve section + // ²׷ + // + // + //̶λ50 + MP_MAX_COUNT = 50, + }EMeaParam; + +#ifdef __cplusplus + } + namespace uci { + using namespace comAPICommon; + namespace cb = comAPICommon;//comAPICommon alias + } +#endif + +#endif // dso_base_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/uci.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/uci.h new file mode 100644 index 0000000..6c73e78 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/uci.h @@ -0,0 +1,228 @@ +/******************************************************************** + created: 2014/12/22 + author: M.Yang + purpose: UCI(united communicate interface) +*********************************************************************/ + +#ifndef uci_h__ +#define uci_h__ + +#include "ucidef.h" + +////////////////////////////////////////////////////////////////////////// +// ڽӿڷص״ֵ̬ +// < 0 : ʾ +// ӦĴϢͨuci_GetLastErrorȡ,Ķucidef.hļС +// < UCI_ERRĴΪlibusbĴ롣 +////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +namespace uci { +extern "C"{ +#endif + //@brief : ִỰ޹صIJѯ + //@param PRParams _params : ѯIJ + //@param u_byte * _data : ݵĻַ + //@param u_size _dataCount : ݵĻСBytes + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_Query(_in_out PRParams _params, _in_out u_byte* _data, _in u_size _dataCount); + + //@brief : ѯͨŽڵ + //@param _in const QParams * _params : ѯ + //@param _out Node * _outBuf : ŲѯĽڵ + //@param _in_out u_size * _nodeCnt : ΪҪȡĽڵΪʵʶȡĽڵ + //@param _in u_size _timeOut : ѯʱ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_QueryNodes(_in const QParams* _params, _out Node* _outBuf, + _in_out u_size* _nodeCnt, _in u_size _timeOut); + + //@brief : ѯͨŽڵ + //@param _msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _nodes : ŲѯĽڵ + //@param _node_count : ҪѯĽڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX(u_cstring _msg, Node* _nodes, u_size _node_count, _in u_size _timeout); + + /*21-7-2017 15:51 by M.J Created <򻯰汾ѯͨѶڵ㲢ͨŵַ>*/ + //@brief : ѯͨŽڵ + //@param _addr_msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _addr_msg_len : յַַbufferij + //@param _node_type : ڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX_Simple(u_tchar* _addr_msg, u_size _addr_msg_len, u_size _node_type, _in u_size _timeout); + + //@brief : 豸 + //@param u_cstring _addr : 豸ַ '\0'β + //@param u_session * _session : ѽĻỰID. + //@param u_uint32 _timeOut : ӳʱʱ ms + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + // UCI_SUCCESS + // UCI_ERR_ARGS_WRONG; + // UCI_ERR_RES_INIT_ERROR; + // UCI_ERR_CONNECT_ADDR_WRONG; + // UCI_ERR_CONNECT_FAILED; + // UCI_ERR_CONNECT_TIMEOUT] + //@remarks : ĵ + u_status _UCIAPI uci_Open(u_cstring _addr, u_session* _session, u_uint32 _timeOut); + + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 + u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + //@brief : ִ + //@param u_session _session : ỰID + //@param PCommandParams _params : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SendCommand(u_session _session, PCommandParams _params); + + //@brief : UCI¼ + //@param uciNotify _pNotify : ӦUCI¼Ļص + //@return u_status _UCIAPI : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SetNotify(UCIMSGProc _pNotify); + + //@brief : + //@param _msg : ַ + //@param _obj : ݻַ + //@param _objSize : ݻС + //@return : 鿴ļеġڽӿڷص״ֵ̬˵s + //@remarks : Ŀǰֻ֧л԰汾Ͷ豸ͷĵ¼鿴ĵ + u_status _UCIAPI uci_SetAttribute(u_session _sesn, u_cstring _msg, const u_object* _obj, u_size _objSize); + + //@brief : ѯ + //@param u_session _sesn : + //@param u_attr _name : + //@param u_attr_v * _value : + //@return u_status _UCIAPI : + //@remarks : + u_status _UCIAPI uci_GetAttribute(u_session _sesn, u_cstring _msg, u_object* _obj, u_size _objSize); + + //@brief : д + //@param u_session _session : ỰID + //@param PWParam _params : д + //@param const u_byte * _data : Ҫдݻַ ΪNULL + //@param u_size _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_params.CMDStringѾҪдֶˣʹuci_FormatWriteӿڣ + // _data != NULLַ_params.CMDStringֻܰһ䡣 + u_status _UCIAPI uci_Write(u_session _session, PWParams _params, const u_byte* _data, u_size _len); + + //@brief : д + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@param _data : Ҫдݻַ ΪNULL + //@param _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_msgѾҪдֶˣ + // _data != NULLַ_msgֻܰһ䡣 + u_status _UCIAPI uci_WriteX(u_session _session, u_cstring _msg, + u_uint32 _timeout, const u_byte* _data, u_size _len); + + //@brief : ֻдַָдָӿ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteSimple(u_session _session, u_cstring _msg, u_uint32 _timeout); + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + //@brief : ȡ + //@param u_session _session : ỰID + //@param PRParams _params : + //@param u_byte * _data : ݵĻ + //@param u_size _dataLen : ݵĻССЭ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ʹuci_ReadX汾 + u_status _UCIAPI uci_Read(u_session _session, PRParams _params, u_byte* _data, u_size _dataLen); + + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 + u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, + u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + //@brief : дļ + //@param u_session _session : ỰID + //@param WFileParams * _info : ļϢ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteFromFile(u_session _session, WFileParams* _info); + + //@brief : дļ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : Ҫдļ·ļ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_WriteFromFileļ򻯰汾 + u_status _UCIAPI uci_WriteFromFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout); + + //@brief : Read data synchronously and store the transferred data in a file. + //@param u_session _session : ỰID + //@param RFileParams _params : Ҫݵļ· + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_ReadToFile(u_session _session, RFileParams* _params); + + //@brief : ȡļ + //@param _session : ỰID. + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : ݵش̵ļ·ļͺ׺ + //Ǿ·Ҳ··ͨ_filePathFinalȡ· + //@param _timeout : ʱ + //@param _filePathFinal : 嵽صļľ· + //@param _filePathFinalLength : _filePathFinalijȣַ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_ReadToFileķǷװ汾 + u_status _UCIAPI uci_ReadToFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength); + + //@brief : رջỰ + //@param u_session _session : ҪرյĻỰID + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + u_status _UCIAPI uci_Close(u_session _session); + + //@brief : һβӦĴ״̬Ϣ + //@return u_cstring : Ϣ + //@remarks : ͨuci_SetAttributeôϢ԰汾 + u_cstring _UCIAPI uci_GetLastError(void); + + //@brief : ˳UCIʵʱá + //@remarks : ˳ʱãͷڲԴ + // ӿڲһҪʹá ֻ.NETйܻ£ + // ͨuci_SetAttribute uci_SetNotifyӿ + // 豸Ƴ¼ʱ˳ʱʹá + void _UCIAPI uci_ExInstance(void); +#ifdef __cplusplus +} + +} +#endif +#endif // uci_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/uci_cpp.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/uci_cpp.h new file mode 100644 index 0000000..79751d8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/uci_cpp.h @@ -0,0 +1,60 @@ +/*! + * \created : 2017/3/17 + * \author : M.Yang + * \purpose : ṩUCIC++汾ӿ + */ +#ifndef uci_cpp_h__ +#define uci_cpp_h__ +#include "uci.h" + +namespace uci { + class Session; +} + +//@brief : UCI Ự +//@remark: uci_ǰ׺CԹ淶Ľӿ򵥷װĺôǣ +// 1SessionʱԶرջỰǣʹõʹʱעʹ߼Ǵ߼ +// 2ÿһӿϣʡȥһSession IDΣҿ趨βεĬֵijЩCԱ֧֣ʹýӿڸ򵥣 +// ע⣺ +// ಻ȫӿڵ䣬Ҫ䡣 +class uci::Session { +public: + Session() : m_Session(INVALID_SESSION) {} + virtual ~Session() { + if (m_Session != INVALID_SESSION) { + uci_Close(m_Session); + m_Session = INVALID_SESSION; + } + } + + u_status Open(u_cstring _addr, u_uint32 _timeout = 2000) { + u_status r = uci_OpenX(_addr, _timeout); + if (UCISUCCESS(r)) + m_Session = (u_session)r; + return r; + } + + u_status Write(u_cstring _msg,u_uint32 _timeout = 1000, const u_byte* _data = NULL, u_size _len = 0) { + return uci_WriteX(m_Session, _msg, _timeout, _data, _len); + } + + u_status Read(u_cstring _msg,u_uint32 _timeout, u_byte* _data, u_size _dataLen) { + return uci_ReadX(m_Session, _msg, _timeout, _data, _dataLen); + } + + u_status WriteFromFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout) { + return uci_WriteFromFileX(m_Session, _msg, _filePath, _timeout); + } + + u_status ReadToFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength) { + return uci_ReadToFileX(m_Session, _msg, _filePath, _timeout, _filePathFinal, _filePathFinalLength); + } + + u_status Close() { return uci_Close(m_Session); } + u_session GetSession() const { return m_Session; } +protected: + u_session m_Session; +}; + +#endif // uci_cpp_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/ucidef.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/ucidef.h new file mode 100644 index 0000000..f5bf38d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/ucidef.h @@ -0,0 +1,571 @@ +/******************************************************************** + created: 2014/12/23 + author: M.Yang + purpose: UCIȫֶļ + modify: + *********************************************************************/ +#ifndef ucidef_h__ +#define ucidef_h__ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +#define _UCIAPI __stdcall +#define _UCICallBack __stdcall +#endif + +#define _in +#define _out +#define _in_out + +#ifdef __cplusplus +namespace uci { +#endif // __cplusplus + +#ifdef _CVI_ +#define u_inline static +#else +#define u_inline inline +#endif // _CVI_ + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif // !MAX_PATH + + ////////////////////////////////////////////////////////////////////////// + //{ Ͷ +#ifdef _UNICODE + //@brief : ʾһ Unicode ַ +#define u_tchar wchar_t +#else + //@brief : ʾһ ASCII ַ +#define u_tchar char +#endif // _UNICODE + +#if defined(_WIN64) + typedef unsigned __int64 u_unit_ptr; + typedef __int64 u_long_ptr; +#else + typedef unsigned int u_unit_ptr; + typedef long u_long_ptr; +#endif + + //@brief : Boolean +#define u_bool bool + //@brief : 8λ޷ +#define u_byte unsigned char + //@brief : 8λз +#define u_char char + //@brief : ָ͵Ļָ +#define u_buf void* + //@brief : ͵ij +#define u_object void + //@brief : ʾ 16 λз +#define u_short short + //@brief : ʾ 16 λ޷ +#define u_ushort unsigned short + //@brief : ʾ 16 λз +#define u_int16 u_short + //@brief : ʾ 16 λ޷ +#define u_uint16 u_ushort + //@brief : ʾ 32 λз +#define u_int32 int + //@brief : ʾ 32 λ޷ +#define u_uint32 unsigned int + //@brief : ʾUCIӿڷص״ֵ̬(32λз) +#define u_status u_int32 + //@brief : ʾС32λ޷ +#define u_size u_uint32 + //@brief : ʾỰID32λ޷ +#define u_session u_uint32 + //@brief : ʾַ +#define u_string u_tchar* + //@brief : ʾַֻ +#define u_cstring const u_tchar* + //@brief : ʾIDͣ32λ޷ +#define u_attr u_int32 + //@brief : ʾֵͣ32λ޷ +#define u_attr_v u_int32 + //@brief : ʾһ16λ޷͵ĵ +#define u_word u_ushort + //@brief : ʾһ32λ޷͵˫ +#define u_dword u_uint32 + //@brief : Ϣ +#define u_wparam u_unit_ptr + //@brief : Ϣ +#define u_lparam u_long_ptr + //} + + ////////////////////////////////////////////////////////////////////////// + //{ ӿڷ״ֵ̬ + //@brief : ɹ +#define UCI_SUCCESS (0) + //@brief : ʼֵ +#define UCI_ERR (-1000) + //@brief : жϵǰӿǷִʧ + //@brief : жϵǰӿǷִгɹ +#define UCIERR(r) (r < 0) +#define UCISUCCESS(r) (!UCIERR(r)) + + //@brief : + typedef enum _UCIErr { + NoError = 0, + + //@brief : Դʼ + InitResourceError = UCI_ERR - 20, + //@brief : ЧĻỰ + Invalid_Session, + //@brief : ʱ + Timeout, + //@brief : ʧ + Failed, + //@brief : ֵ֧IJ + Unsupported, + //@brief : ڴռ䲻 + Insufficient_Memory, + //@brief : ϵͳæ޷Ӧ + Busy, + //@brief : ͨ쳣棡 + COMExpection, + //@brief : ͨδ򿪣 + ChannelNotOpened, + //@brief : WinAPI + API_Failed, + + //@brief : δ֪Ĵ + Unknown = UCI_ERR - 40 - 1, + + //@brief : ӵַַʽ + Connect_InvalidAddress = UCI_ERR - 40, + //@brief : ӻδ + Connect_NotBuild, + //@brief : ѶϿ + Connect_Break, + //@brief : ֵ֧ͨŷʽ + Connect_Unsupported_COMType, + + //@brief : δָ豸 + Device_NoFound = UCI_ERR - 60, + //@brief : ֵ֧豸 + Device_Unsupported, + //@brief : Ҫִвѯ豸IJ + Device_QueryFirst, + //@brief : Ͳƥ + Device_NotMatch, + + //@brief : ѯ豸ʧ + Query_LANNodesFailed, + + //@brief : USB豸ִַֻвѯ豸Ч + //@remarks : UCI⵼USB豸ַֻһб豸ַ + AddrValid_AfterQueryDeviceOper, + + //@brief : δU̽ + UDisk_NotFound, + //@brief : Ѿ + Key_Locked, + + //@brief : ַʽ + CMD_Invalid_StringFormat = UCI_ERR - 80, + //@brief : ֵֻ֧ + CMD_OnlySupportSingle, + //@brief : һֻ֧һ + CMD_OnlySupportSingleAttr, + //@brief : ֵ֧ + CMD_Unsupported, + //@brief : ʧ + CMD_SendFailed, + //@brief : Эݸʽ + CMD_Invalid_ProtocolFormat, + //@brief : 豸дļflashʧܣ + CMD_WriteFileToFlash_Failed, + //@brief : δЧĻظ + CMD_NoFound_Valid_Reply_Data, + //@brief : Ϣ鿴ǷЭ + CMD_Error_Message, + //@brief : Чıʽ + CMD_Invalid_Expression, + //@brief : ڵǰģʽ²ԼⲨļ + CMD_Cannot_LoadARB_InCurrent_MOD_Mode, + + //@brief : + Args_Invalid = UCI_ERR - 100, + //@brief : ṩĿռ̫С + Args_MemoryTooSmall, + //@brief : ṩļ̫(50ֽ) + Args_FileNameTooLong, + //@brief : ݴСЭ鲻ƥ(ֹݴ) + Args_DataLenNotMatch, + + //@brief : + Data_Overflow = UCI_ERR - 120, + //@brief : Χ + Data_OutRange, + //@brief : δȫȡ + Data_NotReadEnoughLenth, + //@brief : Уʧ + Data_ECC_Failed, + //@brief : Ч + Data_Invalid, + //@brief : ѹʧ + Data_Zip_Error, + //@brief : ݽѹʧ + Data_UnZip_Error, + //@brief : ݴʧ + Data_Transfer_Error, + //@brief : ݴʧ + Data_Transfer_Break, + //@brief : Чݿɶȡ + Data_No_Data_Incoming, + + //@brief : + File_AccessDenied = UCI_ERR - 140, + //@brief : An unspecified error occurred. + File_GenericException, + //@brief : The file could not be located. + File_NotFound, + //@brief : All or part of the path is invalid. + File_BadPath, + //@brief : The permitted number of open files was exceeded. + File_TooManyOpenFiles, + //@brief : There was an attempt to use an invalid file handle + // or The file format is unsupported! + // or The file data is error! + File_InvalidFile, + //@brief : The current working directory cannot be removed + File_RemoveCurrentDir, + //@brief : There are no more directory entries + File_DirectoryFull, + //@brief : There was an error trying to set the file pointer + File_BadSeek, + //@brief : There was a hardware error + File_HardIO, + //@brief : SHARE.EXE was not loaded, or a shared region was locked + File_SharingViolation, + //@brief : There was an attempt to lock a region that was already locked + File_LockViolation, + //@brief : The disk is full + File_DiskFull, + //@brief : The end of file was reached + File_EndOfFile, + //@brief : дļʧ + File_SaveToDiskFailed, + //@brief : ļȳΧ + File_Length_OutOfRange, + }UErr; + //} + ////////////////////////////////////////////////////////////////////////// + + //@brief : ĻỰID +#define INVALID_SESSION ((u_uint32)(-1)) + + ////////////////////////////////////////////////////////////////////////// + //{ + //лӢģ "lang:zh-hans" or "lang:en-us" + //ʹUSB豸ƳӼ "devchange:1" +//} + + +#define CACHE_LINE 1 +#define CACHE_ALIGN __declspec(align(CACHE_LINE)) + + //@brief : ýṹĶ뷽ʽ +#define PACK_ALIGN(n) __declspec(align(n)) + + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + + //one Word is 2 bytes + u_inline u_word UCI_HIWORD(u_dword _dw) { return ((u_word)((_dw >> 16) & 0xffff)); } + u_inline u_word UCI_LOWORD(u_dword _dw) { return ((u_word)(_dw & 0xffff)); } + + //#pragma pack(show)// C4810 + //ensure byte-packed structures1ֽڶ룩 +#include //뻷ûиļ滻Ϊǰƽֽ̨ڶ䡣 + + //@brief : ݽӿڵIJ + //@remarks : ͨͨuci_CreateRParamsӿڴ + typedef struct _RParams { + //@brief : ַ'\0'β. ʽЭĵ + u_cstring CMDString; + //@brief : ҪصӾͨҪȡ\ѯǶӦģ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + //@brief : + //@remarks : ͨʹãɿ;ڲѯ豸ʱõ + //ΪQParamsĵΪ׼ + u_buf ExtraData; //reserve + //@brief : ݵij + u_size ExtraDataLen; + }RParams, *PRParams; + +#ifdef __cplusplus + inline RParams* uci_CreateRParams(RParams& _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + _p.ExtraData = _ExtraData; + _p.ExtraDataLen = _ExtraDataLen; + return &_p; + } +#else + u_inline RParams* uci_CreateRParams(RParams* _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + _p->ExtraData = _ExtraData; + _p->ExtraDataLen = _ExtraDataLen; + return _p; + } +#endif + + typedef struct _DeviceIOParams { + u_int32 Count; + u_int32* Data; + }DeviceIOParams; + + typedef struct _QParams { + //@brief : ҪѯͨŽڵ + //@remarks : enum NodeType ȡֵ ͨ־λֵ + //@eg NodeType::USB | NodeType::LAN + u_int32 Type; + //@brief : ˿ڼ˿ + u_int32 PortCount; + //@brief : ˿ڼ + u_int32* Ports; + //@brief : PVIDPVIDĸ + //@remarks : + u_int32 PVIDCount; + //@brief : PID VID + //@remarks : ʹMakePVIDGetPIDGetVIDȡ + u_int32* PVID; + //@brief : ѯַnullptrʱʾѯ豸ѯָ豸豸 + u_cstring Msg; + }QParams, *PQParams;//@brief : ѯ豸ʱò + + u_inline u_int32 MakePVID(u_ushort _pid, u_ushort _vid) { return ((_pid << 16) | (_vid)); }; + + u_inline u_ushort GetPID(u_int32 _pvid) { return UCI_HIWORD(_pvid); } + + u_inline u_ushort GetVID(u_int32 _pvid) { return UCI_LOWORD(_pvid); } + +#ifdef __cplusplus + inline QParams* UCI_CreateQParam(QParams& _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(&_qp, 0, sizeof(_qp)); + _qp.Type = _type; + _qp.Ports = _ports; + _qp.PortCount = _port_cnt; + _qp.PVID = _pvid; + _qp.PVIDCount = _pvid_cnt; + _qp.Msg = _msg; + return &_qp; + } +#else + u_inline QParams* UCI_CreateQParam(QParams* _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(_qp, 0, sizeof(*_qp)); + _qp->Type = _type; + _qp->Ports = _ports; + _qp->PortCount = _port_cnt; + _qp->PVID = _pvid; + _qp->PVIDCount = _pvid_cnt; + _qp->Msg = _msg; + return _qp; + } +#endif + //@brief : дݽӿڲ + //@remarks : ͨӿuci_CreateWParams + typedef struct _WParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : صݣӾ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + }WParams, *PWParams; + +#ifdef __cplusplus + u_inline WParams* uci_CreateWParams(WParams& _p, u_cstring _cmd, u_uint32 _timeout) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + return &_p; + } +#else + u_inline WParams* uci_CreateWParams(WParams* _p, u_cstring _cmd, u_uint32 _timeout) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + return _p; + } +#endif + typedef struct _CommandParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : 1 + u_uint32 Param1; + //@brief : 1 + u_uint32 Param2; + //@brief : ʱ + u_uint32 Timeout; + }CommandParams, *PCommandParams; + + //@brief : дļIJ + typedef struct _WFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : Ҫдļ·ļ + u_cstring FilePath; + //@brief : дʱ(λms) + u_uint32 Timeout; + }WFileParams, *PWFileParams; + + //@brief : ļӿڵIJ + typedef struct _RFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : ݵش̵ļ·ļͺ׺ + u_cstring FilePath; + //@brief : ʱ(λms) + u_uint32 Timeout; + //@brief : ļ· + u_tchar FilePathFinal[MAX_PATH]; + }RFileParams, *PRFileParams; + + //@brief : ͨŽڵ + //@remarks : QParamsǰλ룬Nodeȡenumֵ + typedef enum _NodeType{ + LAN = 0x0001, + USB = 0x0010, + }NodeType; + + //@brief : USB豸 + //@remarks : + typedef struct _USBDescriptor { + //@brief : PID + u_ushort PID; + //@brief : VID + u_ushort VID; + //@brief : ַ + u_ushort Addr; + }USBDescriptor; + + //@brief : IPַ + //@remarks : ˳Ϊ f1(192).f2(168).f3(1).f4(253) - Сģʽ + typedef union _IPAddr { + struct { u_byte f1, f2, f3, f4; } Field; + u_int32 Addr; + }u_IPAddr; + + //@brief : LANͨŵ豸 + //@remarks : + typedef struct _LANDescriptor { + //@brief : IPַַͣ + u_tchar IP[16]; + //@brief : IPַ + u_IPAddr Addr; + //@brief : ˿ + //@remarks : TCPIPõĶ˿ں + u_ushort Port; + }LANDescriptor; + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _Node { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµƣ + // ѳδͳһʱUCIڲԶƥΪUCIЭõ֣ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }Node, *PNode; + + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _NodeEx { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµơ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }NodeEx, *PNodeEx; + + typedef struct _UCIMSG { + u_session Session; + u_uint32 Message; + u_wparam wParams; + u_lparam lParams; + u_byte Reserved[240]; + }UCIMSG;//256Bytes + + ////////////////////////////////////////////////////////////////////////// + typedef enum _uci_msg { + //@brief : 豸ѾϿ + //@remarks : Ŀǰֻ֧LANڷʵӵ + // wParams LAN : ˿ں(ʮ) + // Reserved LAN : IP ַ + UMSG_CONNECT_CLOSED = 1, + //@brief : ļϢ + //@remarks : + // wParams ֡ + // lParams ֡ -1 ʼ䣻 [0,wParams)У wParams + //-> UCIMSGProc return -1 ʾжϴ. + UMSG_FILE_TRANSFER = 2, + //@brief : USBϢ + //@remarks : + // wParams : ʹõ16λУ8λΪpid8λΪvid + // lParams : ¼ͣ Ƴ = 0 = 1 + UMSG_DEVICE_NOTIFY = 3, + }EUCIMSG; + + typedef int(__stdcall *UCIMSGProc)(UCIMSG* _msg); +#include + +#ifdef __cplusplus + } +#endif//__cplusplus + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ucidef_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/unit.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/unit.h new file mode 100644 index 0000000..da0fc1f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/include/unit.h @@ -0,0 +1,117 @@ +/*! +* \created : 2016/10/10 +* \author : M.Yang +* \purpose : ṩλı׼ +* \remarks : еλĶ嶼Ա׼λΪ0Сڱ׼λΪݼڱ׼λʱΪ +* ĺôǣԱ֤Ա׼λΪ׼չ +*/ + +#ifndef Unit_h__ +#define Unit_h__ + +#ifdef __cplusplus +namespace unit { + extern "C"{ +#endif +#ifdef __cplusplus + typedef enum _EScale : char { +#else + typedef enum _EScale { +#endif // DEBUG + SCALE_p = -4, + SCALE_n, + SCALE_u, + SCALE_m, + SCALE_STD = 0, + SCALE_K, + SCALE_M, + SCALE_G, + SCALE_T, + }EScale; + +#ifdef __cplusplus + typedef enum _EType : char{ +#else + typedef enum _EType { +#endif // __cplusplus + TYPE_INVALID = -1, + TYPE_FREQ, + TYPE_TIME, + TYPE_AREA, //(Vs) + TYPE_SAMPLERATE,//ʣSa/s + TYPE_POINT, //Sa + TYPE_VPP, //ֵ + TYPE_VOLTAGE,//ѹ + TYPE_CURRENT,// + TYPE_DB, //DB + TYPE_VV, // + TYPE_PERCENT,//ٷֱ + TYPE_DEGREE, // + TYPE_WATT, //أ + TYPE_UNKNOWN,// δ֪λ + }EType; + + typedef struct _CodeName { + char Code; + char Name[5]; + }CodeName; + + static const CodeName ScaleTabel[] = { + { SCALE_p, "p" }, + { SCALE_n, "n" }, + { SCALE_u, "u" }, + { SCALE_m, "m" }, + { SCALE_STD,"" }, + { SCALE_K, "K" }, + { SCALE_M, "M" }, + { SCALE_G, "G" }, + { SCALE_T, "T" } + }; + + static const CodeName TypeTabel[] = { + { TYPE_FREQ, "Hz" }, + { TYPE_TIME, "s" }, + { TYPE_AREA, "Vs" }, + { TYPE_SAMPLERATE, "Sa/s" }, + { TYPE_POINT, "Sa" }, + { TYPE_VPP, "Vpp" }, + { TYPE_VOLTAGE, "V" }, + { TYPE_CURRENT, "A" }, + { TYPE_DB, "dB" }, + { TYPE_VV, "VV" }, + { TYPE_PERCENT, "%" }, + { TYPE_DEGREE, "" }, + { TYPE_WATT, "W" }, + { TYPE_UNKNOWN, "U" }, + }; + + const char* _UCIAPI uci_UnitFindTypeName(char _code); + + const char* _UCIAPI uci_UnitFindScaleName(char _code); + //@brief : ǰλֵתָĵλ + //@param _cur_value : ǰֵ + //@param _cur_unit : ǰλ + //@param _des_unit : Ҫתĵλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@return : תֵ2.3KHz תΪHz2300Hz + //@remarks : עⵥλEScaleģ + double _UCIAPI uci_UnitConvertTo(double _cur_value, int _cur_unit, int _des_unit, double _scale); + + typedef struct _UVale { + double Value; + long long Unit; + }UVale; + + //@brief : ǰλֵԶתʵĵλͣʹֵСڽơ2300Hzת2.3KHzs + //@param _value : ǰֵ + //@param _unit : ǰλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@remarks : עⵥλEScaleģ + UVale _UCIAPI uci_UnitRefresh(double _value, char _unit, double _scale); + +#ifdef __cplusplus + } +} +#endif + +#endif // Unit_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/lib/C/ASCII/uci.dll b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/lib/C/ASCII/uci.dll new file mode 100644 index 0000000..7f329f4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/lib/C/ASCII/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/lib/C/ASCII/uci.lib b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/lib/C/ASCII/uci.lib new file mode 100644 index 0000000..cc58b46 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/lib/C/ASCII/uci.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/main.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/main.h new file mode 100644 index 0000000..7188f01 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/main.h @@ -0,0 +1,33 @@ +/**************************************************************************/ +/* LabWindows/CVI User Interface Resource (UIR) Include File */ +/* Copyright (c) National Instruments 2016. All Rights Reserved. */ +/* */ +/* WARNING: Do not add to, delete from, or otherwise modify the contents */ +/* of this include file. */ +/**************************************************************************/ + +#include + +#ifdef __cplusplus + extern "C" { +#endif + + /* Panels and Controls: */ + +#define PANEL 1 +#define PANEL_COMMANDBUTTON 2 /* callback function: _Read */ + + + /* Menu Bars, Menus, and Menu Items: */ + + /* (no menu bars in the resource file) */ + + + /* Callback Prototypes: */ + +int CVICALLBACK _Read(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); + + +#ifdef __cplusplus + } +#endif diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/main.uir b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/main.uir new file mode 100644 index 0000000..3751bc2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/main.uir differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/uci.dll b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/uci.dll new file mode 100644 index 0000000..7f329f4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/uci.lib b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/uci.lib new file mode 100644 index 0000000..cc58b46 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/CVI/UCIDEMO/uci.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/ASCII/uci.dll b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/ASCII/uci.dll new file mode 100644 index 0000000..7f329f4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/ASCII/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/CaptureWave.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/CaptureWave.vi new file mode 100644 index 0000000..69aacd4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/CaptureWave.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/CaptureWaveDemo.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/CaptureWaveDemo.vi new file mode 100644 index 0000000..61d4b86 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/CaptureWaveDemo.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Close.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Close.vi new file mode 100644 index 0000000..1f4c886 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Close.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/GetDevAddress.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/GetDevAddress.vi new file mode 100644 index 0000000..6ba6079 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/GetDevAddress.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/MeaAll.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/MeaAll.vi new file mode 100644 index 0000000..45ffec1 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/MeaAll.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Open.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Open.vi new file mode 100644 index 0000000..c3389ff Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Open.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/ParamsMeasure.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/ParamsMeasure.vi new file mode 100644 index 0000000..4d6cae2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/ParamsMeasure.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Read.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Read.vi new file mode 100644 index 0000000..db013ce Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Read.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/TestMethod.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/TestMethod.vi new file mode 100644 index 0000000..ae41972 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/TestMethod.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/WaveAnalysis.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/WaveAnalysis.vi new file mode 100644 index 0000000..b9d9a59 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/WaveAnalysis.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Write.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Write.vi new file mode 100644 index 0000000..2e70915 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/Write.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/demo_proj.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/demo_proj.vi new file mode 100644 index 0000000..187409b Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/demo_proj.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/doc/Chinese/LabView-UCI使用说明.pdf b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/doc/Chinese/LabView-UCI使用说明.pdf new file mode 100644 index 0000000..60f3044 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/doc/Chinese/LabView-UCI使用说明.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/doc/English/LabView-UCI Instructions.pdf b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/doc/English/LabView-UCI Instructions.pdf new file mode 100644 index 0000000..210ec81 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/LabView-UCI/doc/English/LabView-UCI Instructions.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/uci.dll b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/uci.dll new file mode 100644 index 0000000..7f329f4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Close.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Close.vi new file mode 100644 index 0000000..fc9d73f Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Close.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Openx.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Openx.vi new file mode 100644 index 0000000..42e56a4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Openx.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Readx.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Readx.vi new file mode 100644 index 0000000..e304835 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-Readx.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-WriteSimple.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-WriteSimple.vi new file mode 100644 index 0000000..40bde63 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/子VI-WriteSimple.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/输出信息.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/输出信息.vi new file mode 100644 index 0000000..e14f9ee Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/ASCII/输出信息.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/Labview-UCI说明文档.pdf b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/Labview-UCI说明文档.pdf new file mode 100644 index 0000000..d69b471 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/Labview-UCI说明文档.pdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.aliases b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.aliases new file mode 100644 index 0000000..462fa3f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.aliases @@ -0,0 +1,5 @@ +[My Computer] +My Computer = "192.168.16.1" + +[ҵĵ] +ҵĵ = "192.168.1.145" diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.lvlps b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.lvlps new file mode 100644 index 0000000..37e1158 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.lvlps @@ -0,0 +1,3 @@ +[Ŀ(_D)] +ProjectExplorer.ClassicPosition[String] = "221,845,1094,1217" + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.lvproj b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.lvproj new file mode 100644 index 0000000..f713d50 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/UCIProgramme.lvproj @@ -0,0 +1,28 @@ + + + + 3 + true + true + false + 0 + 我的电脑/VI服务器 + 我的电脑/VI服务器 + true + true + false + + + + + + + + + + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/主VI.vi b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/主VI.vi new file mode 100644 index 0000000..0490aed Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/UCI-Labview11.0/主VI.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj.zip b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj.zip new file mode 100644 index 0000000..10c7e47 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj.zip differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/Demo.vb b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/Demo.vb new file mode 100644 index 0000000..0b2ef97 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/Demo.vb @@ -0,0 +1,76 @@ +Module Demo + '目标CPU必须设置为x86平台,将uci.dll和ucivb.dll拷贝到工程运行目录下并添加uci.vb引用到工程中,即可使用接口 + Sub Main() + + Dim ret As Integer = 0 + Dim seesion As UInteger = 0 + + '简单版搜索设备API + 'Dim addr(10 * 256) As Char '表示只搜索10个设备,每个设备地址最大字符串长度不超过256个字节,搜索到的每一个设备地址以逗号隔开 + 'ret = ucivb.UCI.QueryNodes_Simple(addr, UBound(addr), ucivb.NodeType.USB, 2000) + + '搜索设备API + Dim m_Nodes(9) As ucivb.Node + Dim msg As String = "" + Dim type As UInteger = ucivb.NodeType.USB + Select Case type + Case ucivb.NodeType.USB + msg = "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348, 0xE008&0x1A86;" + Case ucivb.NodeType.LAN + msg = "LAN:5000,4162,8000,18191;" + End Select + ret = ucivb.UCI.QueryNodes(msg, m_Nodes, UBound(m_Nodes) + 1, 2000) + + '简单版打开设备API + 'seesion = ucivb.UCI.Open_Simple(m_Nodes(0).UCIAddr, 2000) + '打开设备API + ret = ucivb.UCI.Open(m_Nodes(0).UCIAddr, seesion, 2000) + + '读配置文件测试 + Dim filePath As String = Format(Now, "yyyymmdd_hhmmss") & ".set" + Dim rfp As ucivb.RFileParams + rfp.CMDString = "dconfig;" + rfp.FilePath = filePath + rfp.TimeOut = 2000 + rfp.FilePathFinal = "" + ret = ucivb.UCI.ReadToFile(seesion, rfp) + + '写配置文件测试 + Dim wfp As ucivb.WFileParams + wfp.CMDString = "dconfig;" + wfp.FilePath = rfp.FilePathFinal + wfp.TimeOut = 2000 + ret = ucivb.UCI.WriteFromFile(seesion, wfp) + '简单版写文件API + 'ret = ucivb.UCI.WriteFromFileX(seesion, "dconfig;", rfp.FilePathFinal, 2000) + + '写指令API + ucivb.UCI.Write(seesion, "Proc:STOP;", 2000) + + '读指令API + Dim data(1024) As Byte + ucivb.UCI.Read(seesion, "mea:all?;", 2000, data, 400) + + 'Dim filePath As String = Format(Now, "yyyymmdd_hhmmss") & ".csv" + ''简单版读数据到文件API + ''Dim MAX_PATH_LENGTH As UInteger = 260 + ''Dim finalFilePath(MAX_PATH_LENGTH) As Char + ''ret = ucivb.UCI.ReadToFileX(seesion, "capture wave:.csv@CH:0@DT:vol;", filePath, 2000, finalFilePath, MAX_PATH_LENGTH) + ''读数据到文件API + 'Dim rfp As ucivb.RFileParams + 'rfp.CMDString = "capture wave:.csv@CH:0@DT:vol;" + 'rfp.FilePath = filePath + 'rfp.TimeOut = 2000 + 'rfp.FilePathFinal = "" + 'ret = ucivb.UCI.ReadToFile(seesion, rfp) + + '获取设备产生的最后一个错误信息 + 'Dim errorInfo As String = "" + 'errorInfo = ucivb.UCI.GetLastError() + + '关闭设备 + ret = ucivb.UCI.Close(seesion) + + End Sub + +End Module diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Application.Designer.vb b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Application.myapp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/AssemblyInfo.vb b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..65eb6ee --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' 有关程序集的常规信息通过下列特性集 +' 控制。更改这些特性值可修改 +' 与程序集关联的信息。 + +' 查看程序集特性的值 + + + + + + + + + + +'如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID + + +' 程序集的版本信息由下面四个值组成: +' +' 主版本 +' 次版本 +' 生成号 +' 修订号 +' +' 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +' 方法是按如下所示使用“*”: +' + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Resources.Designer.vb b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Resources.Designer.vb new file mode 100644 index 0000000..aed0e5e --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("UCIDemoVBProj.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Resources.resx b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Settings.Designer.vb b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c492ab4 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.UCIDemoVBProj.My.MySettings + Get + Return Global.UCIDemoVBProj.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Settings.settings b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/UCIDemoVBProj.vbproj b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/UCIDemoVBProj.vbproj new file mode 100644 index 0000000..9443e48 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VB/UCIDemoVBProj/UCIDemoVBProj.vbproj @@ -0,0 +1,118 @@ + + + + + Debug + AnyCPU + {5603097C-BDBE-40C8-9AC7-117A7129E633} + Exe + UCIDemoVBProj.Demo + UCIDemoVBProj + UCIDemoVBProj + 512 + Console + v4.0 + + + x86 + true + full + true + true + ..\Debug\ + UCIDemoVBProj.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + ..\Debug\ + UCIDemoVBProj.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + {79c8a7f9-ebde-438c-ae4e-f247f38aab47} + ucivb + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/Backup/SimpleUCI.sln b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/Backup/SimpleUCI.sln new file mode 100644 index 0000000..817fe3d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/Backup/SimpleUCI.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleUCI", "SimpleUCI.vcproj", "{DA6758AD-C0D6-46D3-813B-4E83712CA7A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Debug|Win32.Build.0 = Debug|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Release|Win32.ActiveCfg = Release|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/File.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/File.cpp new file mode 100644 index 0000000..d770683 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/File.cpp @@ -0,0 +1,51 @@ +#include "stdafx.h" +#include "File.h" + +bool Files::ReadFile(const CString& _fileName, CString& _content) { + _content.Empty(); + + try { + CFile f(_fileName, CFile::modeRead); + + size_t nBytes = (UINT)f.GetLength(); + size_t nChars = nBytes / sizeof(TCHAR); + + //ļȡƵ + nBytes = f.Read(_content.GetBuffer(nChars), nBytes); + + _content.ReleaseBuffer(nChars); + + } + catch (CFileException* e) { + e->ReportError(); + e->Delete(); + return false; + } + + return true; +} + +void Files::WriteFile(const CString& _fileName, CString& _content) { + try { + CFile f(_fileName, CFile::modeWrite | CFile::modeCreate); + f.Write(_content, _content.GetLength()*sizeof(TCHAR)); + } + catch (CFileException* e) { + e->ReportError(); + e->Delete(); + } +} + +bool Files::WriteAllBytes(const CString& _name, const void* _b, size_t _len, CString* _path) { + try { + CFile f(_name, CFile::modeCreate | CFile::modeWrite); + f.Write(_b, _len); + + if (_path != nullptr) + *_path = f.GetFilePath(); + } catch (CException* e) { + e->ReportError(); + e->Delete(); + } + return true; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/File.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/File.h new file mode 100644 index 0000000..dd42012 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/File.h @@ -0,0 +1,11 @@ +#ifndef File_h__ +#define File_h__ + +class Files { +public: + static bool ReadFile(const CString& _fileName, CString& _content); + static void WriteFile(const CString& _fileName, CString& _content); + static bool WriteAllBytes(const CString& _name, const void* _b, size_t _len, CString* _path); +}; + +#endif // File_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/ReadMe.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/ReadMe.txt new file mode 100644 index 0000000..6aa74a7 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/ReadMe.txt @@ -0,0 +1,38 @@ +======================================================================== +̨ӦóSimpleUCI Ŀ +======================================================================== + +ӦóΪ˴ SimpleUCI Ӧó + +ļҪ SimpleUCI Ӧóÿļݡ + + +SimpleUCI.vcproj +ʹӦóɵ VC++ ĿĿļ +ɸļ Visual C++ İ汾ϢԼйʹӦóѡƽ̨úĿܵϢ + +SimpleUCI.cpp +ӦóԴļ + +///////////////////////////////////////////////////////////////////////////// +Ӧó򵼴Դ + +SimpleUCI.rc +dzʹõ Microsoft Windows Դб RES Ŀ¼д洢ͼꡢλͼ͹ꡣļֱ Microsoft Visual C++ нб༭ + +Resource.h +DZ׼ͷļµԴ ID +Microsoft Visual C++ ȡ´ļ + +///////////////////////////////////////////////////////////////////////////// +׼ļ + +StdAfx.h, StdAfx.cpp +ЩļΪ SimpleUCI.pch Ԥͷ (PCH) ļΪ StdAfx.obj Ԥļ + +///////////////////////////////////////////////////////////////////////////// +עͣ + +ӦóʹáTODO:ָʾӦӻԶԴ벿֡ + +///////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/Resource.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/Resource.h new file mode 100644 index 0000000..5f9ceff --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/Resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by SimpleUCI.rc +// + +#define IDS_APP_TITLE 103 + +// ¶һĬֵ +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.cpp new file mode 100644 index 0000000..9484efb --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.cpp @@ -0,0 +1,41 @@ +// SimpleUCI.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" +#include "SimpleUCI.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// ΨһӦó + +CWinApp theApp; + +using namespace std; + +int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) +{ + int nRetCode = 0; + + setlocale(LC_ALL, "CHS"); + + // ʼ MFC ʧʱʾ + if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) + { + // TODO: ĴԷҪ + _tprintf(_T(": MFC ʼʧ\n")); + nRetCode = 1; + } + else + { + // TODO: ڴ˴ΪӦóΪд롣 + + _main(); + + system("pause"); + } + + return nRetCode; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.h new file mode 100644 index 0000000..7b8372e --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.h @@ -0,0 +1,5 @@ +#pragma once + +#include "resource.h" + +void _main(); \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.rc b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.rc new file mode 100644 index 0000000..e4a7199 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.rc @@ -0,0 +1,69 @@ +//Microsoft Visual C++ ɵԴű +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE 2 Դɡ +// +#include "afxres.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +LANGUAGE 4, 2 +#pragma code_page(936) + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// ַ +// + +STRINGTABLE +BEGIN + IDS_APP_TITLE "SimpleUCI" +END + +#endif +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE 3 Դɡ +// +#ifndef _AFXDLL +#include "afxres.rc" +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // APSTUDIO_INVOKED diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.sln b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.sln new file mode 100644 index 0000000..140539b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleUCI", "SimpleUCI.vcxproj", "{DA6758AD-C0D6-46D3-813B-4E83712CA7A1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Debug|Win32.Build.0 = Debug|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Release|Win32.ActiveCfg = Release|Win32 + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcproj b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcproj new file mode 100644 index 0000000..5b80dc3 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcproj @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcxproj b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcxproj new file mode 100644 index 0000000..f9d7764 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcxproj @@ -0,0 +1,117 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {DA6758AD-C0D6-46D3-813B-4E83712CA7A1} + SimpleUCI + Win32Proj + + + + Application + v120 + Dynamic + Static + Unicode + true + + + Application + v120 + Dynamic + Static + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>12.0.30501.0 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + + + + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + EditAndContinue + + + true + Console + MachineX86 + + + + + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + Use + Level3 + ProgramDatabase + + + true + Console + true + true + MachineX86 + + + + + + + Create + Create + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcxproj.filters b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcxproj.filters new file mode 100644 index 0000000..8a33c26 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/SimpleUCI.vcxproj.filters @@ -0,0 +1,62 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 资源文件 + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/UpgradeLog.htm b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/UpgradeLog.htm new file mode 100644 index 0000000..d478f13 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/UpgradeLog.htm differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/_main.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/_main.cpp new file mode 100644 index 0000000..05be8ba --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/_main.cpp @@ -0,0 +1,105 @@ +#include "stdafx.h" +#include "SimpleUCI.h" +#include + +#include "uci.h" +#include "dso_base.h" +#include "unit.h" + +#include "uci_cpp.h" + +#pragma comment(lib, "uci.lib") + +using namespace uci; + +int HandleResult(const TCHAR* _msg, int _r) { + if (UCISUCCESS(_r)) { + _tprintf(_T("%s: OK, r = %d;\n"), _msg, _r); + } else { + _tprintf(_T("%s: Error, r = %d; msg = %s\n"), _msg, _r, uci_GetLastError()); + } + return _r; +} + +void ParseParamsMeasure(byte* _data, int _data_len) { + if (_data_len != (sizeof(cb::MeaValue) * EMeaParam::MP_MAX_COUNT)) + return; + + cb::MeaValue* pmv = reinterpret_cast(_data); + + for (size_t i = 0; i < EMeaParam::MP_MAX_COUNT; i++) { + _tprintf(_T("\r\nIsExist=%d,IsValid=%d,Value=%f, Unit(Type=%d,Scale=%d)"), + pmv->IsExist, pmv->IsValid, pmv->Value, pmv->Unit.Type, pmv->Unit.Scale); + + if (pmv->IsExist && pmv->IsValid) + { + printf("- %s%s", unit::uci_UnitFindScaleName(pmv->Unit.Scale), + unit::uci_UnitFindTypeName(pmv->Unit.Type)); + + printf("- ׼λ %f", unit::uci_UnitConvertTo(pmv->Value, pmv->Unit.Scale, unit::SCALE_STD, 1000.0)); + } + + pmv++; + } +} + +namespace dat { + struct MeaUserParams { + char ID; //-1 : ޲ + char CH; //0 ʼͨţ ID == -1 CHЧ + }; + + enum ECH { + CH1, + CH2, + CH3, + CH4, + }; +} +void _main_c(); +void _main_cpp(); + +void _main() { + //_main_c(); + _main_cpp(); +} + +void _main_c() { + u_session session = INVALID_SESSION; + //u_cstring addr = _T("[C:UPO][D:UPO][T:TCPIP][IP:192.168.1.113][Port:0x1388]"); + u_cstring addr = _T("[C:UPO][D:UPO][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x3][CFG:3][I:0]"); + + try { + u_status r = uci_Open(addr, &session, 1000); + if (UCIERR(r)) { + _tprintf(_T(": 豸ʧܣ ַ%s, Ϣ %s\n"), addr, uci_GetLastError()); + throw r; + } + + } catch (u_status r) { + + if (UCIERR(r)) + _tprintf(_T("Ϣ %s\n"), uci_GetLastError()); + } + + if (session != INVALID_SESSION) { + uci_Close(session); + } +} + +void _main_cpp() { + uci::Session ses; + + u_cstring addr = _T("[C:UPO][D:UPO][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x3][CFG:3][I:0]"); + u_status r = ses.Open(addr); + if (UCIERR(r)) { + _tprintf(_T(": 豸ʧܣ ַ%s, Ϣ %s\n"), addr, uci_GetLastError()); + return; + } + + std::vector buf(400, 0); + r = ses.Read(_T("mea:all?;"), 1000, buf.data(), buf.size()); + HandleResult(_T("mea:all?"), r); + if (UCISUCCESS(r)) + ParseParamsMeasure(buf.data(), buf.size()); +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/dso_base.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/dso_base.h new file mode 100644 index 0000000..7801310 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/dso_base.h @@ -0,0 +1,171 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩUCIӿʹõģDSOͨö塣 + */ +#ifndef dso_base_h__ +#define dso_base_h__ + +#ifdef __cplusplus +namespace comAPICommon { +#endif + //ʱλлһ£˲ͬıԵ +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + TLEVEL_1NS = 0, + TLEVEL_2NS, + TLEVEL_5NS, + TLEVEL_10NS, + TLEVEL_20NS, + TLEVEL_50NS, + TLEVEL_100NS, + TLEVEL_200NS, + TLEVEL_500NS, + TLEVEL_1US, + TLEVEL_2US, + TLEVEL_5US, + TLEVEL_10US, + TLEVEL_20US, + TLEVEL_50US, + TLEVEL_100US, + TLEVEL_200US, + TLEVEL_500US, + TLEVEL_1MS, + TLEVEL_2MS, + TLEVEL_5MS, + TLEVEL_10MS, + TLEVEL_20MS, + TLEVEL_50MS, + TLEVEL_100MS, + TLEVEL_200MS, + TLEVEL_500MS, + TLEVEL_1S, + TLEVEL_2S, + TLEVEL_5S, + TLEVEL_10S, + TLEVEL_20S, + TLEVEL_50S, + TLEVEL_100S, + TLEVEL_200S, + }E_TIMEBASE_LEVEL; + +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + VLEVEL_1MV = 0, + VLEVEL_2MV, + VLEVEL_5MV, + + VLEVEL_10MV, + VLEVEL_20MV, + VLEVEL_50MV, + + VLEVEL_100MV, + VLEVEL_200MV, + VLEVEL_500MV, + + VLEVEL_1V, + VLEVEL_2V, + VLEVEL_5V, + + VLEVEL_10V, + VLEVEL_20V, + } E_VOLTAGEBASE_LEVEL; + + typedef struct _measure_param { + float value; + int unit; + }MeasureParam; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + + typedef struct _UnitParam { + char Type; //λͣTimeFreqȡ嶨ĵ + char Scale; //knpMȡ嶨ĵ + }UnitParam; + + //@brief : ֵ + //@remark: 4Byte align -> 8Bytes + typedef struct _MeaValue { + float Value; + UnitParam Unit; + char IsValid; //ǷЧ 0 ʾЧ 1ʾЧ + char IsExist; //Ƿڡ 0 ʾڣ 1ʾڡ + }MeaValue; + + //@brief : ݰͨö塣 + //@remark: + typedef enum _EMeaParam { + MP_MAX = 0, //ֵ + MP_MIN, //Сֵ + MP_HIGH, //High(Top)-ߵƽ(ֵ) + MP_MIDDLE, //Middle-мֵ + MP_LOW, //Low(Bottom) - ͵ƽ(׶ֵ) + + MP_PKPK, //VPP-ֵ + MP_AMP, //Сֵ + MP_MEAN, //ƽֵ + MP_CYCMEAN, // + MP_RMS, // + + MP_CYCRMS, //ھֵ + MP_AREA, // + MP_CYCAREA, // + MP_OVERSHOOT,// + MP_PRESHOOT, //Ԥ + + MP_PERIOD, // + MP_FREQ, //Ƶ + MP_RISE_TIME,//ʱ + MP_FALL_TIME,//½ʱ + MP_PWIDTH, // + + MP_NWIDTH, // + MP_PDUTY, //ռձ + MP_NDUTY, //ռձ + MP_RISEDELAY,//ʱ + MP_FALLDELAY,//ʱ + + MP_PHASE, //λ + MP_FRR, // + MP_FRF, + MP_FFR, + MP_FFF, + + MP_LRF, + MP_LRR, + MP_LFR, + MP_LFF, + + MP_BURST_WIDTH, //ͻ + + // + //reserve section + // ²׷ + // + // + //̶λ50 + MP_MAX_COUNT = 50, + }EMeaParam; + +#ifdef __cplusplus + } + namespace uci { + using namespace comAPICommon; + namespace cb = comAPICommon;//comAPICommon alias + } +#endif + +#endif // dso_base_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/lib b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/lib new file mode 100644 index 0000000..e182c40 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/stdafx.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/stdafx.cpp new file mode 100644 index 0000000..85f1b3a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// SimpleUCI.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/stdafx.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/stdafx.h new file mode 100644 index 0000000..77b14b0 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/stdafx.h @@ -0,0 +1,53 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +// 뽫λָƽ̨֮ǰƽ̨ΪĿ꣬޸ж塣 +// йزͬƽ̨ӦֵϢο MSDN +#ifndef WINVER // ʹض Windows XP ߰汾Ĺܡ +#define WINVER 0x0501 // ֵΪӦֵ Windows 汾 +#endif + +#ifndef _WIN32_WINNT // ʹض Windows XP ߰汾Ĺܡ +#define _WIN32_WINNT 0x0501 // ֵΪӦֵ Windows 汾 +#endif + +#ifndef _WIN32_WINDOWS // ʹض Windows 98 ߰汾Ĺܡ +#define _WIN32_WINDOWS 0x0410 // ֵΪʵֵָ Windows Me ߰汾ΪĿꡣ +#endif + +#ifndef _WIN32_IE // ʹض IE 6.0 ߰汾Ĺܡ +#define _WIN32_IE 0x0600 // ֵΪӦֵ IE 汾 +#endif + +#define WIN32_LEAN_AND_MEAN // Windows ͷųʹõ +#include +#include +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Windows ͷųʹõ +#endif + +#include +#include // MFC ͱ׼ +#include // MFC չ +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC Internet Explorer 4 ؼ֧ +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC Windows ؼ֧ +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include + + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +#include +#include + +// TODO: ڴ˴óҪͷļ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci.h new file mode 100644 index 0000000..5b81cf5 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci.h @@ -0,0 +1,218 @@ +/******************************************************************** + created: 2014/12/22 + author: M.Yang + purpose: UCI(united communicate interface) +*********************************************************************/ + +#ifndef uci_h__ +#define uci_h__ + +#include "ucidef.h" + +////////////////////////////////////////////////////////////////////////// +// ڽӿڷص״ֵ̬ +// < 0 : ʾ +// ӦĴϢͨuci_GetLastErrorȡ,Ķucidef.hļС +// < UCI_ERRĴΪlibusbĴ롣 +////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +namespace uci { +extern "C"{ +#endif + //@brief : ִỰ޹صIJѯ + //@param PRParams _params : ѯIJ + //@param u_byte * _data : ݵĻַ + //@param u_size _dataCount : ݵĻСBytes + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_Query(_in_out PRParams _params, _in_out u_byte* _data, _in u_size _dataCount); + + //@brief : ѯͨŽڵ + //@param _in const QParams * _params : ѯ + //@param _out Node * _outBuf : ŲѯĽڵ + //@param _in_out u_size * _nodeCnt : ΪҪȡĽڵΪʵʶȡĽڵ + //@param _in u_size _timeOut : ѯʱ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_QueryNodes(_in const QParams* _params, _out Node* _outBuf, + _in_out u_size* _nodeCnt, _in u_size _timeOut); + + //@brief : ѯͨŽڵ + //@param _msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _nodes : ŲѯĽڵ + //@param _node_count : ҪѯĽڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX(u_cstring _msg, Node* _nodes, u_size _node_count, _in u_size _timeout); + + //@brief : 豸 + //@param u_cstring _addr : 豸ַ '\0'β + //@param u_session * _session : ѽĻỰID. + //@param u_uint32 _timeOut : ӳʱʱ ms + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + // UCI_SUCCESS + // UCI_ERR_ARGS_WRONG; + // UCI_ERR_RES_INIT_ERROR; + // UCI_ERR_CONNECT_ADDR_WRONG; + // UCI_ERR_CONNECT_FAILED; + // UCI_ERR_CONNECT_TIMEOUT] + //@remarks : ĵ + u_status _UCIAPI uci_Open(u_cstring _addr, u_session* _session, u_uint32 _timeOut); + + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 + u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + //@brief : ִ + //@param u_session _session : ỰID + //@param PCommandParams _params : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SendCommand(u_session _session, PCommandParams _params); + + //@brief : UCI¼ + //@param uciNotify _pNotify : ӦUCI¼Ļص + //@return u_status _UCIAPI : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SetNotify(UCIMSGProc _pNotify); + + //@brief : + //@param _msg : ַ + //@param _obj : ݻַ + //@param _objSize : ݻС + //@return : 鿴ļеġڽӿڷص״ֵ̬˵s + //@remarks : Ŀǰֻ֧л԰汾Ͷ豸ͷĵ¼鿴ĵ + u_status _UCIAPI uci_SetAttribute(u_session _sesn, u_cstring _msg, const u_object* _obj, u_size _objSize); + + //@brief : ѯ + //@param u_session _sesn : + //@param u_attr _name : + //@param u_attr_v * _value : + //@return u_status _UCIAPI : + //@remarks : + u_status _UCIAPI uci_GetAttribute(u_session _sesn, u_cstring _msg, u_object* _obj, u_size _objSize); + + //@brief : д + //@param u_session _session : ỰID + //@param PWParam _params : д + //@param const u_byte * _data : Ҫдݻַ ΪNULL + //@param u_size _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_params.CMDStringѾҪдֶˣʹuci_FormatWriteӿڣ + // _data != NULLַ_params.CMDStringֻܰһ䡣 + u_status _UCIAPI uci_Write(u_session _session, PWParams _params, const u_byte* _data, u_size _len); + + //@brief : д + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@param _data : Ҫдݻַ ΪNULL + //@param _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_msgѾҪдֶˣ + // _data != NULLַ_msgֻܰһ䡣 + u_status _UCIAPI uci_WriteX(u_session _session, u_cstring _msg, + u_uint32 _timeout, const u_byte* _data, u_size _len); + + //@brief : ֻдַָдָӿ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteSimple(u_session _session, u_cstring _msg, u_uint32 _timeout); + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + //@brief : ȡ + //@param u_session _session : ỰID + //@param PRParams _params : + //@param u_byte * _data : ݵĻ + //@param u_size _dataLen : ݵĻССЭ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ʹuci_ReadX汾 + u_status _UCIAPI uci_Read(u_session _session, PRParams _params, u_byte* _data, u_size _dataLen); + + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 + u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, + u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + //@brief : дļ + //@param u_session _session : ỰID + //@param WFileParams * _info : ļϢ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteFromFile(u_session _session, WFileParams* _info); + + //@brief : дļ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : Ҫдļ·ļ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_WriteFromFileļ򻯰汾 + u_status _UCIAPI uci_WriteFromFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout); + + //@brief : Read data synchronously and store the transferred data in a file. + //@param u_session _session : ỰID + //@param RFileParams _params : Ҫݵļ· + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_ReadToFile(u_session _session, RFileParams* _params); + + //@brief : ȡļ + //@param _session : ỰID. + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : ݵش̵ļ·ļͺ׺ + //Ǿ·Ҳ··ͨ_filePathFinalȡ· + //@param _timeout : ʱ + //@param _filePathFinal : 嵽صļľ· + //@param _filePathFinalLength : _filePathFinalijȣַ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_ReadToFileķǷװ汾 + u_status _UCIAPI uci_ReadToFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength); + + //@brief : رջỰ + //@param u_session _session : ҪرյĻỰID + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + u_status _UCIAPI uci_Close(u_session _session); + + //@brief : һβӦĴ״̬Ϣ + //@return u_cstring : Ϣ + //@remarks : ͨuci_SetAttributeôϢ԰汾 + u_cstring _UCIAPI uci_GetLastError(void); + + //@brief : ˳UCIʵʱá + //@remarks : ˳ʱãͷڲԴ + // ӿڲһҪʹá ֻ.NETйܻ£ + // ͨuci_SetAttribute uci_SetNotifyӿ + // 豸Ƴ¼ʱ˳ʱʹá + void _UCIAPI uci_ExInstance(); +#ifdef __cplusplus +} + +} +#endif +#endif // uci_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci.lib b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci.lib new file mode 100644 index 0000000..75a99f2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci_cpp.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci_cpp.h new file mode 100644 index 0000000..79751d8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/uci_cpp.h @@ -0,0 +1,60 @@ +/*! + * \created : 2017/3/17 + * \author : M.Yang + * \purpose : ṩUCIC++汾ӿ + */ +#ifndef uci_cpp_h__ +#define uci_cpp_h__ +#include "uci.h" + +namespace uci { + class Session; +} + +//@brief : UCI Ự +//@remark: uci_ǰ׺CԹ淶Ľӿ򵥷װĺôǣ +// 1SessionʱԶرջỰǣʹõʹʱעʹ߼Ǵ߼ +// 2ÿһӿϣʡȥһSession IDΣҿ趨βεĬֵijЩCԱ֧֣ʹýӿڸ򵥣 +// ע⣺ +// ಻ȫӿڵ䣬Ҫ䡣 +class uci::Session { +public: + Session() : m_Session(INVALID_SESSION) {} + virtual ~Session() { + if (m_Session != INVALID_SESSION) { + uci_Close(m_Session); + m_Session = INVALID_SESSION; + } + } + + u_status Open(u_cstring _addr, u_uint32 _timeout = 2000) { + u_status r = uci_OpenX(_addr, _timeout); + if (UCISUCCESS(r)) + m_Session = (u_session)r; + return r; + } + + u_status Write(u_cstring _msg,u_uint32 _timeout = 1000, const u_byte* _data = NULL, u_size _len = 0) { + return uci_WriteX(m_Session, _msg, _timeout, _data, _len); + } + + u_status Read(u_cstring _msg,u_uint32 _timeout, u_byte* _data, u_size _dataLen) { + return uci_ReadX(m_Session, _msg, _timeout, _data, _dataLen); + } + + u_status WriteFromFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout) { + return uci_WriteFromFileX(m_Session, _msg, _filePath, _timeout); + } + + u_status ReadToFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength) { + return uci_ReadToFileX(m_Session, _msg, _filePath, _timeout, _filePathFinal, _filePathFinalLength); + } + + u_status Close() { return uci_Close(m_Session); } + u_session GetSession() const { return m_Session; } +protected: + u_session m_Session; +}; + +#endif // uci_cpp_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/ucidef.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/ucidef.h new file mode 100644 index 0000000..5da7c68 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/ucidef.h @@ -0,0 +1,561 @@ +/******************************************************************** + created: 2014/12/23 + author: M.Yang + purpose: UCIȫֶļ + modify: + *********************************************************************/ +#ifndef ucidef_h__ +#define ucidef_h__ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +#define _UCIAPI __stdcall +#define _UCICallBack __stdcall +#endif + +#define _in +#define _out +#define _in_out + +#ifdef __cplusplus +namespace uci { +#endif // __cplusplus + +#ifdef _CVI_ +#define u_inline static +#else +#define u_inline inline +#endif // _CVI_ + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif // !MAX_PATH + + ////////////////////////////////////////////////////////////////////////// + //{ Ͷ +#ifdef _UNICODE + //@brief : ʾһ Unicode ַ +#define u_tchar wchar_t +#else + //@brief : ʾһ ASCII ַ +#define u_tchar char +#endif // _UNICODE + +#if defined(_WIN64) + typedef unsigned __int64 u_unit_ptr; + typedef __int64 u_long_ptr; +#else + typedef unsigned int u_unit_ptr; + typedef long u_long_ptr; +#endif + + //@brief : Boolean +#define u_bool bool + //@brief : 8λ޷ +#define u_byte unsigned char + //@brief : 8λз +#define u_char char + //@brief : ָ͵Ļָ +#define u_buf void* + //@brief : ͵ij +#define u_object void + //@brief : ʾ 16 λз +#define u_short short + //@brief : ʾ 16 λ޷ +#define u_ushort unsigned short + //@brief : ʾ 16 λз +#define u_int16 u_short + //@brief : ʾ 16 λ޷ +#define u_uint16 u_ushort + //@brief : ʾ 32 λз +#define u_int32 int + //@brief : ʾ 32 λ޷ +#define u_uint32 unsigned int + //@brief : ʾUCIӿڷص״ֵ̬(32λз) +#define u_status u_int32 + //@brief : ʾС32λ޷ +#define u_size u_uint32 + //@brief : ʾỰID32λ޷ +#define u_session u_uint32 + //@brief : ʾַ +#define u_string u_tchar* + //@brief : ʾַֻ +#define u_cstring const u_tchar* + //@brief : ʾIDͣ32λ޷ +#define u_attr u_int32 + //@brief : ʾֵͣ32λ޷ +#define u_attr_v u_int32 + //@brief : ʾһ16λ޷͵ĵ +#define u_word u_ushort + //@brief : ʾһ32λ޷͵˫ +#define u_dword u_uint32 + //@brief : Ϣ +#define u_wparam u_unit_ptr + //@brief : Ϣ +#define u_lparam u_long_ptr + //} + + ////////////////////////////////////////////////////////////////////////// + //{ ӿڷ״ֵ̬ + //@brief : ɹ +#define UCI_SUCCESS (0) + //@brief : ʼֵ +#define UCI_ERR (-1000) + //@brief : жϵǰӿǷִʧ + //@brief : жϵǰӿǷִгɹ +#define UCIERR(r) (r < 0) +#define UCISUCCESS(r) (!UCIERR(r)) + + //@brief : + typedef enum _UCIErr { + NoError = 0, + + //@brief : Դʼ + InitResourceError = UCI_ERR - 20, + //@brief : ЧĻỰ + Invalid_Session, + //@brief : ʱ + Timeout, + //@brief : ʧ + Failed, + //@brief : ֵ֧IJ + Unsupported, + //@brief : ڴռ䲻 + Insufficient_Memory, + //@brief : ϵͳæ޷Ӧ + Busy, + //@brief : ͨ쳣棡 + COMExpection, + //@brief : ͨδ򿪣 + ChannelNotOpened, + + //@brief : δ֪Ĵ + Unknown = UCI_ERR - 40 - 1, + + //@brief : ӵַַʽ + Connect_InvalidAddress = UCI_ERR - 40, + //@brief : ӻδ + Connect_NotBuild, + //@brief : ѶϿ + Connect_Break, + //@brief : ֵ֧ͨŷʽ + Connect_Unsupported_COMType, + + //@brief : δָ豸 + Device_NoFound = UCI_ERR - 60, + //@brief : ֵ֧豸 + Device_Unsupported, + //@brief : Ҫִвѯ豸IJ + Device_QueryFirst, + //@brief : Ͳƥ + Device_NotMatch, + + //@brief : ѯ豸ʧ + Query_LANNodesFailed, + + //@brief : USB豸ִַֻвѯ豸Ч + //@remarks : UCI⵼USB豸ַֻһб豸ַ + AddrValid_AfterQueryDeviceOper, + + //@brief : δU̽ + UDisk_NotFound, + //@brief : Ѿ + Key_Locked, + + //@brief : ַʽ + CMD_Invalid_StringFormat = UCI_ERR - 80, + //@brief : ֵֻ֧ + CMD_OnlySupportSingle, + //@brief : һֻ֧һ + CMD_OnlySupportSingleAttr, + //@brief : ֵ֧ + CMD_Unsupported, + //@brief : ʧ + CMD_SendFailed, + //@brief : Эݸʽ + CMD_Invalid_ProtocolFormat, + //@brief : 豸дļflashʧܣ + CMD_WriteFileToFlash_Failed, + //@brief : δЧĻظ + CMD_NoFound_Valid_Reply_Data, + //@brief : Ϣ鿴ǷЭ + CMD_Error_Message, + //@brief : Чıʽ + CMD_Invalid_Expression, + + //@brief : + Args_Invalid = UCI_ERR - 100, + //@brief : ṩĿռ̫С + Args_MemoryTooSmall, + //@brief : ṩļ̫(50ֽ) + Args_FileNameTooLong, + //@brief : ݴСЭ鲻ƥ(ֹݴ) + Args_DataLenNotMatch, + + //@brief : + Data_Overflow = UCI_ERR - 120, + //@brief : Χ + Data_OutRange, + //@brief : δȫȡ + Data_NotReadEnoughLenth, + //@brief : Уʧ + Data_ECC_Failed, + //@brief : Ч + Data_Invalid, + //@brief : ѹʧ + Data_Zip_Error, + //@brief : ݽѹʧ + Data_UnZip_Error, + //@brief : ݴʧ + Data_Transfer_Error, + //@brief : ݴʧ + Data_Transfer_Break, + //@brief : Чݿɶȡ + Data_No_Data_Incoming, + + //@brief : + File_AccessDenied = UCI_ERR - 140, + //@brief : An unspecified error occurred. + File_GenericException, + //@brief : The file could not be located. + File_NotFound, + //@brief : All or part of the path is invalid. + File_BadPath, + //@brief : The permitted number of open files was exceeded. + File_TooManyOpenFiles, + //@brief : There was an attempt to use an invalid file handle + // or The file format is unsupported! + // or The file data is error! + File_InvalidFile, + //@brief : The current working directory cannot be removed + File_RemoveCurrentDir, + //@brief : There are no more directory entries + File_DirectoryFull, + //@brief : There was an error trying to set the file pointer + File_BadSeek, + //@brief : There was a hardware error + File_HardIO, + //@brief : SHARE.EXE was not loaded, or a shared region was locked + File_SharingViolation, + //@brief : There was an attempt to lock a region that was already locked + File_LockViolation, + //@brief : The disk is full + File_DiskFull, + //@brief : The end of file was reached + File_EndOfFile, + //@brief : дļʧ + File_SaveToDiskFailed, + }UErr; + //} + ////////////////////////////////////////////////////////////////////////// + + //@brief : ĻỰID +#define INVALID_SESSION ((u_uint32)(-1)) + + ////////////////////////////////////////////////////////////////////////// + //{ + //лӢģ "lang:zh-hans" or "lang:en-us" + //ʹUSB豸ƳӼ "devchange:1" +//} + + +#define CACHE_LINE 1 +#define CACHE_ALIGN __declspec(align(CACHE_LINE)) + + //@brief : ýṹĶ뷽ʽ +#define PACK_ALIGN(n) __declspec(align(n)) + + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + + //one Word is 2 bytes + u_inline u_word UCI_HIWORD(u_dword _dw) { return ((u_word)((_dw >> 16) & 0xffff)); } + u_inline u_word UCI_LOWORD(u_dword _dw) { return ((u_word)(_dw & 0xffff)); } + + //#pragma pack(show)// C4810 + //ensure byte-packed structures1ֽڶ룩 +#include //뻷ûиļ滻Ϊǰƽֽ̨ڶ䡣 + + //@brief : ݽӿڵIJ + //@remarks : ͨͨuci_CreateRParamsӿڴ + typedef struct _RParams { + //@brief : ַ'\0'β. ʽЭĵ + u_cstring CMDString; + //@brief : ҪصӾͨҪȡ\ѯǶӦģ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + //@brief : + //@remarks : ͨʹãɿ;ڲѯ豸ʱõ + //ΪQParamsĵΪ׼ + u_buf ExtraData; //reserve + //@brief : ݵij + u_size ExtraDataLen; + }RParams, *PRParams; + +#ifdef __cplusplus + inline RParams* uci_CreateRParams(RParams& _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + _p.ExtraData = _ExtraData; + _p.ExtraDataLen = _ExtraDataLen; + return &_p; + } +#else + u_inline RParams* uci_CreateRParams(RParams* _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + _p->ExtraData = _ExtraData; + _p->ExtraDataLen = _ExtraDataLen; + return _p; + } +#endif + + typedef struct _DeviceIOParams { + u_int32 Count; + u_int32* Data; + }DeviceIOParams; + + typedef struct _QParams { + //@brief : ҪѯͨŽڵ + //@remarks : enum NodeType ȡֵ ͨ־λֵ + //@eg NodeType::USB | NodeType::LAN + u_int32 Type; + //@brief : ˿ڼ˿ + u_int32 PortCount; + //@brief : ˿ڼ + u_int32* Ports; + //@brief : PVIDPVIDĸ + //@remarks : + u_int32 PVIDCount; + //@brief : PID VID + //@remarks : ʹMakePVIDGetPIDGetVIDȡ + u_int32* PVID; + //@brief : ѯַnullptrʱʾѯ豸ѯָ豸豸 + u_cstring Msg; + }QParams, *PQParams;//@brief : ѯ豸ʱò + + u_inline u_int32 MakePVID(u_ushort _pid, u_ushort _vid) { return ((_pid << 16) | (_vid)); }; + + u_inline u_ushort GetPID(u_int32 _pvid) { return UCI_HIWORD(_pvid); } + + u_inline u_ushort GetVID(u_int32 _pvid) { return UCI_LOWORD(_pvid); } + +#ifdef __cplusplus + inline QParams* UCI_CreateQParam(QParams& _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(&_qp, 0, sizeof(_qp)); + _qp.Type = _type; + _qp.Ports = _ports; + _qp.PortCount = _port_cnt; + _qp.PVID = _pvid; + _qp.PVIDCount = _pvid_cnt; + _qp.Msg = _msg; + return &_qp; + } +#else + u_inline QParams* UCI_CreateQParam(QParams* _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(_qp, 0, sizeof(*_qp)); + _qp->Type = _type; + _qp->Ports = _ports; + _qp->PortCount = _port_cnt; + _qp->PVID = _pvid; + _qp->PVIDCount = _pvid_cnt; + _qp->Msg = _msg; + return _qp; + } +#endif + //@brief : дݽӿڲ + //@remarks : ͨӿuci_CreateWParams + typedef struct _WParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : صݣӾ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + }WParams, *PWParams; + +#ifdef __cplusplus + u_inline WParams* uci_CreateWParams(WParams& _p, u_cstring _cmd, u_uint32 _timeout) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + return &_p; + } +#else + u_inline WParams* uci_CreateWParams(WParams* _p, u_cstring _cmd, u_uint32 _timeout) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + return _p; + } +#endif + typedef struct _CommandParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : 1 + u_uint32 Param1; + //@brief : 1 + u_uint32 Param2; + //@brief : ʱ + u_uint32 Timeout; + }CommandParams, *PCommandParams; + + //@brief : дļIJ + typedef struct _WFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : Ҫдļ·ļ + u_cstring FilePath; + //@brief : дʱ(λms) + u_uint32 Timeout; + }WFileParams, *PWFileParams; + + //@brief : ļӿڵIJ + typedef struct _RFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : ݵش̵ļ·ļͺ׺ + u_cstring FilePath; + //@brief : ʱ(λms) + u_uint32 Timeout; + //@brief : ļ· + u_tchar FilePathFinal[MAX_PATH]; + }RFileParams, *PRFileParams; + + //@brief : ͨŽڵ + //@remarks : QParamsǰλ룬Nodeȡenumֵ + typedef enum _NodeType{ + LAN = 0x0001, + USB = 0x0010, + }NodeType; + + //@brief : USB豸 + //@remarks : + typedef struct _USBDescriptor { + //@brief : PID + u_ushort PID; + //@brief : VID + u_ushort VID; + //@brief : ַ + u_ushort Addr; + }USBDescriptor; + + //@brief : IPַ + //@remarks : ˳Ϊ f1(192).f2(168).f3(1).f4(253) - Сģʽ + typedef union _IPAddr { + struct { u_byte f1, f2, f3, f4; } Field; + u_int32 Addr; + }u_IPAddr; + + //@brief : LANͨŵ豸 + //@remarks : + typedef struct _LANDescriptor { + //@brief : IPַַͣ + u_tchar IP[16]; + //@brief : IPַ + u_IPAddr Addr; + //@brief : ˿ + //@remarks : TCPIPõĶ˿ں + u_ushort Port; + }LANDescriptor; + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _Node { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµƣ + // ѳδͳһʱUCIڲԶƥΪUCIЭõ֣ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }Node, *PNode; + + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _NodeEx { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµơ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }NodeEx, *PNodeEx; + + typedef struct _UCIMSG { + u_session Session; + u_uint32 Message; + u_wparam wParams; + u_lparam lParams; + u_byte Reserved[240]; + }UCIMSG;//256Bytes + + ////////////////////////////////////////////////////////////////////////// + typedef enum _uci_msg { + UMSG_CONNECT_CLOSED = 1, + //@brief : ļϢ + //@remarks : + // wParams ֡ + // lParams ֡ -1 ʼ䣻 [0,wParams)У wParams + //-> UCIMSGProc return -1 ʾжϴ. + UMSG_FILE_TRANSFER = 2, + //@brief : USBϢ + //@remarks : + // wParams : ʹõ16λУ8λΪpid8λΪvid + // lParams : ¼ͣ Ƴ = 0 = 1 + UMSG_DEVICE_NOTIFY = 3, + }EUCIMSG; + + typedef int(__stdcall *UCIMSGProc)(UCIMSG* _msg); +#include + +#ifdef __cplusplus + } +#endif//__cplusplus + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ucidef_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/unit.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/unit.h new file mode 100644 index 0000000..da0fc1f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/SimpleUCI/unit.h @@ -0,0 +1,117 @@ +/*! +* \created : 2016/10/10 +* \author : M.Yang +* \purpose : ṩλı׼ +* \remarks : еλĶ嶼Ա׼λΪ0Сڱ׼λΪݼڱ׼λʱΪ +* ĺôǣԱ֤Ա׼λΪ׼չ +*/ + +#ifndef Unit_h__ +#define Unit_h__ + +#ifdef __cplusplus +namespace unit { + extern "C"{ +#endif +#ifdef __cplusplus + typedef enum _EScale : char { +#else + typedef enum _EScale { +#endif // DEBUG + SCALE_p = -4, + SCALE_n, + SCALE_u, + SCALE_m, + SCALE_STD = 0, + SCALE_K, + SCALE_M, + SCALE_G, + SCALE_T, + }EScale; + +#ifdef __cplusplus + typedef enum _EType : char{ +#else + typedef enum _EType { +#endif // __cplusplus + TYPE_INVALID = -1, + TYPE_FREQ, + TYPE_TIME, + TYPE_AREA, //(Vs) + TYPE_SAMPLERATE,//ʣSa/s + TYPE_POINT, //Sa + TYPE_VPP, //ֵ + TYPE_VOLTAGE,//ѹ + TYPE_CURRENT,// + TYPE_DB, //DB + TYPE_VV, // + TYPE_PERCENT,//ٷֱ + TYPE_DEGREE, // + TYPE_WATT, //أ + TYPE_UNKNOWN,// δ֪λ + }EType; + + typedef struct _CodeName { + char Code; + char Name[5]; + }CodeName; + + static const CodeName ScaleTabel[] = { + { SCALE_p, "p" }, + { SCALE_n, "n" }, + { SCALE_u, "u" }, + { SCALE_m, "m" }, + { SCALE_STD,"" }, + { SCALE_K, "K" }, + { SCALE_M, "M" }, + { SCALE_G, "G" }, + { SCALE_T, "T" } + }; + + static const CodeName TypeTabel[] = { + { TYPE_FREQ, "Hz" }, + { TYPE_TIME, "s" }, + { TYPE_AREA, "Vs" }, + { TYPE_SAMPLERATE, "Sa/s" }, + { TYPE_POINT, "Sa" }, + { TYPE_VPP, "Vpp" }, + { TYPE_VOLTAGE, "V" }, + { TYPE_CURRENT, "A" }, + { TYPE_DB, "dB" }, + { TYPE_VV, "VV" }, + { TYPE_PERCENT, "%" }, + { TYPE_DEGREE, "" }, + { TYPE_WATT, "W" }, + { TYPE_UNKNOWN, "U" }, + }; + + const char* _UCIAPI uci_UnitFindTypeName(char _code); + + const char* _UCIAPI uci_UnitFindScaleName(char _code); + //@brief : ǰλֵתָĵλ + //@param _cur_value : ǰֵ + //@param _cur_unit : ǰλ + //@param _des_unit : Ҫתĵλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@return : תֵ2.3KHz תΪHz2300Hz + //@remarks : עⵥλEScaleģ + double _UCIAPI uci_UnitConvertTo(double _cur_value, int _cur_unit, int _des_unit, double _scale); + + typedef struct _UVale { + double Value; + long long Unit; + }UVale; + + //@brief : ǰλֵԶתʵĵλͣʹֵСڽơ2300Hzת2.3KHzs + //@param _value : ǰֵ + //@param _unit : ǰλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@remarks : עⵥλEScaleģ + UVale _UCIAPI uci_UnitRefresh(double _value, char _unit, double _scale); + +#ifdef __cplusplus + } +} +#endif + +#endif // Unit_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode.rar b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode.rar new file mode 100644 index 0000000..cdda743 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode.rar differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220104_10-2-15.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220104_10-2-15.txt new file mode 100644 index 0000000..a879a48 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220104_10-2-15.txt differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220225_17-5-7.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220225_17-5-7.txt new file mode 100644 index 0000000..f619c22 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220225_17-5-7.txt differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220308_18-14-53.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220308_18-14-53.txt new file mode 100644 index 0000000..7cd1df4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220308_18-14-53.txt differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220517_14-52-31.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220517_14-52-31.txt new file mode 100644 index 0000000..7ef22d9 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220517_14-52-31.txt differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220517_15-25-48.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220517_15-25-48.txt new file mode 100644 index 0000000..3c4212e Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220517_15-25-48.txt differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220520_10-47-19.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220520_10-47-19.txt new file mode 100644 index 0000000..e982126 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220520_10-47-19.txt differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220520_10-48-0.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220520_10-48-0.txt new file mode 100644 index 0000000..57cb140 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/LOG_20220520_10-48-0.txt differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/RData.dat b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/RData.dat new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/RData.dat differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/UCI_DEMO.exe b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/UCI_DEMO.exe new file mode 100644 index 0000000..0bdd5dd Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/UCI_DEMO.exe differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/cmd.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/cmd.txt new file mode 100644 index 0000000..4e418c7 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/cmd.txt @@ -0,0 +1,21 @@ +wp@CH:0@addr:9@v:60; +wp@CH:0@addr:9@v:60000000; +wp@CH:0@addr:9@v:60000000000000; +wp@CH:0@addr:9@v:10000000000000; +wp@CH:0@addr:0x8008@v:7; +wp@CH:0@addr:0x8008@v:8; +wp@CH:0@addr:0x8008@v:9; +KEY:Menu; +KEY:AF2; +wp@CH:0@addr:0x8009@v:2; +wp@CH:0@addr:0x8001@v:1; +wp@CH:0@addr:0x8008@v:3; +wp@CH:0@addr:0x8008@v:5; +wp@CH:0@addr:0x8008@v:6; +wp@CH:0@addr:0x8009@v:2000; +wp@CH:0@addr:0x8008@v:2; +wp@CH:0@addr:0x8008@v:4; +wp@CH:0@addr:0x8001@v:0; +wp@CH:0@addr:0x800A@v:1000; +wp@CH:0@addr:0x8008@v:0; +wp@CH:0@addr:0x8008@v:1; diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/uci.dll b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/uci.dll new file mode 100644 index 0000000..17dac6f Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDEMO/Unicode/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/File.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/File.cpp new file mode 100644 index 0000000..d770683 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/File.cpp @@ -0,0 +1,51 @@ +#include "stdafx.h" +#include "File.h" + +bool Files::ReadFile(const CString& _fileName, CString& _content) { + _content.Empty(); + + try { + CFile f(_fileName, CFile::modeRead); + + size_t nBytes = (UINT)f.GetLength(); + size_t nChars = nBytes / sizeof(TCHAR); + + //ļȡƵ + nBytes = f.Read(_content.GetBuffer(nChars), nBytes); + + _content.ReleaseBuffer(nChars); + + } + catch (CFileException* e) { + e->ReportError(); + e->Delete(); + return false; + } + + return true; +} + +void Files::WriteFile(const CString& _fileName, CString& _content) { + try { + CFile f(_fileName, CFile::modeWrite | CFile::modeCreate); + f.Write(_content, _content.GetLength()*sizeof(TCHAR)); + } + catch (CFileException* e) { + e->ReportError(); + e->Delete(); + } +} + +bool Files::WriteAllBytes(const CString& _name, const void* _b, size_t _len, CString* _path) { + try { + CFile f(_name, CFile::modeCreate | CFile::modeWrite); + f.Write(_b, _len); + + if (_path != nullptr) + *_path = f.GetFilePath(); + } catch (CException* e) { + e->ReportError(); + e->Delete(); + } + return true; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/File.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/File.h new file mode 100644 index 0000000..dd42012 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/File.h @@ -0,0 +1,11 @@ +#ifndef File_h__ +#define File_h__ + +class Files { +public: + static bool ReadFile(const CString& _fileName, CString& _content); + static void WriteFile(const CString& _fileName, CString& _content); + static bool WriteAllBytes(const CString& _name, const void* _b, size_t _len, CString* _path); +}; + +#endif // File_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.aps b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.aps new file mode 100644 index 0000000..14a30f5 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.aps differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.cpp new file mode 100644 index 0000000..4c03028 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.cpp @@ -0,0 +1,139 @@ + +// UCIDemoProj.cpp : ӦóΪ +// + +#include "stdafx.h" +#include "UCIDemoProj.h" +#include "UCIDemoProjDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CUCIDemoProjApp + +BEGIN_MESSAGE_MAP(CUCIDemoProjApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// CUCIDemoProjApp + +CUCIDemoProjApp::CUCIDemoProjApp() +{ + // ֧ + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: ڴ˴ӹ룬 + // Ҫijʼ InitInstance +} + + +// Ψһһ CUCIDemoProjApp + +CUCIDemoProjApp theApp; + + +// CUCIDemoProjApp ʼ + +BOOL CUCIDemoProjApp::InitInstance() +{ + // һ Windows XP ϵӦó嵥ָҪ + // ʹ ComCtl32.dll 汾 6 ߰汾ÿӻʽ + //Ҫ InitCommonControlsEx() 򣬽޷ڡ + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // ΪҪӦóʹõ + // ؼࡣ + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // shell ԷԻ + // κ shell ͼؼ shell бͼؼ + //CShellManager *pShellManager = new CShellManager; + + // Windows NativeӾԱ MFC ؼ + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // ׼ʼ + // δʹЩܲϣС + // տִļĴСӦƳ + // Ҫضʼ + // ڴ洢õע + // TODO: Ӧʵ޸ĸַ + // ޸Ϊ˾֯ + SetRegistryKey(_T("ӦóɵıӦó")); + m_SystemLange = E_LANG_CHINESE; + LANGID lid = GetSystemDefaultLangID(); + switch ((lid & 0x1ff)) { + case LANG_ENGLISH: + m_SystemLange = E_LANG_ENGLISH; + break; + default: + break; + } + + InitLanguage(m_SystemLange); + + CUCIDemoProjDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: ڴ˷ôʱ + // ȷرնԻĴ + } + else if (nResponse == IDCANCEL) + { + // TODO: ڴ˷ôʱ + // ȡرնԻĴ + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, ": Ի򴴽ʧܣӦóֹ\n"); + TRACE(traceAppMsg, 0, ": ڶԻʹ MFC ؼ޷ #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS\n"); + } + + // ɾ洴 shell +// if (pShellManager != NULL) +// { +// delete pShellManager; +// } + + // ڶԻѹرգԽ FALSE Ա˳Ӧó + // ӦóϢá + return FALSE; +} + +void CUCIDemoProjApp::InitLanguage(ELANGE _lang) { + OSVERSIONINFO ovs; + ovs.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (::GetVersionEx(&ovs)) { + m_IsNewOS = (ovs.dwPlatformId == VER_PLATFORM_WIN32_NT + && ovs.dwMajorVersion >= 6 + && ovs.dwMinorVersion >= 0); + } + + switch (_lang) { + case E_LANG_CHINESE: + if (m_IsNewOS) + SetThreadUILanguage(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED)); + else + SetThreadLocale(MAKELCID(MAKELANGID(LANG_CHINESE_SIMPLIFIED, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT)); + break; + case E_LANG_ENGLISH: + if (m_IsNewOS) + SetThreadUILanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); + else + SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); + break; + default: + break; + } +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.h new file mode 100644 index 0000000..2d4906d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.h @@ -0,0 +1,44 @@ + +// UCIDemoProj.h : PROJECT_NAME Ӧóͷļ +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "ڰļ֮ǰstdafx.h PCH ļ" +#endif + +#include "resource.h" // + + +// CUCIDemoProjApp: +// йشʵ֣ UCIDemoProj.cpp +// + +enum ELANGE { + E_LANG_CHINESE = 0, + E_LANG_ENGLISH, +}; + +class CUCIDemoProjApp : public CWinApp +{ +public: + CUCIDemoProjApp(); + + + ELANGE GetSystemLange() const { return m_SystemLange; } + // д +public: + virtual BOOL InitInstance(); + // ʵ + + DECLARE_MESSAGE_MAP() + +protected: + void InitLanguage(ELANGE _lang); +private: + ELANGE m_SystemLange; + bool m_IsNewOS; +}; + +extern CUCIDemoProjApp theApp; \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.rc b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.rc new file mode 100644 index 0000000..797c1c2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.rc differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.vcxproj b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.vcxproj new file mode 100644 index 0000000..d5c7202 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.vcxproj @@ -0,0 +1,325 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {09EFA3E1-C64B-468C-9980-A583295E0001} + UCIDemoProj + MFCProj + + + + Application + true + v120_xp + Unicode + Static + + + Application + true + v120_xp + Unicode + Static + + + Application + true + v120_xp + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + + + + + + + + + + + + + + + + + + + + + + + true + $(OutDir);$(LibraryPath) + + + true + $(OutDir);$(LibraryPath) + + + true + $(OutDir);$(LibraryPath) + + + false + UCI_DEMO + + + false + UCI_DEMO + + + false + UCI_DEMO + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + true + + + Windows + true + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + true + + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + true + + + Windows + true + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + true + + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + true + + + Windows + true + + + false + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + false + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.vcxproj.filters b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.vcxproj.filters new file mode 100644 index 0000000..1f51829 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProj.vcxproj.filters @@ -0,0 +1,69 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + 资源文件 + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProjDlg.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProjDlg.cpp new file mode 100644 index 0000000..7caf537 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProjDlg.cpp @@ -0,0 +1,1011 @@ +#include "stdafx.h" +#include "UCIDemoProj.h" +#include "UCIDemoProjDlg.h" +#include "afxdialogex.h" + +#include "File.h" +#include "lib\UPO.h" +#include "lib\UTG4162.h" + +using namespace uci; + +#pragma comment(lib, "lib\\uci.lib") + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#define WM_TCPIP_DISCONNECT (WM_USER+2) +u_session g_curSession = -1; + +// CUCIDemoProjDlg Ի + +DWORD g_di = GetTickCount(); + +void ResetTimer() { + g_di = GetTickCount(); +} + +DWORD GetTimeSpan() { + return GetTickCount() - g_di; +} + +CUCIDemoProjDlg::CUCIDemoProjDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(CUCIDemoProjDlg::IDD, pParent) + , m_Val_Timeout(1000) + , m_IsConnect(false) + , m_Val_BytesToRead(4) + , m_MaxCMDHistoryCount(20) + , m_nConnectAddrPort(0) + , m_cbBoxText(_T("")) { +} + +void CUCIDemoProjDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); + DDX_Control(pDX, IDC_EDIT_MSG, m_Ctrl_Edit_Msg); + DDX_Text(pDX, IDC_EDIT_TIMEOUT, m_Val_Timeout); + DDX_Text(pDX, IDC_EDIT_READ_BYTES, m_Val_BytesToRead); + DDX_Control(pDX, IDC_MFCEDITBROWSE1, m_CtrlFileChoose); + DDX_Control(pDX, IDC_COMBO_CMD, m_cbxCMD); + DDX_Control(pDX, IDC_BTN_WRITE_IN_FILE, m_btnWriteParam_File); + DDX_Control(pDX, IDC_COMBO_DEV_ADDR, m_cbxDevAddr); + DDX_CBString(pDX, IDC_COMBO_CMD, m_cbBoxText); + DDV_MaxChars(pDX, m_cbBoxText, 500); +} + +CUCIDemoProjDlg* CUCIDemoProjDlg::c_object = nullptr; + +BEGIN_MESSAGE_MAP(CUCIDemoProjDlg, CDialogEx) + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_BUTTON_QUERY_NODES, &CUCIDemoProjDlg::OnBnClickedButtonQueryNodes) + ON_BN_CLICKED(IDC_BUTTON_CLEAR, &CUCIDemoProjDlg::OnBnClickedButtonClear) + ON_BN_CLICKED(IDC_BUTTON_OPEN, &CUCIDemoProjDlg::OnBnClickedButtonOpen) + ON_BN_CLICKED(IDC_BTN_WRITE, &CUCIDemoProjDlg::OnBnClickedBtnWrite) + ON_BN_CLICKED(IDC_BTN_READ, &CUCIDemoProjDlg::OnBnClickedBtnRead) + ON_BN_CLICKED(IDC_BUTTON_WRITE_FILE, &CUCIDemoProjDlg::OnBnClickedButtonWriteFile) + ON_BN_CLICKED(IDC_BUTTON_READ_FILE, &CUCIDemoProjDlg::OnBnClickedButtonReadFile) + ON_WM_DESTROY() + ON_BN_CLICKED(IDC_BTN_WRITE_IN_FILE, &CUCIDemoProjDlg::OnBnClickedBtnWriteInFile) + ON_BN_SETFOCUS(IDC_BTN_WRITE_IN_FILE, &CUCIDemoProjDlg::OnBnSetfocusBtnWriteInFile) + ON_MESSAGE(WM_TCPIP_DISCONNECT, &CUCIDemoProjDlg::OnLANDisconnect) +END_MESSAGE_MAP() + +BOOL CUCIDemoProjDlg::OnInitDialog() + +{ + auto r = CDialogEx::OnInitDialog(); + SetIcon(m_hIcon, TRUE); + SetIcon(m_hIcon, FALSE); + + //{{initialize for The tips of widgets; + m_tips.Create(this); + m_tips.SetDelayTime(500); + m_tips.SetTipTextColor(RGB(0, 0, 255)); + m_tips.SetTipBkColor(RGB(255, 255, 255)); + m_tips.Activate(true); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_OPEN), IDC_BUTTON_OPEN); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_QUERY_NODES), IDC_BUTTON_QUERY_NODES); + m_tips.AddTool(GetDlgItem(IDC_EDIT_TIMEOUT), IDC_EDIT_TIMEOUT); + //m_tips.AddTool(GetDlgItem(IDC_EDIT_DEV_ADDR), IDC_EDIT_DEV_ADDR); + //m_tips.AddTool(GetDlgItem(IDC_EDIT_DEV_ADDR), IDC_EDIT_DEV_ADDR); + m_tips.AddTool(GetDlgItem(IDC_COMBO_CMD), IDC_COMBO_CMD); + m_tips.AddTool(GetDlgItem(IDC_MFCEDITBROWSE1), IDC_MFCEDITBROWSE1); + m_tips.AddTool(GetDlgItem(IDC_EDIT_READ_BYTES), IDC_EDIT_READ_BYTES); + m_tips.AddTool(GetDlgItem(IDC_BTN_READ), IDC_BTN_READ); + m_tips.AddTool(GetDlgItem(IDC_BTN_WRITE), IDC_BTN_WRITE); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_WRITE_FILE), IDC_BUTTON_WRITE_FILE); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_READ_FILE), IDC_BUTTON_READ_FILE); + m_tips.AddTool(GetDlgItem(IDC_BUTTON_CLEAR), IDC_BUTTON_CLEAR); + //}} + + //{{Get the file path of saved the history of command + GetAppFolderPath(m_strCMDListPath); + m_strCMDListPath += _T("\\cmd.txt"); + //}} + + //{{Get app configuration + m_Val_Timeout = theApp.GetProfileInt(_T("Params"), _T("Timeout"), 1000); + m_Val_BytesToRead = theApp.GetProfileInt(_T("RParams"), _T("BYTES"), 50); + CString addr = _T("[C:UPO][D:UPO2000CS][T:TCPIP][IP:192.168.1.172][Port:0x1388]"); + addr = theApp.GetProfileString(_T("Connect"), _T("Addr"), addr); + m_COMType = theApp.GetProfileInt(_T("RParams"), _T("COMTYPE"), 50); + //}} + + m_cbxDevAddr.AddString(addr); + m_cbxDevAddr.SetCurSel(0); + + InitUI(); + + LoadCMDList(); + + c_object = this; + + //{{ Config for UCI + ELANGE lang = theApp.GetSystemLange(); + switch (lang) { + case E_LANG_CHINESE: + uci_SetAttribute(INVALID_SESSION, _T("lang:zh-Hans;devchange:1;"), nullptr, 0); + break; + case E_LANG_ENGLISH: + uci_SetAttribute(INVALID_SESSION, _T("lang:en-US;devchange:1;"), nullptr, 0); + break; + default: + break; + } + uci_SetNotify(UCI_MessageProc); + +// m_cbxCMD.ModifyStyle(0, CBS_AUTOHSCROLL); +// auto dwStyle = m_cbxCMD.GetStyle(); +// dwStyle |= CBS_AUTOHSCROLL; +// m_cbxCMD.ModifyStyle(0, dwStyle); +// m_cbxCMD.LimitText(0); + + + //}} + return r; + //return TRUE; // ǽõؼ򷵻 TRUE +} + +void CUCIDemoProjDlg::InitUI() { + //{{UI initialization + CheckDlgButton(IDC_CHECK_LAN, m_COMType & uci::NodeType::LAN); + CheckDlgButton(IDC_CHECK_USB, m_COMType & uci::NodeType::USB); + EnableWidgets(FALSE); + m_btnWriteParam_File.SetDelayFullTextTooltipSet(FALSE); + UpdateData(FALSE); + //} +} + +void CUCIDemoProjDlg::LoadCMDList() { + try { + CStdioFile f(m_strCMDListPath, CFile::modeRead | CFile::typeText); + + CString s; + while (f.ReadString(s) && m_cbxCMD.GetCount() <= m_MaxCMDHistoryCount) { + if (m_cbxCMD.GetCount() == 0) { + m_cbxCMD.AddString(s); + } else { + m_cbxCMD.InsertString(0, s); + } + } + } catch (CException* e) { + m_cbxCMD.AddString(_T("CH:0@SEL;")); + m_cbxCMD.AddString(_T("CH:0@EN:1;")); + m_cbxCMD.AddString(_T("CH:0@vp:128;")); + m_cbxCMD.AddString(_T("trig@pos:25;")); + m_cbxCMD.AddString(_T("math@t:f;")); + e->Delete(); + } +} + +bool CUCIDemoProjDlg::GetAppFolderPath(CString& _strPath) { + TCHAR path[MAX_PATH]; + ZeroMemory(path, sizeof(path)); + auto r = GetModuleFileName(AfxGetInstanceHandle(), path, MAX_PATH); + if (r == 0) { + ASSERT(false); + return false; + } + + CString strAppPath(path); + auto i = strAppPath.ReverseFind(_T('\\')); + if (i == -1) { + ASSERT(false); + return false; + } + + _strPath = strAppPath.Left(i); + //AfxMessageBox(_strPath); + return true; +} + +void CUCIDemoProjDlg::EnableWidgets(BOOL _isConnect) { + GetDlgItem(IDC_BTN_WRITE)->EnableWindow(_isConnect); + GetDlgItem(IDC_BTN_READ)->EnableWindow(_isConnect); + GetDlgItem(IDC_BUTTON_WRITE_FILE)->EnableWindow(_isConnect); + GetDlgItem(IDC_BUTTON_READ_FILE)->EnableWindow(_isConnect); + GetDlgItem(IDC_BTN_WRITE_IN_FILE)->EnableWindow(_isConnect); + //GetDlgItem(IDC_CHECK_WITE_FILE)->EnableWindow(_isConnect); +} + +void CUCIDemoProjDlg::OnPaint() { + if (IsIconic()) { + CPaintDC dc(this); + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + dc.DrawIcon(x, y, m_hIcon); + } else { + CDialogEx::OnPaint(); + } +} + +HCURSOR CUCIDemoProjDlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + +void CUCIDemoProjDlg::GetCMDString(CString& _msg) { + GetDlgItemText(IDC_COMBO_CMD, _msg); +} + +int CUCIDemoProjDlg::UCIWrite(const TCHAR* _cmd, UINT _timeOut) { + WParams wp; + ZeroMemory(&wp, sizeof(wp)); + //You can also use the simple interface "uci_WriteX", defined in uci.h + auto r = uci_Write(g_curSession, uci_CreateWParams(wp, _cmd, _timeOut), nullptr, 0); + if (r >= 0) + RecordCMD(_cmd); + return r; +} + +int CUCIDemoProjDlg::UCIRead(const TCHAR* _cmd, u_byte* _data, u_size _dataLen, UINT _timeOut) { +#if 0 + //You can also use the simple interface "uci_ReadX", defined in uci.h + RParams rp; + auto r = uci_Read(g_curSession, uci_CreateRParams(rp, _cmd, _timeOut, NULL, 0), _data, _dataLen); +#else + auto r = uci_ReadX(g_curSession, _cmd, _timeOut, _data, _dataLen); +#endif + if (r >= 0) + RecordCMD(_cmd); + return r; +} + +int __stdcall CUCIDemoProjDlg::UCI_MessageProc(UCIMSG* _msg) { + if (_msg == nullptr) { + ASSERT(FALSE); + return 0; + } + + switch (_msg->Message) { + case uci::EUCIMSG::UMSG_DEVICE_NOTIFY: + { +#if 1 + //if (c_object->m_DevName.CompareNoCase(CString(_msg->Reserved)) == 0) { + if (c_object->m_IsConnect && g_curSession != Invalid_Session) { + c_object->ShowResult(uci_Close(g_curSession), IDS_TIPS_CLOSE_CONNECT); + c_object->SetWidgetText(IDC_BUTTON_OPEN, IDS_BTN_CONNECT); + c_object->m_IsConnect = false; + } + //} +#endif + } + break; + case uci::EUCIMSG::UMSG_CONNECT_CLOSED: + //TCIPIPӵĶϿ¼ʱ̵߳øýӿڣڴ˽ӿвܸUI + //This event can been invoked when the disconnection of tcpip, and it been call in thread, you can not update UI here; + break; + default: + break; + } + + return 1; +} + +void CUCIDemoProjDlg::Disconnect() { + if (m_IsConnect && g_curSession != Invalid_Session) { + ShowResult(uci_Close(g_curSession), IDS_TIPS_CLOSE_CONNECT); + SetWidgetText(IDC_BUTTON_OPEN, IDS_BTN_CONNECT); + m_IsConnect = false; + } +} + + +//@brief : recode cmd for input history +//@param _msg : +//@return : +//@remarks : +void CUCIDemoProjDlg::RecordCMD(const CString& _msg) { + // Delete all items that begin with the specified string. + int nItem = 0; + while ((nItem = m_cbxCMD.FindString(nItem, _msg)) != CB_ERR) { + m_cbxCMD.DeleteString(nItem); + } + + while (m_cbxCMD.GetCount() > m_MaxCMDHistoryCount) { + m_cbxCMD.DeleteString(m_cbxCMD.GetCount() - 1); + } + + m_cbxCMD.InsertString(0, _msg); + m_cbxCMD.SetWindowText(_msg); +} + +void CUCIDemoProjDlg::ShowResult(int _r, int _idsSOerationString, const TCHAR* _format, ...) +{ + CString msg; + if (_format != nullptr) + { + va_list argptr; + va_start(argptr, _format); + msg.FormatV(_format, argptr); + va_end(argptr); + + } + if (_idsSOerationString != -1) + msg = LoadString(_idsSOerationString) + msg; + + CString str; + if (_r < 0) { + str.Format(_T("\r\n[%s], Error id = 0x%x(hex) , %d(dec);\r\n\t->%s;"), msg, _r, _r, uci_GetLastError()); + } else { + str.Format(_T("\r\n[%s], return = %d, Succeed!, use time = %d ms;\r\n"), msg, _r, GetTimeSpan()); + } + + ASSERT(IsWindow(m_Ctrl_Edit_Msg.GetSafeHwnd())); + int indexEnd = m_Ctrl_Edit_Msg.GetWindowTextLength(), index = indexEnd; + m_Ctrl_Edit_Msg.SetSel(index, indexEnd); + m_Ctrl_Edit_Msg.ReplaceSel(str); +} + +void CUCIDemoProjDlg::AppendTraceMsg(const u_tchar *format, ...) { + CString msg; + va_list argptr; + va_start(argptr, format); + msg.FormatV(format, argptr); + va_end(argptr); + + int indexEnd = m_Ctrl_Edit_Msg.GetWindowTextLength(), index = indexEnd; + m_Ctrl_Edit_Msg.SetSel(index, indexEnd); + m_Ctrl_Edit_Msg.ReplaceSel(msg); +} + +void CUCIDemoProjDlg::OnBnClickedButtonClear() { + m_Ctrl_Edit_Msg.SetWindowText(_T("")); +} + +void CUCIDemoProjDlg::OnBnClickedButtonQueryNodes() { + UpdateData(); + if (m_Val_Timeout == 0) { + AfxMessageBox(IDS_TIPS_TIMEOUT_ZERO); + return; + } + + CWaitCursor wc; + + //*******************************delete device addr list:************************** + ResetTimer(); + while (m_cbxDevAddr.GetCount() > 0) { + m_cbxDevAddr.DeleteString(m_cbxDevAddr.GetCount() - 1); + } + + CString strResult; + //*******************************query devices:************************** + //example1: uci_QueryNodes +#if 0 + QParams qp; + + int pvids[] = { + MakePVID(0x1234, 0x5345), + MakePVID(0x7777, 0x5345), + MakePVID(0x0834, 0x5656), + MakePVID(0x5537, 0x4348), + MakePVID(0xE008, 0x1A86), + MakePVID(0xEA80, 0x10C4), + }; + + int ports[] = { + 4162, + 5000, + }; + + //int type = NodeType::LAN | NodeType::USB; + int type = 0; + if (IsDlgButtonChecked (IDC_CHECK_USB)) + type |= NodeType::USB; + + if (IsDlgButtonChecked(IDC_CHECK_LAN)) + type |= NodeType::LAN; + + if (type == 0) + { + AfxMessageBox(_T("ѡҪѯͨŽӿͣ")); + return; + } + UCI_CreateQParam(qp, type, ports, sizeof(ports) / sizeof(int), pvids, sizeof(pvids) / sizeof(int), nullptr); + + Node nodes[10]; + ZeroMemory(nodes, sizeof(nodes)); + u_size notesCNT = sizeof(nodes) / sizeof(nodes[0]); + + int r = uci_QueryNodes(&qp, nodes, ¬esCNT, m_Val_Timeout); +#else + //example2: uci_QueryNodesX + // + CString strQuery; + + //int type = NodeType::LAN | NodeType::USB; + int type = 0; + if (IsDlgButtonChecked(IDC_CHECK_USB)) { + type |= NodeType::USB; + //+ DSO,SG,POWER + strQuery.AppendFormat(_T("USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348")); + //+ DM(HID) + strQuery.AppendFormat(_T(",0xE008&0x1A86,0xEA80&0x10C4;")); + } + + if (IsDlgButtonChecked(IDC_CHECK_LAN)) { + type |= NodeType::LAN; + //8000:UTG2000A series; 5000: UPO2000S/UPO7000Z series; 4162 : UTG4000A series + strQuery.AppendFormat(_T("LAN:5000,4162,8000,18191;")); + } + m_COMType = type; + + ZeroMemory(m_Nodes, sizeof(m_Nodes)); + u_size notesCNT = sizeof(m_Nodes) / sizeof(m_Nodes[0]); + + int r = uci_QueryNodesX(strQuery, m_Nodes, notesCNT, m_Val_Timeout); +#endif + + if (r < 0) { + ShowResult(r, IDS_QUERY_DEVICES_FAILED);// Error to query nodes + return; + } + + if (notesCNT == 0) { + AfxMessageBox(IDS_TIPS_NOT_FOUND_ANY_DEVICES); + return; + } + + //*******************************show result:************************** + notesCNT = r; + for (size_t i = 0; i < notesCNT; i++) { + switch (m_Nodes[i].Type) { + case NodeType::LAN: + { + auto n = &m_Nodes[i].LAN; + TRACE(_T("\r\nIP : %s, Port : %d"), CString(n->IP), n->Port); + strResult.AppendFormat(_T("\r\nIP : %s, Port : %d"), CString(n->IP), n->Port); + break; + } + case NodeType::USB: + { + auto n = &m_Nodes[i].USB; + TRACE(_T("\r\nPID : 0x%x, VID : 0x%x, Addr : %d"), n->PID, n->VID, n->Addr); + strResult.AppendFormat(_T("\r\nPID : %d, VID : %d, Addr : %d"), n->PID, n->VID, n->Addr); + break; + } + default: + ASSERT(FALSE); + break; + } + + strResult.AppendFormat(_T(",%s,SN:%s, status = %d, IDN = %s"), + m_Nodes[i].Name, m_Nodes[i].SN, m_Nodes[i].Status, m_Nodes[i].IDN); + strResult.AppendFormat(_T("\r\n\t->UCI Addr: %s"), m_Nodes[i].UCIAddr); + + m_cbxDevAddr.AddString(m_Nodes[i].UCIAddr); + } + + if (!strResult.IsEmpty ()) + AppendTraceMsg(_T("\r\n--------QUERY Result------------%s"), strResult); + ShowResult(r, -1, _T("Query")); + + AppendTraceMsg(_T("\r\n--------------------")); + AppendTraceMsg(LoadString (IDS_TIPS_COPY_UCI_ADDR)); + AppendTraceMsg(_T("\r\n--------------------\r\n")); + + //SetDlgItemText(IDC_EDIT_DEV_ADDR, nodes[0].UCIAddr); + m_cbxDevAddr.SetWindowText(m_Nodes[0].UCIAddr); +} + +LRESULT AFX_MSG_CALL CUCIDemoProjDlg::OnLANDisconnect(WPARAM wParam, LPARAM lParam) { + Disconnect(); + return 1; +} + +void CUCIDemoProjDlg::OnBnClickedButtonOpen() { + ResetTimer(); + + //{UI + if (m_IsConnect && g_curSession != INVALID_SESSION) { + ShowResult(uci_Close(g_curSession), IDS_TIPS_CLOSE_CONNECT); + SetWidgetText(IDC_BUTTON_OPEN, IDS_BTN_CONNECT); + m_IsConnect = false; + EnableWidgets(FALSE); + return; + } + //} + + CString msg; + m_cbxDevAddr.GetWindowText(msg); + if (msg == _T("")) { + AfxMessageBox(LoadString(IDS_CMD_MSG_EMPTY)); + return; + } + + auto r = uci_Open(msg, &g_curSession, 2000); + ShowResult(r, IDS_TIPS_BUILD_COONNECTION); + m_IsConnect = UCISUCCESS(r); + + if (m_IsConnect) { + //{UI + SetWidgetText(IDC_BUTTON_OPEN, IDS_BTN_DISCONNECT); + EnableWidgets(TRUE); + //} + + //{record the IDN string + m_IDN.Empty(); + for (int count = 0; count < sizeof(m_Nodes) / sizeof(m_Nodes[0]); count++) { + if (msg.CompareNoCase(m_Nodes[count].UCIAddr) == 0) + m_IDN = m_Nodes[count].IDN; + } + //} + + //{parse Fields of UCI Address + m_DevName = FindConnectAddrField(msg, _T("[D:"), _T("]")); + auto comType = FindConnectAddrField(msg, _T("[T:"), _T("]")); + if (comType.CompareNoCase(_T("TCPIP")) == 0) { + m_ConnectAddrIP = FindConnectAddrField(msg, _T("[IP:"), _T("]")); + m_ConnectAddrPort = FindConnectAddrField(msg, _T("[PORT:"), _T("]")); + m_nConnectAddrPort = _tcstol(m_ConnectAddrPort, nullptr, m_ConnectAddrPort.Find(_T("0x")) == -1 ? 10 : 16); + } + //} + + CString tips; + tips.Format(_T("winmsg:0x%x@closed:%d;"), GetSafeHwnd(), WM_TCPIP_DISCONNECT); + uci_SetAttribute(g_curSession, tips, nullptr, 0); + } + + //save the UCI Address for next startup + theApp.WriteProfileString(_T("Connect"), _T("Addr"), msg); +} + +CString CUCIDemoProjDlg::FindConnectAddrField(const CString& _addr, + const CString& _fieldBegin, const CString&_fieldEnd) { + CString addr(_addr), begin(_fieldBegin), end(_fieldEnd); + addr.MakeUpper(); + begin.MakeUpper(); + end.MakeUpper(); + auto i = addr.Find(_fieldBegin); + auto iEnd = addr.Find(_fieldEnd, i); + return addr.Mid(i + _fieldBegin.GetLength(), iEnd - i - _fieldBegin.GetLength()); +} + +void CUCIDemoProjDlg::OnBnClickedBtnWrite() { + if (!CheckConnectiion()) + return; + + UpdateData(); + + CString msg; + GetCMDString(msg); + if (msg.IsEmpty()) { + AfxMessageBox(IDS_CMD_MSG_EMPTY); + return; + } + + ResetTimer(); + + ShowResult(UCIWrite(msg, m_Val_Timeout), IDS_TIPS_CMD_WRITE, msg); +} + +void CUCIDemoProjDlg::OnBnClickedBtnWriteInFile() { + if (!CheckConnectiion()) + return; + + UpdateData(); + + if (!GetCommandString ()) + return; + + CString strPath; + m_CtrlFileChoose.GetWindowText(strPath); + if (strPath.IsEmpty()) { + AfxMessageBox(_T("ļ·Ϊգ")); + return; + } + + strPath.Trim(_T(" ")); + + if (!::PathFileExists(strPath)) { + AfxMessageBox(_T("ļ·")); + return; + } + + ResetTimer(); + + try { + CFile f(strPath, CFile::modeRead); + + std::vector buf((size_t)f.GetLength(), 0); + + f.Read(buf.data(), buf.size()); + + WParams wp; + ZeroMemory(&wp, sizeof(wp)); + auto r = uci_Write(g_curSession, uci_CreateWParams(wp, m_CommandString, m_Val_Timeout), buf.data(), buf.size()); + if (UCISUCCESS(r)) + RecordCMD(m_CommandString); + + ShowResult(r, IDS_TIPS_CMD_WRITE_FILE_AS_WRITE_PARAMS, m_CommandString); + } catch (CException* e) { + e->ReportError(); + e->Delete(); + } +} + +bool CUCIDemoProjDlg::CheckConnectiion() { + if (g_curSession == Invalid_Session || !m_IsConnect) { + AfxMessageBox(IDS_TIPS_NOT_CONNECT); + return false; + } + return true; +} + +void CUCIDemoProjDlg::OnBnClickedBtnRead() { + SetDlgItemText(IDC_EDIT_MSG, _T("")); + + UpdateData(TRUE); + + auto sz = sizeof(upo2k::CellBaseValue); + + if (m_Val_BytesToRead < 2) { + AfxMessageBox(_T("Ҫȡֽ2Bytes, 4Bytes")); + return; + } + + if (m_Val_Timeout == 0) { + AfxMessageBox(_T("ʱʱ䲻Ϊ0")); + return; + } + + theApp.WriteProfileInt(_T("RParams"), _T("BYTES"), m_Val_BytesToRead); + theApp.WriteProfileInt(_T("Params"), _T("Timeout"), m_Val_Timeout); + + if (g_curSession == Invalid_Session || !m_IsConnect) { + AfxMessageBox(_T("Ƚӣ")); + return; + } + + //"USB BIN"ͨŷʽmsgҪ + CString msg; + GetCMDString(msg); + if (msg == _T("")) { + AfxMessageBox(_T("ַΪգ")); + return; + } + + std::vector buf; + try { + buf.resize(m_Val_BytesToRead, 0); + } catch (CException* e) { + e->ReportError(); + e->Delete(); + return; + } + + ResetTimer(); + + //ȡ + auto r = UCIRead(msg, &buf[0], buf.size(), m_Val_Timeout); + ShowResult(r, IDS_TIPS_CMD_READ); + if (UCIERR(r)) + return; + + //ԽͼָõĽͼļ + CString path, fileName = _T("RData.dat"); + fileName = CreateBmpFileName(msg, fileName); + if (r > m_Val_BytesToRead) + r = m_Val_BytesToRead; + + //ԭʼݵļ + Files::WriteAllBytes(fileName, &buf[0], r, &path); + AppendTraceMsg(_T("The received data had been stored in file\r\n -> %s"), path); + + //һ + auto pBin = reinterpret_cast(&buf[0]); + size_t szBin = buf.size() > 100 ? 100 : buf.size(); + CString s, str; + size_t line_count = 10; + for (size_t i = 0; i < szBin; i++) { + if (i > 0 && i % line_count == 0) { + s += _T("| ") + str; + str.Empty(); + s.AppendFormat(_T("\r\n")); + } + s.AppendFormat(_T("%02x\t"), pBin[i]); + str.AppendFormat(_T("%c"), pBin[i] == 0 ? '.' : pBin[i]); + } + //if (szBin < line_count) { + s += _T("| ") + str; + //} + + AppendTraceMsg(_T("\r\n----------------------------")); + AppendTraceMsg(_T("\r\nBinary Data(%dBytes) : \r\n%s"), szBin, s); + + AppendTraceMsg(_T("\r\n----------------------------")); + AppendTraceMsg(_T("\r\nTry parse build-in struct")); + + //Գݽнʾ + auto szV = buf.size(); + switch (szV) { + case 2: + { + auto pb_short = reinterpret_cast(&buf[0]); + auto pb_ushort = reinterpret_cast(&buf[0]); + auto pb_byte = reinterpret_cast(pb_ushort); + AppendTraceMsg(_T("\r\nShort = 0x%x(%d), UShort = 0x%x(%d) -> L-Word(%d) H-Word(%d)"), + *pb_short, *pb_short, *pb_ushort, *pb_ushort, pb_ushort[0], pb_ushort[1]); + break; + } + case 4: + { + auto pb = reinterpret_cast(&buf[0]); + auto pb_uint = reinterpret_cast(&buf[0]); + auto pb_short = reinterpret_cast(pb); + AppendTraceMsg(_T("\r\nInt = 0x%x(%d), UInt = 0x%x(%d) -> L-Word(%d) H-Word(%d)"), + *pb, *pb, *pb_uint, *pb_uint, pb_short[0], pb_short[1]); + + auto pf = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nfloat = %f"), *pf); + break; + } + + case 8:{ + auto pb = reinterpret_cast(&buf[0]); + auto pb_int_64 = reinterpret_cast(&buf[0]); + auto pb_uint_64 = reinterpret_cast(pb); + auto pb_double = reinterpret_cast(pb); + double v = *pb_double; + AppendTraceMsg(_T("\r\nInt64 = 0x%x(%d), UInt64 = 0x%x(%u)"), + *pb_int_64, *pb_int_64, *pb_uint_64, *pb_uint_64); + AppendTraceMsg(_T("\r\ndouble = %f"), *pb_double); + break; + } + default: + break; + } + + AppendTraceMsg(_T("\r\n----------------------------")); + AppendTraceMsg(_T("\r\nTry parse")); + if (buf.size() == sizeof(upo2k::CellBaseValue)) { + upo2k::CellBaseValue * pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nV = %f\r\nU = %d(type = %d, code = %d)\r\nIsLimit = %d"), + pb->Value, pb->Unit, upo2k::GetUnitType(pb->Unit), upo2k::GetUnitCode(pb->Unit), pb->IsLimit); + if (buf.size() == sizeof(double)) { + AppendTraceMsg(_T("\r\n----")); + AppendTraceMsg(_T("\r\nV = %f, %d"), *(reinterpret_cast(&buf[0])), *(reinterpret_cast(&buf[0]))); + } + } else if (buf.size() == sizeof(upo2k::CellBaseValue) * 2) { + upo2k::CellBaseValue * pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\n[Low]V = %f,U = %d,IsLimit = %d;\r\n[High]V = %f,U = %d,IsLimit = %d"), + pb->Value, pb->Unit, pb->IsLimit, pb[1].Value, pb[1].Unit, pb[1].IsLimit); + }else if (buf.size() == sizeof(utg4162::LEDStatus)) { + auto pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\n[LED] CH1 = %d, CH2 = %d, Sine = %d"), pb->CH1, pb->CH2, pb->SINE); + } else if (buf.size() == sizeof(upo2k::UValue)) { + upo2k::UValue * pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nV = %f\r\nU = %d(0x%x)"), pb->value, pb->unit, pb->unit); + } else if (buf.size() == sizeof(upo2k::CursorMeasurePack)) { + auto pb = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nAx : V = %f,U = %d[0x%x t(0x%x) c(%d)]"), + pb->Ax.value, pb->Ax.unit, pb->Ax.unit, upo2k::GetUnitType(pb->Ax.unit), upo2k::GetUnitCode(pb->Ax.unit)); + AppendTraceMsg(_T("\r\nAy : V = %f,U = %d[0x%x t(0x%x) c(%d)]"), + pb->Ay.value, pb->Ay.unit, pb->Ay.unit, upo2k::GetUnitType(pb->Ay.unit), upo2k::GetUnitCode(pb->Ay.unit)); + } else if (buf.size() == sizeof(upo2k::Time)) { + auto pt = reinterpret_cast(&buf[0]); + AppendTraceMsg(_T("\r\nTime: %d-%d-%d, %d:%d:%d"), + pt->Year, pt->Month, pt->Day, pt->Hour, pt->Minute, pt->Second); + } + + if (msg.Find(_T("mea:all?")) != -1) { + ParseParamsMeasure(buf.data(), buf.size()); + } else if (msg.Compare(_T(":MEA:All?")) == 0) { + ParseParamsMeasure(buf.data() + 8 , buf.size() - 8); + } else if (msg.Find(_T("mea:user?")) != -1) { + ParseParamsMeasure_User(buf.data(), buf.size()); + } +} + +const CString& CUCIDemoProjDlg::CreateBmpFileName(CString &msg, CString& fileName) { + if (msg.CompareNoCase(_T("PrtScn:bmp;")) == 0 || msg.CompareNoCase(_T("PrtScn:.bmp;")) == 0) { + if (!m_IDN.IsEmpty()) + fileName = m_IDN; + else + fileName = m_DevName; + fileName += _T("_"); + fileName += GetCurrentTime(); + fileName += ".bmp"; + Sleep(300); + } + return fileName; +} + +void CUCIDemoProjDlg::ParseParamsMeasure(byte* _data, int _data_len) { + float v = 12.0; + float * pv = &v; + cb::MeaValue* pmv = reinterpret_cast(_data); + AppendTraceMsg(_T("\r\n")); + PrintMeaParam(_T("MAX"), pmv[cb::MP_MAX]); + PrintMeaParam(_T("MIN"), pmv[cb::MP_MIN]); + PrintMeaParam(_T("HIGH"), pmv[cb::MP_HIGH]); + PrintMeaParam(_T("MIDDLE"), pmv[cb::MP_MIDDLE]); + PrintMeaParam(_T("LOW"), pmv[cb::MP_LOW]); + PrintMeaParam(_T("PKPK"), pmv[cb::MP_PKPK]); + PrintMeaParam(_T("AMP"), pmv[cb::MP_AMP]); + PrintMeaParam(_T("MEAN"), pmv[cb::MP_MEAN]); + PrintMeaParam(_T("CYCMEAN"), pmv[cb::MP_CYCMEAN]); + PrintMeaParam(_T("RMS"), pmv[cb::MP_RMS]); + + PrintMeaParam(_T("CYCRMS"), pmv[cb::MP_CYCRMS]); + PrintMeaParam(_T("AREA"), pmv[cb::MP_AREA]); + PrintMeaParam(_T("CYCAREA"), pmv[cb::MP_CYCAREA]); + PrintMeaParam(_T("OVERSHOOT"), pmv[cb::MP_OVERSHOOT]); + PrintMeaParam(_T("PRESHOOT"), pmv[cb::MP_PRESHOOT]); + PrintMeaParam(_T("PERIOD"), pmv[cb::MP_PERIOD]); + PrintMeaParam(_T("FREQ"), pmv[cb::MP_FREQ]); + + PrintMeaParam(_T("RISE_TIME"), pmv[cb::MP_RISE_TIME]); + PrintMeaParam(_T("FALL_TIME"), pmv[cb::MP_FALL_TIME]); + PrintMeaParam(_T("PWIDTH"), pmv[cb::MP_PWIDTH]); + PrintMeaParam(_T("NWIDTH"), pmv[cb::MP_NWIDTH]); + PrintMeaParam(_T("PDUTY"), pmv[cb::MP_PDUTY]); + PrintMeaParam(_T("NDUTY"), pmv[cb::MP_NDUTY]); + PrintMeaParam(_T("RISEDELAY"), pmv[cb::MP_RISEDELAY]); + + PrintMeaParam(_T("FALLDELAY"), pmv[cb::MP_FALLDELAY]); + PrintMeaParam(_T("PHASE"), pmv[cb::MP_PHASE]); + PrintMeaParam(_T("FRR"), pmv[cb::MP_FRR]); + PrintMeaParam(_T("FRF"), pmv[cb::MP_FRF]); + + PrintMeaParam(_T("FFR"), pmv[cb::MP_FFR]); + PrintMeaParam(_T("FFF"), pmv[cb::MP_FFF]); + PrintMeaParam(_T("LRF"), pmv[cb::MP_LRF]); + PrintMeaParam(_T("LRR"), pmv[cb::MP_LRR]); + PrintMeaParam(_T("LFR"), pmv[cb::MP_LFR]); + PrintMeaParam(_T("LFF"), pmv[cb::MP_LFF]); + + PrintMeaParam(_T("BURST_WIDTH"), pmv[cb::MP_BURST_WIDTH]); +} + +void CUCIDemoProjDlg::ParseParamsMeasure_User(byte* _data, int _data_len) { + if (_data_len != (sizeof(cb::MeaValue) * 5)) + return; + + cb::MeaValue* pmv = reinterpret_cast(_data); + + for (size_t i = 0; i < 5; i++) { + AppendTraceMsg(_T("\r\nIsExist=%d,IsValid=%d,Value=%f, Unit(Type=%d,Scale=%d)"), + pmv->IsExist, pmv->IsValid, pmv->Value, pmv->Unit.Type, pmv->Unit.Scale); + pmv++; + } +} + +void CUCIDemoProjDlg::PrintMeaParam(const TCHAR * _name, const comAPICommon::MeaValue& _p) { + AppendTraceMsg(_T("%s\t\t\t=\t"), _name); + if (_p.IsExist) { + if (_p.IsValid) + AppendTraceMsg(_T("%f "), _p.Value); + else + AppendTraceMsg(_T("--")); + } else { + AppendTraceMsg(_T("NotExit")); + } + + AppendTraceMsg(_T(" %s%s\n"), unit::uci_UnitFindScaleName(_p.Unit.Scale), + CString(unit::uci_UnitFindTypeName(_p.Unit.Type))); +} + +bool CUCIDemoProjDlg::GetCommandString() { + m_CommandString.Empty(); + GetCMDString(m_CommandString); + if (m_CommandString.IsEmpty()) { + AfxMessageBox(IDS_CMD_MSG_EMPTY);//_T("The command string cannot be empty!") + return false; + } + return true; +} + +bool CUCIDemoProjDlg::GetFilePath() { + m_Path.Empty(); + m_CtrlFileChoose.GetWindowText(m_Path); + if (m_Path.IsEmpty()) { + AfxMessageBox(IDS_TIPS_PATH_EMPTY);//The path cannot be empty + return false; + } + return true; +} + +void CUCIDemoProjDlg::OnBnClickedButtonWriteFile() { + UpdateData(); + + ResetTimer(); + + if (!GetCommandString()) + return; + + if (!GetFilePath()) + return; + + if (!::PathFileExists(m_Path)) { + AfxMessageBox(IDS_TIPS_FILE_NOT_EXIST); + return; + } + + //////////////////////////////////////дļʾ/////////////////////////// + uci::WFileParams wf; + wf.CMDString = m_CommandString; + wf.FilePath = m_Path; + wf.Timeout = m_Val_Timeout; + + auto r = uci_WriteFromFile(g_curSession, &wf); + ShowResult(r, IDS_TIPS_CMD_WRITE_FILE, m_CommandString); + if (UCISUCCESS(r)) + RecordCMD(m_CommandString); +} + + +void CUCIDemoProjDlg::OnBnClickedButtonReadFile() { + if (!GetCommandString()) + return; + + UpdateData(); + ResetTimer(); + + //////////////////////////////////////read file example/////////////////////////// + CString fileName("RFile.bin"); + RFileParams rfp; + ZeroMemory(&rfp, sizeof(rfp)); + rfp.CMDString = m_CommandString; + rfp.FilePath = CreateBmpFileName(m_CommandString, fileName); + //msg.CompareNoCase(_T("prtscn:bmp;")) == 0 ? _T("screen_short.bmp") : _T("RFile.bin"); + rfp.Timeout = m_Val_Timeout; + + auto r = uci_ReadToFile(g_curSession, &rfp); + ShowResult(r, IDS_TIPS_CMD_READFILE, m_CommandString); + + if (UCISUCCESS(r)) { + if (fileName.Right(4).CompareNoCase(_T(".bmp")) == 0) { + AppendTraceMsg(_T("Save path%s"), rfp.FilePathFinal); + } else { + AppendTraceMsg(_T("Save path%s,\r\nIf you want view the file,please change file extention, and use appropriate Viewer to view!"), + rfp.FilePathFinal); + } + RecordCMD(rfp.CMDString); + } +} + +void CUCIDemoProjDlg::OnDestroy() { + CDialogEx::OnDestroy(); + + //////////////////////////////////////remember app data//////////////////////////// + UpdateData(); + + theApp.WriteProfileInt(_T("Params"), _T("Timeout"), m_Val_Timeout); + theApp.WriteProfileInt(_T("RParams"), _T("BYTES"), m_Val_BytesToRead); + theApp.WriteProfileInt(_T("RParams"), _T("COMTYPE"), m_COMType); + + try { + CStdioFile f(m_strCMDListPath, CFile::modeCreate| CFile::modeWrite | CFile::typeText); + + CString str1, str2; + int n; + for (int i = m_cbxCMD.GetCount() - 1; i >= 0; i--) { + n = m_cbxCMD.GetLBTextLen(i); + m_cbxCMD.GetLBText(i, str1.GetBuffer(n)); + str1.ReleaseBuffer(); + + f.WriteString(str1 + _T("\n")); + } + } catch (CException* e) { + e->ReportError(); + e->Delete(); + } +} + +void CUCIDemoProjDlg::OnBnSetfocusBtnWriteInFile() { + m_btnWriteParam_File.SetTooltip(_T("hello")); +} + +BOOL CUCIDemoProjDlg::PreTranslateMessage(MSG* pMsg) { + if (pMsg->message == WM_MOUSEMOVE) + m_tips.RelayEvent(pMsg); + return CDialogEx::PreTranslateMessage(pMsg); +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProjDlg.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProjDlg.h new file mode 100644 index 0000000..9451322 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/UCIDemoProjDlg.h @@ -0,0 +1,145 @@ + +// UCIDemoProjDlg.h : ͷļ +// + +#pragma once + +#include "lib\uci.h" +#include +#include "afxwin.h" +#include "lib\dso_base.h"//ʹ +#include "lib\unit.h"//ʹ + +class CMyMFCButton : public CMFCButton { +public: + void SetDelayFullTextTooltipSet(bool DelayFullTextTooltipSet) { + m_bDelayFullTextTooltipSet = DelayFullTextTooltipSet; + } +}; + +// CUCIDemoProjDlg Ի +class CUCIDemoProjDlg : public CDialogEx +{ +// +public: + CUCIDemoProjDlg(CWnd* pParent = NULL); // ׼캯 + +// Ի + enum { IDD = IDD_UCIDEMOPROJ_DIALOG }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + +public: + static CUCIDemoProjDlg* c_object; +// ʵ +protected: + HICON m_hIcon; + CEdit m_Ctrl_Edit_Msg; + UINT m_Val_Timeout; + int m_Val_BytesToRead; + CMFCEditBrowseCtrl m_CtrlFileChoose; + CComboBox m_cbxCMD; + CMyMFCButton m_btnWriteParam_File; + +protected: + CToolTipCtrl m_tips; +protected: + bool m_IsConnect; + int m_MaxCMDHistoryCount; + CString m_strCMDListPath; + CString m_DevName, m_IDN; + CString m_ConnectAddrIP; + CString m_ConnectAddrPort; + int m_nConnectAddrPort; + int m_COMType; + + uci::Node m_Nodes[100]; + + CString m_CommandString, m_Path; + +protected: + void GetCMDString(CString& _msg); + int UCIWrite(const TCHAR* _cmd, UINT _timeOut); + int UCIRead(const TCHAR* _cmd, u_byte* _data, u_size _dataLen, UINT _timeOut); + + static int __stdcall UCI_MessageProc(uci::UCIMSG* _msg); + + void Disconnect(); + void RecordCMD(const CString& _msg); + + void ShowResult(int _r, int _idsSOerationString, const TCHAR* _format = NULL, ...); + + // @brief : ׷ϢıϢʾ + // @param : const u_tchar * _format + // @param : ... + // @return : void + // @remarks : + void AppendTraceMsg(const u_tchar * _format, ...); + // ɵϢӳ亯 + virtual BOOL OnInitDialog(); + + void InitUI(); + void LoadCMDList(); + bool GetAppFolderPath(CString& _strPath); + void EnableWidgets(BOOL _isConnect); + + CString FindConnectAddrField(const CString& _addr, const CString& _fieldBegin, const CString&_fieldEnd); + + // + void ParseParamsMeasure(byte* _data, int _data_len); + void ParseParamsMeasure_User(byte* _data, int _data_len); + void PrintMeaParam(const TCHAR * _name, const comAPICommon::MeaValue& _p); + + bool GetCommandString(); + bool GetFilePath(); +protected: + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() + afx_msg void OnBnClickedButtonQueryNodes(); + afx_msg LRESULT AFX_MSG_CALL OnLANDisconnect(WPARAM wParam, LPARAM lParam); + +public: + afx_msg void OnBnClickedButtonClear(); + afx_msg void OnBnClickedButtonOpen(); + afx_msg void OnBnClickedBtnWrite(); + afx_msg void OnBnClickedBtnRead(); + + const CString& CreateBmpFileName(CString &msg, CString& fileName); + + afx_msg void OnBnClickedButtonWriteFile(); + afx_msg void OnBnClickedButtonReadFile(); + afx_msg void OnDestroy(); + afx_msg void OnBnClickedBtnWriteInFile(); + + bool CheckConnectiion(); + + afx_msg void OnBnSetfocusBtnWriteInFile(); + virtual BOOL PreTranslateMessage(MSG* pMsg); + + // ʾ豸ַб + CComboBox m_cbxDevAddr; + + inline CString GetCurrentTime() { + SYSTEMTIME t = { 0 }; + GetLocalTime(&t); + + CString s; + s.Format(_T("%02d-%02d-%02d"), t.wHour, t.wMinute, t.wSecond); + return s; + } + + + inline CString LoadString(UINT idRes) { + CString str; + BOOL bNameValid = str.LoadString(idRes); + ASSERT(bNameValid); + return str; + } + + inline void SetWidgetText(UINT _idWidget, UINT _idString) { + SetDlgItemText(_idWidget, LoadString(_idString)); + } + CString m_cbBoxText; +}; diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/CMD_COMVer2.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/CMD_COMVer2.h new file mode 100644 index 0000000..3446546 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/CMD_COMVer2.h @@ -0,0 +1,551 @@ +/*! + * \created : 2016/12/28 + * \author : M.Yang + * \purpose : ʹUTD2000M\UTD4000M\UTD2000CEX-EDUϵлʹõָ塣 + * ʹã鿴Ӧ͵Эĵ + */ +#ifndef CMD_COMVer2_h__ +#define CMD_COMVer2_h__ + +#ifdef __cplusplus +namespace comApiEx { +#endif + static const int Invalid_CMD = -1; + +#ifdef __cplusplus + static bool IsCMDValid(short cmd) { + return (cmd != Invalid_CMD); + } +#else + static int IsCMDValid(short cmd) + { + return (cmd == Invalid_CMD) ? 0 : 1; + } +#endif + + //@brief : ͨ + //@remarks : ӿڲCHΪ-1ΪEnumݣӦĶshot(2Bytes)ͽжд. + typedef enum _commom_cmd { + //@brief : ȡ豸ͱ + //@remarks : {IO:R}{DATA:comAPICommon::E_DSO_TYPE} + CMD_GET_DSO_TYPE = 0, + //@brief : ü + //@remarks : {IO:W}{DATA:null} + CMD_LOCK_KEYPAD, + //@brief : ü̽ + //@remarks : {IO:W}{DATA:null} + CMD_UNLOCK_KEYPAD, + //@brief : ȡ豸״̬ + //@remarks : {IO:R}{DATA:comApi::E_PROC_STATE from } + CMD_PROCSTATE, + //@brief : ִAUTOSET + //@remarks : {IO:W}{DATA:null} + CMD_AUTOSET, + //@brief : ִǿƴFORCE + //@remarks : {IO:W}{DATA:null} + CMD_TRIG_FORCE, + //@brief : ִеδSINGLE + //@remarks : {IO:W}{DATA:null} + CMD_SINGLE, + //@brief : ִCOARSE + //@remarks : {IO:W}{DATA:null} + CMD_COARSE, + //@brief : ִаPRTSC + //@remarks : {IO:W}{DATA:null} + CMD_PRTSC, + //@brief : + CMD_GET_BITMAP_FILENAME, + //@brief : ȡͼ + //@remarks : {IO:R}{DATA: 2000M/4000M768512Bytes} + CMD_GET_BITMAP_FILEDATA, + + //@brief : ָ + //@remarks : {IO:WR}{DATA<8Bytes>:comAPICommon::Key from } + CMD_KEY, + //@brief : ȡѹĻ + CMD_CAPTURE_SCREEN, + //@brief : д + CMD_DEV_CONFIG, + //@brief : ѯ豸ʾ + CMD_IDN, + //@brief : ѯЭ汾š + CMD_CVER, + + //@brief : ȡĻϢ + //@remarks : {IO:R}{DATA<20Bytes>:comApiEx::SCREEN_INFO from } + CMD_GET_SCREEN_INFO = 50, //SCREEN_INFO + //@brief : short 1: usb connection state is ok; other: usb connection state is not ok (ok) + //@remarks : + CMD_GET_USB_CONNECTION_STATE, + //@brief : õǰƵʼֵ + //@remarks : {IO:R}{DATA:comApiEx::SignalFreq from } + CMD_GET_CYMOMETER_VALUE, + //@brief : õǰѡеͨ + //@remarks : short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other (ok) + CMD_GET_CURRENT_ACTIVE_CHANNEL, //short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other (ok) + //@brief : õ豸˵ǰвIJ˵ + //@remarks : short 0: CH1 menu; 1: CH2 menu; 2: MATH or FFT menu; -1: other menu (ok) + CMD_GET_CURRENT_ACTIVE_MENU, + //@brief : ȡǰ˵Ƿʾ + //@remarks : short 0: current menu is not display; 1: current menu is display (ok) + CMD_GET_CURRENT_MENU_SHOW_STATE, + CMD_GET_SAMPLE, + //@brief : UǷ + //@remarks : {IO:R}{DATA: 0 δ룻 1 } + CMD_GET_USBDISK_STATE, + + //{acquire + //@brief : ɼģʽ + //@remarks : {IO:WR}{DATA:comApiEx::E_ACQ_MODE from } + CMD_ACQ_MODE = 400, + //@brief : ƽ + //@remarks : {IO:WR}{DATA: averageNum} + //ʵʴùʽ<2^(averageNum + 1)>, : {(0: 2), (1: 4), (2: 8), (3: 16), (4: 32), (5: 64), (6: 128), (7: 256)} + CMD_ACQ_AVERAGE_NUM, + //@brief : ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_SAMPLE_MODE from } + CMD_ACQ_SAMPLING, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_ACQ_SAV_DEPTH from } + CMD_ACQ_DEPTH, + //@brief : ٲɼ + //@remarks : {IO:WR}{DATA: 0 ر 1 } + CMD_ACQ_FAST, + //} + + //{trigger + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_TYPE from } + CMD_TRIG_TYPE = 500, + //@brief : Դ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_SOURCE from } + CMD_TRIG_SOURCE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_TIRG_COUPLING from } + CMD_TRIG_COUPLING, + //@brief : ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_MODE from } + CMD_TRIG_METHOD, + //@brief : شбʴ-б + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_EDGE_SLOPE(ء) E_SLOP_POLARITY(б) from } + CMD_TRIG_SLOPE_TYPE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_PULSE_POLAR from } + CMD_TRIG_PULSE_POLAR, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_PULSE_CONDITION from } + CMD_TRIG_PULSE_COND, + //@brief : ʱ + //@remarks : {IO:WR}{DATA: ֵstep, 㹫ʽ(t = K * step), һK = 4} + CMD_TRIG_PULSE_TIME, + //@brief : Ƶ-Ƶʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_VIDEO_STANDARD from } + CMD_TRIG_VIDEO_STD, + //@brief : Ƶ-ͬ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_VIDEO_SYNC_MODE from } + CMD_TRIG_VIDEO_SYNC, + //@brief : Ƶ-ָ + //@remarks : {IO:WR}{DATA: } + CMD_TRIG_VIDEO_LINE_NUMBER, + //@brief : бʴ-б + //@remarks : {IO:WR}{DATA: comApiEx::E_SLOP_WHEN from } + CMD_TRIG_SLOPE_COND, + //@brief : бʴ-ʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_SLOPE_TIME, + //@brief : бʴ-ֵ(Ƿ/µֵ) + //@remarks : {IO:WR}{DATA: comApiEx::E_SLOP_THRESHOLD from } + CMD_TRIG_SLOPE_THRESHOLD, + //@brief : бʴ-ѹ + //@remarks : {IO:R}{DATA: ַʽȡ} + CMD_TRIG_SLOPE_VT, + + //@brief : ʱ1 CEM""><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵstep, 㹫ʽ(t = K * step), һK = 4} + CMD_TRIG_PULSE_LT_TIME, + //@brief : бʴ-ʱ2 CEM"б"><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_SLOPE_LT_TIME, + + //@brief : - + //@remarks : {IO:WR}{DATA: comApiEx::E_WINDOE_WHEN from } + CMD_TRIG_WINDOW_COND, + //@brief : -ʱ + //@remarks :{IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_WINDOW_TIME, + //@brief : Ƿ- + //@remarks : {IO:WR}{DATA: comApiEx::E_RUNT_WHEN from } + CMD_TRIG_RUNT_COND, + //@brief : Ƿ-ʱ + //@remarks :{IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_RUNT_TIME, + //@brief : Ƿ-ʱ1 CEM""><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_RUNT_LT_TIME, + //} + + + //{display + //@brief : DISPLAY + //@remarks : {IO:WR}{DATA: comApiEx::E_DISPLAY_TYPE from } + CMD_DISPLAY_TYPE = 600, + //@brief : DISPLAY ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_DISPLAY_FORMAT from } + CMD_DISPLAY_FORMAT, + //@brief : DISPLAY դ + //@remarks : {IO:WR}{DATA: comApiEx::E_Display_Graticule from } + CMD_DISPLAY_GRID, + //@brief : DISPLAY ʱ + //@remarks : {IO:WR}{DATA: comApiEx::E_Dislay_PersistTime from } + CMD_DISPLAY_PERSIST, + //@brief : DISPLAY + //@remarks : {IO:WR}{DATA: һ 1 - 100 2000M4000M step[0,49] = curStep * 2 + 2} + CMD_DISPLAY_WAVE_LUM, + //} + + //{cursor + //@brief : Cursor + //@remarks : {IO:WR}{DATA: comApiEx::E_CURSOR_TYPE from } + CMD_CURSOR_TYPE, + //@brief : Cursor ģʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_CURSOR_MODE from } + CMD_CURSOR_MODE, + //@brief : Cursor ģʽ + //@remarks : {IO:WR}{DATA: ʱ comApiEx::E_CURSOR_V_UNIT ѹ : comApiEx::E_CURSOR_H_UNIT from } + CMD_CURSOR_UNIT, + //@brief : Cursor ׼ + //@remarks : {IO:WR}{DATA: E_CURSOR_POS from } + CMD_CURSOR_BASE, + //@brief : Cursor Aλõ + //@remarks : {IO:WR}{DATA : ˮƽߣΪ0һΪ25ֱߣΪ350һΪ50} + CMD_CURSOR_A_POS, + //@brief : Cursor Bλõ + //@remarks : {IO:WR}{DATA : ˮƽߣΪ0һΪ25ֱߣΪ350һΪ50 } + CMD_CURSOR_B_POS, + //} + + //{windows + CMD_WIN_TYPE, // (ok) + CMD_WIN_HOLDOFF, // + //} + + //{storage + //@brief : Storage + //@remarks : {IO:WR}{DATA: comApiEx::E_STORAGE_TYPE from } + CMD_STORAGE_TYPE = 700, + //@brief : Storage ļ + //@remarks : {IO:WR}{DATA: } + CMD_STORAGE_FILE_NAME, + //@brief : Storage ο-Դ + //@remarks : {IO:WR}{DATA: comApiEx::E_CHANNEL_ID from } + CMD_STORAGE_REFWAVE_SOURCE, + //@brief : Storage ο-ļʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_STORAGE_REFWAVE_FILE_FORMAT from } + CMD_STORAGE_REFWAVE_FILE_FORMAT, + //@brief : ȡô洢ļб + //@remarks :{IO:WR}{DATA: comApiEx::FileList_Flash from } + CMD_STORAGE_GET_FILE_LIST_FLASH, // (ok) + //@brief : ȡô洢ļб + //@remarks :{IO:WR}{DATA: comApiEx::FileList_USB from } + CMD_STORAGE_GET_FILE_LIST_USB, + //@brief : ִSAVE浽Flash. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_SAVE, + //@brief : ִLOADFlash. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_LOAD, + //@brief : ִImportU̼. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_IMPORT, + //@brief : ִExport + //@remarks : {IO:W}{DATA} + CMD_STORAGE_EXPORT, + //@brief : ѯǷѱ + //@remarks : {IO:R}{DATA : 0 ڣ 1 } + CMD_STORAGE_REFSETTING_EXIST, + //@brief : 洢λ + //@remarks : {IO:WR}{DATA : λ} + CMD_STORAGE_POS, + //} + + //{measure + MEASURE_ALL = 800, + MEASURE_CLEAR, + MEASURE_CUSTOMIZE, + MEASURE_INDICATOR, + MEASURE_DELAY_FROM, + MEASURE_DELAY_FEDGE, + MEASURE_DELAY_TO, + MEASURE_DELAY_TEGDE, + MEASURE_DELAY_OK, + MEASURE_PHASE_FROM, + + MEASURE_PHASE_TO, + MEASURE_PHASE_OK, + //} + + //for UTD2102CEX + CMD_MEASURE_SOURCE, + CMD_MEASURE_STATISTICS, + + //{utility + //@brief : ִУ + //@remarks : {IO:W}{DATA} + CMD_UTILITY_SELF_CALIBRATE = 1000, + CMD_UTILITY_SYSTEM_INFO, //(ok) + //@brief : ִClear + //@remarks : {IO:W}{DATA} + CMD_UTILITY_CLEAR_INFO, + //@brief : ִлָ + //@remarks : {IO:W}{DATA} + CMD_UTILITY_RESET_TO_FACTORY, + //@brief : Աȶ + //@remarks : {IO:WR}{DATA} + CMD_UTILITY_CONTRAST, + //@brief : л + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Language from } + CMD_UTILITY_LANGUAGE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Skin from } + CMD_UTILITY_SKIN, + //@brief : ˵ʾʱ + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Menu_Display_Time from } + CMD_UTILITY_MENU_DISP, + //@brief : + //@remarks : {IO:WR}{DATA} + CMD_UTILITY_GRID_LUM, + //@brief : Ƶʼƿ + //@remarks : {IO:WR}{DATA:comApiEx:: E_SWITCH_STATE from } + CMD_UTILITY_CYMOMETER, + + CMD_UTILITY_AUTOSET_CHANNEL, + CMD_UTILITY_AUTOSET_ACQUIRE, + CMD_UTILITY_AUTOSET_TRIG, + CMD_UTILITY_AUTOSET_SIGNAL, + //} + + //{record + CMD_DSO_RECORD_START, + CMD_DSO_RECORD_STOP, + CMD_DSO_RECORD_REPLAY, + CMD_DSO_RECORD_CLEAR, + //} + + //{ + CMD_UTILITY_SQUARE_WAVE, + CMD_UTILITY_SLEEP_TIME, + CMD_UTILITY_MEASURE_UNIT, + //} + + //{ + CMD_SYS_TIME_SWITCH = 1100, + CMD_SYS_TIME, + //} + + //{pass fail + CMD_PASS_FAIL_ALLOW_TEST, + CMD_PASS_FAIL_OUTPUT, + CMD_PASS_FAIL_SOURCE, + CMD_PASS_FAIL_DISP_INFO, + CMD_PASS_FAIL_OPERATION, + CMD_PASS_FAIL_STOP_TYPE, + CMD_PASS_FAIL_STOP_COND, + CMD_PASS_FAIL_STOP_THRESHOLD, + CMD_PASS_FAIL_TEMPLATE_WAVEREF, + CMD_PASS_FAIL_TEMPLATE_REFLOAD, + CMD_PASS_FAIL_TEMPLATE_HRANGE, + CMD_PASS_FAIL_TEMPLATE_VRANGE, + CMD_PASS_FAIL_TEMPLATE_CREATE, + //} + + //@brief : ȡͨݰʽĵ + //@remarks : + CMD_GET_DISPLAY_DATA = 1200, //get ch1, ch2, math, ref a/b data ok + //ͬDSO״̬ͣDSOAttrStateͿͶͬ + CMD_SYNC_DSO, + + //ʱDSOݡ + CMD_PERIOD_MSG2DSO, + + //{CEX-EDUʹ + //CEX-EDUʹãͽҪȡRECݵͷ׼ + CMD_DSO_RECORD_HEADER_READY = 1400, + //CEX-EDUʹãȡRECͷ + CMD_DSO_RECORD_HEADER, + //CEX-EDUʹãͽҪȡREC׼ + CMD_DSO_RECORD_DATA_READY, + //CEX-EDUʹãȡRECݿ顣 + CMD_DSO_RECORD_DATA, + //CEX-EDUʹãжϵǰRECǷЧ + CMD_DSO_RECORD_DATA_VALID, + //} + + //{2000M-special + CMD_VARDEPTH_SAMPLE_RATE = 1420, + CMD_VARDEPTH_SAVE_DEPTH, + CMD_VARDEPTH_PRE_TRIG_TIME, + CMD_VARDEPTH_AUTO_TRIG_TIME, + //} + + // + CMD_MESSAGE = 1430, + // + CMD_DUMP_BEGIN = 1440, + CMD_DUMP_ID = CMD_DUMP_BEGIN, + CMD_DUMP_END = 1500, //#TODO:Ҫṩ룬ͽCEX2000Mıôṩͳһ롣 + }COMMON_CMD; + + //@brief : ͨ + //@remarks : + typedef enum _channel_cmd + { + CH_Invalid_CMD = -1, + //@brief : ͨ + //@remarks : {IO:WR}{DATA:E_CH_COUPLING_TYPE} + CH_ATTR_COUPLING = 0, + //@brief : + //@remarks : {IO:WR}{DATA:E_CH_BANDLIMIT} + CH_ATTR_BAND_WIDTH, + //@brief : + //@remarks : + CH_ATTR_VOLT_SCALE, + //@brief : Ŵ + //@remarks : {IO:WR}{DATA:CH_PROBE} + CH_ATTR_PROBE, + //@brief : + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_INVERT, + //@brief : ƫõѹ + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_PRE_BIAS_VOLT_SWITCH, + //@brief : ƫõѹֵ + //@remarks : {IO:W}{DATA: +1 increase; -1 decrease;} + CH_ATTR_PRE_BIAS_VOLT_VALUE, + //@brief : ƫõѹ + //@remarks : {IO:W}{DATA:null} + CH_ATTR_PRE_BIAS_VOLT_TOZERO, + + //@brief : ͨ + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_CHANNEL_SWITCH = 100, + //@brief : ֱλ + //@remarks : {IO:WR}{DATA: UTD2000M -> ϵΪ [-100 , 100], CEX -> µ[28,128]} + CH_ATTR_VERTICAL_POS, + //@brief : ֱλù + //@remarks : {IO:W}{DATA:null} + CH_ATTR_VERTICAL_POS_TOZERO, + //@brief : Ԥλ + //@remarks : {IO:WR}{DATA: UTD2000M -> ĻмΪ350һΪ50} + CH_ATTR_TRIG_DEPTH, + //@brief : Ԥȹ + //@remarks : {IO:W}{DATA:null} + CH_ATTR_TRIG_DEPTH_TOZERO, + //@brief : ƽϢ + //@remarks : {IO:R}{DATA:comApiEx::CellBaseValue} + // ֻͨһƽ Ϊ comApiEx::CellBaseValues TrigVolt; + // бʴƽ Ϊ comApiEx::CellBaseValues TrigVolt[2]; + CH_ATTR_TRIG_LEVEL, + //@brief : ƽλ + //@remarks : {IO:WR}{DATA: ͨΪ0㣬¸ÿ25} + CH_ATTR_TRIG_LEVEL_POS, + //@brief : ƽλù + //@remarks : {IO:WR}{DATA: ͨΪ0㣬¸ÿ25} + CH_ATTR_TRIG_LEVEL_TOZERO, + //@brief : Ϣ + //@remarks : {IO:R}{DATA: CellBaseValue} + CH_ATTR_VOLT_AMPLITUDE, + //񵲵λΪshort + //@brief : 񵲵λ + //@remarks : {IO:WR}{DATA: +1 increase; -1 decrease; other : code } + CH_ATTR_VOLT_AMPLITUDE_LEVEL, + //ʱλΪshortֻã + //@brief : ʱλ + //@remarks : {IO:W}{DATA: E_TIMEBASE_LEVEL } + CH_ATTR_TIME_BASE, + //@brief : ȡʱʱ + //@remarks : {IO:R}{DATA: CellBaseValue} + CH_ATTR_TIME_BASE_VALUE, + + //@brief : MATH + //@remarks : {IO:WR}{DATA: E_MATH_TYPE } + CH_MATH_TYPE = 200, + //@brief : MATHԴ1 + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_MATH_OP1, + //MATHͣͣshort + //@brief : MATH + //@remarks : {IO:WR}{DATA: E_MATH_OP_SIGN } + CH_MATH_OP, + //@brief : MATHԴ2 + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_MATH_OP2, + //@brief : FFTԴ + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_FFT_SRC, + //@brief : FFT + //@remarks : {IO:WR}{DATA: E_FFT_WINDOW } + CH_FFT_WINDOW, + //@brief : FFTֱλ + //@remarks : {IO:WR}{DATA: E_FFT_UNIT } + CH_FFT_VSCALE, + //@brief : ȡFFTƵֵ + //@remarks : {IO:R}{DATA: SignalFreq } + CH_FFT_FREQ, + //@brief : ˲ + //@remarks : {IO:WR}{DATA: E_FILTER_TYPE } + CH_FILTER_TYPE, + //@brief : Ƶ + //@remarks : {IO:WR}{DATA: ֵƵֵҪм} + CH_FILTER_FREQ_LOW, + //@brief : Ƶ + //@remarks : {IO:WR}{DATA: ֵƵֵҪм} + CH_FILTER_FREQ_HIGH, + //@brief : ˲Դ + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_FILTER_SRC, + + //@brief : REFص() + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_LOAD_FROM_FLASH = 300, + //@brief : REF벨(USB) + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_LOAD_FROM_USB, + //@brief : REF洢λõ + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_POS, + //@brief : жijһλòǷڣλCH_REF_POSõģ + //@remarks : {IO:R}{DATA: Ϊ洢λֵ } + CH_REF_POS_WAVE_EXIST, + //@brief : д洢 + //@remarks : {IO:W}{DATA : null } + CH_REF_CLEAR, + + //[] + CH_DISPLAY_DATA = 400, + //[]ȡԭʼݣCH_GET_SAV_DATA + CH_ORIGIN_DATA, + + //@brief : ȡSAVļݣݸʽ [4Bytes ļ] + [ļ] + //@remarks : ʹ÷ʽĵʾ + // UTD2102CMUTD4000M ӦСΪ32768Bytes UTD2102CEX-EDUӦ32000Bytes + CH_GET_SAV_DATA, + + //{2102CM-x + CH_VARDEPTH_ENABLE = 500, + CH_VARDEPTH_SAMPLE_RATE, + + CH_VARDEPTH_DATA_READY = 510, + CH_VARDEPTH_DATA, + + CH_VOLT_AMPLITUDE_LEVEL, //ѹֵãֱӽ0~15λ + CH_PRE_BIAS_VOLT_VALUE, //ƫõѹãֱõѹȸֵ + + CH_VARDEPTH_TRIG_READY, //ͨDSO׽źŵĻ + //} + }CHAN_CMD; + +#ifdef __cplusplus +} +#endif + +#endif // CMD_COMVer2_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/ItemCode_COMVer2.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/ItemCode_COMVer2.h new file mode 100644 index 0000000..e5b817a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/ItemCode_COMVer2.h @@ -0,0 +1,449 @@ +/*! + * \created : 2016/12/28 + * \author : M.Yang + * \purpose : ģUTD2000M\UTD4000M\UTD2000CEX-EDUϵлʹõѡͲѡ붨塣 + */ +#ifndef ItemCode_COMVer2_h__ +#define ItemCode_COMVer2_h__ + +#ifdef __cplusplus +namespace comApiEx +{ +#endif + +enum E_SWITCH_STATE +{ + SWITCH_OFF, + SWITCH_ON, +}; + +#pragma region Channel +typedef enum{ + CH_Invalid_ID = -1, + CH_1_ID = 0, + CH_2_ID, + CH_MATH_ID, + CH_REF_A_ID, + CH_REF_B_ID, + CH_MAX_CNT, +}E_CHANNEL_ID; + +enum E_REF_SRC +{ + REF_A = 0, + REF_B, +}; + +enum E_CH_COUPLING_TYPE +{ + CH_COUPLING_DC = 0, + CH_COUPLING_AC, + CH_COUPLING_GND, +}; + +enum E_CH_BANDLIMIT +{ + CH_BANDLIMIT_FULL, + CH_BANDLIMIT_HALF, + CH_BANDLIMIT_20MHZ, +}; + +// +typedef enum { + CH_PROBE_1X = 0, + CH_PROBE_10X, + CH_PROBE_100X, + CH_PROBE_1000X, + + //2017-3-13CEM + CH_PROBE_2X, + CH_PROBE_5X, + CH_PROBE_20X, + CH_PROBE_50X, + CH_PROBE_200X, + CH_PROBE_500X, + CH_PROBE_1MX, + CH_PROBE_2MX, + CH_PROBE_5MX, + CH_PROBE_10MX, + CH_PROBE_20MX, + CH_PROBE_50MX, + CH_PROBE_100MX, + CH_PROBE_200MX, + CH_PROBE_500MX, +}CH_PROBE; + +#pragma endregion Channel + +#pragma region Trigger +////////////////////////////Trigger/////////////////////////////////// +//2017-3-13ӴںǷ +enum E_TRIG_TYPE +{ + TRIG_TYPE_EDGE = 0, //: + TRIG_TYPE_PLUSE_WIDTH, //: + TRIG_TYPE_VIDEO, //: Ƶ + TRIG_TYPE_SLOPE, //: б + TRIG_TYPE_WINDOW, //: ڣ + TRIG_TYPE_RUNT, //: Ƿ +}; + +enum E_TRIG_SOURCE +{ + TRIG_CH1 = CH_1_ID, + TRIG_CH2 = CH_2_ID, + TRIG_EXT, + TRIG_EXT_5, //EXT/5 + TRIG_AC_LINE = 4, + TRIG_ALTER, +}; + +enum E_TIRG_COUPLING +{ + TIRG_COUPLING_DC = 0, + TIRG_COUPLING_AC, + TIRG_COUPLING_L_RESTRAIN, //trigger coupling low frequency restrain + TIRG_COUPLING_H_RESTRAIN, //trigger coupling high frequency restrain + TIRG_COUPLING_NOISE_REJ, // +}; + +enum E_TRIG_MODE +{ + TRIG_MODE_AUTO = 0, + TRIG_MODE_NORMAL, + TRIG_MODE_SINGLE, +}; + +enum E_TRIG_EDGE_SLOPE +{ + TRIG_EDGE_SLOP_RISE = 0, + TRIG_EDGE_SLOP_FALL, + TRIG_EDGE_SLOP_RISE_FALL, +}; + +enum E_PULSE_POLAR +{ + PULSE_POLAR_N = 0, + PULSE_POLAR_P , +}; + +//2017-3-13PULSE_CONDITION_GT_LT +enum E_PULSE_CONDITION +{ + PULSE_CONDITION_LT = 0, //pulse condition less than + PULSE_CONDITION_GT, //pulse condition greater than + PULSE_CONDITION_ET, //pulse condition equal to + + PULSE_CONDITION_NO_EQUAL, //pulse not equal to , add by yzz [RESERVE] + PULSE_CONDITION_GT_LT, +}; + +enum E_TRIG_VIDEO_STANDARD +{ + TRIG_Video_NTSC = 0, + TRIG_Video_PAL, +}; + +//Ƶ-ͬʽ(0)ż(1)(2)ָ(3) +enum E_TRIG_VIDEO_SYNC_MODE +{ + TRIG_Video_SyncMode_Odd = 0, + TRIG_Video_SyncMode_Even, + TRIG_Video_SyncMode_ALL, + TRIG_Video_SyncMode_Specified, +}; + +enum E_SLOP_POLARITY +{ + SLOP_POLAR_FALL = 0, + SLOP_POLAR_RISE, +}; + +//2017-3-13SLOP_WHEN_GT_LT +enum E_SLOP_WHEN +{ + SLOP_WHEN_LT = 0, + SLOP_WHEN_GT, + SLOP_WHEN_Equal, + SLOP_WHEN_GT_LT, +}; + +enum E_SLOP_THRESHOLD +{ + SLOP_THRESHOLD_LOW = 0, + SLOP_THRESHOLD_HIGH, + SLOP_THRESHOLD_LOW_HIGH, +}; + +// +enum E_WINDOE_WHEN +{ + TRIG_SCOPE_WHEN_ENTER = 0, + TRIG_SCOPE_WHEN_EXIT, + TRIG_SCOPE_WHEN_TIME, +}; +// Ƿ +enum E_RUNT_WHEN +{ + TRIG_RUNT_WHEN_NO = 0, + TRIG_RUNT_WHEN_GT, + TRIG_RUNT_WHEN_LT, + TRIG_RUNT_WHEN_GT_LT, +}; + +#pragma endregion Trigger + +#pragma region Math +/////////////////////////////Math////////////////////////////////////// +enum E_MATH_TYPE +{ + MATH_TYPE_MATH = 0, + MATH_TYPE_FFT, + MATH_TYPE_FILTER, +}; + +enum E_MATH_OP_SIGN +{ + OP_SIGN_ADD = 0, + OP_SIGN_SUB, + OP_SIGN_MULTIPLY, + OP_SIGN_DIVIDE, +}; + +enum E_FFT_WINDOW +{ + FFT_WIN_HAMMING = 0, + FFT_WIN_BLACKMAN, + FFT_WIN_RECTANGLE, + FFT_WIN_HANNING +}; + +enum E_FFT_UNIT +{ + FFT_UNIT_VRMS = 0, + FFT_UNIT_DBVRMS, +}; + +enum E_FILTER_TYPE +{ + FILTER_LOW = 0, + FILTER_HIGH, + FILTER_BAND, + FILTER_BAND_STOP, //Ӵ +}; + +enum E_MATH_ZOOM_RATE +{ + ZOOM_RATE_DIV_1, + ZOOM_RATE_DIV_10, + ZOOM_RATE_DIV_100, + ZOOM_RATE_DIV_1000, +}; +#pragma endregion Math + +#pragma region Acquire +////////////////////////////Acquire////////////////////////////////// +//2017-3-13Ӹ߷ֱ +enum E_ACQ_MODE +{ + ACQ_MODE_NORMAL = 0, + ACQ_MODE_PEAK, + ACQ_MODE_AVERAGE, + ACQ_MODE_HIGHRESOLUTION, +}; + +enum E_SAMPLE_MODE +{ + ACQ_SAMPLE_EQUIVALENT = 0, + ACQ_SAMPLE_REAL, + ACQ_SAMPLE_SCAN, +}; +//32m,3.2m,32k,3.2k +enum E_ACQ_SAV_DEPTH +{ + ACQ_DEPTH_NORMAL = 0, + ACQ_DEPTH_DEPTH, + ACQ_DEPTH_32M, + ACQ_DEPTH_3POINT2M, + ACQ_DEPTH_32K, + ACQ_DEPTH_3POINT2K, + +}; +#pragma endregion Acquire + +#pragma region Display +////////////////////////////Display////////////////////////////////// +enum E_DISPLAY_TYPE +{ + DISPLAY_TYPE_YT = 0, + DISPLAY_TYPE_XY, +}; + +enum E_DISPLAY_FORMAT +{ + DISPLAY_FORMAT_VECTOR = 0, + DISPLAY_FORMAT_DOT, +}; + +enum E_Display_Graticule +{ + Display_Graticule_Full, + Display_Graticule_Grid, + Display_Graticule_CrossHair, + Display_Graticule_Frame, +}; + +enum E_Dislay_PersistTime +{ + Display_PersistTime_Auto, + Display_PersistTime_Short, + Display_PersistTime_Long, + Display_PersistTime_Unlimited, +}; +#pragma endregion Display + +#pragma region Utility +////////////////////////////Utility////////////////////////////////// +enum E_Utility_Skin +{ + UTILITY_SKIN_CLASSIC, + UTILITY_SKIN_TRADITIONAL, + UTILITY_SKIN_MODERN, +}; + +enum E_Utility_Menu_Display_Time +{ + UTILITY_MENU_DISPLAY_T5S, + UTILITY_MENU_DISPLAY_T10S, + UTILITY_MENU_DISPLAY_T20S, + UTILITY_MENU_DISPLAY_TMANUAL, + + UTILITY_MENU_DISPLAY_T1S, + UTILITY_MENU_DISPLAY_T2S, +}; + +enum E_Utility_Language +{ + UTILITY_LANG_ZHCN, // + UTILITY_LANG_ZHTW, // + UTILITY_LANG_ENGLISH, //Ӣ + UTILITY_LANG_GERMAN, // + UTILITY_LANG_RUSSIANS, // + + UTILITY_LANG_ESPANOL, // + UTILITY_LANG_PORTUGUESE, // + UTILITY_LANG_FRENCH, // + UTILITY_LANG_DUTCH, // +}; + +enum E_Utility_AutoSet +{ + UTILITY_AUTOSET_LOCK_ON, + UTILITY_AUTOSET_LOCK_OFF, +}; + +enum E_Utility_PassFail_AllowTesting +{ + UTILITY_PF_ALLOWTEST_COLSE, + UTILITY_PF_ALLOWTEST_OPEN, +}; + +enum E_Utility_PassFail_Output +{ + UTILITY_PF_OUTPUT_PASS, + UTILITY_PF_OUTPUT_FAIL, +}; + +enum E_Utility_PassFail_DisplayInfo +{ + UTILITY_PF_DISPLAYINFO_OPEN, + UTILITY_PF_DISPLAYINFO_CLOSE, +}; + +enum E_Utility_PassFail_Operation +{ + UTILITY_PF_OPERATION_PLAY, + UTILITY_PF_OPERATION_STOP, +}; + +enum E_Utility_PassFail_StopSet_Type +{ + UTILITY_PF_STOPSET_TYPE_PASSTIMES, + UTILITY_PF_STOPSET_TYPE_FAILTIME, +}; + +enum E_Utility_PassFail_StopSet_Condition +{ + UTILITY_PF_STOPSET_CONDITION_GT_EQU, + UTILITY_PF_STOPSET_CONDITION_LT_EQU, +}; +#pragma endregion Utility + +#pragma region Storage +////////////////////////////Storage////////////////////////////////// +enum E_STORAGE_TYPE +{ + STORAGE_TYPE_SETTING, + STORAGE_TYPE_WAVE, + STORAGE_TYPE_BITMAP, +}; + + +enum E_STORAGE_REFWAVE_FILE_FORMAT +{ + STORAGE_REFWAVE_FILE_FMT_CSV, + STORAGE_REFWAVE_FILE_FMT_INNER, +}; + +#pragma endregion Storage + +#pragma region Cursor +enum E_CURSOR_TYPE +{ + CURSOR_TYPE_TIME, + CURSOR_TYPE_VOLTAGE, + CURSOR_TYPE_TRACK, + CURSOR_TYPE_DUMP, + CURSOR_TYPE_CLOSED, +}; + +enum E_CURSOR_MODE +{ + CURSOR_MODE_INDEPENDENT, + CURSOR_MODE_TRACK, +}; + +enum E_CURSOR_H_UNIT +{ + CURSOR_UNIT_H_BASE, + CURSOR_UNIT_H_PERCENT, +}; + +enum E_CURSOR_V_UNIT +{ + CURSOR_UNIT_V_SECOND, + CURSOR_UNIT_V_HERTZ, + CURSOR_UNIT_V_PERCENT, + CURSOR_UNIT_V_DEGREE, +}; + +enum E_CURSOR_POS +{ + CURSOR_POS_CURRENT = 3, + CURSOR_POS_6DIV, +}; +#pragma endregion Cursor + +enum E_Measure_Edge +{ + Measure_Edge_Fall, + Measure_Edge_Rise, +}; + + +#ifdef __cplusplus +} +#endif + + +#endif // ItemCode_COMVer2_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UPO.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UPO.h new file mode 100644 index 0000000..9be5b1b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UPO.h @@ -0,0 +1,222 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩʹUCIӿڵģDSOض + */ + +#ifndef DSO_UPO_h__ +#define DSO_UPO_h__ + +#ifdef __cplusplus +namespace upo2k { +#endif // __cplusplus + ////////////////////////////////////////////////////////////////////////// + // UPOλ壺 + // 16bit8λΪλͣ8λΪλ! + // ȡʽ short unit + // char unit_code = unit & 0xff; + // if((unit & UT_Time) == UT_Time) unit_code is ETime + // else if((unit & UT_Freq) == UT_Freq) unit_code is EFreq + ////////////////////////////////////////////////////////////////////////// + + //@brief : λ + //@remarks : 8λΪλͣ8λΪλ! +#ifdef __cplusplus + typedef enum _UnitType : unsigned short { +#else + typedef enum _UnitType { +#endif // __cplusplus + UT_Voltage = (0x0000), + UT_Time = (0x0100), + UT_Freq = (0x0200), + UT_Percent = (0x0300), + UT_Degree = (0x0400), + UT_DB = (0x0500), + UT_SamplePoint = (0x0600), + //@brief : + UT_Current = (0x0700), + //@brief : + UT_Watt = (0x0800), + //@brief : δ֪λ + UT_Unknown = (0x0900), + + UT_Invalid = (0x8000), + }UnitType; + + enum EFreq { + Hz = 0, + KHz, + MHz, + GHz, + THz, + }; + + enum ETime { + s = 0, + ms, + s, + ns, + ps, + }; + + enum EVoltage { + V = 0, + mV, + V, + KV + }; + + enum ECurrent { + A = 0, + mA, + A, + KA + }; + + enum EWatt { + W = 0, + mW, + W, + KW + }; + + enum EUnknown { + U = 0, + mU, + U, + KU + }; + + enum EDB { + mdB = 0, + dB, + kdB + }; + + enum EPoint { + Sa = 0, + KSa, + MSa, + GSa, + }; + + enum EPercent { + Percent = 0 + }; + + enum EDegree { + Degree = 0, + }; + + static inline char GetUnitType(short _v) { return (char)(_v >> 8); } + static inline char GetUnitCode(short _v) { return _v & 0xff; } + + //@brief : λ + //@remark: ָͨLock?ȡ64bitλǡ + typedef enum _KeyFlagsPos { + IKEY_F1, + IKEY_F2, + IKEY_F3, + IKEY_F4, + IKEY_F5, + + IKEY_CH1, + IKEY_CH2, + IKEY_CH3, + IKEY_CH4, + + IKEY_MATH, + IKEY_REF, + IKEY_HORIZON, + IKEY_TRIGGER, + IKEY_FORCE, + IKEY_HELP, + IKEY_MEASURE, + IKEY_CURSOR, + IKEY_ACQUIRE, + IKEY_DISPLAY, + IKEY_STORAGE, + IKEY_UTILITY, + IKEY_DECODE, + IKEY_DEFAULT, + IKEY_AUTOSET, + IKEY_RUNSTOP, + IKEY_SINGLE, + IKEY_CLEAR, + IKEY_PRINTSCREEN, + IKEY_MENU, + + IKEY_OFFSET_LEFT, + IKEY_OFFSET_RIGHT, + IKEY_OFFSET_OK, + + IKEY_PRETRIG_LEFT, + IKEY_PRETRIG_RIGHT, + IKEY_PRETRIG_OK, + + IKEY_TRIGLEVEL_LEFT, + IKEY_TRIGLEVEL_RIGHT, + IKEY_TRIGLEVEL_OK, + + IKEY_VOLTS_LEFT, + IKEY_VOLTS_RIGHT, + IKEY_VOLTS_OK, + + IKEY_TIMEBASE_LEFT, + IKEY_TIMEBASE_RIGHT, + IKEY_TIMEBASE_OK, + + IKEY_SELECT_LEFT, + IKEY_SELECT_RIGHT, + IKEY_SELECT, + }KeyFlagsPos; + + typedef struct _CellBaseValue { + float Value; + short Unit; + short IsLimit; // == 1,yes; =0, no! + }CellBaseValue; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + +#include //1ֽڶ + //@brief : λ + //@remark: + typedef struct _measure_param { + float value; //ЧʱֵΪ FLT_MAX + //@brief : λ + //@remark: λUnitType + short unit; //ЧʱֵΪ UT_Invalid = (0x8000) + }UValue; + + //@brief : ȡLED״̬ + //@remark: 1 - 0 δ ָLED? ȡ + typedef struct _KeyLedStat { + char CH1, CH2, CH3, CH4, MATH, REF, RUN_STOP, Single; + }KeyLedStat; + + //@brief : ݰ + typedef struct _CursorMeasurePack { + UValue Ax; + UValue Bx; + UValue Bx_Ax; + UValue Hz_Bx_Ax; + UValue Ay; + UValue By; + UValue By_Ay; + char Reserver[8]; + }CursorMeasurePack; +#include + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // DSO_UPO_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UTG2025Def.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UTG2025Def.h new file mode 100644 index 0000000..4ba8f86 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UTG2025Def.h @@ -0,0 +1,178 @@ +/******************************************************************** + created: 2015/04/08 + author: M.Yang + purpose: ṩUTG2000A&UTG7000źԴض + *********************************************************************/ + +#ifndef UTG2025Def_h__ +#define UTG2025Def_h__ + +#ifdef __cplusplus +namespace SG62_25A { +#endif + //@brief : UTG2000A&UTG7000źԴ + typedef enum _ParamNo { + Invalid_Cmd = -1, + //@brief : ǰģʽ + CurMode = 6, + //@brief : Ⲩģʽ + ArbPlayMode = 7, + //@brief : + WaveType = 8, + //@brief : Ƶ + Freq = 9, + //@brief : + Period = 10, + //@brief : -ֵ + AmpVpp = 11, + //@brief : -Чֵ + AmpVrms = 12, + //@brief : - + AmpDbm = 13, + //@brief : ֱƫ + DCOffset = 14, + //@brief : ߵƽ + High = 15, + //@brief : ͵ƽ + Low = 16, + //@brief : λ + Phase = 17, + //@brief : ռձ + DutyCycle = 18, + //@brief : Գƶ + Symmetry = 19, + //@brief : + PulseWidth = 20, + //@brief : ʱ + PulseRisingTime = 21, + //@brief : ½ʱ + PulseFallingTime = 22, + //@brief : + ArbSampleRate = 23, + //@brief : ARBļ + ArbName = 24, + //@brief : + ArbLength = 25, + + + //@brief : + ModulateType = 40, + //@brief : Ƶ + ModulateFreq = 28, + //@brief : Դ + ModulateSource = 29, + //@brief : Ʋ + ModulateShape = 30, + //@brief : + ModulateOnOff = 31, + //@brief : + ModulateAMDeepth = 32, + //@brief : Ƶƫ + ModulateFMFreqDev = 33, + //@brief : ƫ + ModulatePMPhaseDev = 34, + //@brief : ԾƵ + ModulateFSK_HopFreq = 35, + //@brief : + ModulateFSKRate = 36, + //@brief : Ƽ-λ + ModulatePSKPhase = 37, + //@brief : ƵƼ-زƵ + ModulateFSK_CarrierFreq = 38, + //@brief : -ռձƫ + ModulatePWM_DutyDev = 39, + + //@brief : ɨƵ-ʼƵ + SweepStartFreq = 47, + //@brief : ɨƵ-ֹͣƵ + SweepStopFreq = 48, + //@brief : ɨƵ-ɨʱ + SweepTime = 49, + //@brief : ɨƵ- + SweepType = 50, + + //@brief : лƵ÷ʽ-Ƶʻ + Wave_Freq_Or_Period = 51, + //@brief : л÷ʽ-Ȼ߸ߵ͵ƽ + Wave_Amp_Or_HighLow = 52, + //@brief : лͬķʾλ + Wave_Amp_Unit = 53, + + //@brief : 崮 - ʼλ + BurstStartPhase = 57, + //@brief : 崮 - ⧷ + BurstPeriod = 58, + //@brief : 崮 - ѭ + BurstCycleCount = 59, + //@brief : 崮 - ſ- + BurstPolarity = 60, + //@brief : 崮 - + BurstType = 61, + + //@brief : Դ + TriggerSource = 68, + //@brief : + SyncType = 69, + //@brief : + TriggerEdge = 70, + //@brief : + TriggerOnOff = 71, + + //@brief : CH1 ͨʹ + OutputEnable = 77, + //@brief : CH2 ͨʹ + OutputEnable2 = 78, + //@brief : + Invert = 79, + //@brief : 迹 + OutputExtRes = 80, + //@brief : + OutputLimit = 81, + //@brief : + OutputLimitHigh = 82, + //@brief : + OutputLimitLow = 83, + //@brief : ͬ + SyncOut = 84, + //@brief : + Couple = 85, + //@brief : IPַ + IPAddrType = 101, + //@brief : IPַ + IPAddr = 102, + //@brief : + IPSubnetMask = 103, + //@brief : + IPGateway = 104, + //@brief : DNS + IPDns = 105, + //@brief : MACַ + Mac = 106, + //@brief : + Language = 107, + //@brief : ʱԴ + ClkSource = 108, + //@brief : + PowerOnParam = 109, + //@brief : + BeepOnOff = 110, + //@brief : ַָ + CharDivideInt = 111, + //@brief : + LoadSettting = 112, + //@brief : + SaveSetting = 113, + //@brief : + Backlight = 114, + //@brief : + About = 115, + //@brief : ʱ + ClkOut = 116 + }ParamNo; + +#ifdef __cplusplus +} +#endif + + +#endif // UTG2025Def_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UTG4162.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UTG4162.h new file mode 100644 index 0000000..a629417 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/UTG4162.h @@ -0,0 +1,449 @@ +/******************************************************************** + created: 2015/01/14 + author: M.Yang + purpose: UCIʹõйUTG4000&UTG8000Ķ + *********************************************************************/ +#ifndef UTG4162_h__ +#define UTG4162_h__ + +#ifdef __cplusplus +namespace uci { + namespace utg4162 { +#endif // __cplusplus + + /////////////////////////////////Key Define///////////////////////////// + + //@brief : UTG4000&UTG8000ϵл͵尴ֵ塣 + //@remark: + typedef enum _SGKeys { + Key_F1 = 0, + Key_F2, + Key_F3, + Key_F4, + Key_F5, + Key_F6, + Key_0 = '0', + Key_1, + Key_2, + Key_3, + Key_4, + Key_5, + Key_6, + Key_7, + Key_8, + Key_9, + Key_Dot, + Key_Symbol, + Key_Right, + Key_Left, + Key_Ok, + Key_Up, + Key_Down, + // + Key_User, + Key_Digital, + Key_Counter, + Key_Mod, + Key_Sweep, + Key_Bst, + Key_Sine, + Key_Noise, + Key_Square, + Key_Ramp, + Key_Pulse, + Key_Arb, + Key_Harmonic, + Key_DC, + Key_Ch1, + Key_Ch2, + Key_Trigger, + Key_SwapCh, + Key_OtherPage, + Key_Preset, + Key_Storge, + Key_StorgeL, + Key_Utility, + Key_Help, + Key_HelpL, + Key_Esc, + Key_PrScreen, + Key_Null = 0xff + }SGKeys; + + inline int GetKeyIndex(SGKeys _code) { + return (_code >= Key_F1 && _code < Key_F6) ? _code : _code - '0' + 6; + }; + + + //@brief : жϰǷ + //@param _code : ֵ + //@param _v : ǰ״̬64bitʹָ"lock?"ȡ + //@return : == 0 δ + //@remarks : + inline int IsKeyLocked(SGKeys _code, long long _v) { + return _v & ((long long)1 << GetKeyIndex(_code)); + }; + + //@brief : LED״̬ + //@remarks : 0 ʾ 1 ʾ + typedef struct _LEDStatus { + char Noise; + char UTILTY; + char STORGE; + char RAMP; + char PULSE; + char COUNTER; + char USER; + char DIGTAL; + char HARMONIC; + char DC; + char TRGGER; + char CH2; + char SWAPCH; + char ARB; + char CH1; + char SINE; + char SQUARE; + }LEDStatus; + + + /////////////////////////////////File Load///////////////////////////// + //@brief : Ⲩļطʽ + typedef enum _ARBWriteMode { + //@brief : زʽ + ARB_MODE_CARRIER = 0, + //@brief : ԵƲʽ + ARB_MODE_MOD, + }ARBWriteMode; + + //@brief : صļŽ + typedef enum _FileMedium { + //@brief : ŵRAM + FM_RAM = 0, + //@brief : ŵROM + FM_ROM, + //@brief : ŵTF + FM_TF, + //@brief : ŵU + FM_UDISK + }FileMedium; + + + /////////////////////////////////Parameters Address Define///////////////////////////// + //ģʽ + typedef enum _EWorkMode : long long { + //@brief : ģʽ + WM_BASE = 0, + //@brief : Ʋģʽ + WM_MODE, + //@brief : ɨƵģʽ + WM_SWEEP, + //@brief : ⧷ + WM_BURST, + }EWorkMode; + + // + typedef enum _EBaseWave : long long { + //@brief : Ҳ + BASE_SINE = 0, + //@brief : + BASE_SQUARE = 1, + //@brief : б + BASE_RAMP = 3, + //@brief : 岨 + BASE_PULSE = 4, + //@brief : + BASE_NOISE = 5, + //@brief : Ⲩ + BASE_ARB = 6, + //@brief : г + BASE_HARMONIC = 7, + //@brief : ֱ + BASE_DC = 8 + }EBaseWave; + + typedef enum _EModeType : long long { + MT_AM = 0, + MT_FM = 1, + MT_PM = 2, + MT_ASK = 3, + MT_FSK = 4, + MT_PSK = 5, + MT_BPSK = 6, + MT_QPSK = 7, + MT_OSK = 8, + MT_QAM = 9, + MT_PWM = 10, + MT_SUM = 11, + }EModeType; + + //Ʋ + typedef enum _EModeWaveType : long long { + MOD_WAVE_SINE = 0, + MOD_WAVE_SQUARE = 1, + MOD_WAVE_UPRAMP = 2, + MOD_WAVE_DNRAMP = 3, + MOD_WAVE_NOISE = 4, + MOD_WAVE_ARB = 5, + }EModeWaveType; + + //@brief : źԴ + //@remark: ʹrpָдʹwpָ + //@example: wp@ch:0@addr:0x8000@v:0; + // rp@ch:0@addr:0x8000; + // вĶӦ8bytesdouble + typedef enum _enumRemoteMessage { + //@brief : ģʽ + //@remark: {IO:WR}{DATA:EWorkMode} + RM_WORK_MODE = 0x8000, + + //{ + //@brief : ͨ + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_CH_SW = 0x8001, + //@brief : ͬ + //@remark: {IO:WR}{DATA: 0-OFF1-ON2-reverse} + RM_CH_SYNC_SW, + //@brief : ͨ + //@remark: {IO:WR}{DATA: 0OFF1ON} + RM_CH_REVERTSE, + //@brief : ͨ迹 + //@remark: {IO:WR}{DATA: 1~1000} + RM_CH_LOAD, + //@brief : ͨʹ + //@remark: {IO:WR}{DATA: 0OFF1ON} + RM_CH_OUTPUT_LIMIT_ENABLE, + //@brief : ͨ͵ƽ + //@remark: {IO:WR}{DATA: -10V~MAX_LEVEL} + RM_CH_OUTPUT_LIMIT_MIN_LEVEL, + //@brief : ͨߵƽ + //@remark: {IO:WR}{DATA: MIN_LEVEL~10V} + RM_CH_OUTPUT_LIMIT_MAX_LEVEL, + + //@brief : + //@remark: {IO:WR}{DATA:EBaseWave} + RM_BASE_WAVE_TYPE = 0x8008, + //@brief : Ƶ(λHz) + //@remark: {IO:WR}{DATA: 1uHz~ǰƵ} + RM_BASE_FREQ, + //@brief : λ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_BASE_PHASE = 0x800A, + //@brief : (λVPP) + //@remark: {IO:WR}{DATA: 1mVpp~10Vpp50ŷķ} + RM_BASE_AMP_VPP, + //@brief : (λVRMS) + //@remark: {IO:WR}{DATA: 1mVRMS~5Vpp50ŷķ} + RM_BASE_AMP_VRMS, + //@brief : (λVDBM) + //@remark: {IO:WR}{DATA: -53.010VDBM~26.99VDBM50ŷķ} + RM_BASE_AMP_VDBM, + //@brief : ƫ(λV) + //@remark: {IO:WR}{DATA: -5VRMS~5Vpp50ŷķ} + RM_BASE_OFFSET, + //@brief : ߵƽ(λV) + //@remark: {IO:WR}{DATA: BASE_LOW~5Vpp50ŷķ} + RM_BASE_HIGHT = 0x800F, + //@brief : ͵ƽ(λV) + //@remark: {IO:WR}{DATA: -5VRMS~BASE_HIGHT50ŷķ} + RM_BASE_LOW = 0x8010, + //@brief : ռձȶԷռձȡ岨ռձȡDzԳƶȹ + //@remark: {IO:WR}{DATA: 0~100} + RM_BASE_DUTY, + //@brief : 岨ʱ(λs) + //@remark: {IO:WR}{DATA: min ~ *0.4} + RM_BASE_RISETIME, + //@brief : 岨½ʱ(λs) + //@remark: {IO:WR}{DATA: min ~ *0.4} + RM_BASE_FALLTIME, + //@brief : Ⲩģʽ + //@remark: {IO:WR}{DATA:0OFF1ON} + RM_BASE_ARB_PLAY_ENABLE, + //@brief : г - ģʽ + //@remark: {IO:WR} + //{DATA: + //0: , + //1: ż, + //2: ȫ, + //3: USER,Զ + // } + RM_BASE_HARMOIC_TYPE = 0x8080, + //@brief :г,RM_BASE_HARMOIC_TYPE=USERʱЧ + //@remark: {IO:WR}{DATA:BIT14BIT0ֱӦ2~16гأBIT15Ӧǿƿ} + RM_BASE_HARMONIC_ONOFF, + //N(2~16)г,Կַ: + //EG:N=3(г),AMP = 1Vpp, PHASE = 90 + //1: + //1ָгRM_HARMONIC_NUM = N(2~16), + //2趨гķȺλ, + // RM_HARMONIC_SN_AMP_N = 1.0; RM_HARMONIC_SN_PHASE_N = 90.0; + //1:ֱõгķȺλ + //RM_HARMONIC_SN_AMP_3 = 1.0, RM_HARMONIC_SN_PHASE_3 = 90.0, + + //@brief : г + //@remark: {IO:WR}{DATA:1~15} + RM_HARMONIC_NUM, + //@brief : гVpp + //@remark: {IO:WR}{DATA:0~} + RM_HARMONIC_SN_AMP_N, + //@brief : гλ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_HARMONIC_SN_PHASE_N = 0x8084, + //@brief : г ͬRM_HARMONIC_SN_AMP_N + RM_HARMONIC_SN_AMP_2, + RM_HARMONIC_SN_AMP_3, + RM_HARMONIC_SN_AMP_4, + RM_HARMONIC_SN_AMP_5, + RM_HARMONIC_SN_AMP_6, + RM_HARMONIC_SN_AMP_7 = 0x808A , + RM_HARMONIC_SN_AMP_8, + RM_HARMONIC_SN_AMP_9, + RM_HARMONIC_SN_AMP_10, + RM_HARMONIC_SN_AMP_11, + RM_HARMONIC_SN_AMP_12 = 0x808F, + RM_HARMONIC_SN_AMP_13 = 0x8090, + RM_HARMONIC_SN_AMP_14, + RM_HARMONIC_SN_AMP_15, + RM_HARMONIC_SN_AMP_16, + //@brief : гλ RM_HARMONIC_SN_PHASE_N + RM_HARMONIC_SN_PHASE_2, + RM_HARMONIC_SN_PHASE_3, + RM_HARMONIC_SN_PHASE_4, + RM_HARMONIC_SN_PHASE_5, + RM_HARMONIC_SN_PHASE_6, + RM_HARMONIC_SN_PHASE_7, + RM_HARMONIC_SN_PHASE_8 = 0x809A, + RM_HARMONIC_SN_PHASE_9, + RM_HARMONIC_SN_PHASE_10, + RM_HARMONIC_SN_PHASE_11, + RM_HARMONIC_SN_PHASE_12, + RM_HARMONIC_SN_PHASE_13 = 0x809F, + RM_HARMONIC_SN_PHASE_14 = 0x80A0, + RM_HARMONIC_SN_PHASE_15, + RM_HARMONIC_SN_PHASE_16, + //} + + //{MOD + //@brief : ģʽ + //@remark: {IO:WR}{DATA:EModeType} + RM_MOD_TYPE = 0x8100, + //Ʋ + //0: MOD_SINE, + //1: MOD_SQUARE, + //2: MOD_UPRAMP, + //3: MOD_DNRAMP, + //4: MOD_NOISE, + //5: MOD_ARB, + //@brief : Ʋ + //@remark: {IO:WR}{DATA:EModeWaveType} + RM_MOD_WAVE, + //@brief : ƲƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~200KHz} + RM_MOD_FREQ, + //@brief : Ʋʣλs + //@remark: {IO:WR}{DATA: 2ms~1Ms} + RM_MOD_RATE, + //@brief : ȣλ% + //@remark: {IO:WR}{DATA: 0~120} + RM_MOD_SCOPE, + //@brief : Դ + //@remark: {IO:WR}{DATA: 0-Internal,1-External} + RM_MOD_SOURCE, + //@brief : FMƵλHz + //@remark: {IO:WR}{DATA: 0~زǰƵ} + RM_MOD_FRE_DEV, + //@brief : PM (λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_MOD_PHASE_DEV, + //@brief : FSKƵλHz + //@remark: {IO:WR}{DATA: 0~زƵ} + RM_MOD_HOP_FREQ, + //@brief : BPSKԴ + //@remark: {IO:WR} + //{DATA: + //0: PN7, + //1: PN9, + //2: PN15, + //3: PN21, + //} + RM_MOD_DATA_SOURCE = 0x8109, + //@brief : BPSKλQPSKλ1,(λ) + //@remark: {IO:WR}{DATA: -360~360}} + RM_MOD_PSK_PHASE1, + //@brief : QPSKλ2(λ) + //@remark: {IO:WR}{DATA:-360~360}} + RM_MOD_PSK_PHASE2, + //@brief : QPSKλ3(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_MOD_PSK_PHASE3, + //@brief : OSKʱ(λs) + //@remark: {IO:WR}{DATA: 8ns~200s} + RM_MOD_OSC_TIME, + //@brief : QAMIQ MAM + //@remark: {IO:WR}{DATA: 0-4QAM,1-8QAM,2-16QAM,3-32QAM,4-64QAM,5-128QAM,6-256QAM,} + RM_MOD_IQ_MAP, + //@brief : PWMռձȲֵ + //@remark: {IO:WR}{DATA: 0~PULS DUTY} + RM_MOD_DUTY_DEV, + //} + + //{SWEEP + //@brief : ɨƵ + //@remark: {IO:WR}{DATA: 0ԣ1} + RM_SWEEP_TYPE = 0x8200, + //@brief : ɨƵԴ + //@remark: {IO:WR}{DATA: 0ڲ1ⲿ2ֶ} + RM_SWEEP_SOURCE, + //@brief : ɨƵʱ(λs) + //@remark: {IO:WR}{DATA: 1ms~500s} + RM_SWEEP_TIME, + //@brief : ɨƵʼƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~زƵ} + RM_SWEEP_START_FREQ, + //@brief : ɨƵֹͣƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~زƵ} + RM_SWEEP_STOP_FREQ, + //@brief : ͬƵʣλHz + //@remark: {IO:WR}{DATA: RM_SWEEP_START_FREQ~RM_SWEEP_STOP_FREQ} + RM_SWEEP_SYNC_FREQ, + //@brief : ɨƵ + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_SWEEP_TIRG_OUT, + //} + + //{BURST + //@brief : ⧷ + //@remark: {IO:WR}{DATA: + //0: N, + //1: , + //2: ſ + //} + RM_BURST_TYPE = 0x8300, + //@brief : ⧷Դ + //@remark: {IO:WR}{DATA: 0ڲ1ⲿ2ֶ} + RM_BURST_SOURCE, + //@brief : + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_BURST_TIRG_OUT, + //@brief : ⧷ڣλs + //@remark: {IO:WR}{DATA: 1~500} + RM_BURST_PERIOD, + //@brief : ⧷λ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_BURST_PHASE, + //@brief : ⧷λ + //@remark: {IO:WR}{DATA: 1~50000} + RM_BURST_CYCLES, + //@brief : + //@remark: {IO:WR}{DATA: 0-Rise1-Fall} + RM_BURST_TIRG_EDGE, + //} + }ERemoteMessage; + + +#ifdef __cplusplus + } +} +#endif // __cplusplus + +#endif // UTG4162_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/comApiDef.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/comApiDef.h new file mode 100644 index 0000000..5e04f7d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/comApiDef.h @@ -0,0 +1,903 @@ +#ifndef _DSOCOM_API_COMMON_DEF_H_201212281614 +#define _DSOCOM_API_COMMON_DEF_H_201212281614 + +#include "dso_base.h" + +#ifdef __cplusplus +namespace comApi +{ + using namespace comAPICommon; +#endif + //λ +#ifdef __cplusplus + namespace Units + { +#endif + const int UNIT_NULL = 0; //add by yzz + const int UNIT_PS = 1; //add by yzz + const int UNIT_NS = 2; + const int UNIT_US = 3; + const int UNIT_MS = 4; + const int UNIT_S = 5; + const int UNIT_KS = 6; + + const int UNIT_nVS = 7; + const int UNIT_uVS = 8; + const int UNIT_mVS = 9 ; + + const int UNIT_PER = 10; + + const int UNIT_UV = 11; + const int UNIT_MV = 12; + const int UNIT_V = 13; + const int UNIT_KV = 14; + + const int UNIT_pHZ = 18; + const int UNIT_nHZ = 19; + const int UNIT_uHZ =20; + const int UNIT_mHZ = 21; + const int UNIT_HZ = 22; + const int UNIT_KHZ = 23; + const int UNIT_MHZ = 24; + const int UNIT_GHZ = 25; + + //const int UNIT_VV = 52; //201452311:56:55޸ + const int UNIT_mVV = 52; + const int UNIT_VV = 53; + const int UNIT_KVV = 54; + + const int UNIT_mDB = 80; // add by yzz + const int UNIT_DB = 81; + const int UNIT_KDB = 82; // add by yzz +#ifdef __cplusplus + } +#endif + +#pragma region + enum DataCMD + { + Invalid_Data_CMD = -1, + //get data cmd + GET_DISPLAY_DATA = 150, //get ch1, ch2, math, ref a/b data + GET_CH1_DISPLAY_DATA, //get ch1 display data: + GET_CH1_ORIGIN_DATA, //get ch1 original data + GET_CH2_DISPLAY_DATA, //get ch2 display data + GET_CH2_ORIGIN_DATA, //get ch2 original data + GET_CH3_DISPLAY_DATA, + GET_CH3_ORIGIN_DATA, + GET_CH4_DISPLAY_DATA, + GET_CH4_ORIGIN_DATA, + + GET_MATH_DATA = 200, //get math data + GET_REF_A_DATA, //get ref A data + GET_REF_B_DATA, //get ref B data + + //[Notice] Get_Data_CMD_END ָ DataCMD һ + Get_Data_CMD_END = GET_REF_B_DATA, + }; + + /* Command Type */ + typedef enum _control_cmd{ + Invalid_Control_CMD = -1, + + CMD_GET_DSO_TYPE = 0, + + //special function cmd + LOCK_DSO_KEYPAD, //lock dso keypad: if set this cmd, the dso's keypad will not work + UNLOCK_DSO_KEYPAD, //unlock dso keypad: if set this cmd, the dso's keypad will work normally + SET_PROCSTATE, //PROC_STATE: control run/stop + GET_PROCSTATE, //PROC_STATE: get run/stop state + SET_AUTOSET, //set dso to do auto set + SET_TRIG_FORCE, //set dso to be force trigger state + SET_SINGLE, + SET_COARSE, + SET_PRTSC, //set dso to do print screen + GET_BITMAP_FILENAME, + GET_BITMAP_FILEDATA, + + //@brief : ָ + SET_KEY = 20, + //@brief : ѯָ + GET_KEY, + //@brief : ȡѹĻ + GET_SCREEN_SHOT, + //@brief : + GET_DEV_CONFIG, + //@brief : д + SET_DEV_CONFIG, + //@brief : ѯ豸ʾ + GET_IDN, + //@brief : ȡЭ汾 + //@remark: + GET_CVER, + + GET_SCREEN_INFO = 50, //SCREEN_INFO + GET_USB_CONNECTION_STATE, //short 1: usb connection state is ok; other: usb connection state is not ok + GET_CYMOMETER_VALUE, //SignalFreq + GET_CURRENT_ACTIVE_CHANNEL, //short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other + GET_CURRENT_ACTIVE_MENU, //short 0: CH1 menu; 1: CH2 menu; 2: MATH or FFT menu; -1: other menu + GET_CURRENT_MENU_SHOW_STATE,//x short 0: current menu is not display; 1: current menu is display + GET_SAMPLE, //get sample + + SET_TO_ZERO = 100, //set dso to zero state + SET_CH1_VPOS_TO_ZERO, + SET_CH2_VPOS_TO_ZERO, + SET_CH3_VPOS_TO_ZERO, + SET_CH4_VPOS_TO_ZERO, + SET_HPOS_TO_ZERO, + SET_TRIG_TO_ZERO, + + GET_CH1_MEASURE_PARAM = 250,//get ch1 measure parameters + GET_CH2_MEASURE_PARAM, //get ch2 measure parameters + GET_CH3_MEASURE_PARAM, + GET_CH4_MEASURE_PARAM, + GET_MATH_MEASURE_PARAM, //get math measure parameters + + //set/get channel param cmd + SET_CH1_SWITCH = 300, //ChannelSwitch + GET_CH1_SWITCH, //ChannelSwitch + SET_CH1_ATTRIBUTE, //ChannelAttribute + GET_CH1_ATTRIBUTE, //ChannelAttribute + SET_CH1_VPOS, //ChannelVPos + GET_CH1_VPOS, //ChannelVPos + SET_CH1_VLEVEL, //ChannelVLevel + GET_CH1_VLEVEL, //ChannelVLevel + SET_CH1_TIMEBASE, //ChannelTimeBaseر + GET_CH1_TIMEBASE, //ChannelTimeBase + SET_CH1_TRIG_LEVEL, //ChannelTLevel + GET_CH1_TRIG_LEVEL, //ChannelTLevel + SET_CH1_TRIG_POS, //ChannelTPos + GET_CH1_TRIG_POS, //ChannelTPos + + SET_CH2_SWITCH = 350, //ChannelSwitch + GET_CH2_SWITCH, //ChannelSwitch + SET_CH2_ATTRIBUTE, //ChannelAttribute + GET_CH2_ATTRIBUTE, //ChannelAttribute + SET_CH2_VPOS, //ChannelVPos + GET_CH2_VPOS, //ChannelVPos + SET_CH2_VLEVEL, //ChannelVLevel + GET_CH2_VLEVEL, //ChannelVLevel + SET_CH2_TIMEBASE, //ChannelTimeBase + GET_CH2_TIMEBASE, //ChannelTimeBase ر + SET_CH2_TRIG_LEVEL, //ChannelTLevel + GET_CH2_TRIG_LEVEL, //ChannelTLevel + SET_CH2_TRIG_POS, //ChannelTPos + GET_CH2_TRIG_POS, //ChannelTPos + + //math + SET_MATH_SWITCH = 800, //ChannelSwitch + GET_MATH_SWITCH, //ChannelSwitch + SET_MATH_VPOS, //ChannelVPos + GET_MATH_VPOS, //ChannelVPos + SET_MATH_VLEVEL, //ChannelVLevel + GET_MATH_VLEVEL, //ChannelVLevel + SET_FFT_FREQ, //by change timebase + GET_FFT_FREQ, //SignalFreq + SET_MATH_TYPE, //MathType + GET_MATH_TYPE, //MathType + SET_MATH_CONFIG, //MathConfig + GET_MATH_CONFIG, //MathConfig + SET_FFT_CONFIG, //FFTConfig + GET_FFT_CONFIG, //FFTConfig + SET_FILTER_CONFIG, //FilterConfig + GET_FILTER_CONFIG, //FilterConfig + + //acquire + SET_ACQUIRE_CONFIG = 850, //AcquireConfig + GET_ACQUIRE_CONFIG, //AcquireConfig + + //trig menu + SET_TRIG_EDGE_CONFIG = 900, //EdgeTrig + GET_TRIG_EDGE_CONFIG, //EdgeTrig + SET_TRIG_PULSE_CONFIG, //PulseTrig + GET_TRIG_PULSE_CONFIG, //PulseTrig + SET_TRIG_VIDEO_CONFIG, //VideoTrig + GET_TRIG_VIDEO_CONFIG, //VideoTrig + SET_TRIG_SLOPE_CONFIG, //SlopeTrig + GET_TRIG_SLOPE_CONFIG, //SlopeTrig + + //display menu + SET_DISPLAY_CONFIG = 950, //DisplayConfig + GET_DISPLAY_CONFIG, //DisplayConfig + + //measure menu + SET_MEASURE_SOURCE = 1000, //MeasureSrc + GET_MEASURE_SOURCE, //MeasureSrc + SET_MEASURE_ALL_CONFIG, //MeasureAllConfig + GET_MEASURE_ALL_CONFIG, //MeasureAllConfig + SET_MEASUER_PART_CONFIG, //MeasurePartConfig + GET_MEASURE_PART_CONFIG, //MeasurePartConfig + + //cursor menu + SET_CURSOR_CONFIG = 1050, //CursorConfig + GET_CURSOR_CONFIG, //CursorConfig + GET_CURSOR_MEASURE_RESULT, //CurSorMeasureResult + + //storage config + SET_STORAGE_SETTING = 1100, //StorageSetting + GET_STORAGE_SETTING, //StorageSetting + SET_STORAGE_WAVE, //StorageWave + GET_STORAGE_WAVE, //StorageWave + SET_STORAGE_BITMAP, + GET_STORAGE_BITMAP, + + //reference config + SET_REF_A_SWITCH = 1200, //ChannelSwitch + GET_REF_A_SWITCH, //ChannelSwitch + SET_REF_B_SWITCH, //ChannelSwitch + GET_REF_B_SWITCH, //ChannelSwitch + SET_REF_A_VPOS, //ChannelVPos + GET_REF_A_VPOS, //ChannelVPos + SET_REF_A_VLEVEL, //ChannelVLevel + GET_REF_A_VLEVEL, //ChannelVLevel + SET_REF_A_TRIG_POS, //ChannelTPos + GET_REF_A_TRIG_POS, //ChannelTPos + SET_REF_B_VPOS, //ChannelVPos + GET_REF_B_VPOS, //ChannelVPos + SET_REF_B_VLEVEL, //ChannelVLevel + GET_REF_B_VLEVEL, //ChannelVLevel + SET_REF_B_TRIG_POS, //ChannelTPos + GET_REF_B_TRIG_POS, //ChannelTPos + GET_REF_A_TIMEBASE, //ChannelTimeBase + GET_REF_B_TIMEBASE, //ChannelTimeBase + SET_REF_CONFIG, //RefConfig + GET_REF_A_CONFIG, //RefConfig + GET_REF_B_CONFIG, //RefConfig + GET_REFWAVE_EXIST, //short 0:not exist; 1:exist + GET_REFSETTING_EXIST, //short 0:not exist; 1:exist + + //horizon menu + SET_HORIZON_CONFIG = 1300, //HorizonConfig + GET_HORIZON_CONFIG, //HorizonConfig + + //utility + SET_UTILITY_CONFIG = 1400, //UtilityConfig + GET_UTILITY_CONFIG, //UtilityConfig + + //record + SET_RECORD_CONFIG = 1500, //RecordConfig + GET_RECORD_CONFIG, //RecordConfig + + //auto calibrate + SET_SELF_CALIBRATE = 1600, //set dso to be self-calibrate + //product config + SET_RESET_CONFIG = 1700, //set dso config to product config + + //select cursor +// SET_CURSOR_INDEX = 2000, +// GET_CURSOR_INDEX, + }CONTROL_CMD; +#pragma endregion + +#pragma region öֵ + //״̬Ļȡͨ֡ݰ棬ַʽȡ + typedef enum{ + PROC_STOP = 0, + PROC_RUN, + PROC_ARMED = PROC_RUN, + PROC_READY, + PROC_TRIGED, + PROC_AUTO, + PROC_SCAN, + PROC_OVER, + + PROC_RESET, // Add by yzz, for UTD2102CEX + }E_PROC_STATE; + + typedef enum{ + CH_Invalid_ID = -1, + CH_1_ID = 0, + CH_2_ID, + CH_MATH_ID, + CH_REF_A_ID, + CH_REF_B_ID, + CH_MAX_CNT, + }E_CHANNEL_ID; + + /********************************************** + ****************Channel Attribute***************** + ***********************************************/ + typedef enum{ + CH_COUPLING_DC = 0, + CH_COUPLING_AC, + CH_COUPLING_GND, + }CH_ATTR_COUPLING; + + + typedef enum{ + SWITCH_OFF = 0, + SWITCH_ON, + }SWITCH_STATE; + + typedef enum + { + CH_VOLT_SCALE_COARSE = 0, + CH_VOLT_SCALE_FINE, + }CH_VOLT_SCALE; + + + typedef enum{ + CH_PROBE_1X = 0, + CH_PROBE_10X, + CH_PROBE_100X, + CH_PROBE_1000X, + }CH_PROBE; + + //öֵ̽ͷԣ0ࣨ1 + enum ChannelPolarity + { + CH_Polar_Normal = 0, + CH_Polar_Invert, + }; + + /***********************************************/ + /********** vertical system: channel position *********/ + /***********************************************/ + typedef enum{ + CH_VPOS_TOP = 378, + CH_VPOS_BOT = -122, + }E_CH_VPOS_LIMIT; + + /***********************************************/ + /******** vertical system: channel voltage level *******/ + /***********************************************/ + typedef enum{ + ADJUST_DECREASE = -1, + ADJUST_INCREASE = 1, + }E_ADJUST_DIR; + + /*****************************************************************/ + /* horizontal system: channel horizontal position ,ie channel pre-trigger depth */ + /*****************************************************************/ + typedef enum{ + CH_TPOS_LEFT = 0, + CH_TPOS_RIGHT = 700, + }E_CH_TPOS_LIMIT; + + enum E_CH_TriggerLevel_Limit + { + CH_TriggerLevel_Min = -327, + CH_TriggerLevel_Max = 375, + }; + + /***********************************************/ + /***************** math/fft config *****************/ + /***********************************************/ + enum E_MATH_TYPE + { + MATH_TYPE_MATH = 0, + MATH_TYPE_FFT, + + MATH_TYPE_FILTER, //add by yzz + }; + + typedef enum{ + OP_SIGN_ADD = 0, + OP_SIGN_SUB, + OP_SIGN_MULTIPLY, + OP_SIGN_DIVIDE, + }E_MATH_OP_SIGN; + + typedef enum{ + FFT_WIN_RECTANGLE = 0, + FFT_WIN_HANNING, + FFT_WIN_HAMMING, + FFT_WIN_BLACKMAN, + }E_FFT_WINDOW; + + typedef enum{ + FFT_UNIT_VRMS = 0, + FFT_UNIT_DBVRMS, + }E_FFT_UNIT; + + /***********************************************/ + /***************** acquire config *****************/ + /***********************************************/ + enum E_ACQ_MODE + { + ACQ_MODE_NORMAL = 0, + ACQ_MODE_PEAK, + ACQ_MODE_AVERAGE, + }; + + enum E_SAMPLE_MODE + { + SAMPLE_REAL = 0, + SAMPLE_EQUIVALENT, + + SAMPLE_SCAN //add by yzz + }; + + /***********************************************/ + /***************** trigger config *****************/ + /***********************************************/ + typedef enum{ + TRIG_TYPE_EDGE = 0, //: + TRIG_TYPE_NTSC, //: Ƶ + TRIG_TYPE_WIDTH, //: + }E_TRIG_TYPE; + + typedef enum{ + TRIG_CH1 = CH_1_ID, + TRIG_CH2 = CH_2_ID, + TRIG_EXT, + TRIG_EXT_5, //EXT/5 + TRIG_AC_LINE = 4, + TRIG_ALTER, + }E_TRIG_SOURCE; + + typedef enum{ + TRIG_EDGE_RISE = 0, + TRIG_EDGE_FALL, + TRIG_EDGE_RISE_FALL, + }E_TRIG_SLOPE; + + typedef enum{ + TRIG_MODE_AUTO = 0, + TRIG_MODE_NORMAL, + TRIG_MODE_SINGLE, + }E_TRIG_MODE; + + typedef enum{ + TIRG_COUPLING_DC = 0, + TIRG_COUPLING_AC, + TIRG_COUPLING_H_RESTRAIN, //trigger coupling high frequency restrain + TIRG_COUPLING_L_RESTRAIN, //trigger coupling low frequency restrain + }E_TIRG_COUPLING; + + typedef enum{ + PULSE_CONDITION_GT = 0, //pulse condition greater than + PULSE_CONDITION_LT, //pulse condition less than + PULSE_CONDITION_ET, //pulse condition equal to + + PULSE_CONDITION_NO_EQUAL, //pulse not equal to , add by yzz [RESERVE] + }E_PULSE_CONDITION; + + typedef enum{ + PULSE_POLAR_P = 0, + PULSE_POLAR_N, + }E_PULSE_POLAR; + + enum TriggerType_Video_Standard + { + TRIG_Video_PAL = 0, + TRIG_Video_NTSC, + }; + + //Ƶ-ͬʽ(0)ż(1)(2)ָ(3) + enum TriggerType_Video_SyncMode + { + TRIG_Video_SyncMode_Odd = 0, + TRIG_Video_SyncMode_Even, + TRIG_Video_SyncMode_ALL, + TRIG_Video_SyncMode_Specified, + }; + + /***********************************************/ + /***************** display config *****************/ + /***********************************************/ + typedef enum{ + DISPLAY_TYPE_VECTOR = 0, + DISPLAY_TYPE_DOT, + }E_DISPLAY_TYPE; + + + typedef enum{ + FORMAT_YT = 0, + FORMAT_XY, + }E_FORMAT; + + typedef enum{ + DISPLAY_TIME_CLOSED = 0, + DISPLAY_TIME_1S, + DISPLAY_TIME_2S, + DISPLAY_TIME_5S, + DISPLAY_TIME_INFINITE, + }E_DISPLAY_TIME; + + /***********************************************/ + /***************** horizon config *****************/ + /***********************************************/ + typedef enum{ + WIN_TYPE_MAIN = 0, + WIN_TYPE_WINDOW, + }E_WIN_TYPE; + + /***********************************************/ + /***************** utility config *****************/ + /***********************************************/ + typedef enum{ + MENU_DISPLAY_T5S = 0, + MENU_DISPLAY_T10S, + MENU_DISPLAY_T15S, + MENU_DISPLAY_TMANUAL, + }E_MENU_DISPLAY_TIME; + + typedef enum{ + LANGUAGE_ZHCN, // + LANGUAGE_ZHTW, // + LANGUAGE_ENGLISH, //Ӣ + LANGUAGE_ESPANOL, // + LANGUAGE_PORTUGUESE, // + LANGUAGE_FRENCH, // + LANGUAGE_GERMAN, // + LANGUAGE_DUTCH, // + LANGUAGE_RUSSIANS, // + LANGUAGE_Korean, // + }E_LANGUAGE; + + typedef enum{ + SKIN_GREYISH_GREEN = 0, //dzɫ + SKIN_BLUE, //ɫ + SKIN_RED, //ɫ + SKIN_BOTTLE_GREEN, //ɫ + }E_SKIN; + + /***********************************************/ + /***************** storage config *****************/ + /***********************************************/ + typedef enum{ + STORAGE_TYPE_WAVE = 0, + STORAGE_TYPE_SETTING, + }E_STORAGE_TYPE; + + typedef enum{ + STORAGE_MEDIUM_DSO = 0, + STORAGE_MEDIUM_USB, + }E_STORAGE_MEDIUM; + + typedef enum{ + SAVSRC_CH1 = CH_1_ID, + SAVSRC_CH2 = CH_2_ID, + SAVSRC_ALL, + }E_STORAGE_WAVE_SRC_CH; + + typedef enum{ + STORAGE_DEPTH_NORMAL = 0, //ͨ洢 + STORAGE_DEPTH_LONG, //洢 + }E_STORAGE_DEPTH; + + /***********************************************/ + /**************** reference config *****************/ + /***********************************************/ + typedef enum{ + REF_A = 0, + REF_B, + }E_REF_SRC; + + /***********************************************/ + /***************** Cursor config *****************/ + /***********************************************/ + typedef enum{ + CURSOR_TYPE_VOLTAGE = 0, + CURSOR_TYPE_TIME, + CURSOR_TYPE_TRACK, + CURSOR_TYPE_CLOSED, + }E_CURSOR_TYPE; + + typedef enum{ + CURSOR_ID_1 = 0, + CURSOR_ID_2, + CURSOR_ID_MAX, + }E_CURSOR_ID; + + enum Cursor_Measure_Limit + { + Screen_Scale_H_Min = 50, + Screen_Scale_H_Max = 749, + + Screen_Scale_V_Min = 28, + Screen_Scale_V_Max = 228, + }; +#pragma endregion öֵ + +#pragma region ݽṹ + //Ļ + typedef struct _measure_param_packet + { + MeasureParam freq; + MeasureParam period; + MeasureParam risetime; + MeasureParam falltime; + MeasureParam pwidth; + MeasureParam nwidth; + MeasureParam overshoot; + MeasureParam preshoot; + MeasureParam pduty; + MeasureParam nduty; + MeasureParam vmean; + MeasureParam vpp; + MeasureParam vrms; + MeasureParam vtop; + MeasureParam vbase; + MeasureParam vmid; + MeasureParam vmax; + MeasureParam vmin; + MeasureParam vamp; + }MeasureParamPacket; + + // + typedef struct + { + MeasureParam freq; + MeasureParam period; + MeasureParam risetime; + MeasureParam falltime; + MeasureParam pwidth; + MeasureParam nwidth; + MeasureParam overshoot; + MeasureParam preshoot; + MeasureParam pduty; + MeasureParam nduty; + MeasureParam vmean; + MeasureParam vpp; + MeasureParam vrms; + MeasureParam vtop; + MeasureParam vbase; + MeasureParam vmid; + MeasureParam vmax; + MeasureParam vmin; + MeasureParam vamp; + + // + char Reserve[24]; + }MeasureParamPacket_UTD2000CEX; + + // + typedef struct + { + MeasureParam freq; // + MeasureParam period; // + MeasureParam risetime; // + MeasureParam falltime; // + MeasureParam pwidth; // + MeasureParam nwidth; // + MeasureParam overshoot; // + MeasureParam preshoot; // + MeasureParam pduty; // + MeasureParam nduty; // + MeasureParam vmean; // + MeasureParam vpp; // + MeasureParam vrms; // + MeasureParam vtop; // + MeasureParam vbase; // + MeasureParam vmid; // + MeasureParam vmax; // + MeasureParam vmin; // + MeasureParam vamp; // + + // + MeasureParam area; // + MeasureParam cycleArea; // + MeasureParam cycleMean; //ƽֵ + MeasureParam cycleRms; //ھֵ + MeasureParam burstWidth; //ͻ + } MeasureParamPacket_UTD2102CM; + + //cmd: GET_PROCSTATE, SET_PROCSTATE + typedef struct _proc_state{ + //0, PROC_STOP; 1, PROC_RUN; 1, PROC_ARMED; 2, PROC_READY; 3, PROC_TRIGED; 4, PROC_AUTO; 5, PROC_SCAN; 6, PROC_OVER; + short procState; + }PROC_STATE; + + ////////////////////////////////////////////////////////////////////////// + // ϵ + // ͨGET_CH1_DISPLAY_DATAGET_DISPLAY_DATAȡIJݵϵ + // X ֵ0ʼΧǵ + // Y ȡADCΧֵ[0,255] UTD2102CEX ײ28228ΧΪ200 + ////////////////////////////////////////////////////////////////////////// + //cmd: GET_SCREEN_INFO + typedef struct _screen_info{ + short screen_width; //Ļȣֵ + short screen_height; //Ļ߶ȣֵ + short x_grid_count; // + short y_grid_count; // + short x_grid_pixels; //Ԫ + short y_grid_pixels; //Ԫ + short y_min; //ϵy귶Χ[y_min y_max] + short t_min; //ϵx귶Χ[t_min t_max]0ʼ + short y_max; //ϵy귶Χ[y_min y_max] + short t_max; //ϵx귶Χ[t_min t_max]0ʼ + }ScreenInfo; + + /********************************************** + *************** Channel Switch ****************** + ***********************************************/ + typedef struct _channel_switch{ + short ch_switch; + }ChannelSwitch; + + /* channel attribute configuration : cmd = SET_CH1_ATTRIBUTE, GET_CH1_ATTRIBUTE */ + typedef struct _channel_attribute{ + short coupling; //CH_COUPLING + short bwlimited; //SWITCH_STATE + short voltscale; //CH_VOLT_SCALE + short probe; //CH_PROBE + short inverted; //SWITCH_STATE + }ChannelAttribute; + + /* channel attribute configuration : cmd = SET_CH1_ATTRIBUTE, GET_CH1_ATTRIBUTE */ + typedef struct _pre_offset_volt{ + short preOffsetSwitch; //0, STATE_CLOSED; 1, STATE_OPEN + short coarseValue; // + short fineValue; // + short toZero; //0, don't set to zero; 1, set to zero + }PreOffsetVolt; + + typedef struct _channel_vpos{ + short vpos; //[(TOP: 378), (Middle: 128), (BOTTOM: -122)] + }ChannelVPos; + + typedef struct _channel_volt_level{ + short voltLevel; //when set cmd, para: 1 or -1, when get cmd, voltage level value + float voltValue; //ȡ̽ͷΪX1ǵķֵ + short voltUnit; + short IsLimit; + }ChannelVLevel; + + /***********************************************/ + /******** horizontal system: channel time base *******/ + /***********************************************/ + typedef struct _channel_timebase{ + short timeBase; + }ChannelTimeBase; + + typedef struct _channel_tpos{ + short tpos; //[(Left: 0), (Middle: 350), (Right: 700)] + }ChannelTPos; + + /***********************************************/ + /******** tigger system: channel trigger position ******/ + /***********************************************/ + typedef struct _channel_trig_level{ + short trigLevel; //[-375, 0(middle), 375] + float trigValue; + short trigUnit; + short isLimited; + }ChannelTLevel; + + typedef struct _math_type{ + int mathType; + }MathType; + + typedef struct _fft_freq{ + float freqValue; + int freqUnit; + int IsLimit; // == 1,yes; =0, no! + }SignalFreq; + + typedef struct _math_config{ + short mathOpA; + short mathOpB; + short mathOpSign; + }MathConfig; + + typedef struct _fft_config{ + short fftSource; + short fftWindow; + short fftUnit; + }FFTConfig; + + typedef struct _acquire_config{ + short acquireMode; + short averageNum; //2^(averageNum + 1), ie: {(0: 2), (1: 4), (2: 8), (3: 16), (4: 32), (5: 64), (6: 128), (7: 256)} + short sampleMode; + short fastAcquire; + }AcquireConfig; + + typedef struct _trig_config{ + short trigType; + short trigSource; + short trigMode; + short trigCoupling; + }TriggerConfig; + + typedef struct _trig_edge_config{ + TriggerConfig trigConfig; + short trigSlope; + }TrigEdgeConfig; + + typedef struct _trig_pulse_config{ + TriggerConfig trigConfig; + short pulseCondition; + UINT pulseWidth; + short pulsePolar; + }TrigPulseConfig; + + typedef struct _display_config{ + short displayType; + short displayFormat; + short displayTime; + short displayLum; + }DisplayConfig; + + typedef struct _horizon_config{ + short windowType; //E_WIN_TYPE + unsigned int holdOff; //[10, 187500000] + }HorizonConfig; + + typedef struct _utility_config{ + short autoCalibrate; //0, not do auto calibrate; 1, do auto calibrate + short menuDisplayTime; //E_MENU_DISPLAY_TIME + short language; //E_LANGUAGE + short defaultSetting; //0, not do default setting; 1 do default setting + short skin; //E_SKIN + short gridBrightness; //[1, 100] + short sysInfo; //0, not display system info; 1, display system info; + short cymometer; //0: close; 1: open + }UtilityConfig; + + typedef struct _storage_setting{ + short saveType; //STORAGE_TYPE_SETTING + short savePos; //[1, 20] + + short save; //1, save, 0, not save + short recall; //1, recall, 0, not recall + }StorageSetting; + + typedef struct _storage_wave{ + short saveType; //STORAGE_TYPE_WAVE + short saveSource; + short savePos; + short saveMedium; + short saveDepth; + short save; + }StorageWave; + + /***********************************************/ + /***************** measure config *****************/ + /***********************************************/ + typedef struct _measure_config{ + short measureSrc; + }MeasureConfig; + + typedef struct _ref_timebase{ + float ref_TValue; + int ref_Tunit; + }RefTimeBase; + + + typedef struct _ref_config + { + short refSrc; //REF_A, REF_B + short pos; //[1, 20] + short medium; //MEDIUM_DSO, MEDIUM_USB + + short onoff; //1, on; 0, off; + }RefConfig; + + typedef struct _cursor_measure_result{ + MeasureParam Va; + MeasureParam Vb; + MeasureParam deltaV; + MeasureParam TaFa;// when ch1, ch2, Ta; when math channel, Fa; + MeasureParam TbFb;// when ch1, ch2, Tb; when math channel, Fb; + MeasureParam deltaT; + MeasureParam deltaF; + char Reserve[56]; + }CursorMeasureResult; + + typedef struct _cursor_config{ + short cursorType; + short iActiveCursor; + //Ҫӻʶ + short voltCursorPos[CURSOR_ID_MAX];//[28(top), 428(bottom)] + short timeCursorPos[CURSOR_ID_MAX];//[50(left), 749(right)] + short autoCursorPos[CURSOR_ID_MAX];//[51(left), 749(right)] + }CursorConfig; + + + /***********************************************/ + /***************** measure config *****************/ + /***********************************************/ + typedef struct _measure_src + { + short measureSrc; + }MeasureSrc; +#pragma endregion ݽṹ + +#ifdef __cplusplus +} +#endif + +#endif//end of #ifndef _DSOCOM_API_COMMON_DEF_H_201212281614 \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/dso_base.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/dso_base.h new file mode 100644 index 0000000..7801310 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/dso_base.h @@ -0,0 +1,171 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩUCIӿʹõģDSOͨö塣 + */ +#ifndef dso_base_h__ +#define dso_base_h__ + +#ifdef __cplusplus +namespace comAPICommon { +#endif + //ʱλлһ£˲ͬıԵ +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + TLEVEL_1NS = 0, + TLEVEL_2NS, + TLEVEL_5NS, + TLEVEL_10NS, + TLEVEL_20NS, + TLEVEL_50NS, + TLEVEL_100NS, + TLEVEL_200NS, + TLEVEL_500NS, + TLEVEL_1US, + TLEVEL_2US, + TLEVEL_5US, + TLEVEL_10US, + TLEVEL_20US, + TLEVEL_50US, + TLEVEL_100US, + TLEVEL_200US, + TLEVEL_500US, + TLEVEL_1MS, + TLEVEL_2MS, + TLEVEL_5MS, + TLEVEL_10MS, + TLEVEL_20MS, + TLEVEL_50MS, + TLEVEL_100MS, + TLEVEL_200MS, + TLEVEL_500MS, + TLEVEL_1S, + TLEVEL_2S, + TLEVEL_5S, + TLEVEL_10S, + TLEVEL_20S, + TLEVEL_50S, + TLEVEL_100S, + TLEVEL_200S, + }E_TIMEBASE_LEVEL; + +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + VLEVEL_1MV = 0, + VLEVEL_2MV, + VLEVEL_5MV, + + VLEVEL_10MV, + VLEVEL_20MV, + VLEVEL_50MV, + + VLEVEL_100MV, + VLEVEL_200MV, + VLEVEL_500MV, + + VLEVEL_1V, + VLEVEL_2V, + VLEVEL_5V, + + VLEVEL_10V, + VLEVEL_20V, + } E_VOLTAGEBASE_LEVEL; + + typedef struct _measure_param { + float value; + int unit; + }MeasureParam; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + + typedef struct _UnitParam { + char Type; //λͣTimeFreqȡ嶨ĵ + char Scale; //knpMȡ嶨ĵ + }UnitParam; + + //@brief : ֵ + //@remark: 4Byte align -> 8Bytes + typedef struct _MeaValue { + float Value; + UnitParam Unit; + char IsValid; //ǷЧ 0 ʾЧ 1ʾЧ + char IsExist; //Ƿڡ 0 ʾڣ 1ʾڡ + }MeaValue; + + //@brief : ݰͨö塣 + //@remark: + typedef enum _EMeaParam { + MP_MAX = 0, //ֵ + MP_MIN, //Сֵ + MP_HIGH, //High(Top)-ߵƽ(ֵ) + MP_MIDDLE, //Middle-мֵ + MP_LOW, //Low(Bottom) - ͵ƽ(׶ֵ) + + MP_PKPK, //VPP-ֵ + MP_AMP, //Сֵ + MP_MEAN, //ƽֵ + MP_CYCMEAN, // + MP_RMS, // + + MP_CYCRMS, //ھֵ + MP_AREA, // + MP_CYCAREA, // + MP_OVERSHOOT,// + MP_PRESHOOT, //Ԥ + + MP_PERIOD, // + MP_FREQ, //Ƶ + MP_RISE_TIME,//ʱ + MP_FALL_TIME,//½ʱ + MP_PWIDTH, // + + MP_NWIDTH, // + MP_PDUTY, //ռձ + MP_NDUTY, //ռձ + MP_RISEDELAY,//ʱ + MP_FALLDELAY,//ʱ + + MP_PHASE, //λ + MP_FRR, // + MP_FRF, + MP_FFR, + MP_FFF, + + MP_LRF, + MP_LRR, + MP_LFR, + MP_LFF, + + MP_BURST_WIDTH, //ͻ + + // + //reserve section + // ²׷ + // + // + //̶λ50 + MP_MAX_COUNT = 50, + }EMeaParam; + +#ifdef __cplusplus + } + namespace uci { + using namespace comAPICommon; + namespace cb = comAPICommon;//comAPICommon alias + } +#endif + +#endif // dso_base_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci.h new file mode 100644 index 0000000..6c73e78 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci.h @@ -0,0 +1,228 @@ +/******************************************************************** + created: 2014/12/22 + author: M.Yang + purpose: UCI(united communicate interface) +*********************************************************************/ + +#ifndef uci_h__ +#define uci_h__ + +#include "ucidef.h" + +////////////////////////////////////////////////////////////////////////// +// ڽӿڷص״ֵ̬ +// < 0 : ʾ +// ӦĴϢͨuci_GetLastErrorȡ,Ķucidef.hļС +// < UCI_ERRĴΪlibusbĴ롣 +////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +namespace uci { +extern "C"{ +#endif + //@brief : ִỰ޹صIJѯ + //@param PRParams _params : ѯIJ + //@param u_byte * _data : ݵĻַ + //@param u_size _dataCount : ݵĻСBytes + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_Query(_in_out PRParams _params, _in_out u_byte* _data, _in u_size _dataCount); + + //@brief : ѯͨŽڵ + //@param _in const QParams * _params : ѯ + //@param _out Node * _outBuf : ŲѯĽڵ + //@param _in_out u_size * _nodeCnt : ΪҪȡĽڵΪʵʶȡĽڵ + //@param _in u_size _timeOut : ѯʱ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_QueryNodes(_in const QParams* _params, _out Node* _outBuf, + _in_out u_size* _nodeCnt, _in u_size _timeOut); + + //@brief : ѯͨŽڵ + //@param _msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _nodes : ŲѯĽڵ + //@param _node_count : ҪѯĽڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX(u_cstring _msg, Node* _nodes, u_size _node_count, _in u_size _timeout); + + /*21-7-2017 15:51 by M.J Created <򻯰汾ѯͨѶڵ㲢ͨŵַ>*/ + //@brief : ѯͨŽڵ + //@param _addr_msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _addr_msg_len : յַַbufferij + //@param _node_type : ڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX_Simple(u_tchar* _addr_msg, u_size _addr_msg_len, u_size _node_type, _in u_size _timeout); + + //@brief : 豸 + //@param u_cstring _addr : 豸ַ '\0'β + //@param u_session * _session : ѽĻỰID. + //@param u_uint32 _timeOut : ӳʱʱ ms + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + // UCI_SUCCESS + // UCI_ERR_ARGS_WRONG; + // UCI_ERR_RES_INIT_ERROR; + // UCI_ERR_CONNECT_ADDR_WRONG; + // UCI_ERR_CONNECT_FAILED; + // UCI_ERR_CONNECT_TIMEOUT] + //@remarks : ĵ + u_status _UCIAPI uci_Open(u_cstring _addr, u_session* _session, u_uint32 _timeOut); + + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 + u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + //@brief : ִ + //@param u_session _session : ỰID + //@param PCommandParams _params : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SendCommand(u_session _session, PCommandParams _params); + + //@brief : UCI¼ + //@param uciNotify _pNotify : ӦUCI¼Ļص + //@return u_status _UCIAPI : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SetNotify(UCIMSGProc _pNotify); + + //@brief : + //@param _msg : ַ + //@param _obj : ݻַ + //@param _objSize : ݻС + //@return : 鿴ļеġڽӿڷص״ֵ̬˵s + //@remarks : Ŀǰֻ֧л԰汾Ͷ豸ͷĵ¼鿴ĵ + u_status _UCIAPI uci_SetAttribute(u_session _sesn, u_cstring _msg, const u_object* _obj, u_size _objSize); + + //@brief : ѯ + //@param u_session _sesn : + //@param u_attr _name : + //@param u_attr_v * _value : + //@return u_status _UCIAPI : + //@remarks : + u_status _UCIAPI uci_GetAttribute(u_session _sesn, u_cstring _msg, u_object* _obj, u_size _objSize); + + //@brief : д + //@param u_session _session : ỰID + //@param PWParam _params : д + //@param const u_byte * _data : Ҫдݻַ ΪNULL + //@param u_size _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_params.CMDStringѾҪдֶˣʹuci_FormatWriteӿڣ + // _data != NULLַ_params.CMDStringֻܰһ䡣 + u_status _UCIAPI uci_Write(u_session _session, PWParams _params, const u_byte* _data, u_size _len); + + //@brief : д + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@param _data : Ҫдݻַ ΪNULL + //@param _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_msgѾҪдֶˣ + // _data != NULLַ_msgֻܰһ䡣 + u_status _UCIAPI uci_WriteX(u_session _session, u_cstring _msg, + u_uint32 _timeout, const u_byte* _data, u_size _len); + + //@brief : ֻдַָдָӿ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteSimple(u_session _session, u_cstring _msg, u_uint32 _timeout); + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + //@brief : ȡ + //@param u_session _session : ỰID + //@param PRParams _params : + //@param u_byte * _data : ݵĻ + //@param u_size _dataLen : ݵĻССЭ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ʹuci_ReadX汾 + u_status _UCIAPI uci_Read(u_session _session, PRParams _params, u_byte* _data, u_size _dataLen); + + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 + u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, + u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + //@brief : дļ + //@param u_session _session : ỰID + //@param WFileParams * _info : ļϢ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteFromFile(u_session _session, WFileParams* _info); + + //@brief : дļ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : Ҫдļ·ļ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_WriteFromFileļ򻯰汾 + u_status _UCIAPI uci_WriteFromFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout); + + //@brief : Read data synchronously and store the transferred data in a file. + //@param u_session _session : ỰID + //@param RFileParams _params : Ҫݵļ· + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_ReadToFile(u_session _session, RFileParams* _params); + + //@brief : ȡļ + //@param _session : ỰID. + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : ݵش̵ļ·ļͺ׺ + //Ǿ·Ҳ··ͨ_filePathFinalȡ· + //@param _timeout : ʱ + //@param _filePathFinal : 嵽صļľ· + //@param _filePathFinalLength : _filePathFinalijȣַ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_ReadToFileķǷװ汾 + u_status _UCIAPI uci_ReadToFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength); + + //@brief : رջỰ + //@param u_session _session : ҪرյĻỰID + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + u_status _UCIAPI uci_Close(u_session _session); + + //@brief : һβӦĴ״̬Ϣ + //@return u_cstring : Ϣ + //@remarks : ͨuci_SetAttributeôϢ԰汾 + u_cstring _UCIAPI uci_GetLastError(void); + + //@brief : ˳UCIʵʱá + //@remarks : ˳ʱãͷڲԴ + // ӿڲһҪʹá ֻ.NETйܻ£ + // ͨuci_SetAttribute uci_SetNotifyӿ + // 豸Ƴ¼ʱ˳ʱʹá + void _UCIAPI uci_ExInstance(void); +#ifdef __cplusplus +} + +} +#endif +#endif // uci_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci.lib b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci.lib new file mode 100644 index 0000000..75a99f2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci_cpp.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci_cpp.h new file mode 100644 index 0000000..79751d8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/uci_cpp.h @@ -0,0 +1,60 @@ +/*! + * \created : 2017/3/17 + * \author : M.Yang + * \purpose : ṩUCIC++汾ӿ + */ +#ifndef uci_cpp_h__ +#define uci_cpp_h__ +#include "uci.h" + +namespace uci { + class Session; +} + +//@brief : UCI Ự +//@remark: uci_ǰ׺CԹ淶Ľӿ򵥷װĺôǣ +// 1SessionʱԶرջỰǣʹõʹʱעʹ߼Ǵ߼ +// 2ÿһӿϣʡȥһSession IDΣҿ趨βεĬֵijЩCԱ֧֣ʹýӿڸ򵥣 +// ע⣺ +// ಻ȫӿڵ䣬Ҫ䡣 +class uci::Session { +public: + Session() : m_Session(INVALID_SESSION) {} + virtual ~Session() { + if (m_Session != INVALID_SESSION) { + uci_Close(m_Session); + m_Session = INVALID_SESSION; + } + } + + u_status Open(u_cstring _addr, u_uint32 _timeout = 2000) { + u_status r = uci_OpenX(_addr, _timeout); + if (UCISUCCESS(r)) + m_Session = (u_session)r; + return r; + } + + u_status Write(u_cstring _msg,u_uint32 _timeout = 1000, const u_byte* _data = NULL, u_size _len = 0) { + return uci_WriteX(m_Session, _msg, _timeout, _data, _len); + } + + u_status Read(u_cstring _msg,u_uint32 _timeout, u_byte* _data, u_size _dataLen) { + return uci_ReadX(m_Session, _msg, _timeout, _data, _dataLen); + } + + u_status WriteFromFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout) { + return uci_WriteFromFileX(m_Session, _msg, _filePath, _timeout); + } + + u_status ReadToFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength) { + return uci_ReadToFileX(m_Session, _msg, _filePath, _timeout, _filePathFinal, _filePathFinalLength); + } + + u_status Close() { return uci_Close(m_Session); } + u_session GetSession() const { return m_Session; } +protected: + u_session m_Session; +}; + +#endif // uci_cpp_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/ucidef.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/ucidef.h new file mode 100644 index 0000000..f5bf38d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/ucidef.h @@ -0,0 +1,571 @@ +/******************************************************************** + created: 2014/12/23 + author: M.Yang + purpose: UCIȫֶļ + modify: + *********************************************************************/ +#ifndef ucidef_h__ +#define ucidef_h__ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +#define _UCIAPI __stdcall +#define _UCICallBack __stdcall +#endif + +#define _in +#define _out +#define _in_out + +#ifdef __cplusplus +namespace uci { +#endif // __cplusplus + +#ifdef _CVI_ +#define u_inline static +#else +#define u_inline inline +#endif // _CVI_ + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif // !MAX_PATH + + ////////////////////////////////////////////////////////////////////////// + //{ Ͷ +#ifdef _UNICODE + //@brief : ʾһ Unicode ַ +#define u_tchar wchar_t +#else + //@brief : ʾһ ASCII ַ +#define u_tchar char +#endif // _UNICODE + +#if defined(_WIN64) + typedef unsigned __int64 u_unit_ptr; + typedef __int64 u_long_ptr; +#else + typedef unsigned int u_unit_ptr; + typedef long u_long_ptr; +#endif + + //@brief : Boolean +#define u_bool bool + //@brief : 8λ޷ +#define u_byte unsigned char + //@brief : 8λз +#define u_char char + //@brief : ָ͵Ļָ +#define u_buf void* + //@brief : ͵ij +#define u_object void + //@brief : ʾ 16 λз +#define u_short short + //@brief : ʾ 16 λ޷ +#define u_ushort unsigned short + //@brief : ʾ 16 λз +#define u_int16 u_short + //@brief : ʾ 16 λ޷ +#define u_uint16 u_ushort + //@brief : ʾ 32 λз +#define u_int32 int + //@brief : ʾ 32 λ޷ +#define u_uint32 unsigned int + //@brief : ʾUCIӿڷص״ֵ̬(32λз) +#define u_status u_int32 + //@brief : ʾС32λ޷ +#define u_size u_uint32 + //@brief : ʾỰID32λ޷ +#define u_session u_uint32 + //@brief : ʾַ +#define u_string u_tchar* + //@brief : ʾַֻ +#define u_cstring const u_tchar* + //@brief : ʾIDͣ32λ޷ +#define u_attr u_int32 + //@brief : ʾֵͣ32λ޷ +#define u_attr_v u_int32 + //@brief : ʾһ16λ޷͵ĵ +#define u_word u_ushort + //@brief : ʾһ32λ޷͵˫ +#define u_dword u_uint32 + //@brief : Ϣ +#define u_wparam u_unit_ptr + //@brief : Ϣ +#define u_lparam u_long_ptr + //} + + ////////////////////////////////////////////////////////////////////////// + //{ ӿڷ״ֵ̬ + //@brief : ɹ +#define UCI_SUCCESS (0) + //@brief : ʼֵ +#define UCI_ERR (-1000) + //@brief : жϵǰӿǷִʧ + //@brief : жϵǰӿǷִгɹ +#define UCIERR(r) (r < 0) +#define UCISUCCESS(r) (!UCIERR(r)) + + //@brief : + typedef enum _UCIErr { + NoError = 0, + + //@brief : Դʼ + InitResourceError = UCI_ERR - 20, + //@brief : ЧĻỰ + Invalid_Session, + //@brief : ʱ + Timeout, + //@brief : ʧ + Failed, + //@brief : ֵ֧IJ + Unsupported, + //@brief : ڴռ䲻 + Insufficient_Memory, + //@brief : ϵͳæ޷Ӧ + Busy, + //@brief : ͨ쳣棡 + COMExpection, + //@brief : ͨδ򿪣 + ChannelNotOpened, + //@brief : WinAPI + API_Failed, + + //@brief : δ֪Ĵ + Unknown = UCI_ERR - 40 - 1, + + //@brief : ӵַַʽ + Connect_InvalidAddress = UCI_ERR - 40, + //@brief : ӻδ + Connect_NotBuild, + //@brief : ѶϿ + Connect_Break, + //@brief : ֵ֧ͨŷʽ + Connect_Unsupported_COMType, + + //@brief : δָ豸 + Device_NoFound = UCI_ERR - 60, + //@brief : ֵ֧豸 + Device_Unsupported, + //@brief : Ҫִвѯ豸IJ + Device_QueryFirst, + //@brief : Ͳƥ + Device_NotMatch, + + //@brief : ѯ豸ʧ + Query_LANNodesFailed, + + //@brief : USB豸ִַֻвѯ豸Ч + //@remarks : UCI⵼USB豸ַֻһб豸ַ + AddrValid_AfterQueryDeviceOper, + + //@brief : δU̽ + UDisk_NotFound, + //@brief : Ѿ + Key_Locked, + + //@brief : ַʽ + CMD_Invalid_StringFormat = UCI_ERR - 80, + //@brief : ֵֻ֧ + CMD_OnlySupportSingle, + //@brief : һֻ֧һ + CMD_OnlySupportSingleAttr, + //@brief : ֵ֧ + CMD_Unsupported, + //@brief : ʧ + CMD_SendFailed, + //@brief : Эݸʽ + CMD_Invalid_ProtocolFormat, + //@brief : 豸дļflashʧܣ + CMD_WriteFileToFlash_Failed, + //@brief : δЧĻظ + CMD_NoFound_Valid_Reply_Data, + //@brief : Ϣ鿴ǷЭ + CMD_Error_Message, + //@brief : Чıʽ + CMD_Invalid_Expression, + //@brief : ڵǰģʽ²ԼⲨļ + CMD_Cannot_LoadARB_InCurrent_MOD_Mode, + + //@brief : + Args_Invalid = UCI_ERR - 100, + //@brief : ṩĿռ̫С + Args_MemoryTooSmall, + //@brief : ṩļ̫(50ֽ) + Args_FileNameTooLong, + //@brief : ݴСЭ鲻ƥ(ֹݴ) + Args_DataLenNotMatch, + + //@brief : + Data_Overflow = UCI_ERR - 120, + //@brief : Χ + Data_OutRange, + //@brief : δȫȡ + Data_NotReadEnoughLenth, + //@brief : Уʧ + Data_ECC_Failed, + //@brief : Ч + Data_Invalid, + //@brief : ѹʧ + Data_Zip_Error, + //@brief : ݽѹʧ + Data_UnZip_Error, + //@brief : ݴʧ + Data_Transfer_Error, + //@brief : ݴʧ + Data_Transfer_Break, + //@brief : Чݿɶȡ + Data_No_Data_Incoming, + + //@brief : + File_AccessDenied = UCI_ERR - 140, + //@brief : An unspecified error occurred. + File_GenericException, + //@brief : The file could not be located. + File_NotFound, + //@brief : All or part of the path is invalid. + File_BadPath, + //@brief : The permitted number of open files was exceeded. + File_TooManyOpenFiles, + //@brief : There was an attempt to use an invalid file handle + // or The file format is unsupported! + // or The file data is error! + File_InvalidFile, + //@brief : The current working directory cannot be removed + File_RemoveCurrentDir, + //@brief : There are no more directory entries + File_DirectoryFull, + //@brief : There was an error trying to set the file pointer + File_BadSeek, + //@brief : There was a hardware error + File_HardIO, + //@brief : SHARE.EXE was not loaded, or a shared region was locked + File_SharingViolation, + //@brief : There was an attempt to lock a region that was already locked + File_LockViolation, + //@brief : The disk is full + File_DiskFull, + //@brief : The end of file was reached + File_EndOfFile, + //@brief : дļʧ + File_SaveToDiskFailed, + //@brief : ļȳΧ + File_Length_OutOfRange, + }UErr; + //} + ////////////////////////////////////////////////////////////////////////// + + //@brief : ĻỰID +#define INVALID_SESSION ((u_uint32)(-1)) + + ////////////////////////////////////////////////////////////////////////// + //{ + //лӢģ "lang:zh-hans" or "lang:en-us" + //ʹUSB豸ƳӼ "devchange:1" +//} + + +#define CACHE_LINE 1 +#define CACHE_ALIGN __declspec(align(CACHE_LINE)) + + //@brief : ýṹĶ뷽ʽ +#define PACK_ALIGN(n) __declspec(align(n)) + + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + + //one Word is 2 bytes + u_inline u_word UCI_HIWORD(u_dword _dw) { return ((u_word)((_dw >> 16) & 0xffff)); } + u_inline u_word UCI_LOWORD(u_dword _dw) { return ((u_word)(_dw & 0xffff)); } + + //#pragma pack(show)// C4810 + //ensure byte-packed structures1ֽڶ룩 +#include //뻷ûиļ滻Ϊǰƽֽ̨ڶ䡣 + + //@brief : ݽӿڵIJ + //@remarks : ͨͨuci_CreateRParamsӿڴ + typedef struct _RParams { + //@brief : ַ'\0'β. ʽЭĵ + u_cstring CMDString; + //@brief : ҪصӾͨҪȡ\ѯǶӦģ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + //@brief : + //@remarks : ͨʹãɿ;ڲѯ豸ʱõ + //ΪQParamsĵΪ׼ + u_buf ExtraData; //reserve + //@brief : ݵij + u_size ExtraDataLen; + }RParams, *PRParams; + +#ifdef __cplusplus + inline RParams* uci_CreateRParams(RParams& _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + _p.ExtraData = _ExtraData; + _p.ExtraDataLen = _ExtraDataLen; + return &_p; + } +#else + u_inline RParams* uci_CreateRParams(RParams* _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + _p->ExtraData = _ExtraData; + _p->ExtraDataLen = _ExtraDataLen; + return _p; + } +#endif + + typedef struct _DeviceIOParams { + u_int32 Count; + u_int32* Data; + }DeviceIOParams; + + typedef struct _QParams { + //@brief : ҪѯͨŽڵ + //@remarks : enum NodeType ȡֵ ͨ־λֵ + //@eg NodeType::USB | NodeType::LAN + u_int32 Type; + //@brief : ˿ڼ˿ + u_int32 PortCount; + //@brief : ˿ڼ + u_int32* Ports; + //@brief : PVIDPVIDĸ + //@remarks : + u_int32 PVIDCount; + //@brief : PID VID + //@remarks : ʹMakePVIDGetPIDGetVIDȡ + u_int32* PVID; + //@brief : ѯַnullptrʱʾѯ豸ѯָ豸豸 + u_cstring Msg; + }QParams, *PQParams;//@brief : ѯ豸ʱò + + u_inline u_int32 MakePVID(u_ushort _pid, u_ushort _vid) { return ((_pid << 16) | (_vid)); }; + + u_inline u_ushort GetPID(u_int32 _pvid) { return UCI_HIWORD(_pvid); } + + u_inline u_ushort GetVID(u_int32 _pvid) { return UCI_LOWORD(_pvid); } + +#ifdef __cplusplus + inline QParams* UCI_CreateQParam(QParams& _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(&_qp, 0, sizeof(_qp)); + _qp.Type = _type; + _qp.Ports = _ports; + _qp.PortCount = _port_cnt; + _qp.PVID = _pvid; + _qp.PVIDCount = _pvid_cnt; + _qp.Msg = _msg; + return &_qp; + } +#else + u_inline QParams* UCI_CreateQParam(QParams* _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(_qp, 0, sizeof(*_qp)); + _qp->Type = _type; + _qp->Ports = _ports; + _qp->PortCount = _port_cnt; + _qp->PVID = _pvid; + _qp->PVIDCount = _pvid_cnt; + _qp->Msg = _msg; + return _qp; + } +#endif + //@brief : дݽӿڲ + //@remarks : ͨӿuci_CreateWParams + typedef struct _WParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : صݣӾ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + }WParams, *PWParams; + +#ifdef __cplusplus + u_inline WParams* uci_CreateWParams(WParams& _p, u_cstring _cmd, u_uint32 _timeout) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + return &_p; + } +#else + u_inline WParams* uci_CreateWParams(WParams* _p, u_cstring _cmd, u_uint32 _timeout) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + return _p; + } +#endif + typedef struct _CommandParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : 1 + u_uint32 Param1; + //@brief : 1 + u_uint32 Param2; + //@brief : ʱ + u_uint32 Timeout; + }CommandParams, *PCommandParams; + + //@brief : дļIJ + typedef struct _WFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : Ҫдļ·ļ + u_cstring FilePath; + //@brief : дʱ(λms) + u_uint32 Timeout; + }WFileParams, *PWFileParams; + + //@brief : ļӿڵIJ + typedef struct _RFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : ݵش̵ļ·ļͺ׺ + u_cstring FilePath; + //@brief : ʱ(λms) + u_uint32 Timeout; + //@brief : ļ· + u_tchar FilePathFinal[MAX_PATH]; + }RFileParams, *PRFileParams; + + //@brief : ͨŽڵ + //@remarks : QParamsǰλ룬Nodeȡenumֵ + typedef enum _NodeType{ + LAN = 0x0001, + USB = 0x0010, + }NodeType; + + //@brief : USB豸 + //@remarks : + typedef struct _USBDescriptor { + //@brief : PID + u_ushort PID; + //@brief : VID + u_ushort VID; + //@brief : ַ + u_ushort Addr; + }USBDescriptor; + + //@brief : IPַ + //@remarks : ˳Ϊ f1(192).f2(168).f3(1).f4(253) - Сģʽ + typedef union _IPAddr { + struct { u_byte f1, f2, f3, f4; } Field; + u_int32 Addr; + }u_IPAddr; + + //@brief : LANͨŵ豸 + //@remarks : + typedef struct _LANDescriptor { + //@brief : IPַַͣ + u_tchar IP[16]; + //@brief : IPַ + u_IPAddr Addr; + //@brief : ˿ + //@remarks : TCPIPõĶ˿ں + u_ushort Port; + }LANDescriptor; + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _Node { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµƣ + // ѳδͳһʱUCIڲԶƥΪUCIЭõ֣ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }Node, *PNode; + + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _NodeEx { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµơ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }NodeEx, *PNodeEx; + + typedef struct _UCIMSG { + u_session Session; + u_uint32 Message; + u_wparam wParams; + u_lparam lParams; + u_byte Reserved[240]; + }UCIMSG;//256Bytes + + ////////////////////////////////////////////////////////////////////////// + typedef enum _uci_msg { + //@brief : 豸ѾϿ + //@remarks : Ŀǰֻ֧LANڷʵӵ + // wParams LAN : ˿ں(ʮ) + // Reserved LAN : IP ַ + UMSG_CONNECT_CLOSED = 1, + //@brief : ļϢ + //@remarks : + // wParams ֡ + // lParams ֡ -1 ʼ䣻 [0,wParams)У wParams + //-> UCIMSGProc return -1 ʾжϴ. + UMSG_FILE_TRANSFER = 2, + //@brief : USBϢ + //@remarks : + // wParams : ʹõ16λУ8λΪpid8λΪvid + // lParams : ¼ͣ Ƴ = 0 = 1 + UMSG_DEVICE_NOTIFY = 3, + }EUCIMSG; + + typedef int(__stdcall *UCIMSGProc)(UCIMSG* _msg); +#include + +#ifdef __cplusplus + } +#endif//__cplusplus + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ucidef_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/unit.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/unit.h new file mode 100644 index 0000000..da0fc1f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/lib/unit.h @@ -0,0 +1,117 @@ +/*! +* \created : 2016/10/10 +* \author : M.Yang +* \purpose : ṩλı׼ +* \remarks : еλĶ嶼Ա׼λΪ0Сڱ׼λΪݼڱ׼λʱΪ +* ĺôǣԱ֤Ա׼λΪ׼չ +*/ + +#ifndef Unit_h__ +#define Unit_h__ + +#ifdef __cplusplus +namespace unit { + extern "C"{ +#endif +#ifdef __cplusplus + typedef enum _EScale : char { +#else + typedef enum _EScale { +#endif // DEBUG + SCALE_p = -4, + SCALE_n, + SCALE_u, + SCALE_m, + SCALE_STD = 0, + SCALE_K, + SCALE_M, + SCALE_G, + SCALE_T, + }EScale; + +#ifdef __cplusplus + typedef enum _EType : char{ +#else + typedef enum _EType { +#endif // __cplusplus + TYPE_INVALID = -1, + TYPE_FREQ, + TYPE_TIME, + TYPE_AREA, //(Vs) + TYPE_SAMPLERATE,//ʣSa/s + TYPE_POINT, //Sa + TYPE_VPP, //ֵ + TYPE_VOLTAGE,//ѹ + TYPE_CURRENT,// + TYPE_DB, //DB + TYPE_VV, // + TYPE_PERCENT,//ٷֱ + TYPE_DEGREE, // + TYPE_WATT, //أ + TYPE_UNKNOWN,// δ֪λ + }EType; + + typedef struct _CodeName { + char Code; + char Name[5]; + }CodeName; + + static const CodeName ScaleTabel[] = { + { SCALE_p, "p" }, + { SCALE_n, "n" }, + { SCALE_u, "u" }, + { SCALE_m, "m" }, + { SCALE_STD,"" }, + { SCALE_K, "K" }, + { SCALE_M, "M" }, + { SCALE_G, "G" }, + { SCALE_T, "T" } + }; + + static const CodeName TypeTabel[] = { + { TYPE_FREQ, "Hz" }, + { TYPE_TIME, "s" }, + { TYPE_AREA, "Vs" }, + { TYPE_SAMPLERATE, "Sa/s" }, + { TYPE_POINT, "Sa" }, + { TYPE_VPP, "Vpp" }, + { TYPE_VOLTAGE, "V" }, + { TYPE_CURRENT, "A" }, + { TYPE_DB, "dB" }, + { TYPE_VV, "VV" }, + { TYPE_PERCENT, "%" }, + { TYPE_DEGREE, "" }, + { TYPE_WATT, "W" }, + { TYPE_UNKNOWN, "U" }, + }; + + const char* _UCIAPI uci_UnitFindTypeName(char _code); + + const char* _UCIAPI uci_UnitFindScaleName(char _code); + //@brief : ǰλֵתָĵλ + //@param _cur_value : ǰֵ + //@param _cur_unit : ǰλ + //@param _des_unit : Ҫתĵλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@return : תֵ2.3KHz תΪHz2300Hz + //@remarks : עⵥλEScaleģ + double _UCIAPI uci_UnitConvertTo(double _cur_value, int _cur_unit, int _des_unit, double _scale); + + typedef struct _UVale { + double Value; + long long Unit; + }UVale; + + //@brief : ǰλֵԶתʵĵλͣʹֵСڽơ2300Hzת2.3KHzs + //@param _value : ǰֵ + //@param _unit : ǰλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@remarks : עⵥλEScaleģ + UVale _UCIAPI uci_UnitRefresh(double _value, char _unit, double _scale); + +#ifdef __cplusplus + } +} +#endif + +#endif // Unit_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/UCIDemoProj.ico b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/UCIDemoProj.ico new file mode 100644 index 0000000..7b546ef Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/UCIDemoProj.ico differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/UCIDemoProj.rc2 b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/UCIDemoProj.rc2 new file mode 100644 index 0000000..2608c99 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/UCIDemoProj.rc2 differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/icon1.ico b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/icon1.ico new file mode 100644 index 0000000..b53b36e Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/res/icon1.ico differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/resource.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/resource.h new file mode 100644 index 0000000..06d95f4 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/resource.h differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/stdafx.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/stdafx.cpp new file mode 100644 index 0000000..09648fe --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/stdafx.cpp @@ -0,0 +1,8 @@ + +// stdafx.cpp : ֻ׼ļԴļ +// UCIDemoProj.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/stdafx.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/stdafx.h new file mode 100644 index 0000000..d45b135 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/stdafx.h @@ -0,0 +1,49 @@ + +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Windows ͷųʹõ +#endif + +#define _CRT_SECURE_NO_WARNINGS + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +// ر MFC ijЩɷĺԵľϢ +#define _AFX_ALL_WARNINGS + +#include // MFC ͱ׼ +#include // MFC չ + + +#include // MFC Զ + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC Internet Explorer 4 ؼ֧ +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC Windows ؼ֧ +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // Ϳؼ MFC ֧ + +#include "resource.h" + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + +#include \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/targetver.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/targetver.h new file mode 100644 index 0000000..0afac5b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UCIDemoProj/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h ߰汾Ŀ Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/ReadMe.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/ReadMe.txt new file mode 100644 index 0000000..7bc3bfa --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/ReadMe.txt @@ -0,0 +1,39 @@ +======================================================================== + 控制台应用程序:UTP3000C_Test 项目概述 +======================================================================== + +应用程序向导已为您创建了此 UTP3000C_Test 应用程序。 + +本文件概要介绍组成 UTP3000C_Test 应用程序的每个文件的内容。 + + +UTP3000C_Test.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +UTP3000C_Test.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +UTP3000C_Test.cpp + 这是主应用程序源文件。 + +///////////////////////////////////////////////////////////////////////////// +应用程序向导创建了下列资源: + +UTP3000C_Test.rc + 这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。 + +Resource.h + 这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 + +///////////////////////////////////////////////////////////////////////////// +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 UTP3000C_Test.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +///////////////////////////////////////////////////////////////////////////// +其他注释: + +应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/Resource.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/Resource.h new file mode 100644 index 0000000..84e9751 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/Resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by UTP3000C_Test.rc +// + +#define IDS_APP_TITLE 103 + +// ¶һĬֵ +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/TestApp.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/TestApp.cpp new file mode 100644 index 0000000..a80161f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/TestApp.cpp @@ -0,0 +1,68 @@ +#include "stdafx.h" +#include "TestApp.h" + +#pragma comment(lib, "lib\\uci.lib") + +using namespace uci; + +TestApp::TestApp() : m_session(INVALID_SESSION){} + + +TestApp::~TestApp() {} + +u_status TestApp::Run(const TCHAR* _addr) { + return 0; +} + +int TestApp::HandleResult(const TCHAR* _msg, int _r) { + if (UCISUCCESS(_r)) { + _tprintf(_T("%s: OK, r = %d;\n"), _msg, _r); + } else { + _tprintf(_T("%s: Error, r = %d; msg = %s\n"), _msg, _r, uci_GetLastError()); + } + return _r; +} + +u_status TestApp::Open(const u_tchar* _addr, int _timeout) { + uci_SetAttribute(INVALID_SESSION, _T("lang:zh-Hans;"), nullptr, 0); + return uci_Open(_addr, &m_session, _timeout); +} + +u_status TestApp::Write(int _timeout, const void* _data, unsigned int _data_len, const TCHAR *format, ...) { + m_dwTime = GetTickCount(); + + CString msg; + va_list argptr; + va_start(argptr, format); + msg.FormatV(format, argptr); + + auto r = uci::uci_WriteX(m_session, msg, _timeout, (const byte*)_data, _data_len); +// _tprintf(_T("Write [%s], r = %s, %s, use time = %d ms\n"), msg, r, +// UCISUCCESS(r) ? _T("OK") : _T("Error"), uci_GetLastError(), GetTickCount() - m_dwTime); +// ASSERT(r >= 0); + va_end(argptr); + return r; +} + +u_status TestApp::Read(u_cstring _msg, u_uint32 _timeout, u_byte* _data, u_size _dataLen) { + m_dwTime = GetTickCount(); + auto r = uci::uci_ReadX(m_session, _msg, _timeout, _data, _dataLen); +// _tprintf(_T("Read %s, r = %s, time = %d\n"), _msg, uci_GetLastError(), GetTickCount() - m_dwTime); +// ASSERT(r >= 0); + return r; +} + +u_status TestApp::Read(u_uint32 _timeout, u_byte* _data, u_size _dataLen, u_cstring format, ...) { + CString msg; + va_list argptr; + va_start(argptr, format); + msg.FormatV(format, argptr); + + m_dwTime = GetTickCount(); + auto r = uci_ReadX(m_session, msg, _timeout, _data, _dataLen); +// _tprintf(_T("Read %s, r = %s, time = %d\n"), msg, uci_GetLastError(), GetTickCount() - m_dwTime); +// ASSERT(r >= 0); + + va_end(argptr); + return r; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/TestApp.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/TestApp.h new file mode 100644 index 0000000..142087e --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/TestApp.h @@ -0,0 +1,26 @@ +#pragma once + +#include "lib\uci.h" + +class TestApp { +public: + TestApp(); + virtual ~TestApp(); + + virtual u_status Run(const TCHAR* _addr); + +protected: + virtual int HandleResult(const TCHAR* _msg, int _r); + + virtual u_status Open(const u_tchar* _addr, int _timeout = 1000); + + virtual u_status Write(int _timeout, const void* _data, unsigned int _data_len, const TCHAR *format, ...); + + virtual u_status Read(u_cstring _msg, u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + virtual u_status Read(u_uint32 _timeout, u_byte* _data, u_size _dataLen, u_cstring format, ...); +protected: + u_session m_session; + DWORD m_dwTime; +}; + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.cpp new file mode 100644 index 0000000..3eb1b69 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.cpp @@ -0,0 +1,624 @@ +// UTP3000C_Test.cpp : ̨Ӧóڵ㡣 +// + +#include "stdafx.h" +#include "UTP3000C_Test.h" +#include "TestApp.h" + + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#define DELAY_WRITE_AND_READ (50) + +// ΨһӦó + +CWinApp theApp; + +TestP330XC testApp; + +using namespace std; + +int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) +{ + int nRetCode = 0; + + HMODULE hModule = ::GetModuleHandle(NULL); + + setlocale(LC_ALL, "CHS"); + + if (hModule != NULL) + { + // ʼ MFC ʧʱʾ + if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0)) + { + // TODO: ĴԷҪ + _tprintf(_T(": MFC ʼʧ\n")); + nRetCode = 1; + } + else { + // TODO: ڴ˴ΪӦóΪд롣 + if (argc < 2) { + _tprintf(_T("ֱĬϲUSBͨš\n")); + testApp.Run(_T("[C:POWER][D:P330XC][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x2][CFG:1][I:1]")); + } else { + _tprintf(_T("%s\n"), argv[1]); + if (CString(argv[1]).Find(_T("UTP3305S"), 0) != -1) + { + testApp.Run_UTP3305S(argv[1]); + } + else + { + testApp.Run(argv[1]); + } + } + system("pause"); + } + } + else + { + // TODO: ĴԷҪ + _tprintf(_T(": GetModuleHandle ʧ\n")); + nRetCode = 1; + } + + return nRetCode; +} + +u_status TestP330XC::Run_UTP3305S(const TCHAR* _addr) +{ + auto r = HandleResult(_T("豸"), _base::Open(_addr)); + if (UCIERR(r)) { + _tprintf(_T(": 豸 ʧ\n")); + AfxMessageBox(_T("豸ʧܣǷװɹǷӣǴӣrun_utp3000c_test.batļе[PORT:4]ָĴںǷȷ")); + return r; + } + + _tprintf(_T("------------ע--------------\n")); + _tprintf(_T("1ԶдָǷһ£\n")); + _tprintf(_T("2ԶдָǷ豸״̬һ\n")); + + + _tprintf(_T("------------ Ե1--------------\n")); + + CString strIDN; + r = QueryParam_CString(_T("*IDN?\r\n"), strIDN); + if (UCISUCCESS(r)) { + CString strName = _T("޷ʶ"); + if (strIDN.Find(_T("P3303"), 0) != -1) { + strName = _T("UTP3303S"); + } + else if (strIDN.Find(_T("P3305"), 0) != -1) { + strName = _T("UTP3305S"); + } + else if (strIDN.Find(_T("P8303"), 0) != -1) { + strName = _T("UTP8303Z"); + } + else if (strIDN.Find(_T("P8305"), 0) != -1) { + strName = _T("UTP8305Z"); + } + _tprintf(_T("ʶ %s \n"), strName); + } + + _tprintf(_T("豸ע⣺ \n")); + _tprintf(_T(" USB ̼еIJƷ P830XZ *IDN? P8303Z P8305Z\n")); + _tprintf(_T(" USB ̼еIJƷ P330XS *IDN? P3303S P3305S\n")); + + if (!IsContinue(UCISUCCESS(r))) + return -1; + + double v = 0.0; + std::vector result; + + CString strMsg; + + _tprintf(_T("------------ Ե2--------------\n")); + r = SetParam(_T(":SYSTem:BEEPer 0\r\n"), _T(":SYSTem:BEEPer?\r\n"), 0); + if (UCISUCCESS(r)) { + r = AfxMessageBox(_T("Ѿ·:SYSTem:BEEPer 0顾ǷѾرա"), + MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + + if (r < 0) + _tprintf(_T("--ERROR-- [:SYSTem:BEEPer 0]豸״̬ƥ䣡\n")); + } + + r = SetParam(_T(":SYSTem:BEEPer 1\r\n"), _T(":SYSTem:BEEPer?\r\n"), 1); + if (UCISUCCESS(r)) { + r = AfxMessageBox(_T("Ѿ·:SYSTem:BEEPer 1顾ǷѾ򿪡"), + MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + + if (r < 0) + _tprintf(_T("--ERROR-- [:SYSTem:BEEPer 1]豸״̬ƥ䣡\n")); + } + + if (!IsContinue(UCISUCCESS(r))) + return -1; + + _tprintf(_T("------------ Ե3--------------\n")); + r = SetParam(_T(":SYSTem:LOCK 1\r\n"), _T(":SYSTem:LOCK?\r\n"), 1); + if (UCISUCCESS(r)) { + r = AfxMessageBox(_T("Ѿü顾̡ǷѾ"), + MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + + if (r < 0) + _tprintf(_T("--ERROR-- [:SYSTem:LOCK 1]豸״̬ƥ䣡\n")); + } + + Sleep(1000); + + r = SetParam(_T(":SYSTem:LOCK 0\r\n"), _T(":SYSTem:LOCK?\r\n"), 0); + if (UCISUCCESS(r)) { + r = AfxMessageBox(_T("Ѿ·:SYSTem:LOCK 0顾̡ǷѾ"), + MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + + if (r < 0) + _tprintf(_T("--ERROR-- [:SYSTem:LOCK 0]豸״̬ƥ䣡\n")); + } + + if (!IsContinue(UCISUCCESS(r))) + return -1; + + _tprintf(_T("------------ Ե4--------------\n")); + _tprintf(_T("׼:KEY:ָM1~M5Ƿα: \n")); + Sleep(3000); + r = SendMsg(_T(":KEY:F1\r\n")); + Sleep(1000); + r = SendMsg(_T(":KEY:F2\r\n")); + Sleep(1000); + r = SendMsg(_T(":KEY:F3\r\n")); + Sleep(1000); + r = SendMsg(_T(":KEY:F4\r\n")); + Sleep(1000); + r = SendMsg(_T(":KEY:F5\r\n")); + Sleep(1000); + r = AfxMessageBox(_T("ǷM1~M5α"), MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + if (r < 0) + _tprintf(_T("--ERROR-- [KEY:]豸״̬ƥ䣡\n")); + + _tprintf(_T("------------ Ե5--------------\n")); + _tprintf(_T("׼:OUTPut:MODEָ\n")); + r = SendMsg(_T(":OUTP:MODE SER\r\n")); + Sleep(1000); + r = SendMsg(_T(":OUTP:MODE PARA\r\n")); + Sleep(1000); + r = SendMsg(_T(":OUTP:MODE NOMAL\r\n")); + Sleep(1000); + + /*_tprintf(_T("------------ Ե6--------------\n")); + _tprintf(_T("׼OVPأ\n")); + SetStatusParams(_T("OVP1"), 1, 4, 0x1); + SetStatusParams(_T("OVP0"), 0, 4, 0x1); + + _tprintf(_T("------------ Ե7--------------\n")); + _tprintf(_T("׼OCPأ\n")); + SetStatusParams(_T("OCP1"), 1, 5, 0x1); + SetStatusParams(_T("OCP0"), 0, 5, 0x1); + Sleep(1000);*/ + + if (!IsContinue(UCISUCCESS(r))) + return -1; + + _tprintf(_T("------------ Ե6--------------\n")); + _tprintf(_T("׼ָͨ:OUTPutע⣺UTP3305SûOCPOVPأ֮Զر\n")); + _tprintf(_T("׼ͨһ\n")); + SetParam(_T(":OUTPut1 1\r\n"), _T(":OUTPut1?\r\n"), 1); + Sleep(1000); + SetParam(_T(":OUTPut1 0\r\n"), _T(":OUTPut1?\r\n"), 0); + _tprintf(_T("׼ͨ\n")); + SetParam(_T(":OUTPut2 1\r\n"), _T(":OUTPut2?\r\n"), 1); + Sleep(1000); + SetParam(_T(":OUTPut2 0\r\n"), _T(":OUTPut2?\r\n"), 0); + _tprintf(_T("׼ͨ\n")); + SetParam(_T(":OUTPut3 1\r\n"), _T(":OUTPut3?\r\n"), 1); + Sleep(1000); + SetParam(_T(":OUTPut3 0\r\n"), _T(":OUTPut3?\r\n"), 0); + + _tprintf(_T("------------ Ե7--------------\n")); + QueryParam_Double(_T(":SOURce1:CURRent?\r\n"), v); + QueryParam_Double(_T(":SOURce2:CURRent?\r\n"), v); + QueryParam_Double(_T(":SOURce3:CURRent?\r\n"), v); + + _tprintf(_T("------------ Ե8--------------\n")); + QueryParam_Double(_T(":SOURce1:VOLTage?\r\n"), v); + QueryParam_Double(_T(":SOURce2:VOLTage?\r\n"), v); + QueryParam_Double(_T(":SOURce3:VOLTage?\r\n"), v); + + _tprintf(_T("------------ Ե9--------------\n")); + SetParam(_T(":SOURce1:VOLTage 20\r\n"), _T(":SOURce1:VOLTage?\r\n"), 20.000); + SetParam(_T(":SOURce1:VOLTage 10\r\n"), _T(":SOURce1:VOLTage?\r\n"), 10.000); + + SetParam(_T(":SOURce2:VOLTage 20\r\n"), _T(":SOURce2:VOLTage?\r\n"), 20.000); + SetParam(_T(":SOURce2:VOLTage 10\r\n"), _T(":SOURce2:VOLTage?\r\n"), 10.000); + + SetParam(_T(":SOURce3:VOLTage 3.3\r\n"), _T(":SOURce3:VOLTage?\r\n"), 3.300); + SetParam(_T(":SOURce3:VOLTage 5\r\n"), _T(":SOURce3:VOLTage?\r\n"), 5.000); + + _tprintf(_T("------------ Ե10--------------\n")); + SetParam(_T(":SOURce1:CURRent 3\r\n"), _T(":SOURce1:CURRent?\r\n"), 3.000); + SetParam(_T(":SOURce1:CURRent 2\r\n"), _T(":SOURce1:CURRent?\r\n?"), 2.000); + + SetParam(_T(":SOURce2:CURRent 3\r\n"), _T(":SOURce2:CURRent?\r\n"), 3.000); + SetParam(_T(":SOURce2:CURRent 2\r\n"), _T(":SOURce2:CURRent?\r\n?"), 2.000); + + _tprintf(_T("------------ Ե11--------------\n")); + _tprintf(_T("ע:ѹֵڵǰõѹ10%ϲóɹ\n")); + + SetParam(_T(":SOURce1:VOLTage:PROTection 30\r\n"), _T(":SOURce1:VOLTage:PROTection?\r\n"), 30.000); + SetParam(_T(":SOURce1:VOLTage:PROTection 20\r\n"), _T(":SOURce1:VOLTage:PROTection?\r\n"), 20.000); + + SetParam(_T(":SOURce2:VOLTage:PROTection 30\r\n"), _T(":SOURce2:VOLTage:PROTection?\r\n"), 30.000); + SetParam(_T(":SOURce2:VOLTage:PROTection 20\r\n"), _T(":SOURce2:VOLTage:PROTection?\r\n"), 20.000); + + _tprintf(_T("------------ Ե12--------------\n")); + _tprintf(_T("ע:ֵڵǰõ10%ϲóɹ\n")); + + SetParam(_T(":SOURce1:CURRent:PROTection 3\r\n"), _T(":SOURce1:CURRent:PROTection?\r\n"), 3.000); + SetParam(_T(":SOURce1:CURRent:PROTection 2.2\r\n"), _T(":SOURce1:CURRent:PROTection?\r\n"), 2.200); + + SetParam(_T(":SOURce2:CURRent:PROTection 3\r\n"), _T(":SOURce2:CURRent:PROTection?\r\n"), 3.000); + SetParam(_T(":SOURce2:CURRent:PROTection 2.2\r\n"), _T(":SOURce2:CURRent:PROTection?\r\n"), 2.200); + + _tprintf(_T("Խ: \n")); + _tprintf(_T("ָָҪһʱòɹOVPSET1:10.00󣬱ʱ50msִOVPSET1?IJѯָ \n")); + + if (IsTestOk()) + AfxMessageBox(_T("ָͨ")); + else + AfxMessageBox(_T("ָʧܣ")); + return r; +} + +u_status TestP330XC::Run(const TCHAR* _addr) { + auto r = HandleResult(_T("豸"), _base::Open(_addr)); + if (UCIERR(r)) { + _tprintf(_T(": 豸 ʧ\n")); + AfxMessageBox(_T("豸ʧܣǷװɹǷӣǴӣrun_utp3000c_test.batļе[PORT:4]ָĴںǷȷ")); + return r; + } + + _tprintf(_T("------------ע--------------\n")); + _tprintf(_T("1ԶдָǷһ£\n")); + _tprintf(_T("2ԶдָǷ豸״̬һ\n")); + + + _tprintf(_T("------------ Ե1--------------\n")); + + CString strIDN; + r = QueryParam_CString(_T("*IDN?"), strIDN); + if (UCISUCCESS(r)) { + CString strName = _T("޷ʶ"); + if (strIDN.Find(_T("P3303"), 0) != -1) { + strName = _T("UTP3303C"); + } else if (strIDN.Find(_T("P3305"), 0) != -1) { + strName = _T("UTP3305C"); + } else if (strIDN.Find(_T("P8303M"), 0) != -1) { + strName = _T("UTP8303M"); + } else if (strIDN.Find(_T("P8305M"), 0) != -1) { + strName = _T("UTP8305M"); + } + _tprintf(_T("ʶ %s \n"), strName); + } + + _tprintf(_T("豸ע⣺ \n")); + _tprintf(_T(" USB ̼еIJƷ P830XM *IDN? P8303M P8305M\n")); + _tprintf(_T(" USB ̼еIJƷ P330XC *IDN? P3303C P3305C\n")); + + if (!IsContinue(UCISUCCESS(r))) + return -1; + + double v = 0.0; + std::vector result; + + CString strMsg ; + + _tprintf(_T("------------ Ե2--------------\n")); + r = SetParam(_T("BEEP0"), _T("BEEP?"), 0); + if (UCISUCCESS(r)) { + r = AfxMessageBox(_T("Ѿ·BEEP0顾ǷѾرա"), + MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + + if (r < 0) + _tprintf(_T("--ERROR-- [BEEP0]豸״̬ƥ䣡\n")); + } + + r = SetParam(_T("BEEP1"), _T("BEEP?"), 1); + if (UCISUCCESS(r)) { + r = AfxMessageBox(_T("Ѿ·BEEP1顾ǷѾ򿪡"), + MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + + if (r < 0) + _tprintf(_T("--ERROR-- [BEEP1]豸״̬ƥ䣡\n")); + } + + if (!IsContinue(UCISUCCESS(r))) + return -1; + + _tprintf(_T("------------ Ե3--------------\n")); + r = SetParam(_T("LOCK1"), _T("LOCK?"), 1); + if (UCISUCCESS(r)) { + r = AfxMessageBox(_T("Ѿü顾̡ǷѾ"), + MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + + if (r < 0) + _tprintf(_T("--ERROR-- [LOCK1]豸״̬ƥ䣡\n")); + } + + r = SetParam(_T("LOCK0"), _T("LOCK?"), 0); + if (UCISUCCESS(r)) { + r = AfxMessageBox(_T("Ѿ·LOCK0顾̡ǷѾ"), + MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + + if (r < 0) + _tprintf(_T("--ERROR-- [LOCK0]豸״̬ƥ䣡\n")); + } + + if (!IsContinue(UCISUCCESS(r))) + return -1; + + _tprintf(_T("ע⣺ ڶԴģBEEP1BEEP0Ƿģ \n")); + + _tprintf(_T("------------ Ե4--------------\n")); + _tprintf(_T("׼RCLָM1~M5Ƿα: \n")); + Sleep(3000); + r = SendMsg(_T("RCL1")); + Sleep(1000); + r = SendMsg(_T("RCL2")); + Sleep(1000); + r = SendMsg(_T("RCL3")); + Sleep(1000); + r = SendMsg(_T("RCL4")); + Sleep(1000); + r = SendMsg(_T("RCL5")); + Sleep(1000); + r = AfxMessageBox(_T("ǷM1~M5α"), MB_YESNO | MB_ICONQUESTION) == IDYES ? 0 : -1; + m_result.push_back(r); + if (r < 0) + _tprintf(_T("--ERROR-- [RCL]豸״̬ƥ䣡\n")); + + _tprintf(_T("------------ Ե5--------------\n")); + _tprintf(_T("׼TRACKָ\n")); + SetTrackMode(E_TRACK_MODE::TRACK_SERIES); + Sleep(1000); + SetTrackMode(E_TRACK_MODE::TRACK_PARA); + Sleep(1000); + SetTrackMode(E_TRACK_MODE::TRACK_INDEPENDENT); + Sleep(1000); + + _tprintf(_T("------------ Ե6--------------\n")); + _tprintf(_T("׼OVPأ\n")); + SetStatusParams(_T("OVP1"), 1, 4, 0x1); + SetStatusParams(_T("OVP0"), 0, 4, 0x1); + + _tprintf(_T("------------ Ե7--------------\n")); + _tprintf(_T("׼OCPأע⣺ڶԴУOCP0޷رOCPأ\n")); + SetStatusParams(_T("OCP1"), 1, 5, 0x1); + SetStatusParams(_T("OCP0"), 0, 5, 0x1); + Sleep(1000); + + if (!IsContinue(UCISUCCESS(r))) + return -1; + + _tprintf(_T("------------ Ե8--------------\n")); + _tprintf(_T("׼ָͨOUT ȷȹرOCPOVPٲԡ\n")); + SetStatusParams(_T("OUT1"), 0x3, 6, 0x3); + Sleep(1000); + SetStatusParams(_T("OUT0"), 0x0, 6, 0x3); + + _tprintf(_T("------------ Ե9--------------\n")); + QueryParam_Double(_T("IOUT1?"), v); + QueryParam_Double(_T("IOUT2?"), v); + + _tprintf(_T("------------ Ե10--------------\n")); + QueryParam_Double(_T("VOUT1?"), v); + QueryParam_Double(_T("VOUT2?"), v); + + _tprintf(_T("------------ Ե11--------------\n")); + SetParam(_T("VSET1:20.00"), _T("VSET1?"), 20.00); + SetParam(_T("VSET1:10.00"), _T("VSET1?"), 10.00); + + SetParam(_T("VSET2:20.00"), _T("VSET2?"), 20.00); + SetParam(_T("VSET2:10.00"), _T("VSET2?"), 10.00); + + _tprintf(_T("------------ Ե12--------------\n")); + SetParam(_T("ISET1:2.000"), _T("ISET1?"), 2.000); + SetParam(_T("ISET1:3.000"), _T("ISET1?"), 3.000); + + SetParam(_T("ISET2:2.000"), _T("ISET2?"), 2.000); + SetParam(_T("ISET2:3.000"), _T("ISET2?"), 3.000); + + _tprintf(_T("------------ Ե13--------------\n")); + SetParam(_T("OVPSET1:30.00"), _T("OVPSET1?"), 30.00); + SetParam(_T("OVPSET1:20.00"), _T("OVPSET1?"), 20.00); + + SetParam(_T("OVPSET2:30.00"), _T("OVPSET2?"), 30.00); + SetParam(_T("OVPSET2:20.00"), _T("OVPSET2?"), 20.00); + + _tprintf(_T("------------ Ե14--------------\n")); + SetParam(_T("OCPSET1:3.000"), _T("OCPSET1?"), 3.000); + SetParam(_T("OCPSET1:2.000"), _T("OCPSET1?"), 2.000); + + SetParam(_T("OCPSET2:3.000"), _T("OCPSET2?"), 3.000); + SetParam(_T("OCPSET2:2.000"), _T("OCPSET2?"), 2.000); + + _tprintf(_T("Խ: \n")); + _tprintf(_T("ָָҪһʱòɹOVPSET1:10.00󣬱ʱ50msִOVPSET1?IJѯָ \n")); + + _tprintf(_T("ݵСλҪ ѹ2λ3λ 磺Ͳɹ \n")); + SetParam(_T("OVPSET1:15.000"), _T("OVPSET1?"), 15.00); + _tprintf(_T("޸ijλСλOK \n")); + SetParam(_T("OVPSET1:16.00"), _T("OVPSET1?"), 16.00); + + _tprintf(_T("ע: \n")); + _tprintf(_T("˵Ƿ BEEP?\\LOCK? \nSTATUS?ǷЭĵһ£: \n")); + + if (IsTestOk()) + AfxMessageBox(_T("ָͨ")); + else + AfxMessageBox(_T("ָʧܣ")); + return r; +} + +u_status TestP330XC::QueryStauts(Status& _st, byte* _stautsCode) { + char v = 0; + auto r = QueryParam(_T("STATUS?"), &v, sizeof(v)); + if (UCISUCCESS(r)) { + _st = ParseStatus(v); + if (_stautsCode != nullptr) + *_stautsCode = v; + } else { + m_result.push_back(r); + } + return r; +} + +u_status TestP330XC::QueryParam_Double(const u_tchar* _msg, double& _v, int _timeout /*= 50*/, bool _traceEnable /*= true*/) { + char buf[20]; + ZeroMemory(buf, sizeof(buf)); + + auto r = QueryParam(_msg, buf, sizeof(buf), _timeout); + + if (UCISUCCESS(r)) { + _v = atof(buf); + if (_traceEnable) + _tprintf(_T("[%s] -> OK, Value = %f \n"), _msg, _v); + } else { + if (_traceEnable) { + _tprintf(_T("[%s] -> Error, r = %d, msg = %s \n"), _msg, r, uci::uci_GetLastError()); + m_result.push_back(r); + } + } + return r; +} + +u_status TestP330XC::SendMsg(const u_tchar* _msg, int _timeout /*= 50*/) { + auto r = _base::Write(_timeout, nullptr, 0, _msg); + if (UCISUCCESS(r)) { + _tprintf(_T("[%s] -> OK! \n"), _msg); + } else { + _tprintf(_T("[%s] -> Error, r = %d, msg = %s! \n"), _msg, r, uci::uci_GetLastError()); + m_result.push_back(r); + } + return r; +} + +u_status TestP330XC::SetParam(const u_tchar* _msgWrite, const u_tchar* _msgQuery, + double _vWrite, int _readTimeout /*= 50*/) { + auto r = _base::Write(50, nullptr, 0, _msgWrite); + if (UCISUCCESS(r)) { + double vRead = 0.0; + Sleep(DELAY_WRITE_AND_READ); + r = QueryParam_Double(_msgQuery, vRead, _readTimeout, false); + if (UCISUCCESS(r)) { + if (_vWrite == vRead) { + _tprintf(_T("[%s] -> ضֵ[%s] = %f ->OK! \n"), _msgWrite, _msgQuery, vRead); + } else { + _tprintf(_T("[%s] -> ضֵ[%s] = %f ->Error! \n"), _msgWrite, _msgQuery, vRead); + m_result.push_back(r); + } + return _vWrite == vRead ? 0 : -1; + } + else { + _tprintf(_T("[%s] -> ض[%s]ʧܣ r = %d : %s ->Error!! \n"), _msgWrite, _msgQuery, r, uci::uci_GetLastError()); + m_result.push_back(r); + } + } else { + _tprintf(_T("[%s] -> ʧܣ r = %d : %s ->Error!! \n"), _msgWrite, r, uci::uci_GetLastError()); + m_result.push_back(r); + } + return r; +} + +u_status TestP330XC::SetTrackMode(E_TRACK_MODE _mode) { + CString s; + s.Format(_T("TRACK%d"), _mode); + auto r = SendMsg(s); + + Status st; + if (UCISUCCESS(r)) { + Sleep(DELAY_WRITE_AND_READ); + r = QueryStauts(st); + if (UCISUCCESS(r)) { + _tprintf(_T("[%s] -> ض[STATU?]-> TRACK = %d -> %s\n"), + s, st.Track, st.Track == _mode ? _T("OK") : _T("Error")); + } else { + _tprintf(_T("[%s] -> ض[STATU?] -> ʧܣ\n"), s); + } + } + return r; +} + +u_status TestP330XC::SetStatusParams(const u_tchar* _msg, byte _v, char _statusBitOffset, char _statusMaskBits) { + auto r = SendMsg(_msg); + + Status st; + if (UCISUCCESS(r)) { + Sleep(DELAY_WRITE_AND_READ); + byte st_code = 0; + r = QueryStauts(st, &st_code); + if (UCISUCCESS(r)) { + auto bits = GetBit(st_code, _statusBitOffset, _statusMaskBits); + _tprintf(_T("[%s] -> ض[STATU? = 0x%x]-> Bits = 0x%x -> %s\n"), + _msg, st_code , bits, bits == _v ? _T("OK") : _T("Error")); + } else { + _tprintf(_T("[%s] -> ض[STATU?] -> ʧܣ\n"), _msg); + m_result.push_back(r); + } + } + return r; +} + +TestP330XC::Status TestP330XC::ParseStatus(byte _byte) { + Status st; + ZeroMemory(&st, sizeof(st)); + st.CH1_CC_CV = (_byte & 0x1) == 0 ? E_CC_CV_MODE::CC : E_CC_CV_MODE::CV; + st.CH2_CC_CV = (_byte & 0x2) == 0 ? E_CC_CV_MODE::CC : E_CC_CV_MODE::CV; + + switch (GetBit(_byte, 2, 0x3)) { + case 0: + st.Track = E_TRACK_MODE::TRACK_INDEPENDENT; + break; + case 1: + st.Track = E_TRACK_MODE::TRACK_SERIES; + break; + case 2: + st.Track = E_TRACK_MODE::TRACK_PARA; + break; + default: + st.Track = E_TRACK_MODE::TRACK_UNKNOWN; + break; + } + + st.IsOVPEnable = GetBit(_byte, 4, 0x1) == 1; + st.IsOCPEnable = GetBit(_byte, 5, 0x1) == 1; + + st.IsCH1ON = GetBit(_byte, 6, 0x1) == 1; + st.IsCH2ON = GetBit(_byte, 7, 0x1) == 1; + + return st; +} + +bool TestP330XC::IsTestOk() { + for each (auto var in m_result) { + if (var < 0) + return false; + } + return true; +} + +bool TestP330XC::IsContinue(bool _isok) { + if (!_isok && AfxMessageBox(_T("ִǷ"), + MB_YESNO | MB_ICONQUESTION) == IDNO) { + return false; + } + return true; +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.h new file mode 100644 index 0000000..043b5ff --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.h @@ -0,0 +1,113 @@ +#pragma once + +#include "resource.h" + +#include +#include "TestApp.h" + +class TestP330XC : public TestApp { + typedef TestApp _base; +public: + TestP330XC() {} + virtual ~TestP330XC() {} + + enum E_CC_CV_MODE{ + CC = 0, + CV = 1 + }; + + enum E_TRACK_MODE { + TRACK_UNKNOWN = -1, + TRACK_INDEPENDENT = 0, + TRACK_SERIES = 1, + TRACK_PARA = 2 + }; + + struct Status { + E_CC_CV_MODE CH1_CC_CV; + E_CC_CV_MODE CH2_CC_CV; + E_TRACK_MODE Track; + bool IsOVPEnable; + bool IsOCPEnable; + bool IsCH1ON; + bool IsCH2ON; + }; + + virtual u_status Run(const TCHAR* _addr) override; + u_status Run_UTP3305S(const TCHAR* _addr); + u_status QueryStauts(Status& _st, byte* _stautsCode = nullptr); + u_status QueryParam(const u_tchar* _msg, char* _data, int _data_count, int _timeout = 50) { + auto r = _base::Write(_timeout, nullptr, 0, _msg); + Sleep(50); + return UCIERR(r) ? r: _base::Read(_msg, (UINT)_timeout, (byte*)_data, (UINT)_data_count); + } + + u_status QueryParam_Double(const u_tchar* _msg, double& _v, int _timeout = 50, bool _traceEnable = true); + + u_status QueryParam_CString(const u_tchar* _msg, CString& _v, int _timeout = 60, bool _traceEnable = true) { + _v = _T(""); + + char buf[64]; + ZeroMemory(buf, sizeof(buf)); + auto r = QueryParam(_msg, buf, sizeof(buf), _timeout); + if (UCISUCCESS(r)) { + _v = CStringA(buf); + if (_traceEnable) + _tprintf(_T("[%s] -> ضOK, %s \n"), _msg, _v); + } else { + if (_traceEnable) { + _tprintf(_T("[%s] -> ض %s \n"), _msg, _v); + m_result.push_back(r); + } + } + return r; + } + u_status SendMsg(const u_tchar* _msg, int _timeout = 50); + + u_status SetParam(const u_tchar* _msgWrite, const u_tchar* _msgQuery, + double _vWrite, int _readTimeout = 50); + + u_status SetTrackMode(E_TRACK_MODE _mode); + + u_status SetStatusParams(const u_tchar* _msg, byte _v, char _statusBitOffset, char _statusMaskBits); +protected: + inline char GetBit(byte _byte, byte _offset, byte _mask) { + return (char)((_byte >> _offset) & _mask); + } + + Status ParseStatus(byte _byte); + + + bool IsTestOk(); + + bool IsContinue(bool _isok); +private: + std::vector m_result; +}; +#if 0 +u_session m_session; + +u_status r = uci_Open("[C:POWER][D:P330XC][T:USB][PID:0x1234][VID:0x5345][EI:0x81][EO:0x2][CFG:1][I:1]", + &m_session, 1000); + +auto r = uci_WriteX(m_session, "*IDN?", 1000, NULL, 0); + +char buf[20]; +ZeroMemory(buf, sizeof(buf)); +auto r = uci_ReadX(m_session, "*IDN?", 100, buf, sizeof(buf));//ȡʱ_msgΪգ + +uci_Close(m_session); + +/* +//@brief : ȡ +//@param _session : ỰID +//@param _msg : ַ'\0'β. ʽĵ +//@param _timeout : ȡʱ +//@param _data : նȡݵĻַ +//@param _dataLen : _dataָĻȣBytes +//@return : 鿴ļеġڽӿڷص״ֵ̬˵ +//@remarks : ӿuci_Readļ򻯰汾 +u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, +u_uint32 _timeout, u_byte* _data, u_size _dataLen); +*/ +#endif \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.rc b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.rc new file mode 100644 index 0000000..31d90ed Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.rc differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.vcxproj b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.vcxproj new file mode 100644 index 0000000..07824bf --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.vcxproj @@ -0,0 +1,250 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {839523F4-DFF9-4A65-B7B4-8E9760C40532} + Win32Proj + UTP3000C_Test + + + + Application + true + v120 + Unicode + Dynamic + + + Application + true + v120 + Unicode + Dynamic + + + Application + true + v120 + Unicode + Dynamic + + + Application + false + v120_xp + true + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + Application + false + v120_xp + true + Unicode + Static + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + false + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + true + true + + + Console + true + + + true + + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + true + true + + + Console + true + + + true + + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + true + true + + + Console + true + + + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.vcxproj.filters b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.vcxproj.filters new file mode 100644 index 0000000..48acfbf --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/UTP3000C_Test.vcxproj.filters @@ -0,0 +1,53 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.dll b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.dll new file mode 100644 index 0000000..2dec612 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.h new file mode 100644 index 0000000..786edd9 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.h @@ -0,0 +1,212 @@ +/******************************************************************** + created: 2014/12/22 + author: M.Yang + purpose: UCI(united communicate interface) +*********************************************************************/ + +#ifndef uci_h__ +#define uci_h__ + +#include "ucidef.h" + +////////////////////////////////////////////////////////////////////////// +// ڽӿڷص״ֵ̬ +// < 0 : ʾ +// ӦĴϢͨuci_GetLastErrorȡ,Ķucidef.hļС +// < UCI_ERRĴΪlibusbĴ롣 +////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +namespace uci { +extern "C"{ +#endif + //@brief : ִỰ޹صIJѯ + //@param PRParams _params : ѯIJ + //@param u_byte * _data : ݵĻַ + //@param u_size _dataCount : ݵĻСBytes + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_Query(_in_out PRParams _params, _in_out u_byte* _data, _in u_size _dataCount); + + //@brief : ѯͨŽڵ + //@param _in const QParams * _params : ѯ + //@param _out Node * _outBuf : ŲѯĽڵ + //@param _in_out u_size * _nodeCnt : ΪҪȡĽڵΪʵʶȡĽڵ + //@param _in u_size _timeOut : ѯʱ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_QueryNodes(_in const QParams* _params, _out Node* _outBuf, + _in_out u_size* _nodeCnt, _in u_size _timeOut); + + //@brief : ѯͨŽڵ + //@param _msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _nodes : ŲѯĽڵ + //@param _node_count : ҪѯĽڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX(u_cstring _msg, Node* _nodes, u_size _node_count, _in u_size _timeout); + + //@brief : 豸 + //@param u_cstring _addr : 豸ַ '\0'β + //@param u_session * _session : ѽĻỰID. + //@param u_uint32 _timeOut : ӳʱʱ ms + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + // UCI_SUCCESS + // UCI_ERR_ARGS_WRONG; + // UCI_ERR_RES_INIT_ERROR; + // UCI_ERR_CONNECT_ADDR_WRONG; + // UCI_ERR_CONNECT_FAILED; + // UCI_ERR_CONNECT_TIMEOUT] + //@remarks : ĵ + u_status _UCIAPI uci_Open(u_cstring _addr, u_session* _session, u_uint32 _timeOut); + + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 + u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + //@brief : ִ + //@param u_session _session : ỰID + //@param PCommandParams _params : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SendCommand(u_session _session, PCommandParams _params); + + //@brief : + //@param uciNotify _pNotify : + //@return u_status _UCIAPI : + //@remarks : + u_status _UCIAPI uci_SetNotify(UCIMSGProc _pNotify); + + //@brief : + //@param _msg : + //@param _obj : + //@param _objSize : + //@return : + //@remarks : + u_status _UCIAPI uci_SetAttribute(u_session _sesn, u_cstring _msg, const u_object* _obj, u_size _objSize); + + //@brief : ѯ + //@param u_session _sesn : + //@param u_attr _name : + //@param u_attr_v * _value : + //@return u_status _UCIAPI : + //@remarks : + //u_status _UCIAPI uci_GetAttribute(u_session _sesn, u_attr _name, u_attr_v* _value); + u_status _UCIAPI uci_GetAttribute(u_session _sesn, u_cstring _msg, u_object* _obj, u_size _objSize); + + //@brief : д + //@param u_session _session : ỰID + //@param PWParam _params : д + //@param const u_byte * _data : Ҫдݻַ ΪNULL + //@param u_size _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_params.CMDStringѾҪдֶˣ + // _data != NULLַ_params.CMDStringֻܰһ䡣 +#ifdef __cplusplus + u_status _UCIAPI uci_Write(u_session _session, PWParams _params, const u_byte* _data = nullptr, u_size _len = 0); +#else + u_status _UCIAPI uci_Write(u_session _session, PWParams _params, const u_byte* _data, u_size _len); +#endif // __cplusplus + + //@brief : д + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@param _data : Ҫдݻַ ΪNULL + //@param _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_msgѾҪдֶˣ + //_data != NULLַ_msgֻܰһ䡣 + u_status _UCIAPI uci_WriteX(u_session _session, u_cstring _msg, + u_uint32 _timeout, const u_byte* _data, u_size _len); + + u_status _UCIAPI uci_WriteSimple(u_session _session, u_cstring _msg, u_uint32 _timeout); + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + //@brief : ȡ + //@param u_session _session : ỰID + //@param PRParams _params : + //@param u_byte * _data : ݵĻ + //@param u_size _dataLen : ݵĻССЭ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_Read(u_session _session, PRParams _params, u_byte* _data, u_size _dataLen); + + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 + u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, + u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + //@brief : дļ + //@param u_session _session : ỰID + //@param WFileParams * _info : ļϢ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteFromFile(u_session _session, WFileParams* _info); + + //@brief : дļ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : Ҫдļ·ļ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_WriteFromFileļ򻯰汾 + u_status _UCIAPI uci_WriteFromFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout); + + //@brief : Read data synchronously and store the transferred data in a file. + //@param u_session _session : ỰID + //@param RFileParams _params : Ҫݵļ· + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_ReadToFile(u_session _session, RFileParams* _params); + + //@brief : ȡļ + //@param _session : ỰID. + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : ݵش̵ļ·ļͺ׺ + //Ǿ·Ҳ··ͨ_filePathFinalȡ· + //@param _timeout : ʱ + //@param _filePathFinal : 嵽صļľ· + //@param _filePathFinalLength : _filePathFinalijȣַ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_ReadToFileķǷװ汾 + u_status _UCIAPI uci_ReadToFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength); + + //@brief : رջỰ + //@param u_session _session : ҪرյĻỰID + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + u_status _UCIAPI uci_Close(u_session _session); + + //@brief : һβӦĴ״̬Ϣ + //@return u_cstring : + //@remarks : + u_cstring _UCIAPI uci_GetLastError(void); + + void _UCIAPI uci_ExInstance(); +#ifdef __cplusplus +} + +} +#endif +#endif // uci_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.lib b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.lib new file mode 100644 index 0000000..7d8bbbd Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/uci.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucicpp.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucicpp.cpp new file mode 100644 index 0000000..e062ac8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucicpp.cpp @@ -0,0 +1,22 @@ +#include "stdafx.h" +#include "ucicpp.h" + +u_status uci::UCISession::Write(int _timeout, const void* _data, + u_uint32 _data_len, const u_tchar *format, ...) { + va_list argptr; + va_start(argptr, format); + u_tchar msg[256]; + _vstprintf_s(msg, sizeof(msg) / sizeof(msg[0]), format, argptr); + va_end(argptr); + + return uci_WriteX(m_session, msg, _timeout, (const u_byte*)_data, _data_len); +} + +u_status uci::UCISession::Read(u_uint32 _timeout, u_byte* _data, u_size _dataLen, u_cstring format, ...) { + va_list argptr; + va_start(argptr, format); + u_tchar msg[256]; + _vstprintf_s(msg, sizeof(msg) / sizeof(msg[0]), format, argptr); + va_end(argptr); + return uci_ReadX(m_session, msg, _timeout, _data, _dataLen); +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucicpp.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucicpp.h new file mode 100644 index 0000000..8025b67 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucicpp.h @@ -0,0 +1,34 @@ +/*! + * \created : 2016/11/9 + * \author : M.Yang + * \purpose : ṩUCIC++ӿ + */ +#ifndef ucicpp_h__ +#define ucicpp_h__ + +#include "lib\uci.h" + +namespace uci { + class UCISession; +} +class uci::UCISession { +public: + UCISession() : m_session(INVALID_SESSION){} + virtual ~UCISession() {} + + u_status Open(u_cstring _addr, u_uint32 _timeOut = 2000) { + auto r = uci_OpenX(_addr, 1000); + if (UCISUCCESS(r)) + m_session = (u_session)r; + return r; + } + + u_status Write(int _timeout, const void* _data, + u_uint32 _data_len, const u_tchar *format, ...); + + u_status Read(u_uint32 _timeout, u_byte* _data, u_size _dataLen, u_cstring format, ...); +private: + u_session m_session; +}; + +#endif // ucicpp_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucidef.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucidef.h new file mode 100644 index 0000000..5da7c68 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/lib/ucidef.h @@ -0,0 +1,561 @@ +/******************************************************************** + created: 2014/12/23 + author: M.Yang + purpose: UCIȫֶļ + modify: + *********************************************************************/ +#ifndef ucidef_h__ +#define ucidef_h__ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +#define _UCIAPI __stdcall +#define _UCICallBack __stdcall +#endif + +#define _in +#define _out +#define _in_out + +#ifdef __cplusplus +namespace uci { +#endif // __cplusplus + +#ifdef _CVI_ +#define u_inline static +#else +#define u_inline inline +#endif // _CVI_ + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif // !MAX_PATH + + ////////////////////////////////////////////////////////////////////////// + //{ Ͷ +#ifdef _UNICODE + //@brief : ʾһ Unicode ַ +#define u_tchar wchar_t +#else + //@brief : ʾһ ASCII ַ +#define u_tchar char +#endif // _UNICODE + +#if defined(_WIN64) + typedef unsigned __int64 u_unit_ptr; + typedef __int64 u_long_ptr; +#else + typedef unsigned int u_unit_ptr; + typedef long u_long_ptr; +#endif + + //@brief : Boolean +#define u_bool bool + //@brief : 8λ޷ +#define u_byte unsigned char + //@brief : 8λз +#define u_char char + //@brief : ָ͵Ļָ +#define u_buf void* + //@brief : ͵ij +#define u_object void + //@brief : ʾ 16 λз +#define u_short short + //@brief : ʾ 16 λ޷ +#define u_ushort unsigned short + //@brief : ʾ 16 λз +#define u_int16 u_short + //@brief : ʾ 16 λ޷ +#define u_uint16 u_ushort + //@brief : ʾ 32 λз +#define u_int32 int + //@brief : ʾ 32 λ޷ +#define u_uint32 unsigned int + //@brief : ʾUCIӿڷص״ֵ̬(32λз) +#define u_status u_int32 + //@brief : ʾС32λ޷ +#define u_size u_uint32 + //@brief : ʾỰID32λ޷ +#define u_session u_uint32 + //@brief : ʾַ +#define u_string u_tchar* + //@brief : ʾַֻ +#define u_cstring const u_tchar* + //@brief : ʾIDͣ32λ޷ +#define u_attr u_int32 + //@brief : ʾֵͣ32λ޷ +#define u_attr_v u_int32 + //@brief : ʾһ16λ޷͵ĵ +#define u_word u_ushort + //@brief : ʾһ32λ޷͵˫ +#define u_dword u_uint32 + //@brief : Ϣ +#define u_wparam u_unit_ptr + //@brief : Ϣ +#define u_lparam u_long_ptr + //} + + ////////////////////////////////////////////////////////////////////////// + //{ ӿڷ״ֵ̬ + //@brief : ɹ +#define UCI_SUCCESS (0) + //@brief : ʼֵ +#define UCI_ERR (-1000) + //@brief : жϵǰӿǷִʧ + //@brief : жϵǰӿǷִгɹ +#define UCIERR(r) (r < 0) +#define UCISUCCESS(r) (!UCIERR(r)) + + //@brief : + typedef enum _UCIErr { + NoError = 0, + + //@brief : Դʼ + InitResourceError = UCI_ERR - 20, + //@brief : ЧĻỰ + Invalid_Session, + //@brief : ʱ + Timeout, + //@brief : ʧ + Failed, + //@brief : ֵ֧IJ + Unsupported, + //@brief : ڴռ䲻 + Insufficient_Memory, + //@brief : ϵͳæ޷Ӧ + Busy, + //@brief : ͨ쳣棡 + COMExpection, + //@brief : ͨδ򿪣 + ChannelNotOpened, + + //@brief : δ֪Ĵ + Unknown = UCI_ERR - 40 - 1, + + //@brief : ӵַַʽ + Connect_InvalidAddress = UCI_ERR - 40, + //@brief : ӻδ + Connect_NotBuild, + //@brief : ѶϿ + Connect_Break, + //@brief : ֵ֧ͨŷʽ + Connect_Unsupported_COMType, + + //@brief : δָ豸 + Device_NoFound = UCI_ERR - 60, + //@brief : ֵ֧豸 + Device_Unsupported, + //@brief : Ҫִвѯ豸IJ + Device_QueryFirst, + //@brief : Ͳƥ + Device_NotMatch, + + //@brief : ѯ豸ʧ + Query_LANNodesFailed, + + //@brief : USB豸ִַֻвѯ豸Ч + //@remarks : UCI⵼USB豸ַֻһб豸ַ + AddrValid_AfterQueryDeviceOper, + + //@brief : δU̽ + UDisk_NotFound, + //@brief : Ѿ + Key_Locked, + + //@brief : ַʽ + CMD_Invalid_StringFormat = UCI_ERR - 80, + //@brief : ֵֻ֧ + CMD_OnlySupportSingle, + //@brief : һֻ֧һ + CMD_OnlySupportSingleAttr, + //@brief : ֵ֧ + CMD_Unsupported, + //@brief : ʧ + CMD_SendFailed, + //@brief : Эݸʽ + CMD_Invalid_ProtocolFormat, + //@brief : 豸дļflashʧܣ + CMD_WriteFileToFlash_Failed, + //@brief : δЧĻظ + CMD_NoFound_Valid_Reply_Data, + //@brief : Ϣ鿴ǷЭ + CMD_Error_Message, + //@brief : Чıʽ + CMD_Invalid_Expression, + + //@brief : + Args_Invalid = UCI_ERR - 100, + //@brief : ṩĿռ̫С + Args_MemoryTooSmall, + //@brief : ṩļ̫(50ֽ) + Args_FileNameTooLong, + //@brief : ݴСЭ鲻ƥ(ֹݴ) + Args_DataLenNotMatch, + + //@brief : + Data_Overflow = UCI_ERR - 120, + //@brief : Χ + Data_OutRange, + //@brief : δȫȡ + Data_NotReadEnoughLenth, + //@brief : Уʧ + Data_ECC_Failed, + //@brief : Ч + Data_Invalid, + //@brief : ѹʧ + Data_Zip_Error, + //@brief : ݽѹʧ + Data_UnZip_Error, + //@brief : ݴʧ + Data_Transfer_Error, + //@brief : ݴʧ + Data_Transfer_Break, + //@brief : Чݿɶȡ + Data_No_Data_Incoming, + + //@brief : + File_AccessDenied = UCI_ERR - 140, + //@brief : An unspecified error occurred. + File_GenericException, + //@brief : The file could not be located. + File_NotFound, + //@brief : All or part of the path is invalid. + File_BadPath, + //@brief : The permitted number of open files was exceeded. + File_TooManyOpenFiles, + //@brief : There was an attempt to use an invalid file handle + // or The file format is unsupported! + // or The file data is error! + File_InvalidFile, + //@brief : The current working directory cannot be removed + File_RemoveCurrentDir, + //@brief : There are no more directory entries + File_DirectoryFull, + //@brief : There was an error trying to set the file pointer + File_BadSeek, + //@brief : There was a hardware error + File_HardIO, + //@brief : SHARE.EXE was not loaded, or a shared region was locked + File_SharingViolation, + //@brief : There was an attempt to lock a region that was already locked + File_LockViolation, + //@brief : The disk is full + File_DiskFull, + //@brief : The end of file was reached + File_EndOfFile, + //@brief : дļʧ + File_SaveToDiskFailed, + }UErr; + //} + ////////////////////////////////////////////////////////////////////////// + + //@brief : ĻỰID +#define INVALID_SESSION ((u_uint32)(-1)) + + ////////////////////////////////////////////////////////////////////////// + //{ + //лӢģ "lang:zh-hans" or "lang:en-us" + //ʹUSB豸ƳӼ "devchange:1" +//} + + +#define CACHE_LINE 1 +#define CACHE_ALIGN __declspec(align(CACHE_LINE)) + + //@brief : ýṹĶ뷽ʽ +#define PACK_ALIGN(n) __declspec(align(n)) + + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + + //one Word is 2 bytes + u_inline u_word UCI_HIWORD(u_dword _dw) { return ((u_word)((_dw >> 16) & 0xffff)); } + u_inline u_word UCI_LOWORD(u_dword _dw) { return ((u_word)(_dw & 0xffff)); } + + //#pragma pack(show)// C4810 + //ensure byte-packed structures1ֽڶ룩 +#include //뻷ûиļ滻Ϊǰƽֽ̨ڶ䡣 + + //@brief : ݽӿڵIJ + //@remarks : ͨͨuci_CreateRParamsӿڴ + typedef struct _RParams { + //@brief : ַ'\0'β. ʽЭĵ + u_cstring CMDString; + //@brief : ҪصӾͨҪȡ\ѯǶӦģ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + //@brief : + //@remarks : ͨʹãɿ;ڲѯ豸ʱõ + //ΪQParamsĵΪ׼ + u_buf ExtraData; //reserve + //@brief : ݵij + u_size ExtraDataLen; + }RParams, *PRParams; + +#ifdef __cplusplus + inline RParams* uci_CreateRParams(RParams& _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + _p.ExtraData = _ExtraData; + _p.ExtraDataLen = _ExtraDataLen; + return &_p; + } +#else + u_inline RParams* uci_CreateRParams(RParams* _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + _p->ExtraData = _ExtraData; + _p->ExtraDataLen = _ExtraDataLen; + return _p; + } +#endif + + typedef struct _DeviceIOParams { + u_int32 Count; + u_int32* Data; + }DeviceIOParams; + + typedef struct _QParams { + //@brief : ҪѯͨŽڵ + //@remarks : enum NodeType ȡֵ ͨ־λֵ + //@eg NodeType::USB | NodeType::LAN + u_int32 Type; + //@brief : ˿ڼ˿ + u_int32 PortCount; + //@brief : ˿ڼ + u_int32* Ports; + //@brief : PVIDPVIDĸ + //@remarks : + u_int32 PVIDCount; + //@brief : PID VID + //@remarks : ʹMakePVIDGetPIDGetVIDȡ + u_int32* PVID; + //@brief : ѯַnullptrʱʾѯ豸ѯָ豸豸 + u_cstring Msg; + }QParams, *PQParams;//@brief : ѯ豸ʱò + + u_inline u_int32 MakePVID(u_ushort _pid, u_ushort _vid) { return ((_pid << 16) | (_vid)); }; + + u_inline u_ushort GetPID(u_int32 _pvid) { return UCI_HIWORD(_pvid); } + + u_inline u_ushort GetVID(u_int32 _pvid) { return UCI_LOWORD(_pvid); } + +#ifdef __cplusplus + inline QParams* UCI_CreateQParam(QParams& _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(&_qp, 0, sizeof(_qp)); + _qp.Type = _type; + _qp.Ports = _ports; + _qp.PortCount = _port_cnt; + _qp.PVID = _pvid; + _qp.PVIDCount = _pvid_cnt; + _qp.Msg = _msg; + return &_qp; + } +#else + u_inline QParams* UCI_CreateQParam(QParams* _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(_qp, 0, sizeof(*_qp)); + _qp->Type = _type; + _qp->Ports = _ports; + _qp->PortCount = _port_cnt; + _qp->PVID = _pvid; + _qp->PVIDCount = _pvid_cnt; + _qp->Msg = _msg; + return _qp; + } +#endif + //@brief : дݽӿڲ + //@remarks : ͨӿuci_CreateWParams + typedef struct _WParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : صݣӾ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + }WParams, *PWParams; + +#ifdef __cplusplus + u_inline WParams* uci_CreateWParams(WParams& _p, u_cstring _cmd, u_uint32 _timeout) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + return &_p; + } +#else + u_inline WParams* uci_CreateWParams(WParams* _p, u_cstring _cmd, u_uint32 _timeout) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + return _p; + } +#endif + typedef struct _CommandParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : 1 + u_uint32 Param1; + //@brief : 1 + u_uint32 Param2; + //@brief : ʱ + u_uint32 Timeout; + }CommandParams, *PCommandParams; + + //@brief : дļIJ + typedef struct _WFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : Ҫдļ·ļ + u_cstring FilePath; + //@brief : дʱ(λms) + u_uint32 Timeout; + }WFileParams, *PWFileParams; + + //@brief : ļӿڵIJ + typedef struct _RFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : ݵش̵ļ·ļͺ׺ + u_cstring FilePath; + //@brief : ʱ(λms) + u_uint32 Timeout; + //@brief : ļ· + u_tchar FilePathFinal[MAX_PATH]; + }RFileParams, *PRFileParams; + + //@brief : ͨŽڵ + //@remarks : QParamsǰλ룬Nodeȡenumֵ + typedef enum _NodeType{ + LAN = 0x0001, + USB = 0x0010, + }NodeType; + + //@brief : USB豸 + //@remarks : + typedef struct _USBDescriptor { + //@brief : PID + u_ushort PID; + //@brief : VID + u_ushort VID; + //@brief : ַ + u_ushort Addr; + }USBDescriptor; + + //@brief : IPַ + //@remarks : ˳Ϊ f1(192).f2(168).f3(1).f4(253) - Сģʽ + typedef union _IPAddr { + struct { u_byte f1, f2, f3, f4; } Field; + u_int32 Addr; + }u_IPAddr; + + //@brief : LANͨŵ豸 + //@remarks : + typedef struct _LANDescriptor { + //@brief : IPַַͣ + u_tchar IP[16]; + //@brief : IPַ + u_IPAddr Addr; + //@brief : ˿ + //@remarks : TCPIPõĶ˿ں + u_ushort Port; + }LANDescriptor; + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _Node { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµƣ + // ѳδͳһʱUCIڲԶƥΪUCIЭõ֣ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }Node, *PNode; + + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _NodeEx { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµơ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }NodeEx, *PNodeEx; + + typedef struct _UCIMSG { + u_session Session; + u_uint32 Message; + u_wparam wParams; + u_lparam lParams; + u_byte Reserved[240]; + }UCIMSG;//256Bytes + + ////////////////////////////////////////////////////////////////////////// + typedef enum _uci_msg { + UMSG_CONNECT_CLOSED = 1, + //@brief : ļϢ + //@remarks : + // wParams ֡ + // lParams ֡ -1 ʼ䣻 [0,wParams)У wParams + //-> UCIMSGProc return -1 ʾжϴ. + UMSG_FILE_TRANSFER = 2, + //@brief : USBϢ + //@remarks : + // wParams : ʹõ16λУ8λΪpid8λΪvid + // lParams : ¼ͣ Ƴ = 0 = 1 + UMSG_DEVICE_NOTIFY = 3, + }EUCIMSG; + + typedef int(__stdcall *UCIMSGProc)(UCIMSG* _msg); +#include + +#ifdef __cplusplus + } +#endif//__cplusplus + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ucidef_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/stdafx.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/stdafx.cpp new file mode 100644 index 0000000..2b1d533 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ֻ׼ļԴļ +// UTP3000C_Test.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + +// TODO: STDAFX.H +// κĸͷļڴļ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/stdafx.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/stdafx.h new file mode 100644 index 0000000..4417a67 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/stdafx.h @@ -0,0 +1,37 @@ +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ +// + +#pragma once + +#include "targetver.h" + +#include +#include +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ +#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS // ƳԻе MFC ؼ֧ + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Windows ͷļųʹõϢ +#endif + +#include +#include // MFC ͱ׼ +#include // MFC չ +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC Internet Explorer 4 ؼ֧ +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC Windows ؼ֧ +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include + + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +#include +#include + +// TODO: ڴ˴óҪͷļ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/targetver.h b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/targetver.h new file mode 100644 index 0000000..7a7d2c8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/VC/UTP3000C_Test/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h õ߰汾 Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/UCI/说明.txt b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/说明.txt new file mode 100644 index 0000000..ae5c5b7 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/UCI/说明.txt @@ -0,0 +1,26 @@ +C# + C#ƽ̨ʾ +VC\UCIDEMO\UCI_DEMO.exe + Դ빤UCIDemoProjıij + óUCIͨŽӿڵʾͲԳ ԶĵָͲĽӿӡ + +VC\SimpleUCI + Ǽ򵥵UCIӿڵʾ̣ʾCӿںC++ֽӿʹá + +VB\UCIDemoVBProj.zip + Ǽ򵥵VBӿʹõʾ̡ + +CVI + ʹCVIʾ + +UCI-Labview11.0 + LabViewƽ̨µʾ + +LabView-UCI + ǽµLabViewƽ̨µʹýӿںʾ + +Ҫѡʵƽ̨жο + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/App.ico b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/App.ico new file mode 100644 index 0000000..403417b Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/App.ico differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/AssemblyInfo.cs b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/MainForm.cs b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/MainForm.cs new file mode 100644 index 0000000..c869010 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/MainForm.cs @@ -0,0 +1,331 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using NationalInstruments.VisaNS; + +namespace NationalInstruments.Examples.SimpleReadWrite +{ + /// + /// Summary description for Form1. + /// + public class MainForm : System.Windows.Forms.Form + { + private MessageBasedSession mbSession; + private string lastResourceString = null; + private System.Windows.Forms.TextBox writeTextBox; + private System.Windows.Forms.TextBox readTextBox; + private System.Windows.Forms.Button queryButton; + private System.Windows.Forms.Button writeButton; + private System.Windows.Forms.Button readButton; + private System.Windows.Forms.Button openSessionButton; + private System.Windows.Forms.Button clearButton; + private System.Windows.Forms.Button closeSessionButton; + private System.Windows.Forms.Label stringToWriteLabel; + private System.Windows.Forms.Label stringToReadLabel; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + public MainForm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + SetupControlState(false); + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(mbSession != null) + { + mbSession.Dispose(); + } + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.queryButton = new System.Windows.Forms.Button(); + this.writeButton = new System.Windows.Forms.Button(); + this.readButton = new System.Windows.Forms.Button(); + this.openSessionButton = new System.Windows.Forms.Button(); + this.writeTextBox = new System.Windows.Forms.TextBox(); + this.readTextBox = new System.Windows.Forms.TextBox(); + this.clearButton = new System.Windows.Forms.Button(); + this.closeSessionButton = new System.Windows.Forms.Button(); + this.stringToWriteLabel = new System.Windows.Forms.Label(); + this.stringToReadLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // queryButton + // + this.queryButton.Location = new System.Drawing.Point(6, 89); + this.queryButton.Name = "queryButton"; + this.queryButton.Size = new System.Drawing.Size(89, 25); + this.queryButton.TabIndex = 3; + this.queryButton.Text = "Query"; + this.queryButton.Click += new System.EventHandler(this.query_Click); + // + // writeButton + // + this.writeButton.Location = new System.Drawing.Point(95, 89); + this.writeButton.Name = "writeButton"; + this.writeButton.Size = new System.Drawing.Size(89, 25); + this.writeButton.TabIndex = 4; + this.writeButton.Text = "Write"; + this.writeButton.Click += new System.EventHandler(this.write_Click); + // + // readButton + // + this.readButton.Location = new System.Drawing.Point(184, 89); + this.readButton.Name = "readButton"; + this.readButton.Size = new System.Drawing.Size(88, 25); + this.readButton.TabIndex = 5; + this.readButton.Text = "Read"; + this.readButton.Click += new System.EventHandler(this.read_Click); + // + // openSessionButton + // + this.openSessionButton.Location = new System.Drawing.Point(6, 5); + this.openSessionButton.Name = "openSessionButton"; + this.openSessionButton.Size = new System.Drawing.Size(110, 24); + this.openSessionButton.TabIndex = 0; + this.openSessionButton.Text = "Open Session"; + this.openSessionButton.Click += new System.EventHandler(this.openSession_Click); + // + // writeTextBox + // + this.writeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.writeTextBox.Location = new System.Drawing.Point(6, 58); + this.writeTextBox.Name = "writeTextBox"; + this.writeTextBox.Size = new System.Drawing.Size(324, 21); + this.writeTextBox.TabIndex = 2; + this.writeTextBox.Text = "*IDN?\\n"; + // + // readTextBox + // + this.readTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.readTextBox.Location = new System.Drawing.Point(6, 146); + this.readTextBox.Multiline = true; + this.readTextBox.Name = "readTextBox"; + this.readTextBox.ReadOnly = true; + this.readTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.readTextBox.Size = new System.Drawing.Size(324, 119); + this.readTextBox.TabIndex = 6; + this.readTextBox.TabStop = false; + // + // clearButton + // + this.clearButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.clearButton.Location = new System.Drawing.Point(7, 267); + this.clearButton.Name = "clearButton"; + this.clearButton.Size = new System.Drawing.Size(324, 26); + this.clearButton.TabIndex = 7; + this.clearButton.Text = "Clear"; + this.clearButton.Click += new System.EventHandler(this.clear_Click); + // + // closeSessionButton + // + this.closeSessionButton.Location = new System.Drawing.Point(116, 5); + this.closeSessionButton.Name = "closeSessionButton"; + this.closeSessionButton.Size = new System.Drawing.Size(111, 24); + this.closeSessionButton.TabIndex = 1; + this.closeSessionButton.Text = "Close Session"; + this.closeSessionButton.Click += new System.EventHandler(this.closeSession_Click); + // + // stringToWriteLabel + // + this.stringToWriteLabel.Location = new System.Drawing.Point(6, 37); + this.stringToWriteLabel.Name = "stringToWriteLabel"; + this.stringToWriteLabel.Size = new System.Drawing.Size(109, 15); + this.stringToWriteLabel.TabIndex = 8; + this.stringToWriteLabel.Text = "String to Write:"; + // + // stringToReadLabel + // + this.stringToReadLabel.Location = new System.Drawing.Point(6, 126); + this.stringToReadLabel.Name = "stringToReadLabel"; + this.stringToReadLabel.Size = new System.Drawing.Size(121, 16); + this.stringToReadLabel.TabIndex = 9; + this.stringToReadLabel.Text = "String to Read:"; + // + // MainForm + // + this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); + this.ClientSize = new System.Drawing.Size(338, 301); + this.Controls.Add(this.stringToReadLabel); + this.Controls.Add(this.stringToWriteLabel); + this.Controls.Add(this.closeSessionButton); + this.Controls.Add(this.clearButton); + this.Controls.Add(this.readTextBox); + this.Controls.Add(this.writeTextBox); + this.Controls.Add(this.openSessionButton); + this.Controls.Add(this.readButton); + this.Controls.Add(this.writeButton); + this.Controls.Add(this.queryButton); + this.MaximizeBox = false; + this.MinimumSize = new System.Drawing.Size(354, 340); + this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Simple Read/Write"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + #endregion + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.Run(new MainForm()); + } + + private void openSession_Click(object sender, System.EventArgs e) + { + using (SelectResource sr = new SelectResource()) + { + if(lastResourceString != null) + { + sr.ResourceName = lastResourceString; + } + DialogResult result = sr.ShowDialog(this); + if(result == DialogResult.OK) + { + lastResourceString = sr.ResourceName; + Cursor.Current = Cursors.WaitCursor; + try + { + mbSession = (MessageBasedSession)ResourceManager.GetLocalManager().Open(sr.ResourceName); + SetupControlState(true); + } + catch(InvalidCastException) + { + MessageBox.Show("Resource selected must be a message-based session"); + } + catch(Exception exp) + { + MessageBox.Show(exp.Message); + } + finally + { + Cursor.Current = Cursors.Default; + } + } + } + } + + private void closeSession_Click(object sender, System.EventArgs e) + { + SetupControlState(false); + mbSession.Dispose(); + } + + private void query_Click(object sender, System.EventArgs e) + { + Cursor.Current = Cursors.WaitCursor; + try + { + string textToWrite = ReplaceCommonEscapeSequences(writeTextBox.Text); + string responseString = mbSession.Query(textToWrite); + readTextBox.Text = InsertCommonEscapeSequences(responseString); + } + catch(Exception exp) + { + MessageBox.Show(exp.Message); + } + finally + { + Cursor.Current = Cursors.Default; + } + } + + private void write_Click(object sender, System.EventArgs e) + { + try + { + string textToWrite = ReplaceCommonEscapeSequences(writeTextBox.Text); + mbSession.Write(textToWrite); + } + catch(Exception exp) + { + MessageBox.Show(exp.Message); + } + } + + private void read_Click(object sender, System.EventArgs e) + { + Cursor.Current = Cursors.WaitCursor; + try + { + string responseString = mbSession.ReadString(); + readTextBox.Text = InsertCommonEscapeSequences(responseString); + } + catch(Exception exp) + { + MessageBox.Show(exp.Message); + } + finally + { + Cursor.Current = Cursors.Default; + } + } + + private void clear_Click(object sender, System.EventArgs e) + { + readTextBox.Text = String.Empty; + } + + private void SetupControlState(bool isSessionOpen) + { + openSessionButton.Enabled = !isSessionOpen; + closeSessionButton.Enabled = isSessionOpen; + queryButton.Enabled = isSessionOpen; + writeButton.Enabled = isSessionOpen; + readButton.Enabled = isSessionOpen; + writeTextBox.Enabled = isSessionOpen; + clearButton.Enabled = isSessionOpen; + if(isSessionOpen) + { + readTextBox.Text = String.Empty; + writeTextBox.Focus(); + } + } + + private string ReplaceCommonEscapeSequences(string s) + { + return s.Replace("\\n", "\n").Replace("\\r", "\r"); + } + + private string InsertCommonEscapeSequences(string s) + { + return s.Replace("\n", "\\n").Replace("\r", "\\r"); + } + } +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/MainForm.resx b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/MainForm.resx new file mode 100644 index 0000000..513f0b8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/MainForm.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SelectResource.cs b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SelectResource.cs new file mode 100644 index 0000000..4a18ddf --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SelectResource.cs @@ -0,0 +1,175 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using NationalInstruments.VisaNS; + +namespace NationalInstruments.Examples.SimpleReadWrite +{ + public class SelectResource : System.Windows.Forms.Form + { + private System.Windows.Forms.ListBox availableResourcesListBox; + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button closeButton; + private System.Windows.Forms.TextBox visaResourceNameTextBox; + private System.Windows.Forms.Label AvailableResourcesLabel; + private System.Windows.Forms.Label ResourceStringLabel; + + + private System.ComponentModel.Container components = null; + + public SelectResource() + { + + InitializeComponent(); + } + + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + private void InitializeComponent() + { + this.availableResourcesListBox = new System.Windows.Forms.ListBox(); + this.okButton = new System.Windows.Forms.Button(); + this.closeButton = new System.Windows.Forms.Button(); + this.visaResourceNameTextBox = new System.Windows.Forms.TextBox(); + this.AvailableResourcesLabel = new System.Windows.Forms.Label(); + this.ResourceStringLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // availableResourcesListBox + // + this.availableResourcesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.availableResourcesListBox.ItemHeight = 12; + this.availableResourcesListBox.Location = new System.Drawing.Point(6, 19); + this.availableResourcesListBox.Name = "availableResourcesListBox"; + this.availableResourcesListBox.Size = new System.Drawing.Size(280, 88); + this.availableResourcesListBox.TabIndex = 0; + this.availableResourcesListBox.SelectedIndexChanged += new System.EventHandler(this.availableResourcesListBox_SelectedIndexChanged); + this.availableResourcesListBox.DoubleClick += new System.EventHandler(this.availableResourcesListBox_DoubleClick); + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(6, 191); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(92, 27); + this.okButton.TabIndex = 2; + this.okButton.Text = "OK"; + // + // closeButton + // + this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.closeButton.Location = new System.Drawing.Point(98, 191); + this.closeButton.Name = "closeButton"; + this.closeButton.Size = new System.Drawing.Size(93, 27); + this.closeButton.TabIndex = 3; + this.closeButton.Text = "Cancel"; + // + // visaResourceNameTextBox + // + this.visaResourceNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.visaResourceNameTextBox.Location = new System.Drawing.Point(6, 159); + this.visaResourceNameTextBox.Name = "visaResourceNameTextBox"; + this.visaResourceNameTextBox.Size = new System.Drawing.Size(280, 21); + this.visaResourceNameTextBox.TabIndex = 4; + this.visaResourceNameTextBox.Text = "GPIB0::2::INSTR"; + // + // AvailableResourcesLabel + // + this.AvailableResourcesLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.AvailableResourcesLabel.Location = new System.Drawing.Point(6, 5); + this.AvailableResourcesLabel.Name = "AvailableResourcesLabel"; + this.AvailableResourcesLabel.Size = new System.Drawing.Size(277, 13); + this.AvailableResourcesLabel.TabIndex = 5; + this.AvailableResourcesLabel.Text = "Available Resources:"; + // + // ResourceStringLabel + // + this.ResourceStringLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.ResourceStringLabel.Location = new System.Drawing.Point(6, 142); + this.ResourceStringLabel.Name = "ResourceStringLabel"; + this.ResourceStringLabel.Size = new System.Drawing.Size(277, 14); + this.ResourceStringLabel.TabIndex = 6; + this.ResourceStringLabel.Text = "Resource String:"; + // + // SelectResource + // + this.AcceptButton = this.okButton; + this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); + this.CancelButton = this.closeButton; + this.ClientSize = new System.Drawing.Size(292, 227); + this.Controls.Add(this.ResourceStringLabel); + this.Controls.Add(this.AvailableResourcesLabel); + this.Controls.Add(this.visaResourceNameTextBox); + this.Controls.Add(this.closeButton); + this.Controls.Add(this.okButton); + this.Controls.Add(this.availableResourcesListBox); + this.KeyPreview = true; + this.MaximizeBox = false; + this.MinimumSize = new System.Drawing.Size(212, 266); + this.Name = "SelectResource"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Select Resource"; + this.Load += new System.EventHandler(this.OnLoad); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + + private void OnLoad(object sender, System.EventArgs e) + { + string[] resources = ResourceManager.GetLocalManager().FindResources("?*"); + foreach(string s in resources) + { + availableResourcesListBox.Items.Add(s); + } + availableResourcesListBox.Items.Add("TCPIP[board]::host address[::LAN device name][::INSTR]"); + availableResourcesListBox.Items.Add("TCPIP[board]::host address::port::SOCKET"); + } + + private void availableResourcesListBox_DoubleClick(object sender, System.EventArgs e) + { + string selectedString = (string)availableResourcesListBox.SelectedItem; + ResourceName = selectedString; + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void availableResourcesListBox_SelectedIndexChanged(object sender, System.EventArgs e) + { + string selectedString = (string)availableResourcesListBox.SelectedItem; + ResourceName = selectedString; + } + + public string ResourceName + { + get + { + return visaResourceNameTextBox.Text; + } + set + { + visaResourceNameTextBox.Text = value; + } + } + } +} diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SelectResource.resx b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SelectResource.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SelectResource.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SimpleReadWrite.2013.csproj b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SimpleReadWrite.2013.csproj new file mode 100644 index 0000000..45ef2ff --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SimpleReadWrite.2013.csproj @@ -0,0 +1,132 @@ + + + + Local + 12.0.21005.1 RTMREL + 2.0 + {B8E8C039-E317-4A83-94BA-BC85DA03F880} + Debug + AnyCPU + + + + + SimpleReadWrite + + + JScript + Grid + IE50 + false + WinExe + NationalInstruments.Examples.SimpleReadWrite + OnBuildSuccess + + + + + v4.5.1 + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE;NETFX3_5;NETFX2_0;NETFX4_0;NETFX4_5_1 + + + true + 4096 + false + + + false + false + false + false + 4 + AnyCPU + false + + + bin\Release\ + false + 285212672 + false + + + TRACE;NETFX3_5;NETFX2_0;NETFX4_0;NETFX4_5_1 + + + false + 4096 + false + + + true + false + false + false + 4 + AnyCPU + false + + + + NationalInstruments.Common + + + + NationalInstruments.VisaNS + ..\..\..\..\..\..\Program Files\National Instruments\MeasurementStudio\DotNET\Assemblies\Current\NationalInstruments.VisaNS.dll + + + System + + + + System.Data + + + + System.Drawing + + + + System.Windows.Forms + + + + System.Xml + + + + + + + Code + + + Form + + + Form + + + MainForm.cs + + + SelectResource.cs + + + + + + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SimpleReadWrite.2013.sln b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SimpleReadWrite.2013.sln new file mode 100644 index 0000000..6bd6a86 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/cs/SimpleReadWrite.2013.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleReadWrite", "SimpleReadWrite.2013.csproj", "{B8E8C039-E317-4A83-94BA-BC85DA03F880}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B8E8C039-E317-4A83-94BA-BC85DA03F880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8E8C039-E317-4A83-94BA-BC85DA03F880}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8E8C039-E317-4A83-94BA-BC85DA03F880}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8E8C039-E317-4A83-94BA-BC85DA03F880}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview/SimpleReadWrite.vi b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview/SimpleReadWrite.vi new file mode 100644 index 0000000..d256968 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview/SimpleReadWrite.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/ReadVamp.vi b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/ReadVamp.vi new file mode 100644 index 0000000..c8b169f Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/ReadVamp.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/ReadWave.vi b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/ReadWave.vi new file mode 100644 index 0000000..62b7460 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/ReadWave.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetChannel.vi b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetChannel.vi new file mode 100644 index 0000000..3b812c5 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetChannel.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetReadTrigger.vi b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetReadTrigger.vi new file mode 100644 index 0000000..86610e7 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetReadTrigger.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetTimeBase.vi b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetTimeBase.vi new file mode 100644 index 0000000..f1b2faa Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SetTimeBase.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SimpleReadWrite.vi b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SimpleReadWrite.vi new file mode 100644 index 0000000..a5c938a Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/Example/SimpleReadWrite.vi differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.aliases b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.aliases new file mode 100644 index 0000000..e9d47d3 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.aliases @@ -0,0 +1,3 @@ +[ҵĵ] +ҵĵ = "192.168.243.1" + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.lvlps b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.lvlps new file mode 100644 index 0000000..b27cd21 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.lvlps @@ -0,0 +1,3 @@ +[Ŀ(_D)] +ProjectExplorer.ClassicPosition[String] = "326,689,703,1151" + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.lvproj b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.lvproj new file mode 100644 index 0000000..f30ba78 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/labview2/UNI-T.lvproj @@ -0,0 +1,24 @@ + + + + true + true + false + 0 + 我的电脑/VI服务器 + 我的电脑/VI服务器 + true + true + false + + + + + + + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/readme.txt b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/readme.txt new file mode 100644 index 0000000..6a60198 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/readme.txt @@ -0,0 +1,2 @@ +1ֻUPO3000CS֧VISAӿڣһɲοuciӿͨѶ +2ʾʹVISAͨѶҪװNI-VISA5.4ûаװNI-VISAȵNIվ(http://www.ni.com/china)ءֻ֧UPO3000CS豸IJҡ򿪡д \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/App.ico b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/App.ico new file mode 100644 index 0000000..403417b Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/App.ico differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/AssemblyInfo.vb b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/AssemblyInfo.vb new file mode 100644 index 0000000..b3ef74a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/MainForm.resx b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/MainForm.resx new file mode 100644 index 0000000..513f0b8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/MainForm.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/MainForm.vb b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/MainForm.vb new file mode 100644 index 0000000..ce899f2 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/MainForm.vb @@ -0,0 +1,265 @@ +Imports NationalInstruments.VisaNS + +Public Class MainForm + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + InitializeComponent() + End Sub + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + Private components As System.ComponentModel.IContainer + Private mbSession As MessageBasedSession + Private lastResourceString As String = Nothing + Private WithEvents writeTextBox As System.Windows.Forms.TextBox + Private WithEvents readTextBox As System.Windows.Forms.TextBox + + Private WithEvents queryButton As System.Windows.Forms.Button + Private WithEvents writeButton As System.Windows.Forms.Button + Private WithEvents readButton As System.Windows.Forms.Button + Private WithEvents openSessionButton As System.Windows.Forms.Button + Private WithEvents clearButton As System.Windows.Forms.Button + Private WithEvents closeSessionButton As System.Windows.Forms.Button + Private WithEvents stringToWriteLabel As System.Windows.Forms.Label + Private WithEvents stringToReadLabel As System.Windows.Forms.Label + _ + Private Sub InitializeComponent() + Me.queryButton = New System.Windows.Forms.Button() + Me.writeButton = New System.Windows.Forms.Button() + Me.readButton = New System.Windows.Forms.Button() + Me.openSessionButton = New System.Windows.Forms.Button() + Me.writeTextBox = New System.Windows.Forms.TextBox() + Me.readTextBox = New System.Windows.Forms.TextBox() + Me.clearButton = New System.Windows.Forms.Button() + Me.closeSessionButton = New System.Windows.Forms.Button() + Me.stringToWriteLabel = New System.Windows.Forms.Label() + Me.stringToReadLabel = New System.Windows.Forms.Label() + Me.SuspendLayout() + ' + 'ѯ + ' + Me.queryButton.Enabled = False + Me.queryButton.Location = New System.Drawing.Point(6, 89) + Me.queryButton.Name = "queryButton" + Me.queryButton.Size = New System.Drawing.Size(89, 25) + Me.queryButton.TabIndex = 3 + Me.queryButton.Text = "Query" + ' + 'д + ' + Me.writeButton.Enabled = False + Me.writeButton.Location = New System.Drawing.Point(95, 89) + Me.writeButton.Name = "writeButton" + Me.writeButton.Size = New System.Drawing.Size(89, 25) + Me.writeButton.TabIndex = 4 + Me.writeButton.Text = "Write" + ' + ' + ' + Me.readButton.Enabled = False + Me.readButton.Location = New System.Drawing.Point(184, 89) + Me.readButton.Name = "readButton" + Me.readButton.Size = New System.Drawing.Size(88, 25) + Me.readButton.TabIndex = 5 + Me.readButton.Text = "Read" + ' + ' + ' + Me.openSessionButton.Location = New System.Drawing.Point(6, 5) + Me.openSessionButton.Name = "openSessionButton" + Me.openSessionButton.Size = New System.Drawing.Size(110, 24) + Me.openSessionButton.TabIndex = 0 + Me.openSessionButton.Text = "Open Session" + ' + 'дָ + ' + Me.writeTextBox.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.writeTextBox.Enabled = False + Me.writeTextBox.Location = New System.Drawing.Point(6, 58) + Me.writeTextBox.Name = "writeTextBox" + Me.writeTextBox.Size = New System.Drawing.Size(324, 21) + Me.writeTextBox.TabIndex = 2 + Me.writeTextBox.Text = "*IDN?\n" + ' + ' + ' + Me.readTextBox.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.readTextBox.Location = New System.Drawing.Point(6, 146) + Me.readTextBox.Multiline = True + Me.readTextBox.Name = "readTextBox" + Me.readTextBox.ReadOnly = True + Me.readTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.readTextBox.Size = New System.Drawing.Size(324, 119) + Me.readTextBox.TabIndex = 6 + Me.readTextBox.TabStop = False + ' + ' + ' + Me.clearButton.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.clearButton.Enabled = False + Me.clearButton.Location = New System.Drawing.Point(7, 267) + Me.clearButton.Name = "clearButton" + Me.clearButton.Size = New System.Drawing.Size(324, 26) + Me.clearButton.TabIndex = 7 + Me.clearButton.Text = "Clear" + ' + 'رԴ + ' + Me.closeSessionButton.Enabled = False + Me.closeSessionButton.Location = New System.Drawing.Point(116, 5) + Me.closeSessionButton.Name = "closeSessionButton" + Me.closeSessionButton.Size = New System.Drawing.Size(111, 24) + Me.closeSessionButton.TabIndex = 1 + Me.closeSessionButton.Text = "Close Session" + ' + 'д + ' + Me.stringToWriteLabel.Location = New System.Drawing.Point(6, 37) + Me.stringToWriteLabel.Name = "stringToWriteLabel" + Me.stringToWriteLabel.Size = New System.Drawing.Size(109, 15) + Me.stringToWriteLabel.TabIndex = 8 + Me.stringToWriteLabel.Text = "String to Write:" + ' + ' + ' + Me.stringToReadLabel.Location = New System.Drawing.Point(6, 126) + Me.stringToReadLabel.Name = "stringToReadLabel" + Me.stringToReadLabel.Size = New System.Drawing.Size(121, 16) + Me.stringToReadLabel.TabIndex = 9 + Me.stringToReadLabel.Text = "String to Read:" + ' + ' + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14) + Me.ClientSize = New System.Drawing.Size(338, 301) + Me.Controls.Add(Me.stringToReadLabel) + Me.Controls.Add(Me.stringToWriteLabel) + Me.Controls.Add(Me.closeSessionButton) + Me.Controls.Add(Me.clearButton) + Me.Controls.Add(Me.readTextBox) + Me.Controls.Add(Me.writeTextBox) + Me.Controls.Add(Me.openSessionButton) + Me.Controls.Add(Me.readButton) + Me.Controls.Add(Me.writeButton) + Me.Controls.Add(Me.queryButton) + Me.MaximizeBox = False + Me.MinimumSize = New System.Drawing.Size(354, 340) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Simple Read/Write" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + +#End Region + + _ + Public Shared Sub Main() + Application.Run(New MainForm) + End Sub + + + Private Sub openSession_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles openSessionButton.Click + Dim sr As SelectResource = New SelectResource + If lastResourceString <> Nothing Then + sr.ResourceName = lastResourceString + End If + Dim result As DialogResult = sr.ShowDialog(Me) + If result = Windows.Forms.DialogResult.OK Then + lastResourceString = sr.ResourceName + Windows.Forms.Cursor.Current = Cursors.WaitCursor + Try + mbSession = CType(ResourceManager.GetLocalManager().Open(sr.ResourceName), MessageBasedSession) + SetupControlState(True) + Catch exp As InvalidCastException + MessageBox.Show("Resource selected must be a message-based session") + Catch exp As Exception + MessageBox.Show(exp.Message) + Finally + Windows.Forms.Cursor.Current = Cursors.Default + End Try + End If + sr.Dispose() + End Sub + + Private Sub closeSession_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeSessionButton.Click + SetupControlState(False) + mbSession.Dispose() + End Sub + + Private Sub query_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles queryButton.Click + Windows.Forms.Cursor.Current = Cursors.WaitCursor + Try + Dim textToWrite As String = ReplaceCommonEscapeSequences(writeTextBox.Text) + Dim responseString As String = mbSession.Query(textToWrite) + readTextBox.Text = InsertCommonEscapeSequences(responseString) + Catch exp As Exception + MessageBox.Show(exp.Message) + Finally + Windows.Forms.Cursor.Current = Cursors.Default + End Try + End Sub + + Private Sub write_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles writeButton.Click + Try + Dim textToWrite As String = ReplaceCommonEscapeSequences(writeTextBox.Text) + mbSession.Write(textToWrite) + Catch exp As Exception + MessageBox.Show(exp.Message) + End Try + End Sub + + Private Sub read_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles readButton.Click + Windows.Forms.Cursor.Current = Cursors.WaitCursor + Try + Dim responseString As String = mbSession.ReadString() + readTextBox.Text = InsertCommonEscapeSequences(responseString) + Catch exp As Exception + MessageBox.Show(exp.Message) + Finally + Windows.Forms.Cursor.Current = Cursors.Default + End Try + End Sub + + Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click + readTextBox.Text = String.Empty + End Sub + + Private Sub SetupControlState(ByVal isSessionOpen As Boolean) + openSessionButton.Enabled = Not isSessionOpen + closeSessionButton.Enabled = isSessionOpen + queryButton.Enabled = isSessionOpen + writeButton.Enabled = isSessionOpen + readButton.Enabled = isSessionOpen + writeTextBox.Enabled = isSessionOpen + clearButton.Enabled = isSessionOpen + If isSessionOpen Then + readTextBox.Text = String.Empty + writeTextBox.Focus() + End If + End Sub + + Private Function ReplaceCommonEscapeSequences(ByVal s As String) As String + Return s.Replace("\n", vbLf).Replace("\r", vbCr) + End Function + + Private Function InsertCommonEscapeSequences(ByVal s As String) As String + Return s.Replace(vbLf, "\n").Replace(vbCr, "\r") + End Function + +End Class \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/My Project/app.manifest b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/My Project/app.manifest new file mode 100644 index 0000000..998c852 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/My Project/app.manifest @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SelectResource.resx b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SelectResource.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SelectResource.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SelectResource.vb b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SelectResource.vb new file mode 100644 index 0000000..2ffdaa4 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SelectResource.vb @@ -0,0 +1,169 @@ +Option Explicit On + +Imports NationalInstruments.VisaNS + +Public Class SelectResource + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + Private WithEvents availableResourcesListBox As System.Windows.Forms.ListBox + Private WithEvents okButton As System.Windows.Forms.Button + Private WithEvents closeButton As System.Windows.Forms.Button + Private WithEvents visaResourceNameTextBox As System.Windows.Forms.TextBox + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Private WithEvents AvailableResourcesLabel As System.Windows.Forms.Label + Private WithEvents ResourceStringLabel As System.Windows.Forms.Label + _ + Private Sub InitializeComponent() + Me.availableResourcesListBox = New System.Windows.Forms.ListBox() + Me.okButton = New System.Windows.Forms.Button() + Me.closeButton = New System.Windows.Forms.Button() + Me.visaResourceNameTextBox = New System.Windows.Forms.TextBox() + Me.AvailableResourcesLabel = New System.Windows.Forms.Label() + Me.ResourceStringLabel = New System.Windows.Forms.Label() + Me.SuspendLayout() + ' + 'availableResourcesListBox + ' + Me.availableResourcesListBox.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.availableResourcesListBox.ItemHeight = 12 + Me.availableResourcesListBox.Location = New System.Drawing.Point(6, 19) + Me.availableResourcesListBox.Name = "availableResourcesListBox" + Me.availableResourcesListBox.Size = New System.Drawing.Size(280, 88) + Me.availableResourcesListBox.TabIndex = 0 + ' + 'okButton + ' + Me.okButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.okButton.DialogResult = System.Windows.Forms.DialogResult.OK + Me.okButton.Location = New System.Drawing.Point(6, 191) + Me.okButton.Name = "okButton" + Me.okButton.Size = New System.Drawing.Size(92, 27) + Me.okButton.TabIndex = 2 + Me.okButton.Text = "OK" + ' + 'closeButton + ' + Me.closeButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.closeButton.Location = New System.Drawing.Point(98, 191) + Me.closeButton.Name = "closeButton" + Me.closeButton.Size = New System.Drawing.Size(93, 27) + Me.closeButton.TabIndex = 3 + Me.closeButton.Text = "Cancel" + ' + 'visaResourceNameTextBox + ' + Me.visaResourceNameTextBox.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.visaResourceNameTextBox.Location = New System.Drawing.Point(6, 159) + Me.visaResourceNameTextBox.Name = "visaResourceNameTextBox" + Me.visaResourceNameTextBox.Size = New System.Drawing.Size(280, 21) + Me.visaResourceNameTextBox.TabIndex = 4 + Me.visaResourceNameTextBox.Text = "GPIB0::2::INSTR" + ' + 'AvailableResourcesLabel + ' + Me.AvailableResourcesLabel.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.AvailableResourcesLabel.Location = New System.Drawing.Point(6, 5) + Me.AvailableResourcesLabel.Name = "AvailableResourcesLabel" + Me.AvailableResourcesLabel.Size = New System.Drawing.Size(277, 13) + Me.AvailableResourcesLabel.TabIndex = 5 + Me.AvailableResourcesLabel.Text = "Available Resources:" + ' + 'ResourceStringLabel + ' + Me.ResourceStringLabel.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ResourceStringLabel.Location = New System.Drawing.Point(6, 142) + Me.ResourceStringLabel.Name = "ResourceStringLabel" + Me.ResourceStringLabel.Size = New System.Drawing.Size(277, 14) + Me.ResourceStringLabel.TabIndex = 6 + Me.ResourceStringLabel.Text = "Resource String:" + ' + 'SelectResource + ' + Me.AcceptButton = Me.okButton + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14) + Me.CancelButton = Me.closeButton + Me.ClientSize = New System.Drawing.Size(292, 227) + Me.Controls.Add(Me.ResourceStringLabel) + Me.Controls.Add(Me.AvailableResourcesLabel) + Me.Controls.Add(Me.visaResourceNameTextBox) + Me.Controls.Add(Me.closeButton) + Me.Controls.Add(Me.okButton) + Me.Controls.Add(Me.availableResourcesListBox) + Me.KeyPreview = True + Me.MaximizeBox = False + Me.MinimumSize = New System.Drawing.Size(212, 266) + Me.Name = "SelectResource" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Text = "Select Resource" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + +#End Region + + Private Sub SelectResource_OnLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load + Dim resources() As String = ResourceManager.GetLocalManager().FindResources("?*") + Dim s As String + For Each s In resources + availableResourcesListBox.Items.Add(s) + Next + availableResourcesListBox.Items.Add("TCPIP[board]::host address[::LAN device name][::INSTR]") + availableResourcesListBox.Items.Add("TCPIP[board]::host address::port::SOCKET") + End Sub + + Private Sub availableResourcesListBox_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles availableResourcesListBox.DoubleClick + Dim selectedString As String = CType(availableResourcesListBox.SelectedItem, String) + ResourceName = selectedString + Me.DialogResult = Windows.Forms.DialogResult.OK + Me.Close() + End Sub + + Private Sub availableResourcesListBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles availableResourcesListBox.SelectedIndexChanged + Dim selectedString As String = CType(availableResourcesListBox.SelectedItem, String) + ResourceName = selectedString + End Sub + + Public Property ResourceName() As String + Get + Return visaResourceNameTextBox.Text + End Get + Set(ByVal Value As String) + visaResourceNameTextBox.Text = Value + End Set + End Property + +End Class \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SimpleReadWrite.2013.sln b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SimpleReadWrite.2013.sln new file mode 100644 index 0000000..40ef6f3 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SimpleReadWrite.2013.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SimpleReadWrite", "SimpleReadWrite.2013.vbproj", "{D8E64EC0-4CD2-4ACA-9A67-748F5BA579EF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D8E64EC0-4CD2-4ACA-9A67-748F5BA579EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8E64EC0-4CD2-4ACA-9A67-748F5BA579EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8E64EC0-4CD2-4ACA-9A67-748F5BA579EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8E64EC0-4CD2-4ACA-9A67-748F5BA579EF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SimpleReadWrite.2013.vbproj b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SimpleReadWrite.2013.vbproj new file mode 100644 index 0000000..b23bfb5 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vb/SimpleReadWrite.2013.vbproj @@ -0,0 +1,171 @@ + + + + Local + 12.0.21005.1 RTMREL + 2.0 + {D8E64EC0-4CD2-4ACA-9A67-748F5BA579EF} + Debug + AnyCPU + + + + + SimpleReadWrite + + + None + JScript + Grid + IE50 + false + WinExe + Binary + On + Off + NationalInstruments.Examples.SimpleReadWrite + NationalInstruments.Examples.SimpleReadWrite.MainForm + + + v4.5.1 + 发布\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + bin\ + 285212672 + + + NETFX2_0,NETFX3_5,NETFX4_0,NETFX4_5_1 + true + true + true + false + false + false + false + 1 + 42016,42017,42018,42019,42032 + AnyCPU + false + + + bin\ + 285212672 + + + NETFX2_0,NETFX3_5,NETFX4_0,NETFX4_5_1 + false + true + false + true + false + false + false + 1 + 42016,42017,42018,42019,42032 + AnyCPU + false + + + My Project\app.manifest + + + + NationalInstruments.Common + + + + NationalInstruments.VisaNS + C:\Program Files\National Instruments\MeasurementStudio\DotNET\Assemblies\Current\NationalInstruments.VisaNS.dll + + + System + + + + System.Data + + + + System.Drawing + + + + System.Windows.Forms + + + + System.Xml + + + + + + + + + + + + + + + + Code + + + Form + + + Form + + + MainForm.vb + + + SelectResource.vb + + + + + + False + Microsoft .NET Framework 4.5.1 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + + + + + + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013.sdf b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013.sdf new file mode 100644 index 0000000..86dea8e Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013.sdf differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013.sln b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013.sln new file mode 100644 index 0000000..8e52733 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleReadWrite.2013", "SimpleReadWrite.2013\SimpleReadWrite.2013.vcxproj", "{D087FC62-A5AF-4770-9CEF-40CAB4B558F1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D087FC62-A5AF-4770-9CEF-40CAB4B558F1}.Debug|Win32.ActiveCfg = Debug|Win32 + {D087FC62-A5AF-4770-9CEF-40CAB4B558F1}.Debug|Win32.Build.0 = Debug|Win32 + {D087FC62-A5AF-4770-9CEF-40CAB4B558F1}.Release|Win32.ActiveCfg = Release|Win32 + {D087FC62-A5AF-4770-9CEF-40CAB4B558F1}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/ReadMe.txt b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/ReadMe.txt new file mode 100644 index 0000000..f93ffc1 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/ReadMe.txt @@ -0,0 +1,67 @@ +================================================================================ + MICROSOFT 基础类库 : SimpleReadWrite.2013 项目概述 +=============================================================================== + +应用程序向导已为您创建了此 SimpleReadWrite.2013 应用程序。此应用程序不仅演示 Microsoft 基础类的基本使用方法,还可作为您编写应用程序的起点。 + +本文件概要介绍组成 SimpleReadWrite.2013 应用程序的每个文件的内容。 + +SimpleReadWrite.2013.vcxproj + 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 + +SimpleReadWrite.2013.vcxproj.filters + 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 + +SimpleReadWrite.2013.h + 这是应用程序的主头文件。 + 其中包括其他项目特定的标头(包括 Resource.h),并声明 CSimpleReadWrite2013App 应用程序类。 + +SimpleReadWrite.2013.cpp + 这是包含应用程序类 CSimpleReadWrite2013App 的主应用程序源文件。 + +SimpleReadWrite.2013.rc + 这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源包含在 2052 中。 + +res\SimpleReadWrite.2013.ico + 这是用作应用程序图标的图标文件。此图标包括在主资源文件 SimpleReadWrite.2013.rc 中。 + +res\SimpleReadWrite2013.rc2 + 此文件包含不在 Microsoft Visual C++ 中进行编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。 + + +///////////////////////////////////////////////////////////////////////////// + +应用程序向导创建一个对话框类: + +SimpleReadWrite.2013Dlg.h、SimpleReadWrite.2013Dlg.cpp - 对话框 + 这些文件包含 CSimpleReadWrite2013Dlg 类。此类定义应用程序的主对话框的行为。对话框模板包含在 SimpleReadWrite.2013.rc 中,该文件可以在 Microsoft Visual C++ 中编辑。 + +///////////////////////////////////////////////////////////////////////////// + +其他功能: + +ActiveX 控件 + 该应用程序包含对使用 ActiveX 控件的支持。 + +///////////////////////////////////////////////////////////////////////////// + +其他标准文件: + +StdAfx.h, StdAfx.cpp + 这些文件用于生成名为 SimpleReadWrite.2013.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 + +Resource.h + 这是标准头文件,可用于定义新的资源 ID。Microsoft Visual C++ 将读取并更新此文件。 + +SimpleReadWrite.2013.manifest + Windows XP 使用应用程序清单文件来描述特定版本的并行程序集的应用程序依赖项。加载程序使用这些信息来从程序集缓存中加载相应的程序集,并保护其不被应用程序访问。应用程序清单可能会包含在内,以作为与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件进行重新分发,它还可能以资源的形式包含在可执行文件中。 +///////////////////////////////////////////////////////////////////////////// + +其他注释: + +应用程序向导使用“TODO:”来指示应添加或自定义的源代码部分。 + +如果应用程序使用共享 DLL 中的 MFC,您将需要重新分发 MFC DLL。如果应用程序所使用的语言与操作系统的区域设置不同,则还需要重新分发相应的本地化资源 mfc110XXX.DLL。 +有关上述话题的更多信息,请参见 MSDN 文档中有关重新分发 Visual C++ 应用程序的部分。 + +///////////////////////////////////////////////////////////////////////////// diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/Resource.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/Resource.h new file mode 100644 index 0000000..70d1832 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/Resource.h @@ -0,0 +1,21 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ ɵİļ +// SimpleReadWrite.2013.rc ʹ +// +#define IDR_MAINFRAME 128 +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_SIMPLEREADWRITE2013_DIALOG 102 + +// ¶һĬֵ +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.aps b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.aps new file mode 100644 index 0000000..22e841d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.aps differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.cpp new file mode 100644 index 0000000..1c74271 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.cpp @@ -0,0 +1,102 @@ + +// SimpleReadWrite.2013.cpp : ӦóΪ +// + +#include "stdafx.h" +#include "SimpleReadWrite.2013.h" +#include "SimpleReadWrite.2013Dlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CSimpleReadWrite2013App + +BEGIN_MESSAGE_MAP(CSimpleReadWrite2013App, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// CSimpleReadWrite2013App + +CSimpleReadWrite2013App::CSimpleReadWrite2013App() +{ + // ֧ + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: ڴ˴ӹ룬 + // Ҫijʼ InitInstance +} + + +// Ψһһ CSimpleReadWrite2013App + +CSimpleReadWrite2013App theApp; + + +// CSimpleReadWrite2013App ʼ + +BOOL CSimpleReadWrite2013App::InitInstance() +{ + // һ Windows XP ϵӦó嵥ָҪ + // ʹ ComCtl32.dll 汾 6 ߰汾ÿӻʽ + //Ҫ InitCommonControlsEx() 򣬽޷ڡ + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // ΪҪӦóʹõ + // ؼࡣ + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // shell ԷԻ + // κ shell ͼؼ shell бͼؼ + CShellManager *pShellManager = new CShellManager; + + // Windows NativeӾԱ MFC ؼ + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // ׼ʼ + // δʹЩܲϣС + // տִļĴСӦƳ + // Ҫضʼ + // ڴ洢õע + // TODO: Ӧʵ޸ĸַ + // ޸Ϊ˾֯ + SetRegistryKey(_T("ӦóɵıӦó")); + + CSimpleReadWrite2013Dlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: ڴ˷ôʱ + // ȷرնԻĴ + } + else if (nResponse == IDCANCEL) + { + // TODO: ڴ˷ôʱ + // ȡرնԻĴ + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, ": Ի򴴽ʧܣӦóֹ\n"); + TRACE(traceAppMsg, 0, ": ڶԻʹ MFC ؼ޷ #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS\n"); + } + + // ɾ洴 shell + if (pShellManager != NULL) + { + delete pShellManager; + } + + // ڶԻѹرգԽ FALSE Ա˳Ӧó + // ӦóϢá + return FALSE; +} + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.h new file mode 100644 index 0000000..a9ce032 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.h @@ -0,0 +1,32 @@ + +// SimpleReadWrite.2013.h : PROJECT_NAME Ӧóͷļ +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "ڰļ֮ǰstdafx.h PCH ļ" +#endif + +#include "resource.h" // + + +// CSimpleReadWrite2013App: +// йشʵ֣ SimpleReadWrite.2013.cpp +// + +class CSimpleReadWrite2013App : public CWinApp +{ +public: + CSimpleReadWrite2013App(); + +// д +public: + virtual BOOL InitInstance(); + +// ʵ + + DECLARE_MESSAGE_MAP() +}; + +extern CSimpleReadWrite2013App theApp; \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.rc b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.rc new file mode 100644 index 0000000..ff3be9d Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.rc differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.vcxproj b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.vcxproj new file mode 100644 index 0000000..1f2cf7e --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.vcxproj @@ -0,0 +1,141 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {D087FC62-A5AF-4770-9CEF-40CAB4B558F1} + SimpleReadWrite2013 + MFCProj + + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + true + + + false + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0804 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0804 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + + + + Create + Create + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.vcxproj.filters b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.vcxproj.filters new file mode 100644 index 0000000..5d30ce4 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013.vcxproj.filters @@ -0,0 +1,84 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + 资源文件 + + + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013Dlg.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013Dlg.cpp new file mode 100644 index 0000000..a6e0774 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013Dlg.cpp @@ -0,0 +1,174 @@ + +// SimpleReadWrite.2013Dlg.cpp : ʵļ +// + +#include "stdafx.h" +#include "SimpleReadWrite.2013.h" +#include "SimpleReadWrite.2013Dlg.h" +#include "afxdialogex.h" +#include "VISAHelper.h" +#include + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Ӧó򡰹ڡ˵ CAboutDlg Ի + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg(); + +// Ի + enum { IDD = IDD_ABOUTBOX }; + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + +// ʵ +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + + +// CSimpleReadWrite2013Dlg Ի + + + +CSimpleReadWrite2013Dlg::CSimpleReadWrite2013Dlg(CWnd* pParent /*=NULL*/) + : CDialogEx(CSimpleReadWrite2013Dlg::IDD, pParent) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void CSimpleReadWrite2013Dlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CSimpleReadWrite2013Dlg, CDialogEx) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() +END_MESSAGE_MAP() + + +// CSimpleReadWrite2013Dlg Ϣ + +BOOL CSimpleReadWrite2013Dlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // ...˵ӵϵͳ˵С + + // IDM_ABOUTBOX ϵͳΧڡ + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != NULL) + { + BOOL bNameValid; + CString strAboutMenu; + bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); + ASSERT(bNameValid); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // ô˶Իͼꡣ ӦóڲǶԻʱܽԶ + // ִд˲ + SetIcon(m_hIcon, TRUE); // ôͼ + SetIcon(m_hIcon, FALSE); // Сͼ + + + #pragma region VISA ӿʾ + //豸ֻ10̨豸ҵ豸ַ洢findAddressListУ + ViChar findAddressList[10][VI_FIND_BUFLEN]; + ViUInt32 retNumInstrs = 0; + visa::GetInstance()->FindDev("?*", findAddressList, 10, &retNumInstrs); + + //豸(򿪲ҵĵһ豸) + visa::GetInstance()->OpenDev(findAddressList[0], 2000); + + //дָ + //visa::GetInstance()->Write(_T("*IDN?\r\n"), 2000); + + //,ضֽ + std::vector readBuf;// + readBuf.resize(1024); + auto retcnt = visa::GetInstance()->Read(_T("*IDN?\r\n"), &readBuf[0], 1024, 2000); + #pragma endregion + + + + + return TRUE; // ǽõؼ򷵻 TRUE +} + +void CSimpleReadWrite2013Dlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialogEx::OnSysCommand(nID, lParam); + } +} + +// ԻСťҪĴ +// Ƹͼꡣ ʹĵ/ͼģ͵ MFC Ӧó +// ⽫ɿԶɡ + +void CSimpleReadWrite2013Dlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // ڻƵ豸 + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + + // ʹͼڹо + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // ͼ + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialogEx::OnPaint(); + } +} + +//û϶Сʱϵͳô˺ȡù +//ʾ +HCURSOR CSimpleReadWrite2013Dlg::OnQueryDragIcon() +{ + return static_cast(m_hIcon); +} + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013Dlg.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013Dlg.h new file mode 100644 index 0000000..c64fb58 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/SimpleReadWrite.2013Dlg.h @@ -0,0 +1,32 @@ + +// SimpleReadWrite.2013Dlg.h : ͷļ +// + +#pragma once + + +// CSimpleReadWrite2013Dlg Ի +class CSimpleReadWrite2013Dlg : public CDialogEx +{ +// +public: + CSimpleReadWrite2013Dlg(CWnd* pParent = NULL); // ׼캯 + +// Ի + enum { IDD = IDD_SIMPLEREADWRITE2013_DIALOG }; + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV ֧ + + +// ʵ +protected: + HICON m_hIcon; + + // ɵϢӳ亯 + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + DECLARE_MESSAGE_MAP() +}; diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/Singleton.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/Singleton.h new file mode 100644 index 0000000..b8b0635 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/Singleton.h @@ -0,0 +1,46 @@ +/* + *ʹ÷ + ͨ䣺CSingleton<>::Instance()ȡָijʵָ롣 + **/ +template +class CSingleton +{ +public: + static T* Instance() + { + if (NULL == m_pInstance) + { + // μ + if (NULL == m_pInstance) + { + m_pInstance = new T; + atexit(Destory); + } + } + + return m_pInstance; + } + +protected: + CSingleton() {} //ֹʵ + CSingleton(const CSingleton&) {} //ֹһʵ + CSingleton& operator=(const CSingleton&){} //ֵֹһʵ + + virtual ~CSingleton() + { + } + + static void Destory() + { + if (m_pInstance) + { + delete m_pInstance; + m_pInstance = NULL; + } + } + +private: + static T* m_pInstance; +}; + +template T* CSingleton::m_pInstance = NULL; \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/VISAHelper.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/VISAHelper.cpp new file mode 100644 index 0000000..1eb5dd6 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/VISAHelper.cpp @@ -0,0 +1,703 @@ +/******************************************************************** + * Copyright(c) 2017-2018 UNI-T, + * + * All Rights Reserved. + * + * FileName: VisaHleper.cpp + * Author : M.Jiang + * Created : 2017/09/14 + * + * Description: + * + * History : 14-9-2017 16:12 by M.J Created +*********************************************************************/ + +#include "stdafx.h" +#include "VISAHelper.h" +#include + +#pragma comment(lib,"visa32.lib") + +using std::vector; +/********************************************************* + * @version : Ver1.0 + * @brief : ʱж϶ʱ + * @date : 2017/11/08 16:45:26 + * @author : M.Jiang + * @param : const double & start + * @param : const double & length + * @return : bool + * @remarks : ѭǰ涨const double start=clock();ȻΪtimerĵһʱΪڶλms + ********************************************************/ +bool timer(const double & start, const double& length) +{ + if (((double)clock() - start) >= length) + return false; + else + return true; +} + +VISAHelper::VISAHelper(): +status(-1), +defaultRM(VI_NULL), +instrHandle(VI_NULL) +{ + +} + +VISAHelper::~VISAHelper() +{ + +} + +/****************************************************************** + * @version : Ver1.0 + * @brief : VISA豸 + * @date : 2017/09/15 9:23:19 + * @author : M.Jiang + * @param : ViString expression ޶ַ + * + Interface Expression + -------------------------------------- + GPIB "GPIB[0-9]*::?*INSTR" + VXI "VXI?*INSTR" + GPIB-VXI "GPIB-VXI?*INSTR" + Any VXI "?*VXI[0-9]*::?*INSTR" + Serial "ASRL[0-9]*::?*INSTR" + PXI "PXI?*INSTR" + USB "USB?*" + All instruments "?*INSTR" + All resources "?*" + * + * @param : ViChar findAddressList[][VI_FIND_BUFLEN] 豸б + * @param : ViUInt32 numInstrs Ҫ豸 + * @param : ViPUInt32 retNumInstrs ʵ豸 + * @return : ViStatus + * @remarks : + ******************************************************************/ +ViStatus VISAHelper::FindDev(ViString expression, ViChar findAddressList[][VI_FIND_BUFLEN], ViUInt32 numInstrs, ViPUInt32 retNumInstrs) +{ + ViFindList findList = VI_NULL; + char instrDescriptor[VI_FIND_BUFLEN]; + + /* ĬϵVISAԴ */ + status = viOpenDefaultRM(&defaultRM); + if (status < VI_SUCCESS) + { + TRACE(_T("Could not open a session to the VISA Resource Manager!\n")); + } + //豸ַԴб + status = viFindRsrc(defaultRM, expression, &findList, retNumInstrs, instrDescriptor); + if (status < VI_SUCCESS) + { + TRACE(_T("An error occurred while finding resources\n")); + viClose(defaultRM); + return status; + } + + //õһַ + memcpy(findAddressList[0], instrDescriptor, strlen(instrDescriptor)+1); + + //findAddressListСװ豸ַб + int num = numInstrs <= *retNumInstrs ? numInstrs : *retNumInstrs; + for (int i = 1; i < num ; i++) + { + status = viFindNext(findList, instrDescriptor);//һ豸ַ + memcpy(findAddressList[i], instrDescriptor, strlen(instrDescriptor)+1); + if (status < VI_SUCCESS) + { + TRACE(_T("An error occurred finding the next resource\n")); + viClose(defaultRM); + return status; + } + } + + //ͷVISAбԴ + status = viClose(findList); + findList = VI_NULL; + + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : + * @date : 2017/09/15 11:21:30 + * @author : M.Jiang + * @param : ViString instrDescriptor Դ + * @param : ViUInt32 timeout ʱʱ + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::OpenDev(ViString instrDescriptor, ViUInt32 timeout = 0) +{ + /* ĬϵVISAԴ */ + status = viOpenDefaultRM(&defaultRM); + if (status < VI_SUCCESS) + { + TRACE(_T("Could not open a session to the VISA Resource Manager!\n")); + } + + status = viOpen(defaultRM, instrDescriptor, VI_NULL, VI_NULL, &instrHandle);//timeoutָòڷش֮ǰȴʱ(ԺΪλ) + if (status < VI_SUCCESS) + { + TRACE(_T("An error occurred opening a session to %s\n"), instrDescriptor); + } + + return status; +} + +/********************************************************* +* @version : Ver1.0 +* @brief : +* @date : 2017/09/15 11:21:30 +* @author : M.Jiang +* @param : ViString instrDescriptor Դ +* @param : ViUInt32 timeout ʱʱ +* @return : ViStatus +* @remarks : +********************************************************/ +ViStatus VISAHelper::OpenDev(CString instrDescriptor, ViUInt32 timeout = 0) +{ + char visaAddr[VI_FIND_BUFLEN]; + memset(visaAddr, 0, sizeof(visaAddr)); + memcpy(visaAddr, CStringA(instrDescriptor), CStringA(instrDescriptor).GetLength()); + + /* ĬϵVISAԴ */ + status = viOpenDefaultRM(&defaultRM); + if (status < VI_SUCCESS) + { + TRACE(_T("Could not open a session to the VISA Resource Manager!\n")); + } + + status = viOpen(defaultRM, visaAddr, VI_NULL, timeout, &instrHandle);//VISA򿪳ʱָVISA򿪡ڷشǰȴʱֵԺΪλI/OʱVISAóʱָVISAỰ֮IJʱֵ + if (status < VI_SUCCESS) + { + TRACE(_T("An error occurred opening a session to %s\n"), instrDescriptor); + } + + status = viLock(instrHandle, VI_EXCLUSIVE_LOCK, 2000, NULL, NULL); + status = viSetAttribute(instrHandle, VI_ATTR_TERMCHAR_EN, VI_FALSE); + status = viSetAttribute(instrHandle, VI_ATTR_SEND_END_EN, VI_TRUE);//ʹܷENDָʾдй,һΪ\0 + + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : ֻд + * @date : 2017/09/15 11:22:02 + * @author : M.Jiang + * @param : ViBuf buf д + * @param : ViUInt32 cnt Ҫдֽ + * @param : ViPUInt32 retCnt ʵдֽ + * @param : ViUInt32 timeout ʱʱ + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::Write(ViBuf buf, ViUInt32 cnt, ViPUInt32 retCnt, ViUInt32 timeout) +{ + status = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, timeout); + status = viWrite(instrHandle, buf, cnt, retCnt); + if (status < VI_SUCCESS) + { + TRACE(_T("Error writing to the device\n")); + } + + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : ֻ + * @date : 2017/09/15 11:24:14 + * @author : M.Jiang + * @param : ViPBuf buf + * @param : ViUInt32 cnt Ҫȡֽ + * @param : ViPUInt32 retCnt ʵʶȡֽ + * @param : ViUInt32 timeout ʱʱ + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::Read(ViPBuf buf, ViUInt32 cnt, ViPUInt32 retCnt, ViUInt32 timeout) +{ + status = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, timeout); + + status = viRead(instrHandle, buf, cnt, retCnt); + if (status < VI_SUCCESS) + { + TRACE(_T("Error reading a response from the device\n")); + } + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : + * @date : 2017/10/24 11:16:21 + * @author : M.Jiang + * @param : ViPBuf writeBuf дָ + * @param : ViUInt32 writeCnt дָ + * @param : ViPBuf readBuf + * @param : ViUInt32 readCnt Ҫȡֽ + * @param : ViPUInt32 retCnt ʵʶȡֽ + * @param : ViUInt32 timeout ʱʱ + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::Query(ViPBuf writeBuf, ViUInt32 writeCnt, ViPBuf readBuf, ViUInt32 readCnt, ViPUInt32 retCnt, ViUInt32 timeout) +{ + ViUInt32 retWCnt; + + status = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, timeout); + status = viWrite(instrHandle, writeBuf, writeCnt, &retWCnt); + Sleep(50); + status = viRead(instrHandle, readBuf, readCnt, retCnt); + + if (status < VI_SUCCESS) + { + TRACE(_T("Error query from the device\n")); + } + + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : 󷵻(д) + * @date : 2017/09/15 11:25:01 + * @author : M.Jiang + * @param : ViString writeBuf дָ + * @param : ViPBuf readBuf + * @param : ViUInt32 cnt Ҫȡֽ + * @param : ViPUInt32 retCnt ʵʶȡֽ + * @param : ViUInt32 timeout ʱʱ + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::Query(ViString writeBuf, ViPBuf readBuf, ViUInt32 cnt, ViPUInt32 retCnt, ViUInt32 timeout) +{ + ViUInt32 writeCount; + + status = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, timeout); + + status = viWrite(instrHandle, (ViBuf)writeBuf, (ViUInt32)strlen(writeBuf), &writeCount); + status = viRead(instrHandle, readBuf, cnt, retCnt); + + if (status < VI_SUCCESS) + { + TRACE(_T("Error query from the device\n")); + } + + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : 첽ص + * @date : 2017/09/19 9:38:12 + * @author : M.Jiang + * @param : ViSession vi + * @param : ViEventType etype + * @param : ViEvent event + * @param : ViAddr userHandle + * @return : ViStatus _VI_FUNCH + * @remarks : + ********************************************************/ +ViStatus _VI_FUNCH AsyncHandler(ViSession vi, ViEventType etype, ViEvent event, ViAddr userHandle) +{ + ViUInt32 retCount = 0; + viGetAttribute(event, VI_ATTR_RET_COUNT, &retCount); + return VI_SUCCESS; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : 첽IOװ + * @date : 2017/09/19 9:38:52 + * @author : M.Jiang + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::AsyncInstall() +{ + ViAddr userHandle = nullptr; + + status = viInstallHandler(instrHandle, VI_EVENT_IO_COMPLETION, AsyncHandler, userHandle); + if (status < VI_SUCCESS) + { + TRACE(_T("Could not install the interrupt handler\n")); + } + status = viEnableEvent(instrHandle, VI_EVENT_IO_COMPLETION, VI_HNDLR, VI_NULL); + if (status < VI_SUCCESS) + { + TRACE(_T("Could not enable the interrupt event\n")); + } + + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : 첽IOж + * @date : 2017/09/19 9:39:09 + * @author : M.Jiang + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::AsyncUnInstall() +{ + status = viUninstallHandler(instrHandle, VI_EVENT_IO_COMPLETION, AsyncHandler, VI_NULL); + if (status < VI_SUCCESS) + { + TRACE(_T("Could not uninstall the interrupt handler\n")); + } + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : 첽ȡjobIdÿһ첽ָʾID + * @date : 2017/09/19 9:39:29 + * @author : M.Jiang + * @param : ViPBuf buf ȡ + * @param : ViUInt32 cnt ȡ + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::AsyncRead(ViPBuf buf, ViUInt32 cnt) +{ + ViJobId jobId; + + status = viReadAsync(instrHandle, buf, cnt, &jobId); + if (status < VI_SUCCESS) + { + TRACE(_T("Error Async Read\n")); + } + + return status; +} + +/********************************************************* + * @version : Ver1.0 + * @brief : رͷԴ + * @date : 2017/09/15 11:28:10 + * @author : M.Jiang + * @return : ViStatus + * @remarks : + ********************************************************/ +ViStatus VISAHelper::CloseDev() +{ + status = VI_SUCCESS; + + //ͷԴ + if (instrHandle != VI_NULL) + { + status = viUnlock(instrHandle); + status = viClose(instrHandle); + instrHandle = VI_NULL; + } + //ͷԴԴ + if (defaultRM != VI_NULL) + { + status = viClose(defaultRM); + defaultRM = VI_NULL; + } + + return status; +} + + +int VISAHelper::Write(const TCHAR* _cmd, UINT _timeOut) +{ + CStringA cmd = CStringA(_cmd); + char* pCmd = cmd.GetBuffer(); + + int ret = 0; + DWORD retCnt = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + ret = viWrite(instrHandle, (byte*)pCmd, cmd.GetLength(), &retCnt); + + cmd.ReleaseBuffer(); + + return retCnt > 0 ? retCnt : ret; +} +int VISAHelper::FormatWrite(UINT _timeOut, _In_z_ _FormatMessage_format_string_ const TCHAR *_pszFormat, ...) +{ + CStringA pszFormat = CStringA(_pszFormat); + char* ppszFormat = pszFormat.GetBuffer(); + + ppszFormat[pszFormat.GetLength()] = '\0'; + + va_list argList; + + int ret = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + va_start(argList, _pszFormat); + ret = viVPrintf(instrHandle, ppszFormat, argList); + va_end(argList); + + pszFormat.ReleaseBuffer(); + + return ret; +} +int VISAHelper::FormatVWrite(UINT _timeOut, const TCHAR *_pszFormat, va_list _argList) +{ + CStringA pszFormat = CStringA(_pszFormat); + char* ppszFormat = pszFormat.GetBuffer(); + + ppszFormat[pszFormat.GetLength()] = '\0'; + + int ret = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + ret = viVPrintf(instrHandle, ppszFormat, _argList); + + pszFormat.ReleaseBuffer(); + + return ret; +} +int VISAHelper::WriteFile(const TCHAR* _cmd, const TCHAR* _filename, UINT _dataLen, UINT _timeOut) +{ + CStringA fileName = CStringA(_filename); + char* pFileName = fileName.GetBuffer(); + + CStringA cmd = CStringA(_cmd); + char* pCmd = cmd.GetBuffer(); + + int ret = 0; + DWORD retCnt = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + ret = viWrite(instrHandle, (byte*)pCmd, cmd.GetLength(), &retCnt); + ret = viWriteFromFile(instrHandle, pFileName, _dataLen, &retCnt); + + cmd.ReleaseBuffer(); + fileName.ReleaseBuffer(); + + return retCnt > 0 ? retCnt : ret; +} + +int VISAHelper::Read(const TCHAR* _cmd, void* _data, UINT _dataLen, UINT _timeOut) +{ + CStringA cmd = CStringA(_cmd); + char* pCmd = cmd.GetBuffer(); + + int ret = 0; + DWORD retCnt = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + //ret = viFlush(instrHandle, 0x10); + ret = viWrite(instrHandle, (byte*)pCmd, cmd.GetLength(), &retCnt); + + double start = clock(); + while (timer(start, _timeOut)){ + //ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + ret = viRead(instrHandle, (byte*)_data, _dataLen, &retCnt); + if (retCnt > 0) { + break; + } + } + + cmd.ReleaseBuffer(); + + return retCnt > 0 ? retCnt : ret; +} +int VISAHelper::FormatRead(void* _data, UINT _dataLen, UINT _timeOut, _In_z_ _FormatMessage_format_string_ const TCHAR *_pszFormat, ...) +{ + CStringA pszFormat = CStringA(_pszFormat); + char* ppszFormat = pszFormat.GetBuffer(); + + ppszFormat[pszFormat.GetLength()] = '\0'; + + va_list argList; + + int ret = 0; + DWORD retCnt = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + va_start(argList, _pszFormat); + ret = viVPrintf(instrHandle, ppszFormat, argList); + va_end(argList); + ret = viRead(instrHandle, (byte*)_data, _dataLen, &retCnt); + + pszFormat.ReleaseBuffer(); + + return retCnt > 0 ? retCnt : ret; +} +int VISAHelper::FormatVRead(void* _data, UINT _dataLen, UINT _timeOut, const TCHAR *_pszFormat, va_list _argList) +{ + CStringA pszFormat = CStringA(_pszFormat); + char* ppszFormat = pszFormat.GetBuffer(); + + ppszFormat[pszFormat.GetLength()] = '\0'; + + int ret = 0; + DWORD retCnt = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + //ret = viFlush(instrHandle, 0x10); + ret = viVPrintf(instrHandle, ppszFormat, _argList); + + double start = clock(); + unsigned int count = 0; + while (timer(start, _timeOut)) + { + //ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + ret = viRead(instrHandle, (byte*)_data + count, _dataLen, &retCnt); + count += retCnt; + if (count >= _dataLen){ + break; + } + } + + pszFormat.ReleaseBuffer(); + + if (count == _dataLen)return count; + else return ret; + + /*return retCnt > 0 ? retCnt : ret;*/ +} +int VISAHelper::ReadFile(const TCHAR* _cmd, const TCHAR* _filename, UINT _dataLen, UINT _timeOut) +{ + CStringA fileName = CStringA(_filename); + char* pFileName = fileName.GetBuffer(); + + CStringA cmd = CStringA(_cmd); + char* pCmd = cmd.GetBuffer(); + + int ret = 0; + DWORD retCnt = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + //ret = viFlush(instrHandle, 0x10); + ret = viWrite(instrHandle, (byte*)pCmd, cmd.GetLength(), &retCnt); + + double start = clock(); + unsigned int count = 0; + while (timer(start, _timeOut)) + { + ret = viReadToFile(instrHandle, pFileName, _dataLen, &retCnt); + count += retCnt; + if (count == _dataLen){ + break; + } + } + + cmd.ReleaseBuffer(); + fileName.ReleaseBuffer(); + + return retCnt > 0 ? retCnt : ret; +} +int VISAHelper::FormatQuery(UINT _timeOut, const TCHAR *_cmd, _In_z_ _FormatMessage_format_string_ const TCHAR *_readFmt, ...) +{ + CStringA cmd = CStringA(_cmd); + char* pcmd = cmd.GetBuffer(); + pcmd[cmd.GetLength()] = '\0'; + + CStringA readFmt = CStringA(_readFmt); + char* preadFmt = readFmt.GetBuffer(); + preadFmt[readFmt.GetLength()] = '\0'; + + va_list argList; + + int ret = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + va_start(argList, _readFmt); + ret = viVQueryf(instrHandle, pcmd, preadFmt, argList); + va_end(argList); + + cmd.ReleaseBuffer(); + readFmt.ReleaseBuffer(); + + return ret; +} +int VISAHelper::FormatVQuery(UINT _timeOut, const TCHAR *_cmd, const TCHAR *_readFmt, va_list _argList) +{ + CStringA cmd = CStringA(_cmd); + char* pcmd = cmd.GetBuffer(); + pcmd[cmd.GetLength()] = '\0'; + + CStringA readFmt = CStringA(_readFmt); + char* preadFmt = readFmt.GetBuffer(); + preadFmt[readFmt.GetLength()] = '\0'; + + int ret = 0; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + ret = viVQueryf(instrHandle, pcmd, preadFmt, _argList); + + cmd.ReleaseBuffer(); + readFmt.ReleaseBuffer(); + + return ret; +} + +int VISAHelper::ReadFileNoIEEEBlock(const TCHAR* _cmd, const TCHAR* _filename , UINT _timeOut) +{ + CStringA fileName = CStringA(_filename); + char* pFileName = fileName.GetBuffer(); + + CStringA cmd = CStringA(_cmd); + char* pCmd = cmd.GetBuffer(); + + int ret = 0; + DWORD retCnt = 0; + byte tmp[9]; + + CSingleLock slIO(&m_csAccessSession, TRUE); + ret = viSetAttribute(instrHandle, VI_ATTR_TMO_VALUE, _timeOut); + ret = viWrite(instrHandle, (byte*)pCmd, cmd.GetLength(), &retCnt); + + /*IEEEBlockݰͷ*/ + ret = viRead(instrHandle, tmp, 2, &retCnt);//ȶȡ"#+λ"2ֽ + if (ret < 0) return ret; + int lengthLen = tmp[1] - '0';//Ȼݳռֽ,ֵ9 + ret = viRead(instrHandle, tmp, lengthLen, &retCnt);//ȡݳַ + if (ret < 0) return ret; + tmp[lengthLen] = '\0';//ַ + int dataLen = atoi((char*)tmp);//ҪȡЧݳ + + vector buf; + buf.resize(dataLen); + + double start = clock(); + unsigned int count = 0; + while (timer(start, _timeOut)) + { + ret = viRead(instrHandle, &buf[0] + count, dataLen, &retCnt); + count += retCnt; + if (count == dataLen){ + break; + } + } + + //ʾдļ + if (count == dataLen){ + CFile f(CString(pFileName), CFile::modeCreate | CFile::modeWrite); + f.Write(&buf[0], dataLen); + f.Close(); + } + + //ͷڴ + buf.clear(); + buf.shrink_to_fit(); + cmd.ReleaseBuffer(); + fileName.ReleaseBuffer(); + + return retCnt > 0 ? retCnt : ret; +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/VISAHelper.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/VISAHelper.h new file mode 100644 index 0000000..2aaf779 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/VISAHelper.h @@ -0,0 +1,74 @@ +/******************************************************************** + * Copyright(c) 2017-2018 UNI-T, + * + * All Rights Reserved. + * + * FileName: VisaHleper.h + * Author : M.Jiang + * Created : 2017/09/14 + * + * Description:VISA࣬õģʽ + * + * History : 14-9-2017 16:11 by M.J Created +*********************************************************************/ +#include "./include/visa.h" +#include "Singleton.h" + +#pragma once + +class VISAHelper +{ +public: + VISAHelper(); + ~VISAHelper(); + +private: + ViStatus status; + ViSession defaultRM; + ViSession instrHandle; + +public: + ViSession GetInstrHandle() { return instrHandle; } + +public: + ViStatus FindDev(ViString expression, ViChar findAddressList[][VI_FIND_BUFLEN], ViUInt32 numInstrs, ViPUInt32 retNumInstrs); + ViStatus OpenDev(ViString instrDescriptor, ViUInt32 timeout); + ViStatus OpenDev(CString instrDescriptor, ViUInt32 timeout); + ViStatus CloseDev(); + + //ͬдAPI + //viReadִͬеķֱijŻ᷵أ + //<1>ʱ + //<2>յϣֽ + //<3>յսַENDָʾ + ViStatus Write(ViBuf buf, ViUInt32 cnt, ViPUInt32 retCnt, ViUInt32 timeout); + ViStatus Read(ViPBuf buf, ViUInt32 cnt, ViPUInt32 retCnt, ViUInt32 timeout); + ViStatus Query(ViPBuf writeBuf, ViUInt32 writeCnt, ViPBuf readBuf, ViUInt32 readCnt, ViPUInt32 retCnt, ViUInt32 timeout); + ViStatus Query(ViString writeBuf, ViPBuf readBuf, ViUInt32 cnt, ViPUInt32 retCnt, ViUInt32 timeout); + + //ӿ + int Write(const TCHAR* _cmd, UINT _timeOut = 2000); + int FormatWrite(UINT _timeOut, _In_z_ _FormatMessage_format_string_ const TCHAR *_pszFormat, ...);//ɱַͣΪcharַ + int FormatVWrite(UINT _timeOut, const TCHAR *_pszFormat, va_list _argList); + int WriteFile(const TCHAR* _cmd, const TCHAR* _filename, UINT _dataLen = 0, UINT _timeOut = 2000);//߱ļ·뵱ǰĿ¼µļ + int Read(const TCHAR* _cmd, void* _data, UINT _dataLen = 0, UINT _timeOut = 2000); + int FormatRead(void* _data, UINT _dataLen, UINT _timeOut, _In_z_ _FormatMessage_format_string_ const TCHAR *_pszFormat, ...);//ɱַͣΪcharַ + int FormatVRead(void* _data, UINT _dataLen, UINT _timeOut, const TCHAR *_pszFormat, va_list _argList); + int ReadFile(const TCHAR* _cmd, const TCHAR* _filename, UINT _dataLen = 0, UINT _timeOut = 2000); + int FormatQuery(UINT _timeOut, const TCHAR *_cmd, _In_z_ _FormatMessage_format_string_ const TCHAR *_readFmt, ...);//ɱַͣΪcharַ + int FormatVQuery(UINT _timeOut, const TCHAR *_cmd, const TCHAR *_readFmt, va_list _argList); + + int ReadFileNoIEEEBlock(const TCHAR* _cmd, const TCHAR* _filename, UINT _timeOut = 2000); + + //첽дAPI + ViStatus AsyncInstall(); + ViStatus AsyncUnInstall(); + ViStatus AsyncRead(ViPBuf buf, ViUInt32 cnt); + + CCriticalSection m_csAccessSession;//̼߳ͬдʱԶͷ +}; + +//VISAȫַʽӿڣõģʽֻʵһ +namespace visa{ + static VISAHelper* GetInstance(){ return CSingleton::Instance(); }; +} \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/visa.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/visa.h new file mode 100644 index 0000000..e5de466 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/visa.h @@ -0,0 +1,1144 @@ +/*---------------------------------------------------------------------------*/ +/* Distributed by IVI Foundation Inc. */ +/* Contains National Instruments extensions. */ +/* Do not modify the contents of this file. */ +/*---------------------------------------------------------------------------*/ +/* */ +/* Title : VISA.H */ +/* Date : 02-12-2016 */ +/* Purpose : Include file for the VISA Library 5.7 specification */ +/* */ +/*---------------------------------------------------------------------------*/ +/* When using NI-VISA extensions, you must link with the VISA library that */ +/* comes with NI-VISA. Currently, the extensions provided by NI-VISA are: */ +/* */ +/* PXI (Compact PCI eXtensions for Instrumentation) and PCI support. To use */ +/* this, you must define the macro NIVISA_PXI before including this header. */ +/* You must also create an INF file with the VISA Driver Development Wizard. */ +/* */ +/* A fast set of macros for viPeekXX/viPokeXX that guarantees binary */ +/* compatibility with other implementations of VISA. To use this, you must */ +/* define the macro NIVISA_PEEKPOKE before including this header. */ +/* */ +/* Support for USB devices that do not conform to a specific class. To use */ +/* this, you must define the macro NIVISA_USB before including this header. */ +/* You must also create an INF file with the VISA Driver Development Wizard. */ +/*---------------------------------------------------------------------------*/ + +#ifndef __VISA_HEADER__ +#define __VISA_HEADER__ + +#include + +#if !defined(__VISATYPE_HEADER__) +#include "visatype.h" +#endif + +#define VI_SPEC_VERSION (0x00500700UL) + +#if defined(__cplusplus) || defined(__cplusplus__) + extern "C" { +#endif + +#if defined(_CVI_) +#pragma EnableLibraryRuntimeChecking +#endif + +/*- VISA Types --------------------------------------------------------------*/ + +typedef ViObject ViEvent; +typedef ViEvent _VI_PTR ViPEvent; +typedef ViObject ViFindList; +typedef ViFindList _VI_PTR ViPFindList; + +#if defined(_VI_INT64_UINT64_DEFINED) && defined(_VISA_ENV_IS_64_BIT) +typedef ViUInt64 ViBusAddress; +typedef ViUInt64 ViBusSize; +typedef ViUInt64 ViAttrState; +#else +typedef ViUInt32 ViBusAddress; +typedef ViUInt32 ViBusSize; +typedef ViUInt32 ViAttrState; +#endif + +#if defined(_VI_INT64_UINT64_DEFINED) +typedef ViUInt64 ViBusAddress64; +typedef ViBusAddress64 _VI_PTR ViPBusAddress64; +#endif + +typedef ViUInt32 ViEventType; +typedef ViEventType _VI_PTR ViPEventType; +typedef ViEventType _VI_PTR ViAEventType; +typedef void _VI_PTR ViPAttrState; +typedef ViAttr _VI_PTR ViPAttr; +typedef ViAttr _VI_PTR ViAAttr; + +typedef ViString ViKeyId; +typedef ViPString ViPKeyId; +typedef ViUInt32 ViJobId; +typedef ViJobId _VI_PTR ViPJobId; +typedef ViUInt32 ViAccessMode; +typedef ViAccessMode _VI_PTR ViPAccessMode; +typedef ViBusAddress _VI_PTR ViPBusAddress; +typedef ViUInt32 ViEventFilter; + +typedef va_list ViVAList; + +typedef ViStatus (_VI_FUNCH _VI_PTR ViHndlr) + (ViSession vi, ViEventType eventType, ViEvent event, ViAddr userHandle); + +/*- Resource Manager Functions and Operations -------------------------------*/ + +ViStatus _VI_FUNC viOpenDefaultRM (ViPSession vi); +ViStatus _VI_FUNC viFindRsrc (ViSession sesn, ViString expr, ViPFindList vi, + ViPUInt32 retCnt, ViChar _VI_FAR desc[]); +ViStatus _VI_FUNC viFindNext (ViFindList vi, ViChar _VI_FAR desc[]); +ViStatus _VI_FUNC viParseRsrc (ViSession rmSesn, ViRsrc rsrcName, + ViPUInt16 intfType, ViPUInt16 intfNum); +ViStatus _VI_FUNC viParseRsrcEx (ViSession rmSesn, ViRsrc rsrcName, ViPUInt16 intfType, + ViPUInt16 intfNum, ViChar _VI_FAR rsrcClass[], + ViChar _VI_FAR expandedUnaliasedName[], + ViChar _VI_FAR aliasIfExists[]); +ViStatus _VI_FUNC viOpen (ViSession sesn, ViRsrc name, ViAccessMode mode, + ViUInt32 timeout, ViPSession vi); + +/*- Resource Template Operations --------------------------------------------*/ + +ViStatus _VI_FUNC viClose (ViObject vi); +ViStatus _VI_FUNC viSetAttribute (ViObject vi, ViAttr attrName, ViAttrState attrValue); +ViStatus _VI_FUNC viGetAttribute (ViObject vi, ViAttr attrName, void _VI_PTR attrValue); +ViStatus _VI_FUNC viStatusDesc (ViObject vi, ViStatus status, ViChar _VI_FAR desc[]); +ViStatus _VI_FUNC viTerminate (ViObject vi, ViUInt16 degree, ViJobId jobId); + +ViStatus _VI_FUNC viLock (ViSession vi, ViAccessMode lockType, ViUInt32 timeout, + ViKeyId requestedKey, ViChar _VI_FAR accessKey[]); +ViStatus _VI_FUNC viUnlock (ViSession vi); +ViStatus _VI_FUNC viEnableEvent (ViSession vi, ViEventType eventType, ViUInt16 mechanism, + ViEventFilter context); +ViStatus _VI_FUNC viDisableEvent (ViSession vi, ViEventType eventType, ViUInt16 mechanism); +ViStatus _VI_FUNC viDiscardEvents (ViSession vi, ViEventType eventType, ViUInt16 mechanism); +ViStatus _VI_FUNC viWaitOnEvent (ViSession vi, ViEventType inEventType, ViUInt32 timeout, + ViPEventType outEventType, ViPEvent outContext); +ViStatus _VI_FUNC viInstallHandler(ViSession vi, ViEventType eventType, ViHndlr handler, + ViAddr userHandle); +ViStatus _VI_FUNC viUninstallHandler(ViSession vi, ViEventType eventType, ViHndlr handler, + ViAddr userHandle); + +/*- Basic I/O Operations ----------------------------------------------------*/ + +ViStatus _VI_FUNC viRead (ViSession vi, ViPBuf buf, ViUInt32 cnt, ViPUInt32 retCnt); +ViStatus _VI_FUNC viReadAsync (ViSession vi, ViPBuf buf, ViUInt32 cnt, ViPJobId jobId); +ViStatus _VI_FUNC viReadToFile (ViSession vi, ViConstString filename, ViUInt32 cnt, + ViPUInt32 retCnt); +ViStatus _VI_FUNC viWrite (ViSession vi, ViBuf buf, ViUInt32 cnt, ViPUInt32 retCnt); +ViStatus _VI_FUNC viWriteAsync (ViSession vi, ViBuf buf, ViUInt32 cnt, ViPJobId jobId); +ViStatus _VI_FUNC viWriteFromFile (ViSession vi, ViConstString filename, ViUInt32 cnt, + ViPUInt32 retCnt); +ViStatus _VI_FUNC viAssertTrigger (ViSession vi, ViUInt16 protocol); +ViStatus _VI_FUNC viReadSTB (ViSession vi, ViPUInt16 status); +ViStatus _VI_FUNC viClear (ViSession vi); + +/*- Formatted and Buffered I/O Operations -----------------------------------*/ + +ViStatus _VI_FUNC viSetBuf (ViSession vi, ViUInt16 mask, ViUInt32 size); +ViStatus _VI_FUNC viFlush (ViSession vi, ViUInt16 mask); + +ViStatus _VI_FUNC viBufWrite (ViSession vi, ViBuf buf, ViUInt32 cnt, ViPUInt32 retCnt); +ViStatus _VI_FUNC viBufRead (ViSession vi, ViPBuf buf, ViUInt32 cnt, ViPUInt32 retCnt); + +ViStatus _VI_FUNCC viPrintf (ViSession vi, ViString writeFmt, ...); +ViStatus _VI_FUNC viVPrintf (ViSession vi, ViString writeFmt, ViVAList params); +ViStatus _VI_FUNCC viSPrintf (ViSession vi, ViPBuf buf, ViString writeFmt, ...); +ViStatus _VI_FUNC viVSPrintf (ViSession vi, ViPBuf buf, ViString writeFmt, + ViVAList parms); + +ViStatus _VI_FUNCC viScanf (ViSession vi, ViString readFmt, ...); +ViStatus _VI_FUNC viVScanf (ViSession vi, ViString readFmt, ViVAList params); +ViStatus _VI_FUNCC viSScanf (ViSession vi, ViBuf buf, ViString readFmt, ...); +ViStatus _VI_FUNC viVSScanf (ViSession vi, ViBuf buf, ViString readFmt, + ViVAList parms); + +ViStatus _VI_FUNCC viQueryf (ViSession vi, ViString writeFmt, ViString readFmt, ...); +ViStatus _VI_FUNC viVQueryf (ViSession vi, ViString writeFmt, ViString readFmt, + ViVAList params); + +/*- Memory I/O Operations ---------------------------------------------------*/ + +ViStatus _VI_FUNC viIn8 (ViSession vi, ViUInt16 space, + ViBusAddress offset, ViPUInt8 val8); +ViStatus _VI_FUNC viOut8 (ViSession vi, ViUInt16 space, + ViBusAddress offset, ViUInt8 val8); +ViStatus _VI_FUNC viIn16 (ViSession vi, ViUInt16 space, + ViBusAddress offset, ViPUInt16 val16); +ViStatus _VI_FUNC viOut16 (ViSession vi, ViUInt16 space, + ViBusAddress offset, ViUInt16 val16); +ViStatus _VI_FUNC viIn32 (ViSession vi, ViUInt16 space, + ViBusAddress offset, ViPUInt32 val32); +ViStatus _VI_FUNC viOut32 (ViSession vi, ViUInt16 space, + ViBusAddress offset, ViUInt32 val32); + +#if defined(_VI_INT64_UINT64_DEFINED) +ViStatus _VI_FUNC viIn64 (ViSession vi, ViUInt16 space, + ViBusAddress offset, ViPUInt64 val64); +ViStatus _VI_FUNC viOut64 (ViSession vi, ViUInt16 space, + ViBusAddress offset, ViUInt64 val64); + +ViStatus _VI_FUNC viIn8Ex (ViSession vi, ViUInt16 space, + ViBusAddress64 offset, ViPUInt8 val8); +ViStatus _VI_FUNC viOut8Ex (ViSession vi, ViUInt16 space, + ViBusAddress64 offset, ViUInt8 val8); +ViStatus _VI_FUNC viIn16Ex (ViSession vi, ViUInt16 space, + ViBusAddress64 offset, ViPUInt16 val16); +ViStatus _VI_FUNC viOut16Ex (ViSession vi, ViUInt16 space, + ViBusAddress64 offset, ViUInt16 val16); +ViStatus _VI_FUNC viIn32Ex (ViSession vi, ViUInt16 space, + ViBusAddress64 offset, ViPUInt32 val32); +ViStatus _VI_FUNC viOut32Ex (ViSession vi, ViUInt16 space, + ViBusAddress64 offset, ViUInt32 val32); +ViStatus _VI_FUNC viIn64Ex (ViSession vi, ViUInt16 space, + ViBusAddress64 offset, ViPUInt64 val64); +ViStatus _VI_FUNC viOut64Ex (ViSession vi, ViUInt16 space, + ViBusAddress64 offset, ViUInt64 val64); +#endif + +ViStatus _VI_FUNC viMoveIn8 (ViSession vi, ViUInt16 space, ViBusAddress offset, + ViBusSize length, ViAUInt8 buf8); +ViStatus _VI_FUNC viMoveOut8 (ViSession vi, ViUInt16 space, ViBusAddress offset, + ViBusSize length, ViAUInt8 buf8); +ViStatus _VI_FUNC viMoveIn16 (ViSession vi, ViUInt16 space, ViBusAddress offset, + ViBusSize length, ViAUInt16 buf16); +ViStatus _VI_FUNC viMoveOut16 (ViSession vi, ViUInt16 space, ViBusAddress offset, + ViBusSize length, ViAUInt16 buf16); +ViStatus _VI_FUNC viMoveIn32 (ViSession vi, ViUInt16 space, ViBusAddress offset, + ViBusSize length, ViAUInt32 buf32); +ViStatus _VI_FUNC viMoveOut32 (ViSession vi, ViUInt16 space, ViBusAddress offset, + ViBusSize length, ViAUInt32 buf32); + +#if defined(_VI_INT64_UINT64_DEFINED) +ViStatus _VI_FUNC viMoveIn64 (ViSession vi, ViUInt16 space, ViBusAddress offset, + ViBusSize length, ViAUInt64 buf64); +ViStatus _VI_FUNC viMoveOut64 (ViSession vi, ViUInt16 space, ViBusAddress offset, + ViBusSize length, ViAUInt64 buf64); + +ViStatus _VI_FUNC viMoveIn8Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset, + ViBusSize length, ViAUInt8 buf8); +ViStatus _VI_FUNC viMoveOut8Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset, + ViBusSize length, ViAUInt8 buf8); +ViStatus _VI_FUNC viMoveIn16Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset, + ViBusSize length, ViAUInt16 buf16); +ViStatus _VI_FUNC viMoveOut16Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset, + ViBusSize length, ViAUInt16 buf16); +ViStatus _VI_FUNC viMoveIn32Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset, + ViBusSize length, ViAUInt32 buf32); +ViStatus _VI_FUNC viMoveOut32Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset, + ViBusSize length, ViAUInt32 buf32); +ViStatus _VI_FUNC viMoveIn64Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset, + ViBusSize length, ViAUInt64 buf64); +ViStatus _VI_FUNC viMoveOut64Ex (ViSession vi, ViUInt16 space, ViBusAddress64 offset, + ViBusSize length, ViAUInt64 buf64); +#endif + +ViStatus _VI_FUNC viMove (ViSession vi, ViUInt16 srcSpace, ViBusAddress srcOffset, + ViUInt16 srcWidth, ViUInt16 destSpace, + ViBusAddress destOffset, ViUInt16 destWidth, + ViBusSize srcLength); +ViStatus _VI_FUNC viMoveAsync (ViSession vi, ViUInt16 srcSpace, ViBusAddress srcOffset, + ViUInt16 srcWidth, ViUInt16 destSpace, + ViBusAddress destOffset, ViUInt16 destWidth, + ViBusSize srcLength, ViPJobId jobId); + +#if defined(_VI_INT64_UINT64_DEFINED) +ViStatus _VI_FUNC viMoveEx (ViSession vi, ViUInt16 srcSpace, ViBusAddress64 srcOffset, + ViUInt16 srcWidth, ViUInt16 destSpace, + ViBusAddress64 destOffset, ViUInt16 destWidth, + ViBusSize srcLength); +ViStatus _VI_FUNC viMoveAsyncEx (ViSession vi, ViUInt16 srcSpace, ViBusAddress64 srcOffset, + ViUInt16 srcWidth, ViUInt16 destSpace, + ViBusAddress64 destOffset, ViUInt16 destWidth, + ViBusSize srcLength, ViPJobId jobId); +#endif + +ViStatus _VI_FUNC viMapAddress (ViSession vi, ViUInt16 mapSpace, ViBusAddress mapOffset, + ViBusSize mapSize, ViBoolean access, + ViAddr suggested, ViPAddr address); +ViStatus _VI_FUNC viUnmapAddress (ViSession vi); + +#if defined(_VI_INT64_UINT64_DEFINED) +ViStatus _VI_FUNC viMapAddressEx (ViSession vi, ViUInt16 mapSpace, ViBusAddress64 mapOffset, + ViBusSize mapSize, ViBoolean access, + ViAddr suggested, ViPAddr address); +#endif + +void _VI_FUNC viPeek8 (ViSession vi, ViAddr address, ViPUInt8 val8); +void _VI_FUNC viPoke8 (ViSession vi, ViAddr address, ViUInt8 val8); +void _VI_FUNC viPeek16 (ViSession vi, ViAddr address, ViPUInt16 val16); +void _VI_FUNC viPoke16 (ViSession vi, ViAddr address, ViUInt16 val16); +void _VI_FUNC viPeek32 (ViSession vi, ViAddr address, ViPUInt32 val32); +void _VI_FUNC viPoke32 (ViSession vi, ViAddr address, ViUInt32 val32); + +#if defined(_VI_INT64_UINT64_DEFINED) +void _VI_FUNC viPeek64 (ViSession vi, ViAddr address, ViPUInt64 val64); +void _VI_FUNC viPoke64 (ViSession vi, ViAddr address, ViUInt64 val64); +#endif + +/*- Shared Memory Operations ------------------------------------------------*/ + +ViStatus _VI_FUNC viMemAlloc (ViSession vi, ViBusSize size, ViPBusAddress offset); +ViStatus _VI_FUNC viMemFree (ViSession vi, ViBusAddress offset); + +#if defined(_VI_INT64_UINT64_DEFINED) +ViStatus _VI_FUNC viMemAllocEx (ViSession vi, ViBusSize size, ViPBusAddress64 offset); +ViStatus _VI_FUNC viMemFreeEx (ViSession vi, ViBusAddress64 offset); +#endif + +/*- Interface Specific Operations -------------------------------------------*/ + +ViStatus _VI_FUNC viGpibControlREN(ViSession vi, ViUInt16 mode); +ViStatus _VI_FUNC viGpibControlATN(ViSession vi, ViUInt16 mode); +ViStatus _VI_FUNC viGpibSendIFC (ViSession vi); +ViStatus _VI_FUNC viGpibCommand (ViSession vi, ViBuf cmd, ViUInt32 cnt, ViPUInt32 retCnt); +ViStatus _VI_FUNC viGpibPassControl(ViSession vi, ViUInt16 primAddr, ViUInt16 secAddr); + +ViStatus _VI_FUNC viVxiCommandQuery(ViSession vi, ViUInt16 mode, ViUInt32 cmd, + ViPUInt32 response); +ViStatus _VI_FUNC viAssertUtilSignal(ViSession vi, ViUInt16 line); +ViStatus _VI_FUNC viAssertIntrSignal(ViSession vi, ViInt16 mode, ViUInt32 statusID); +ViStatus _VI_FUNC viMapTrigger (ViSession vi, ViInt16 trigSrc, ViInt16 trigDest, + ViUInt16 mode); +ViStatus _VI_FUNC viUnmapTrigger (ViSession vi, ViInt16 trigSrc, ViInt16 trigDest); +ViStatus _VI_FUNC viUsbControlOut (ViSession vi, ViInt16 bmRequestType, ViInt16 bRequest, + ViUInt16 wValue, ViUInt16 wIndex, ViUInt16 wLength, + ViBuf buf); +ViStatus _VI_FUNC viUsbControlIn (ViSession vi, ViInt16 bmRequestType, ViInt16 bRequest, + ViUInt16 wValue, ViUInt16 wIndex, ViUInt16 wLength, + ViPBuf buf, ViPUInt16 retCnt); +ViStatus _VI_FUNC viPxiReserveTriggers(ViSession vi, ViInt16 cnt, ViAInt16 trigBuses, + ViAInt16 trigLines, ViPInt16 failureIndex); + +/*- Attributes (platform independent size) ----------------------------------*/ + +#define VI_ATTR_RSRC_CLASS (0xBFFF0001UL) +#define VI_ATTR_RSRC_NAME (0xBFFF0002UL) +#define VI_ATTR_RSRC_IMPL_VERSION (0x3FFF0003UL) +#define VI_ATTR_RSRC_LOCK_STATE (0x3FFF0004UL) +#define VI_ATTR_MAX_QUEUE_LENGTH (0x3FFF0005UL) +#define VI_ATTR_USER_DATA_32 (0x3FFF0007UL) +#define VI_ATTR_FDC_CHNL (0x3FFF000DUL) +#define VI_ATTR_FDC_MODE (0x3FFF000FUL) +#define VI_ATTR_FDC_GEN_SIGNAL_EN (0x3FFF0011UL) +#define VI_ATTR_FDC_USE_PAIR (0x3FFF0013UL) +#define VI_ATTR_SEND_END_EN (0x3FFF0016UL) +#define VI_ATTR_TERMCHAR (0x3FFF0018UL) +#define VI_ATTR_TMO_VALUE (0x3FFF001AUL) +#define VI_ATTR_GPIB_READDR_EN (0x3FFF001BUL) +#define VI_ATTR_IO_PROT (0x3FFF001CUL) +#define VI_ATTR_DMA_ALLOW_EN (0x3FFF001EUL) +#define VI_ATTR_ASRL_BAUD (0x3FFF0021UL) +#define VI_ATTR_ASRL_DATA_BITS (0x3FFF0022UL) +#define VI_ATTR_ASRL_PARITY (0x3FFF0023UL) +#define VI_ATTR_ASRL_STOP_BITS (0x3FFF0024UL) +#define VI_ATTR_ASRL_FLOW_CNTRL (0x3FFF0025UL) +#define VI_ATTR_RD_BUF_OPER_MODE (0x3FFF002AUL) +#define VI_ATTR_RD_BUF_SIZE (0x3FFF002BUL) +#define VI_ATTR_WR_BUF_OPER_MODE (0x3FFF002DUL) +#define VI_ATTR_WR_BUF_SIZE (0x3FFF002EUL) +#define VI_ATTR_SUPPRESS_END_EN (0x3FFF0036UL) +#define VI_ATTR_TERMCHAR_EN (0x3FFF0038UL) +#define VI_ATTR_DEST_ACCESS_PRIV (0x3FFF0039UL) +#define VI_ATTR_DEST_BYTE_ORDER (0x3FFF003AUL) +#define VI_ATTR_SRC_ACCESS_PRIV (0x3FFF003CUL) +#define VI_ATTR_SRC_BYTE_ORDER (0x3FFF003DUL) +#define VI_ATTR_SRC_INCREMENT (0x3FFF0040UL) +#define VI_ATTR_DEST_INCREMENT (0x3FFF0041UL) +#define VI_ATTR_WIN_ACCESS_PRIV (0x3FFF0045UL) +#define VI_ATTR_WIN_BYTE_ORDER (0x3FFF0047UL) +#define VI_ATTR_GPIB_ATN_STATE (0x3FFF0057UL) +#define VI_ATTR_GPIB_ADDR_STATE (0x3FFF005CUL) +#define VI_ATTR_GPIB_CIC_STATE (0x3FFF005EUL) +#define VI_ATTR_GPIB_NDAC_STATE (0x3FFF0062UL) +#define VI_ATTR_GPIB_SRQ_STATE (0x3FFF0067UL) +#define VI_ATTR_GPIB_SYS_CNTRL_STATE (0x3FFF0068UL) +#define VI_ATTR_GPIB_HS488_CBL_LEN (0x3FFF0069UL) +#define VI_ATTR_CMDR_LA (0x3FFF006BUL) +#define VI_ATTR_VXI_DEV_CLASS (0x3FFF006CUL) +#define VI_ATTR_MAINFRAME_LA (0x3FFF0070UL) +#define VI_ATTR_MANF_NAME (0xBFFF0072UL) +#define VI_ATTR_MODEL_NAME (0xBFFF0077UL) +#define VI_ATTR_VXI_VME_INTR_STATUS (0x3FFF008BUL) +#define VI_ATTR_VXI_TRIG_STATUS (0x3FFF008DUL) +#define VI_ATTR_VXI_VME_SYSFAIL_STATE (0x3FFF0094UL) +#define VI_ATTR_WIN_BASE_ADDR_32 (0x3FFF0098UL) +#define VI_ATTR_WIN_SIZE_32 (0x3FFF009AUL) +#define VI_ATTR_ASRL_AVAIL_NUM (0x3FFF00ACUL) +#define VI_ATTR_MEM_BASE_32 (0x3FFF00ADUL) +#define VI_ATTR_ASRL_CTS_STATE (0x3FFF00AEUL) +#define VI_ATTR_ASRL_DCD_STATE (0x3FFF00AFUL) +#define VI_ATTR_ASRL_DSR_STATE (0x3FFF00B1UL) +#define VI_ATTR_ASRL_DTR_STATE (0x3FFF00B2UL) +#define VI_ATTR_ASRL_END_IN (0x3FFF00B3UL) +#define VI_ATTR_ASRL_END_OUT (0x3FFF00B4UL) +#define VI_ATTR_ASRL_REPLACE_CHAR (0x3FFF00BEUL) +#define VI_ATTR_ASRL_RI_STATE (0x3FFF00BFUL) +#define VI_ATTR_ASRL_RTS_STATE (0x3FFF00C0UL) +#define VI_ATTR_ASRL_XON_CHAR (0x3FFF00C1UL) +#define VI_ATTR_ASRL_XOFF_CHAR (0x3FFF00C2UL) +#define VI_ATTR_WIN_ACCESS (0x3FFF00C3UL) +#define VI_ATTR_RM_SESSION (0x3FFF00C4UL) +#define VI_ATTR_VXI_LA (0x3FFF00D5UL) +#define VI_ATTR_MANF_ID (0x3FFF00D9UL) +#define VI_ATTR_MEM_SIZE_32 (0x3FFF00DDUL) +#define VI_ATTR_MEM_SPACE (0x3FFF00DEUL) +#define VI_ATTR_MODEL_CODE (0x3FFF00DFUL) +#define VI_ATTR_SLOT (0x3FFF00E8UL) +#define VI_ATTR_INTF_INST_NAME (0xBFFF00E9UL) +#define VI_ATTR_IMMEDIATE_SERV (0x3FFF0100UL) +#define VI_ATTR_INTF_PARENT_NUM (0x3FFF0101UL) +#define VI_ATTR_RSRC_SPEC_VERSION (0x3FFF0170UL) +#define VI_ATTR_INTF_TYPE (0x3FFF0171UL) +#define VI_ATTR_GPIB_PRIMARY_ADDR (0x3FFF0172UL) +#define VI_ATTR_GPIB_SECONDARY_ADDR (0x3FFF0173UL) +#define VI_ATTR_RSRC_MANF_NAME (0xBFFF0174UL) +#define VI_ATTR_RSRC_MANF_ID (0x3FFF0175UL) +#define VI_ATTR_INTF_NUM (0x3FFF0176UL) +#define VI_ATTR_TRIG_ID (0x3FFF0177UL) +#define VI_ATTR_GPIB_REN_STATE (0x3FFF0181UL) +#define VI_ATTR_GPIB_UNADDR_EN (0x3FFF0184UL) +#define VI_ATTR_DEV_STATUS_BYTE (0x3FFF0189UL) +#define VI_ATTR_FILE_APPEND_EN (0x3FFF0192UL) +#define VI_ATTR_VXI_TRIG_SUPPORT (0x3FFF0194UL) +#define VI_ATTR_TCPIP_ADDR (0xBFFF0195UL) +#define VI_ATTR_TCPIP_HOSTNAME (0xBFFF0196UL) +#define VI_ATTR_TCPIP_PORT (0x3FFF0197UL) +#define VI_ATTR_TCPIP_DEVICE_NAME (0xBFFF0199UL) +#define VI_ATTR_TCPIP_NODELAY (0x3FFF019AUL) +#define VI_ATTR_TCPIP_KEEPALIVE (0x3FFF019BUL) +#define VI_ATTR_4882_COMPLIANT (0x3FFF019FUL) +#define VI_ATTR_USB_SERIAL_NUM (0xBFFF01A0UL) +#define VI_ATTR_USB_INTFC_NUM (0x3FFF01A1UL) +#define VI_ATTR_USB_PROTOCOL (0x3FFF01A7UL) +#define VI_ATTR_USB_MAX_INTR_SIZE (0x3FFF01AFUL) +#define VI_ATTR_PXI_DEV_NUM (0x3FFF0201UL) +#define VI_ATTR_PXI_FUNC_NUM (0x3FFF0202UL) +#define VI_ATTR_PXI_BUS_NUM (0x3FFF0205UL) +#define VI_ATTR_PXI_CHASSIS (0x3FFF0206UL) +#define VI_ATTR_PXI_SLOTPATH (0xBFFF0207UL) +#define VI_ATTR_PXI_SLOT_LBUS_LEFT (0x3FFF0208UL) +#define VI_ATTR_PXI_SLOT_LBUS_RIGHT (0x3FFF0209UL) +#define VI_ATTR_PXI_TRIG_BUS (0x3FFF020AUL) +#define VI_ATTR_PXI_STAR_TRIG_BUS (0x3FFF020BUL) +#define VI_ATTR_PXI_STAR_TRIG_LINE (0x3FFF020CUL) +#define VI_ATTR_PXI_SRC_TRIG_BUS (0x3FFF020DUL) +#define VI_ATTR_PXI_DEST_TRIG_BUS (0x3FFF020EUL) +#define VI_ATTR_PXI_MEM_TYPE_BAR0 (0x3FFF0211UL) +#define VI_ATTR_PXI_MEM_TYPE_BAR1 (0x3FFF0212UL) +#define VI_ATTR_PXI_MEM_TYPE_BAR2 (0x3FFF0213UL) +#define VI_ATTR_PXI_MEM_TYPE_BAR3 (0x3FFF0214UL) +#define VI_ATTR_PXI_MEM_TYPE_BAR4 (0x3FFF0215UL) +#define VI_ATTR_PXI_MEM_TYPE_BAR5 (0x3FFF0216UL) +#define VI_ATTR_PXI_MEM_BASE_BAR0_32 (0x3FFF0221UL) +#define VI_ATTR_PXI_MEM_BASE_BAR1_32 (0x3FFF0222UL) +#define VI_ATTR_PXI_MEM_BASE_BAR2_32 (0x3FFF0223UL) +#define VI_ATTR_PXI_MEM_BASE_BAR3_32 (0x3FFF0224UL) +#define VI_ATTR_PXI_MEM_BASE_BAR4_32 (0x3FFF0225UL) +#define VI_ATTR_PXI_MEM_BASE_BAR5_32 (0x3FFF0226UL) +#define VI_ATTR_PXI_MEM_BASE_BAR0_64 (0x3FFF0228UL) +#define VI_ATTR_PXI_MEM_BASE_BAR1_64 (0x3FFF0229UL) +#define VI_ATTR_PXI_MEM_BASE_BAR2_64 (0x3FFF022AUL) +#define VI_ATTR_PXI_MEM_BASE_BAR3_64 (0x3FFF022BUL) +#define VI_ATTR_PXI_MEM_BASE_BAR4_64 (0x3FFF022CUL) +#define VI_ATTR_PXI_MEM_BASE_BAR5_64 (0x3FFF022DUL) +#define VI_ATTR_PXI_MEM_SIZE_BAR0_32 (0x3FFF0231UL) +#define VI_ATTR_PXI_MEM_SIZE_BAR1_32 (0x3FFF0232UL) +#define VI_ATTR_PXI_MEM_SIZE_BAR2_32 (0x3FFF0233UL) +#define VI_ATTR_PXI_MEM_SIZE_BAR3_32 (0x3FFF0234UL) +#define VI_ATTR_PXI_MEM_SIZE_BAR4_32 (0x3FFF0235UL) +#define VI_ATTR_PXI_MEM_SIZE_BAR5_32 (0x3FFF0236UL) +#define VI_ATTR_PXI_MEM_SIZE_BAR0_64 (0x3FFF0238UL) +#define VI_ATTR_PXI_MEM_SIZE_BAR1_64 (0x3FFF0239UL) +#define VI_ATTR_PXI_MEM_SIZE_BAR2_64 (0x3FFF023AUL) +#define VI_ATTR_PXI_MEM_SIZE_BAR3_64 (0x3FFF023BUL) +#define VI_ATTR_PXI_MEM_SIZE_BAR4_64 (0x3FFF023CUL) +#define VI_ATTR_PXI_MEM_SIZE_BAR5_64 (0x3FFF023DUL) +#define VI_ATTR_PXI_IS_EXPRESS (0x3FFF0240UL) +#define VI_ATTR_PXI_SLOT_LWIDTH (0x3FFF0241UL) +#define VI_ATTR_PXI_MAX_LWIDTH (0x3FFF0242UL) +#define VI_ATTR_PXI_ACTUAL_LWIDTH (0x3FFF0243UL) +#define VI_ATTR_PXI_DSTAR_BUS (0x3FFF0244UL) +#define VI_ATTR_PXI_DSTAR_SET (0x3FFF0245UL) +#define VI_ATTR_PXI_ALLOW_WRITE_COMBINE (0x3FFF0246UL) +#define VI_ATTR_TCPIP_HISLIP_OVERLAP_EN (0x3FFF0300UL) +#define VI_ATTR_TCPIP_HISLIP_VERSION (0x3FFF0301UL) +#define VI_ATTR_TCPIP_HISLIP_MAX_MESSAGE_KB (0x3FFF0302UL) +#define VI_ATTR_TCPIP_IS_HISLIP (0x3FFF0303UL) + +#define VI_ATTR_JOB_ID (0x3FFF4006UL) +#define VI_ATTR_EVENT_TYPE (0x3FFF4010UL) +#define VI_ATTR_SIGP_STATUS_ID (0x3FFF4011UL) +#define VI_ATTR_RECV_TRIG_ID (0x3FFF4012UL) +#define VI_ATTR_INTR_STATUS_ID (0x3FFF4023UL) +#define VI_ATTR_STATUS (0x3FFF4025UL) +#define VI_ATTR_RET_COUNT_32 (0x3FFF4026UL) +#define VI_ATTR_BUFFER (0x3FFF4027UL) +#define VI_ATTR_RECV_INTR_LEVEL (0x3FFF4041UL) +#define VI_ATTR_OPER_NAME (0xBFFF4042UL) +#define VI_ATTR_GPIB_RECV_CIC_STATE (0x3FFF4193UL) +#define VI_ATTR_RECV_TCPIP_ADDR (0xBFFF4198UL) +#define VI_ATTR_USB_RECV_INTR_SIZE (0x3FFF41B0UL) +#define VI_ATTR_USB_RECV_INTR_DATA (0xBFFF41B1UL) +#define VI_ATTR_PXI_RECV_INTR_SEQ (0x3FFF4240UL) +#define VI_ATTR_PXI_RECV_INTR_DATA (0x3FFF4241UL) + +/*- Attributes (platform dependent size) ------------------------------------*/ + +#if defined(_VI_INT64_UINT64_DEFINED) && defined(_VISA_ENV_IS_64_BIT) +#define VI_ATTR_USER_DATA_64 (0x3FFF000AUL) +#define VI_ATTR_RET_COUNT_64 (0x3FFF4028UL) +#define VI_ATTR_USER_DATA (VI_ATTR_USER_DATA_64) +#define VI_ATTR_RET_COUNT (VI_ATTR_RET_COUNT_64) +#else +#define VI_ATTR_USER_DATA (VI_ATTR_USER_DATA_32) +#define VI_ATTR_RET_COUNT (VI_ATTR_RET_COUNT_32) +#endif + +#if defined(_VI_INT64_UINT64_DEFINED) +#define VI_ATTR_WIN_BASE_ADDR_64 (0x3FFF009BUL) +#define VI_ATTR_WIN_SIZE_64 (0x3FFF009CUL) +#define VI_ATTR_MEM_BASE_64 (0x3FFF00D0UL) +#define VI_ATTR_MEM_SIZE_64 (0x3FFF00D1UL) +#endif +#if defined(_VI_INT64_UINT64_DEFINED) && defined(_VISA_ENV_IS_64_BIT) +#define VI_ATTR_WIN_BASE_ADDR (VI_ATTR_WIN_BASE_ADDR_64) +#define VI_ATTR_WIN_SIZE (VI_ATTR_WIN_SIZE_64) +#define VI_ATTR_MEM_BASE (VI_ATTR_MEM_BASE_64) +#define VI_ATTR_MEM_SIZE (VI_ATTR_MEM_SIZE_64) +#define VI_ATTR_PXI_MEM_BASE_BAR0 (VI_ATTR_PXI_MEM_BASE_BAR0_64) +#define VI_ATTR_PXI_MEM_BASE_BAR1 (VI_ATTR_PXI_MEM_BASE_BAR1_64) +#define VI_ATTR_PXI_MEM_BASE_BAR2 (VI_ATTR_PXI_MEM_BASE_BAR2_64) +#define VI_ATTR_PXI_MEM_BASE_BAR3 (VI_ATTR_PXI_MEM_BASE_BAR3_64) +#define VI_ATTR_PXI_MEM_BASE_BAR4 (VI_ATTR_PXI_MEM_BASE_BAR4_64) +#define VI_ATTR_PXI_MEM_BASE_BAR5 (VI_ATTR_PXI_MEM_BASE_BAR5_64) +#define VI_ATTR_PXI_MEM_SIZE_BAR0 (VI_ATTR_PXI_MEM_SIZE_BAR0_64) +#define VI_ATTR_PXI_MEM_SIZE_BAR1 (VI_ATTR_PXI_MEM_SIZE_BAR1_64) +#define VI_ATTR_PXI_MEM_SIZE_BAR2 (VI_ATTR_PXI_MEM_SIZE_BAR2_64) +#define VI_ATTR_PXI_MEM_SIZE_BAR3 (VI_ATTR_PXI_MEM_SIZE_BAR3_64) +#define VI_ATTR_PXI_MEM_SIZE_BAR4 (VI_ATTR_PXI_MEM_SIZE_BAR4_64) +#define VI_ATTR_PXI_MEM_SIZE_BAR5 (VI_ATTR_PXI_MEM_SIZE_BAR5_64) +#else +#define VI_ATTR_WIN_BASE_ADDR (VI_ATTR_WIN_BASE_ADDR_32) +#define VI_ATTR_WIN_SIZE (VI_ATTR_WIN_SIZE_32) +#define VI_ATTR_MEM_BASE (VI_ATTR_MEM_BASE_32) +#define VI_ATTR_MEM_SIZE (VI_ATTR_MEM_SIZE_32) +#define VI_ATTR_PXI_MEM_BASE_BAR0 (VI_ATTR_PXI_MEM_BASE_BAR0_32) +#define VI_ATTR_PXI_MEM_BASE_BAR1 (VI_ATTR_PXI_MEM_BASE_BAR1_32) +#define VI_ATTR_PXI_MEM_BASE_BAR2 (VI_ATTR_PXI_MEM_BASE_BAR2_32) +#define VI_ATTR_PXI_MEM_BASE_BAR3 (VI_ATTR_PXI_MEM_BASE_BAR3_32) +#define VI_ATTR_PXI_MEM_BASE_BAR4 (VI_ATTR_PXI_MEM_BASE_BAR4_32) +#define VI_ATTR_PXI_MEM_BASE_BAR5 (VI_ATTR_PXI_MEM_BASE_BAR5_32) +#define VI_ATTR_PXI_MEM_SIZE_BAR0 (VI_ATTR_PXI_MEM_SIZE_BAR0_32) +#define VI_ATTR_PXI_MEM_SIZE_BAR1 (VI_ATTR_PXI_MEM_SIZE_BAR1_32) +#define VI_ATTR_PXI_MEM_SIZE_BAR2 (VI_ATTR_PXI_MEM_SIZE_BAR2_32) +#define VI_ATTR_PXI_MEM_SIZE_BAR3 (VI_ATTR_PXI_MEM_SIZE_BAR3_32) +#define VI_ATTR_PXI_MEM_SIZE_BAR4 (VI_ATTR_PXI_MEM_SIZE_BAR4_32) +#define VI_ATTR_PXI_MEM_SIZE_BAR5 (VI_ATTR_PXI_MEM_SIZE_BAR5_32) +#endif + +/*- Event Types -------------------------------------------------------------*/ + +#define VI_EVENT_IO_COMPLETION (0x3FFF2009UL) +#define VI_EVENT_TRIG (0xBFFF200AUL) +#define VI_EVENT_SERVICE_REQ (0x3FFF200BUL) +#define VI_EVENT_CLEAR (0x3FFF200DUL) +#define VI_EVENT_EXCEPTION (0xBFFF200EUL) +#define VI_EVENT_GPIB_CIC (0x3FFF2012UL) +#define VI_EVENT_GPIB_TALK (0x3FFF2013UL) +#define VI_EVENT_GPIB_LISTEN (0x3FFF2014UL) +#define VI_EVENT_VXI_VME_SYSFAIL (0x3FFF201DUL) +#define VI_EVENT_VXI_VME_SYSRESET (0x3FFF201EUL) +#define VI_EVENT_VXI_SIGP (0x3FFF2020UL) +#define VI_EVENT_VXI_VME_INTR (0xBFFF2021UL) +#define VI_EVENT_PXI_INTR (0x3FFF2022UL) +#define VI_EVENT_TCPIP_CONNECT (0x3FFF2036UL) +#define VI_EVENT_USB_INTR (0x3FFF2037UL) + +#define VI_ALL_ENABLED_EVENTS (0x3FFF7FFFUL) + +/*- Completion and Error Codes ----------------------------------------------*/ + +#define VI_SUCCESS_EVENT_EN (0x3FFF0002L) /* 3FFF0002, 1073676290 */ +#define VI_SUCCESS_EVENT_DIS (0x3FFF0003L) /* 3FFF0003, 1073676291 */ +#define VI_SUCCESS_QUEUE_EMPTY (0x3FFF0004L) /* 3FFF0004, 1073676292 */ +#define VI_SUCCESS_TERM_CHAR (0x3FFF0005L) /* 3FFF0005, 1073676293 */ +#define VI_SUCCESS_MAX_CNT (0x3FFF0006L) /* 3FFF0006, 1073676294 */ +#define VI_SUCCESS_DEV_NPRESENT (0x3FFF007DL) /* 3FFF007D, 1073676413 */ +#define VI_SUCCESS_TRIG_MAPPED (0x3FFF007EL) /* 3FFF007E, 1073676414 */ +#define VI_SUCCESS_QUEUE_NEMPTY (0x3FFF0080L) /* 3FFF0080, 1073676416 */ +#define VI_SUCCESS_NCHAIN (0x3FFF0098L) /* 3FFF0098, 1073676440 */ +#define VI_SUCCESS_NESTED_SHARED (0x3FFF0099L) /* 3FFF0099, 1073676441 */ +#define VI_SUCCESS_NESTED_EXCLUSIVE (0x3FFF009AL) /* 3FFF009A, 1073676442 */ +#define VI_SUCCESS_SYNC (0x3FFF009BL) /* 3FFF009B, 1073676443 */ + +#define VI_WARN_QUEUE_OVERFLOW (0x3FFF000CL) /* 3FFF000C, 1073676300 */ +#define VI_WARN_CONFIG_NLOADED (0x3FFF0077L) /* 3FFF0077, 1073676407 */ +#define VI_WARN_NULL_OBJECT (0x3FFF0082L) /* 3FFF0082, 1073676418 */ +#define VI_WARN_NSUP_ATTR_STATE (0x3FFF0084L) /* 3FFF0084, 1073676420 */ +#define VI_WARN_UNKNOWN_STATUS (0x3FFF0085L) /* 3FFF0085, 1073676421 */ +#define VI_WARN_NSUP_BUF (0x3FFF0088L) /* 3FFF0088, 1073676424 */ +#define VI_WARN_EXT_FUNC_NIMPL (0x3FFF00A9L) /* 3FFF00A9, 1073676457 */ + +#define VI_ERROR_SYSTEM_ERROR (_VI_ERROR+0x3FFF0000L) /* BFFF0000, -1073807360 */ +#define VI_ERROR_INV_OBJECT (_VI_ERROR+0x3FFF000EL) /* BFFF000E, -1073807346 */ +#define VI_ERROR_RSRC_LOCKED (_VI_ERROR+0x3FFF000FL) /* BFFF000F, -1073807345 */ +#define VI_ERROR_INV_EXPR (_VI_ERROR+0x3FFF0010L) /* BFFF0010, -1073807344 */ +#define VI_ERROR_RSRC_NFOUND (_VI_ERROR+0x3FFF0011L) /* BFFF0011, -1073807343 */ +#define VI_ERROR_INV_RSRC_NAME (_VI_ERROR+0x3FFF0012L) /* BFFF0012, -1073807342 */ +#define VI_ERROR_INV_ACC_MODE (_VI_ERROR+0x3FFF0013L) /* BFFF0013, -1073807341 */ +#define VI_ERROR_TMO (_VI_ERROR+0x3FFF0015L) /* BFFF0015, -1073807339 */ +#define VI_ERROR_CLOSING_FAILED (_VI_ERROR+0x3FFF0016L) /* BFFF0016, -1073807338 */ +#define VI_ERROR_INV_DEGREE (_VI_ERROR+0x3FFF001BL) /* BFFF001B, -1073807333 */ +#define VI_ERROR_INV_JOB_ID (_VI_ERROR+0x3FFF001CL) /* BFFF001C, -1073807332 */ +#define VI_ERROR_NSUP_ATTR (_VI_ERROR+0x3FFF001DL) /* BFFF001D, -1073807331 */ +#define VI_ERROR_NSUP_ATTR_STATE (_VI_ERROR+0x3FFF001EL) /* BFFF001E, -1073807330 */ +#define VI_ERROR_ATTR_READONLY (_VI_ERROR+0x3FFF001FL) /* BFFF001F, -1073807329 */ +#define VI_ERROR_INV_LOCK_TYPE (_VI_ERROR+0x3FFF0020L) /* BFFF0020, -1073807328 */ +#define VI_ERROR_INV_ACCESS_KEY (_VI_ERROR+0x3FFF0021L) /* BFFF0021, -1073807327 */ +#define VI_ERROR_INV_EVENT (_VI_ERROR+0x3FFF0026L) /* BFFF0026, -1073807322 */ +#define VI_ERROR_INV_MECH (_VI_ERROR+0x3FFF0027L) /* BFFF0027, -1073807321 */ +#define VI_ERROR_HNDLR_NINSTALLED (_VI_ERROR+0x3FFF0028L) /* BFFF0028, -1073807320 */ +#define VI_ERROR_INV_HNDLR_REF (_VI_ERROR+0x3FFF0029L) /* BFFF0029, -1073807319 */ +#define VI_ERROR_INV_CONTEXT (_VI_ERROR+0x3FFF002AL) /* BFFF002A, -1073807318 */ +#define VI_ERROR_QUEUE_OVERFLOW (_VI_ERROR+0x3FFF002DL) /* BFFF002D, -1073807315 */ +#define VI_ERROR_NENABLED (_VI_ERROR+0x3FFF002FL) /* BFFF002F, -1073807313 */ +#define VI_ERROR_ABORT (_VI_ERROR+0x3FFF0030L) /* BFFF0030, -1073807312 */ +#define VI_ERROR_RAW_WR_PROT_VIOL (_VI_ERROR+0x3FFF0034L) /* BFFF0034, -1073807308 */ +#define VI_ERROR_RAW_RD_PROT_VIOL (_VI_ERROR+0x3FFF0035L) /* BFFF0035, -1073807307 */ +#define VI_ERROR_OUTP_PROT_VIOL (_VI_ERROR+0x3FFF0036L) /* BFFF0036, -1073807306 */ +#define VI_ERROR_INP_PROT_VIOL (_VI_ERROR+0x3FFF0037L) /* BFFF0037, -1073807305 */ +#define VI_ERROR_BERR (_VI_ERROR+0x3FFF0038L) /* BFFF0038, -1073807304 */ +#define VI_ERROR_IN_PROGRESS (_VI_ERROR+0x3FFF0039L) /* BFFF0039, -1073807303 */ +#define VI_ERROR_INV_SETUP (_VI_ERROR+0x3FFF003AL) /* BFFF003A, -1073807302 */ +#define VI_ERROR_QUEUE_ERROR (_VI_ERROR+0x3FFF003BL) /* BFFF003B, -1073807301 */ +#define VI_ERROR_ALLOC (_VI_ERROR+0x3FFF003CL) /* BFFF003C, -1073807300 */ +#define VI_ERROR_INV_MASK (_VI_ERROR+0x3FFF003DL) /* BFFF003D, -1073807299 */ +#define VI_ERROR_IO (_VI_ERROR+0x3FFF003EL) /* BFFF003E, -1073807298 */ +#define VI_ERROR_INV_FMT (_VI_ERROR+0x3FFF003FL) /* BFFF003F, -1073807297 */ +#define VI_ERROR_NSUP_FMT (_VI_ERROR+0x3FFF0041L) /* BFFF0041, -1073807295 */ +#define VI_ERROR_LINE_IN_USE (_VI_ERROR+0x3FFF0042L) /* BFFF0042, -1073807294 */ +#define VI_ERROR_LINE_NRESERVED (_VI_ERROR+0x3FFF0043L) /* BFFF0043, -1073807293 */ +#define VI_ERROR_NSUP_MODE (_VI_ERROR+0x3FFF0046L) /* BFFF0046, -1073807290 */ +#define VI_ERROR_SRQ_NOCCURRED (_VI_ERROR+0x3FFF004AL) /* BFFF004A, -1073807286 */ +#define VI_ERROR_INV_SPACE (_VI_ERROR+0x3FFF004EL) /* BFFF004E, -1073807282 */ +#define VI_ERROR_INV_OFFSET (_VI_ERROR+0x3FFF0051L) /* BFFF0051, -1073807279 */ +#define VI_ERROR_INV_WIDTH (_VI_ERROR+0x3FFF0052L) /* BFFF0052, -1073807278 */ +#define VI_ERROR_NSUP_OFFSET (_VI_ERROR+0x3FFF0054L) /* BFFF0054, -1073807276 */ +#define VI_ERROR_NSUP_VAR_WIDTH (_VI_ERROR+0x3FFF0055L) /* BFFF0055, -1073807275 */ +#define VI_ERROR_WINDOW_NMAPPED (_VI_ERROR+0x3FFF0057L) /* BFFF0057, -1073807273 */ +#define VI_ERROR_RESP_PENDING (_VI_ERROR+0x3FFF0059L) /* BFFF0059, -1073807271 */ +#define VI_ERROR_NLISTENERS (_VI_ERROR+0x3FFF005FL) /* BFFF005F, -1073807265 */ +#define VI_ERROR_NCIC (_VI_ERROR+0x3FFF0060L) /* BFFF0060, -1073807264 */ +#define VI_ERROR_NSYS_CNTLR (_VI_ERROR+0x3FFF0061L) /* BFFF0061, -1073807263 */ +#define VI_ERROR_NSUP_OPER (_VI_ERROR+0x3FFF0067L) /* BFFF0067, -1073807257 */ +#define VI_ERROR_INTR_PENDING (_VI_ERROR+0x3FFF0068L) /* BFFF0068, -1073807256 */ +#define VI_ERROR_ASRL_PARITY (_VI_ERROR+0x3FFF006AL) /* BFFF006A, -1073807254 */ +#define VI_ERROR_ASRL_FRAMING (_VI_ERROR+0x3FFF006BL) /* BFFF006B, -1073807253 */ +#define VI_ERROR_ASRL_OVERRUN (_VI_ERROR+0x3FFF006CL) /* BFFF006C, -1073807252 */ +#define VI_ERROR_TRIG_NMAPPED (_VI_ERROR+0x3FFF006EL) /* BFFF006E, -1073807250 */ +#define VI_ERROR_NSUP_ALIGN_OFFSET (_VI_ERROR+0x3FFF0070L) /* BFFF0070, -1073807248 */ +#define VI_ERROR_USER_BUF (_VI_ERROR+0x3FFF0071L) /* BFFF0071, -1073807247 */ +#define VI_ERROR_RSRC_BUSY (_VI_ERROR+0x3FFF0072L) /* BFFF0072, -1073807246 */ +#define VI_ERROR_NSUP_WIDTH (_VI_ERROR+0x3FFF0076L) /* BFFF0076, -1073807242 */ +#define VI_ERROR_INV_PARAMETER (_VI_ERROR+0x3FFF0078L) /* BFFF0078, -1073807240 */ +#define VI_ERROR_INV_PROT (_VI_ERROR+0x3FFF0079L) /* BFFF0079, -1073807239 */ +#define VI_ERROR_INV_SIZE (_VI_ERROR+0x3FFF007BL) /* BFFF007B, -1073807237 */ +#define VI_ERROR_WINDOW_MAPPED (_VI_ERROR+0x3FFF0080L) /* BFFF0080, -1073807232 */ +#define VI_ERROR_NIMPL_OPER (_VI_ERROR+0x3FFF0081L) /* BFFF0081, -1073807231 */ +#define VI_ERROR_INV_LENGTH (_VI_ERROR+0x3FFF0083L) /* BFFF0083, -1073807229 */ +#define VI_ERROR_INV_MODE (_VI_ERROR+0x3FFF0091L) /* BFFF0091, -1073807215 */ +#define VI_ERROR_SESN_NLOCKED (_VI_ERROR+0x3FFF009CL) /* BFFF009C, -1073807204 */ +#define VI_ERROR_MEM_NSHARED (_VI_ERROR+0x3FFF009DL) /* BFFF009D, -1073807203 */ +#define VI_ERROR_LIBRARY_NFOUND (_VI_ERROR+0x3FFF009EL) /* BFFF009E, -1073807202 */ +#define VI_ERROR_NSUP_INTR (_VI_ERROR+0x3FFF009FL) /* BFFF009F, -1073807201 */ +#define VI_ERROR_INV_LINE (_VI_ERROR+0x3FFF00A0L) /* BFFF00A0, -1073807200 */ +#define VI_ERROR_FILE_ACCESS (_VI_ERROR+0x3FFF00A1L) /* BFFF00A1, -1073807199 */ +#define VI_ERROR_FILE_IO (_VI_ERROR+0x3FFF00A2L) /* BFFF00A2, -1073807198 */ +#define VI_ERROR_NSUP_LINE (_VI_ERROR+0x3FFF00A3L) /* BFFF00A3, -1073807197 */ +#define VI_ERROR_NSUP_MECH (_VI_ERROR+0x3FFF00A4L) /* BFFF00A4, -1073807196 */ +#define VI_ERROR_INTF_NUM_NCONFIG (_VI_ERROR+0x3FFF00A5L) /* BFFF00A5, -1073807195 */ +#define VI_ERROR_CONN_LOST (_VI_ERROR+0x3FFF00A6L) /* BFFF00A6, -1073807194 */ +#define VI_ERROR_MACHINE_NAVAIL (_VI_ERROR+0x3FFF00A7L) /* BFFF00A7, -1073807193 */ +#define VI_ERROR_NPERMISSION (_VI_ERROR+0x3FFF00A8L) /* BFFF00A8, -1073807192 */ + +/*- Other VISA Definitions --------------------------------------------------*/ + +#define VI_VERSION_MAJOR(ver) ((((ViVersion)ver) & 0xFFF00000UL) >> 20) +#define VI_VERSION_MINOR(ver) ((((ViVersion)ver) & 0x000FFF00UL) >> 8) +#define VI_VERSION_SUBMINOR(ver) ((((ViVersion)ver) & 0x000000FFUL) ) + +#define VI_FIND_BUFLEN (256) + +#define VI_INTF_GPIB (1) +#define VI_INTF_VXI (2) +#define VI_INTF_GPIB_VXI (3) +#define VI_INTF_ASRL (4) +#define VI_INTF_PXI (5) +#define VI_INTF_TCPIP (6) +#define VI_INTF_USB (7) + +#define VI_PROT_NORMAL (1) +#define VI_PROT_FDC (2) +#define VI_PROT_HS488 (3) +#define VI_PROT_4882_STRS (4) +#define VI_PROT_USBTMC_VENDOR (5) + +#define VI_FDC_NORMAL (1) +#define VI_FDC_STREAM (2) + +#define VI_LOCAL_SPACE (0) +#define VI_A16_SPACE (1) +#define VI_A24_SPACE (2) +#define VI_A32_SPACE (3) +#define VI_A64_SPACE (4) +#define VI_PXI_ALLOC_SPACE (9) +#define VI_PXI_CFG_SPACE (10) +#define VI_PXI_BAR0_SPACE (11) +#define VI_PXI_BAR1_SPACE (12) +#define VI_PXI_BAR2_SPACE (13) +#define VI_PXI_BAR3_SPACE (14) +#define VI_PXI_BAR4_SPACE (15) +#define VI_PXI_BAR5_SPACE (16) +#define VI_OPAQUE_SPACE (0xFFFF) + +#define VI_UNKNOWN_LA (-1) +#define VI_UNKNOWN_SLOT (-1) +#define VI_UNKNOWN_LEVEL (-1) +#define VI_UNKNOWN_CHASSIS (-1) + +#define VI_QUEUE (1) +#define VI_HNDLR (2) +#define VI_SUSPEND_HNDLR (4) +#define VI_ALL_MECH (0xFFFF) + +#define VI_ANY_HNDLR (0) + +#define VI_TRIG_ALL (-2) +#define VI_TRIG_SW (-1) +#define VI_TRIG_TTL0 (0) +#define VI_TRIG_TTL1 (1) +#define VI_TRIG_TTL2 (2) +#define VI_TRIG_TTL3 (3) +#define VI_TRIG_TTL4 (4) +#define VI_TRIG_TTL5 (5) +#define VI_TRIG_TTL6 (6) +#define VI_TRIG_TTL7 (7) +#define VI_TRIG_ECL0 (8) +#define VI_TRIG_ECL1 (9) +#define VI_TRIG_ECL2 (10) +#define VI_TRIG_ECL3 (11) +#define VI_TRIG_ECL4 (12) +#define VI_TRIG_ECL5 (13) +#define VI_TRIG_STAR_SLOT1 (14) +#define VI_TRIG_STAR_SLOT2 (15) +#define VI_TRIG_STAR_SLOT3 (16) +#define VI_TRIG_STAR_SLOT4 (17) +#define VI_TRIG_STAR_SLOT5 (18) +#define VI_TRIG_STAR_SLOT6 (19) +#define VI_TRIG_STAR_SLOT7 (20) +#define VI_TRIG_STAR_SLOT8 (21) +#define VI_TRIG_STAR_SLOT9 (22) +#define VI_TRIG_STAR_SLOT10 (23) +#define VI_TRIG_STAR_SLOT11 (24) +#define VI_TRIG_STAR_SLOT12 (25) +#define VI_TRIG_STAR_INSTR (26) +#define VI_TRIG_PANEL_IN (27) +#define VI_TRIG_PANEL_OUT (28) +#define VI_TRIG_STAR_VXI0 (29) +#define VI_TRIG_STAR_VXI1 (30) +#define VI_TRIG_STAR_VXI2 (31) +#define VI_TRIG_TTL8 (32) +#define VI_TRIG_TTL9 (33) +#define VI_TRIG_TTL10 (34) +#define VI_TRIG_TTL11 (35) + +#define VI_TRIG_PROT_DEFAULT (0) +#define VI_TRIG_PROT_ON (1) +#define VI_TRIG_PROT_OFF (2) +#define VI_TRIG_PROT_SYNC (5) +#define VI_TRIG_PROT_RESERVE (6) +#define VI_TRIG_PROT_UNRESERVE (7) + +#define VI_READ_BUF (1) +#define VI_WRITE_BUF (2) +#define VI_READ_BUF_DISCARD (4) +#define VI_WRITE_BUF_DISCARD (8) +#define VI_IO_IN_BUF (16) +#define VI_IO_OUT_BUF (32) +#define VI_IO_IN_BUF_DISCARD (64) +#define VI_IO_OUT_BUF_DISCARD (128) + +#define VI_FLUSH_ON_ACCESS (1) +#define VI_FLUSH_WHEN_FULL (2) +#define VI_FLUSH_DISABLE (3) + +#define VI_NMAPPED (1) +#define VI_USE_OPERS (2) +#define VI_DEREF_ADDR (3) +#define VI_DEREF_ADDR_BYTE_SWAP (4) + +#define VI_TMO_IMMEDIATE (0L) +#define VI_TMO_INFINITE (0xFFFFFFFFUL) + +#define VI_NO_LOCK (0) +#define VI_EXCLUSIVE_LOCK (1) +#define VI_SHARED_LOCK (2) +#define VI_LOAD_CONFIG (4) + +#define VI_NO_SEC_ADDR (0xFFFF) + +#define VI_ASRL_PAR_NONE (0) +#define VI_ASRL_PAR_ODD (1) +#define VI_ASRL_PAR_EVEN (2) +#define VI_ASRL_PAR_MARK (3) +#define VI_ASRL_PAR_SPACE (4) + +#define VI_ASRL_STOP_ONE (10) +#define VI_ASRL_STOP_ONE5 (15) +#define VI_ASRL_STOP_TWO (20) + +#define VI_ASRL_FLOW_NONE (0) +#define VI_ASRL_FLOW_XON_XOFF (1) +#define VI_ASRL_FLOW_RTS_CTS (2) +#define VI_ASRL_FLOW_DTR_DSR (4) + +#define VI_ASRL_END_NONE (0) +#define VI_ASRL_END_LAST_BIT (1) +#define VI_ASRL_END_TERMCHAR (2) +#define VI_ASRL_END_BREAK (3) + +#define VI_STATE_ASSERTED (1) +#define VI_STATE_UNASSERTED (0) +#define VI_STATE_UNKNOWN (-1) + +#define VI_BIG_ENDIAN (0) +#define VI_LITTLE_ENDIAN (1) + +#define VI_DATA_PRIV (0) +#define VI_DATA_NPRIV (1) +#define VI_PROG_PRIV (2) +#define VI_PROG_NPRIV (3) +#define VI_BLCK_PRIV (4) +#define VI_BLCK_NPRIV (5) +#define VI_D64_PRIV (6) +#define VI_D64_NPRIV (7) +#define VI_D64_2EVME (8) +#define VI_D64_SST160 (9) +#define VI_D64_SST267 (10) +#define VI_D64_SST320 (11) + +#define VI_WIDTH_8 (1) +#define VI_WIDTH_16 (2) +#define VI_WIDTH_32 (4) +#define VI_WIDTH_64 (8) + +#define VI_GPIB_REN_DEASSERT (0) +#define VI_GPIB_REN_ASSERT (1) +#define VI_GPIB_REN_DEASSERT_GTL (2) +#define VI_GPIB_REN_ASSERT_ADDRESS (3) +#define VI_GPIB_REN_ASSERT_LLO (4) +#define VI_GPIB_REN_ASSERT_ADDRESS_LLO (5) +#define VI_GPIB_REN_ADDRESS_GTL (6) + +#define VI_GPIB_ATN_DEASSERT (0) +#define VI_GPIB_ATN_ASSERT (1) +#define VI_GPIB_ATN_DEASSERT_HANDSHAKE (2) +#define VI_GPIB_ATN_ASSERT_IMMEDIATE (3) + +#define VI_GPIB_HS488_DISABLED (0) +#define VI_GPIB_HS488_NIMPL (-1) + +#define VI_GPIB_UNADDRESSED (0) +#define VI_GPIB_TALKER (1) +#define VI_GPIB_LISTENER (2) + +#define VI_VXI_CMD16 (0x0200) +#define VI_VXI_CMD16_RESP16 (0x0202) +#define VI_VXI_RESP16 (0x0002) +#define VI_VXI_CMD32 (0x0400) +#define VI_VXI_CMD32_RESP16 (0x0402) +#define VI_VXI_CMD32_RESP32 (0x0404) +#define VI_VXI_RESP32 (0x0004) + +#define VI_ASSERT_SIGNAL (-1) +#define VI_ASSERT_USE_ASSIGNED (0) +#define VI_ASSERT_IRQ1 (1) +#define VI_ASSERT_IRQ2 (2) +#define VI_ASSERT_IRQ3 (3) +#define VI_ASSERT_IRQ4 (4) +#define VI_ASSERT_IRQ5 (5) +#define VI_ASSERT_IRQ6 (6) +#define VI_ASSERT_IRQ7 (7) + +#define VI_UTIL_ASSERT_SYSRESET (1) +#define VI_UTIL_ASSERT_SYSFAIL (2) +#define VI_UTIL_DEASSERT_SYSFAIL (3) + +#define VI_VXI_CLASS_MEMORY (0) +#define VI_VXI_CLASS_EXTENDED (1) +#define VI_VXI_CLASS_MESSAGE (2) +#define VI_VXI_CLASS_REGISTER (3) +#define VI_VXI_CLASS_OTHER (4) + +#define VI_PXI_ADDR_NONE (0) +#define VI_PXI_ADDR_MEM (1) +#define VI_PXI_ADDR_IO (2) +#define VI_PXI_ADDR_CFG (3) + +#define VI_TRIG_UNKNOWN (-1) + +#define VI_PXI_LBUS_UNKNOWN (-1) +#define VI_PXI_LBUS_NONE (0) +#define VI_PXI_LBUS_STAR_TRIG_BUS_0 (1000) +#define VI_PXI_LBUS_STAR_TRIG_BUS_1 (1001) +#define VI_PXI_LBUS_STAR_TRIG_BUS_2 (1002) +#define VI_PXI_LBUS_STAR_TRIG_BUS_3 (1003) +#define VI_PXI_LBUS_STAR_TRIG_BUS_4 (1004) +#define VI_PXI_LBUS_STAR_TRIG_BUS_5 (1005) +#define VI_PXI_LBUS_STAR_TRIG_BUS_6 (1006) +#define VI_PXI_LBUS_STAR_TRIG_BUS_7 (1007) +#define VI_PXI_LBUS_STAR_TRIG_BUS_8 (1008) +#define VI_PXI_LBUS_STAR_TRIG_BUS_9 (1009) +#define VI_PXI_STAR_TRIG_CONTROLLER (1413) + +/*- Backward Compatibility Macros -------------------------------------------*/ + +#define viGetDefaultRM(vi) viOpenDefaultRM(vi) +#define VI_ERROR_INV_SESSION (VI_ERROR_INV_OBJECT) +#define VI_INFINITE (VI_TMO_INFINITE) +#define VI_NORMAL (VI_PROT_NORMAL) +#define VI_FDC (VI_PROT_FDC) +#define VI_HS488 (VI_PROT_HS488) +#define VI_ASRL488 (VI_PROT_4882_STRS) +#define VI_ASRL_IN_BUF (VI_IO_IN_BUF) +#define VI_ASRL_OUT_BUF (VI_IO_OUT_BUF) +#define VI_ASRL_IN_BUF_DISCARD (VI_IO_IN_BUF_DISCARD) +#define VI_ASRL_OUT_BUF_DISCARD (VI_IO_OUT_BUF_DISCARD) + +/*- National Instruments ----------------------------------------------------*/ + +#if defined(_CVI_DEBUG_) +#pragma soft_reference (viGetAttribute); +#endif + +#define VI_INTF_RIO (8) +#define VI_INTF_FIREWIRE (9) + +#define VI_ATTR_SYNC_MXI_ALLOW_EN (0x3FFF0161UL) /* ViBoolean, read/write */ + +/* This is for VXI SERVANT resources */ + +#define VI_EVENT_VXI_DEV_CMD (0xBFFF200FUL) +#define VI_ATTR_VXI_DEV_CMD_TYPE (0x3FFF4037UL) /* ViInt16, read-only */ +#define VI_ATTR_VXI_DEV_CMD_VALUE (0x3FFF4038UL) /* ViUInt32, read-only */ + +#define VI_VXI_DEV_CMD_TYPE_16 (16) +#define VI_VXI_DEV_CMD_TYPE_32 (32) + +ViStatus _VI_FUNC viVxiServantResponse(ViSession vi, ViInt16 mode, ViUInt32 resp); +/* mode values include VI_VXI_RESP16, VI_VXI_RESP32, and the next 2 values */ +#define VI_VXI_RESP_NONE (0) +#define VI_VXI_RESP_PROT_ERROR (-1) + +/* This is for VXI TTL Trigger routing */ + +#define VI_ATTR_VXI_TRIG_LINES_EN (0x3FFF4043UL) +#define VI_ATTR_VXI_TRIG_DIR (0x3FFF4044UL) + +/* This allows extended Serial support on Win32 and on NI ENET Serial products */ + +#define VI_ATTR_ASRL_DISCARD_NULL (0x3FFF00B0UL) +#define VI_ATTR_ASRL_CONNECTED (0x3FFF01BBUL) +#define VI_ATTR_ASRL_BREAK_STATE (0x3FFF01BCUL) +#define VI_ATTR_ASRL_BREAK_LEN (0x3FFF01BDUL) +#define VI_ATTR_ASRL_ALLOW_TRANSMIT (0x3FFF01BEUL) +#define VI_ATTR_ASRL_WIRE_MODE (0x3FFF01BFUL) + +#define VI_ASRL_WIRE_485_4 (0) +#define VI_ASRL_WIRE_485_2_DTR_ECHO (1) +#define VI_ASRL_WIRE_485_2_DTR_CTRL (2) +#define VI_ASRL_WIRE_485_2_AUTO (3) +#define VI_ASRL_WIRE_232_DTE (128) +#define VI_ASRL_WIRE_232_DCE (129) +#define VI_ASRL_WIRE_232_AUTO (130) + +#define VI_EVENT_ASRL_BREAK (0x3FFF2023UL) +#define VI_EVENT_ASRL_CTS (0x3FFF2029UL) +#define VI_EVENT_ASRL_DSR (0x3FFF202AUL) +#define VI_EVENT_ASRL_DCD (0x3FFF202CUL) +#define VI_EVENT_ASRL_RI (0x3FFF202EUL) +#define VI_EVENT_ASRL_CHAR (0x3FFF2035UL) +#define VI_EVENT_ASRL_TERMCHAR (0x3FFF2024UL) + +/* This is for fast viPeek/viPoke macros */ + +#if defined(NIVISA_PEEKPOKE) + +#if defined(NIVISA_PEEKPOKE_SUPP) +#undef NIVISA_PEEKPOKE_SUPP +#endif + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +/* This macro is supported for all Win32 compilers, including CVI. */ +#define NIVISA_PEEKPOKE_SUPP +#elif (defined(_WINDOWS) || defined(_Windows)) && !defined(_CVI_) && !defined(_NI_mswin16_) +/* This macro is supported for Borland and Microsoft compilers on Win16, but not CVI. */ +#define NIVISA_PEEKPOKE_SUPP +#elif defined(_CVI_) && defined(_NI_sparc_) +/* This macro is supported for Solaris 1 and 2, from CVI only. */ +#define NIVISA_PEEKPOKE_SUPP +#else +/* This macro is not supported on other platforms. */ +#endif + +#if defined(NIVISA_PEEKPOKE_SUPP) + +extern ViBoolean NI_viImplVISA1; +ViStatus _VI_FUNC NI_viOpenDefaultRM (ViPSession vi); +#define viOpenDefaultRM(vi) NI_viOpenDefaultRM(vi) + +#define viPeek8(vi,addr,val) \ + { \ + if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \ + { \ + do (*((ViPUInt8)(val)) = *((volatile ViUInt8 _VI_PTR)(addr))); \ + while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \ + } \ + else \ + { \ + (viPeek8)((vi),(addr),(val)); \ + } \ + } + +#define viPoke8(vi,addr,val) \ + { \ + if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \ + { \ + do (*((volatile ViUInt8 _VI_PTR)(addr)) = ((ViUInt8)(val))); \ + while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \ + } \ + else \ + { \ + (viPoke8)((vi),(addr),(val)); \ + } \ + } + +#define viPeek16(vi,addr,val) \ + { \ + if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \ + { \ + do (*((ViPUInt16)(val)) = *((volatile ViUInt16 _VI_PTR)(addr))); \ + while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \ + } \ + else \ + { \ + (viPeek16)((vi),(addr),(val)); \ + } \ + } + +#define viPoke16(vi,addr,val) \ + { \ + if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \ + { \ + do (*((volatile ViUInt16 _VI_PTR)(addr)) = ((ViUInt16)(val))); \ + while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \ + } \ + else \ + { \ + (viPoke16)((vi),(addr),(val)); \ + } \ + } + +#define viPeek32(vi,addr,val) \ + { \ + if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \ + { \ + do (*((ViPUInt32)(val)) = *((volatile ViUInt32 _VI_PTR)(addr))); \ + while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \ + } \ + else \ + { \ + (viPeek32)((vi),(addr),(val)); \ + } \ + } + +#define viPoke32(vi,addr,val) \ + { \ + if ((NI_viImplVISA1) && (*((ViPUInt32)(vi)))) \ + { \ + do (*((volatile ViUInt32 _VI_PTR)(addr)) = ((ViUInt32)(val))); \ + while (**((volatile ViUInt8 _VI_PTR _VI_PTR)(vi)) & 0x10); \ + } \ + else \ + { \ + (viPoke32)((vi),(addr),(val)); \ + } \ + } + +#endif + +#endif + +#if defined(NIVISA_PXI) || defined(PXISAVISA_PXI) + +#if 0 +/* The following 2 attributes were incorrectly implemented in earlier + versions of NI-VISA. You should now query VI_ATTR_MANF_ID or + VI_ATTR_MODEL_CODE. Those attributes contain sub-vendor information + when it exists. To get both the actual primary and subvendor codes + from the device, you should call viIn16 using VI_PXI_CFG_SPACE. */ +#define VI_ATTR_PXI_SUB_MANF_ID (0x3FFF0203UL) +#define VI_ATTR_PXI_SUB_MODEL_CODE (0x3FFF0204UL) +#endif + +#define VI_ATTR_PXI_USE_PREALLOC_POOL (0x3FFF020FUL) +#endif + +#if defined(NIVISA_USB) + +#define VI_ATTR_USB_BULK_OUT_PIPE (0x3FFF01A2UL) +#define VI_ATTR_USB_BULK_IN_PIPE (0x3FFF01A3UL) +#define VI_ATTR_USB_INTR_IN_PIPE (0x3FFF01A4UL) +#define VI_ATTR_USB_CLASS (0x3FFF01A5UL) +#define VI_ATTR_USB_SUBCLASS (0x3FFF01A6UL) +#define VI_ATTR_USB_ALT_SETTING (0x3FFF01A8UL) +#define VI_ATTR_USB_END_IN (0x3FFF01A9UL) +#define VI_ATTR_USB_NUM_INTFCS (0x3FFF01AAUL) +#define VI_ATTR_USB_NUM_PIPES (0x3FFF01ABUL) +#define VI_ATTR_USB_BULK_OUT_STATUS (0x3FFF01ACUL) +#define VI_ATTR_USB_BULK_IN_STATUS (0x3FFF01ADUL) +#define VI_ATTR_USB_INTR_IN_STATUS (0x3FFF01AEUL) +#define VI_ATTR_USB_CTRL_PIPE (0x3FFF01B0UL) + +#define VI_USB_PIPE_STATE_UNKNOWN (-1) +#define VI_USB_PIPE_READY (0) +#define VI_USB_PIPE_STALLED (1) + +#define VI_USB_END_NONE (0) +#define VI_USB_END_SHORT (4) +#define VI_USB_END_SHORT_OR_COUNT (5) + +#endif + +#define VI_ATTR_FIREWIRE_DEST_UPPER_OFFSET (0x3FFF01F0UL) +#define VI_ATTR_FIREWIRE_SRC_UPPER_OFFSET (0x3FFF01F1UL) +#define VI_ATTR_FIREWIRE_WIN_UPPER_OFFSET (0x3FFF01F2UL) +#define VI_ATTR_FIREWIRE_VENDOR_ID (0x3FFF01F3UL) +#define VI_ATTR_FIREWIRE_LOWER_CHIP_ID (0x3FFF01F4UL) +#define VI_ATTR_FIREWIRE_UPPER_CHIP_ID (0x3FFF01F5UL) + +#define VI_FIREWIRE_DFLT_SPACE (5) + +#if defined(__cplusplus) || defined(__cplusplus__) + } +#endif + +#endif + +/*- The End -----------------------------------------------------------------*/ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/visatype.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/visatype.h new file mode 100644 index 0000000..2eba6eb --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/visatype.h @@ -0,0 +1,205 @@ +/*---------------------------------------------------------------------------*/ +/* Distributed by IVI Foundation Inc. */ +/* */ +/* Do not modify the contents of this file. */ +/*---------------------------------------------------------------------------*/ +/* */ +/* Title : VISATYPE.H */ +/* Date : 07-22-2015 */ +/* Purpose : Fundamental VISA data types and macro definitions */ +/* */ +/*---------------------------------------------------------------------------*/ + +/* IviVisaType.h defines the include guard of this file for backward + * compatibility reasons. Please ensure that changes in this file are reflected + * in IviVisaType.h when necessary. + */ +#ifndef __VISATYPE_HEADER__ +#define __VISATYPE_HEADER__ + +#if defined(_WIN64) +#define _VI_FAR +#define _VI_FUNC __fastcall +#define _VI_FUNCC __fastcall +#define _VI_FUNCH __fastcall +#define _VI_SIGNED signed +#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +#define _VI_FAR +#define _VI_FUNC __stdcall +#define _VI_FUNCC __cdecl +#define _VI_FUNCH __stdcall +#define _VI_SIGNED signed +#elif defined(_CVI_) && defined(_NI_i386_) +#define _VI_FAR +#define _VI_FUNC _pascal +#define _VI_FUNCC +#define _VI_FUNCH _pascal +#define _VI_SIGNED signed +#elif (defined(_WINDOWS) || defined(_Windows)) && !defined(_NI_mswin16_) +#define _VI_FAR _far +#define _VI_FUNC _far _pascal _export +#define _VI_FUNCC _far _cdecl _export +#define _VI_FUNCH _far _pascal +#define _VI_SIGNED signed +#elif (defined(hpux) || defined(__hpux)) && (defined(__cplusplus) || defined(__cplusplus__)) +#define _VI_FAR +#define _VI_FUNC +#define _VI_FUNCC +#define _VI_FUNCH +#define _VI_SIGNED +#else +#define _VI_FAR +#define _VI_FUNC +#define _VI_FUNCC +#define _VI_FUNCH +#define _VI_SIGNED signed +#endif + +#define _VI_ERROR (-2147483647L-1) /* 0x80000000 */ +#define _VI_PTR _VI_FAR * + +/*- VISA Types --------------------------------------------------------------*/ + +#ifndef _VI_INT64_UINT64_DEFINED +#if defined(_WIN64) || ((defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_)) +#if (defined(_MSC_VER) && (_MSC_VER >= 1200)) || (defined(_CVI_) && (_CVI_ >= 700)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)) || defined(__LCC__) || (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__clang__) && (__clang_major__ >= 3)) +typedef unsigned __int64 ViUInt64; +typedef _VI_SIGNED __int64 ViInt64; +#define _VI_INT64_UINT64_DEFINED +#if defined(_WIN64) +#define _VISA_ENV_IS_64_BIT +#else +/* This is a 32-bit OS, not a 64-bit OS */ +#endif +#endif +#elif defined(__GNUC__) && (__GNUC__ >= 3) +#include +#include +typedef u_int64_t ViUInt64; +typedef int64_t ViInt64; +#define _VI_INT64_UINT64_DEFINED +#if defined(LONG_MAX) && (LONG_MAX > 0x7FFFFFFFL) +#define _VISA_ENV_IS_64_BIT +#else +/* This is a 32-bit OS, not a 64-bit OS */ +#endif +#else +/* This platform does not support 64-bit types */ +#endif +#endif + +#if defined(_VI_INT64_UINT64_DEFINED) +typedef ViUInt64 _VI_PTR ViPUInt64; +typedef ViUInt64 _VI_PTR ViAUInt64; +typedef ViInt64 _VI_PTR ViPInt64; +typedef ViInt64 _VI_PTR ViAInt64; +#endif + +#if defined(LONG_MAX) && (LONG_MAX > 0x7FFFFFFFL) +typedef unsigned int ViUInt32; +typedef _VI_SIGNED int ViInt32; +#else +typedef unsigned long ViUInt32; +typedef _VI_SIGNED long ViInt32; +#endif + +typedef ViUInt32 _VI_PTR ViPUInt32; +typedef ViUInt32 _VI_PTR ViAUInt32; +typedef ViInt32 _VI_PTR ViPInt32; +typedef ViInt32 _VI_PTR ViAInt32; + +typedef unsigned short ViUInt16; +typedef ViUInt16 _VI_PTR ViPUInt16; +typedef ViUInt16 _VI_PTR ViAUInt16; + +typedef _VI_SIGNED short ViInt16; +typedef ViInt16 _VI_PTR ViPInt16; +typedef ViInt16 _VI_PTR ViAInt16; + +typedef unsigned char ViUInt8; +typedef ViUInt8 _VI_PTR ViPUInt8; +typedef ViUInt8 _VI_PTR ViAUInt8; + +typedef _VI_SIGNED char ViInt8; +typedef ViInt8 _VI_PTR ViPInt8; +typedef ViInt8 _VI_PTR ViAInt8; + +typedef char ViChar; +typedef ViChar _VI_PTR ViPChar; +typedef ViChar _VI_PTR ViAChar; + +typedef unsigned char ViByte; +typedef ViByte _VI_PTR ViPByte; +typedef ViByte _VI_PTR ViAByte; + +typedef void _VI_PTR ViAddr; +typedef ViAddr _VI_PTR ViPAddr; +typedef ViAddr _VI_PTR ViAAddr; + +typedef float ViReal32; +typedef ViReal32 _VI_PTR ViPReal32; +typedef ViReal32 _VI_PTR ViAReal32; + +typedef double ViReal64; +typedef ViReal64 _VI_PTR ViPReal64; +typedef ViReal64 _VI_PTR ViAReal64; + +typedef ViPByte ViBuf; +typedef ViPByte ViPBuf; +typedef ViPByte _VI_PTR ViABuf; + +typedef ViPChar ViString; +typedef ViPChar ViPString; +typedef ViPChar _VI_PTR ViAString; + +typedef ViString ViRsrc; +typedef ViString ViPRsrc; +typedef ViString _VI_PTR ViARsrc; + +typedef ViUInt16 ViBoolean; +typedef ViBoolean _VI_PTR ViPBoolean; +typedef ViBoolean _VI_PTR ViABoolean; + +typedef ViInt32 ViStatus; +typedef ViStatus _VI_PTR ViPStatus; +typedef ViStatus _VI_PTR ViAStatus; + +typedef ViUInt32 ViVersion; +typedef ViVersion _VI_PTR ViPVersion; +typedef ViVersion _VI_PTR ViAVersion; + +typedef ViUInt32 ViObject; +typedef ViObject _VI_PTR ViPObject; +typedef ViObject _VI_PTR ViAObject; + +typedef ViObject ViSession; +typedef ViSession _VI_PTR ViPSession; +typedef ViSession _VI_PTR ViASession; + +typedef ViUInt32 ViAttr; + +#ifndef _VI_CONST_STRING_DEFINED +typedef const ViChar * ViConstString; +#define _VI_CONST_STRING_DEFINED +#endif + +/*- Completion and Error Codes ----------------------------------------------*/ + +#define VI_SUCCESS (0L) + +/*- Other VISA Definitions --------------------------------------------------*/ + +#define VI_NULL (0) + +#define VI_TRUE (1) +#define VI_FALSE (0) + +/*- Backward Compatibility Macros -------------------------------------------*/ + +#define VISAFN _VI_FUNC +#define ViPtr _VI_PTR + +#endif + +/*- The End -----------------------------------------------------------------*/ + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/vpptype.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/vpptype.h new file mode 100644 index 0000000..88f0453 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/include/vpptype.h @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*/ +/* Distributed by VXIplug&play Systems Alliance */ +/* */ +/* Do not modify the contents of this file. */ +/*---------------------------------------------------------------------------*/ +/* */ +/* Title : VPPTYPE.H */ +/* Date : 02-14-95 */ +/* Purpose : VXIplug&play instrument driver header file */ +/* */ +/*---------------------------------------------------------------------------*/ + +/* IviVisaType.h defines the include guard of this file for backward + * compatibility reasons. Please ensure that changes in this file are reflected + * in IviVisaType.h when necessary. + */ +#ifndef __VPPTYPE_HEADER__ +#define __VPPTYPE_HEADER__ + +#include "visatype.h" + +/*- Completion and Error Codes ----------------------------------------------*/ + +#define VI_WARN_NSUP_ID_QUERY ( 0x3FFC0101L) +#define VI_WARN_NSUP_RESET ( 0x3FFC0102L) +#define VI_WARN_NSUP_SELF_TEST ( 0x3FFC0103L) +#define VI_WARN_NSUP_ERROR_QUERY ( 0x3FFC0104L) +#define VI_WARN_NSUP_REV_QUERY ( 0x3FFC0105L) + +#define VI_ERROR_PARAMETER1 (_VI_ERROR+0x3FFC0001L) +#define VI_ERROR_PARAMETER2 (_VI_ERROR+0x3FFC0002L) +#define VI_ERROR_PARAMETER3 (_VI_ERROR+0x3FFC0003L) +#define VI_ERROR_PARAMETER4 (_VI_ERROR+0x3FFC0004L) +#define VI_ERROR_PARAMETER5 (_VI_ERROR+0x3FFC0005L) +#define VI_ERROR_PARAMETER6 (_VI_ERROR+0x3FFC0006L) +#define VI_ERROR_PARAMETER7 (_VI_ERROR+0x3FFC0007L) +#define VI_ERROR_PARAMETER8 (_VI_ERROR+0x3FFC0008L) +#define VI_ERROR_FAIL_ID_QUERY (_VI_ERROR+0x3FFC0011L) +#define VI_ERROR_INV_RESPONSE (_VI_ERROR+0x3FFC0012L) + + +/*- Additional Definitions --------------------------------------------------*/ + +#define VI_ON (1) +#define VI_OFF (0) + +#endif + +/*- The End -----------------------------------------------------------------*/ + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/lib/visa32.lib b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/lib/visa32.lib new file mode 100644 index 0000000..535ef74 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/lib/visa32.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/res/SimpleReadWrite.2013.ico b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/res/SimpleReadWrite.2013.ico new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/res/SimpleReadWrite.2013.ico differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/res/SimpleReadWrite2013.rc2 b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/res/SimpleReadWrite2013.rc2 new file mode 100644 index 0000000..8dbd92f Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/res/SimpleReadWrite2013.rc2 differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/stdafx.cpp b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/stdafx.cpp new file mode 100644 index 0000000..106aacf --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/stdafx.cpp @@ -0,0 +1,8 @@ + +// stdafx.cpp : ֻ׼ļԴļ +// SimpleReadWrite.2013.pch ΪԤͷ +// stdafx.obj ԤϢ + +#include "stdafx.h" + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/stdafx.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/stdafx.h new file mode 100644 index 0000000..7d8a96a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/stdafx.h @@ -0,0 +1,54 @@ + +// stdafx.h : ׼ϵͳļİļ +// Ǿʹõĵ +// ضĿİļ + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Windows ͷųʹõ +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // ijЩ CString 캯ʽ + +// ر MFC ijЩɷĺԵľϢ +#define _AFX_ALL_WARNINGS + +#include // MFC ͱ׼ +#include // MFC չ + + +#include // MFC Զ + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // MFC Internet Explorer 4 ؼ֧ +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC Windows ؼ֧ +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // Ϳؼ MFC ֧ + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/targetver.h b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/targetver.h new file mode 100644 index 0000000..0afac5b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/SimpleReadWrite.2013/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h ߰汾Ŀ Windows ƽ̨ + +// ҪΪǰ Windows ƽ̨Ӧó WinSDKVer.h +// WIN32_WINNT ΪҪֵ֧ƽ̨Ȼٰ SDKDDKVer.h + +#include diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/ipch/simplereadwrite.2013-6900cd3f/simplereadwrite.ipch b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/ipch/simplereadwrite.2013-6900cd3f/simplereadwrite.ipch new file mode 100644 index 0000000..6606111 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/ipch/simplereadwrite.2013-6900cd3f/simplereadwrite.ipch differ diff --git a/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/ipch/simplereadwrite.2013-7bc6d8d7/simplereadwrite.ipch b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/ipch/simplereadwrite.2013-7bc6d8d7/simplereadwrite.ipch new file mode 100644 index 0000000..7e715ce Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/examples/VISA/vc/SimpleReadWrite.2013/ipch/simplereadwrite.2013-7bc6d8d7/simplereadwrite.ipch differ diff --git a/Driver/UDP5080-100/UNI-T SDK/include/CMD_COMVer2.h b/Driver/UDP5080-100/UNI-T SDK/include/CMD_COMVer2.h new file mode 100644 index 0000000..3446546 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/CMD_COMVer2.h @@ -0,0 +1,551 @@ +/*! + * \created : 2016/12/28 + * \author : M.Yang + * \purpose : ʹUTD2000M\UTD4000M\UTD2000CEX-EDUϵлʹõָ塣 + * ʹã鿴Ӧ͵Эĵ + */ +#ifndef CMD_COMVer2_h__ +#define CMD_COMVer2_h__ + +#ifdef __cplusplus +namespace comApiEx { +#endif + static const int Invalid_CMD = -1; + +#ifdef __cplusplus + static bool IsCMDValid(short cmd) { + return (cmd != Invalid_CMD); + } +#else + static int IsCMDValid(short cmd) + { + return (cmd == Invalid_CMD) ? 0 : 1; + } +#endif + + //@brief : ͨ + //@remarks : ӿڲCHΪ-1ΪEnumݣӦĶshot(2Bytes)ͽжд. + typedef enum _commom_cmd { + //@brief : ȡ豸ͱ + //@remarks : {IO:R}{DATA:comAPICommon::E_DSO_TYPE} + CMD_GET_DSO_TYPE = 0, + //@brief : ü + //@remarks : {IO:W}{DATA:null} + CMD_LOCK_KEYPAD, + //@brief : ü̽ + //@remarks : {IO:W}{DATA:null} + CMD_UNLOCK_KEYPAD, + //@brief : ȡ豸״̬ + //@remarks : {IO:R}{DATA:comApi::E_PROC_STATE from } + CMD_PROCSTATE, + //@brief : ִAUTOSET + //@remarks : {IO:W}{DATA:null} + CMD_AUTOSET, + //@brief : ִǿƴFORCE + //@remarks : {IO:W}{DATA:null} + CMD_TRIG_FORCE, + //@brief : ִеδSINGLE + //@remarks : {IO:W}{DATA:null} + CMD_SINGLE, + //@brief : ִCOARSE + //@remarks : {IO:W}{DATA:null} + CMD_COARSE, + //@brief : ִаPRTSC + //@remarks : {IO:W}{DATA:null} + CMD_PRTSC, + //@brief : + CMD_GET_BITMAP_FILENAME, + //@brief : ȡͼ + //@remarks : {IO:R}{DATA: 2000M/4000M768512Bytes} + CMD_GET_BITMAP_FILEDATA, + + //@brief : ָ + //@remarks : {IO:WR}{DATA<8Bytes>:comAPICommon::Key from } + CMD_KEY, + //@brief : ȡѹĻ + CMD_CAPTURE_SCREEN, + //@brief : д + CMD_DEV_CONFIG, + //@brief : ѯ豸ʾ + CMD_IDN, + //@brief : ѯЭ汾š + CMD_CVER, + + //@brief : ȡĻϢ + //@remarks : {IO:R}{DATA<20Bytes>:comApiEx::SCREEN_INFO from } + CMD_GET_SCREEN_INFO = 50, //SCREEN_INFO + //@brief : short 1: usb connection state is ok; other: usb connection state is not ok (ok) + //@remarks : + CMD_GET_USB_CONNECTION_STATE, + //@brief : õǰƵʼֵ + //@remarks : {IO:R}{DATA:comApiEx::SignalFreq from } + CMD_GET_CYMOMETER_VALUE, + //@brief : õǰѡеͨ + //@remarks : short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other (ok) + CMD_GET_CURRENT_ACTIVE_CHANNEL, //short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other (ok) + //@brief : õ豸˵ǰвIJ˵ + //@remarks : short 0: CH1 menu; 1: CH2 menu; 2: MATH or FFT menu; -1: other menu (ok) + CMD_GET_CURRENT_ACTIVE_MENU, + //@brief : ȡǰ˵Ƿʾ + //@remarks : short 0: current menu is not display; 1: current menu is display (ok) + CMD_GET_CURRENT_MENU_SHOW_STATE, + CMD_GET_SAMPLE, + //@brief : UǷ + //@remarks : {IO:R}{DATA: 0 δ룻 1 } + CMD_GET_USBDISK_STATE, + + //{acquire + //@brief : ɼģʽ + //@remarks : {IO:WR}{DATA:comApiEx::E_ACQ_MODE from } + CMD_ACQ_MODE = 400, + //@brief : ƽ + //@remarks : {IO:WR}{DATA: averageNum} + //ʵʴùʽ<2^(averageNum + 1)>, : {(0: 2), (1: 4), (2: 8), (3: 16), (4: 32), (5: 64), (6: 128), (7: 256)} + CMD_ACQ_AVERAGE_NUM, + //@brief : ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_SAMPLE_MODE from } + CMD_ACQ_SAMPLING, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_ACQ_SAV_DEPTH from } + CMD_ACQ_DEPTH, + //@brief : ٲɼ + //@remarks : {IO:WR}{DATA: 0 ر 1 } + CMD_ACQ_FAST, + //} + + //{trigger + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_TYPE from } + CMD_TRIG_TYPE = 500, + //@brief : Դ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_SOURCE from } + CMD_TRIG_SOURCE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_TIRG_COUPLING from } + CMD_TRIG_COUPLING, + //@brief : ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_MODE from } + CMD_TRIG_METHOD, + //@brief : شбʴ-б + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_EDGE_SLOPE(ء) E_SLOP_POLARITY(б) from } + CMD_TRIG_SLOPE_TYPE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_PULSE_POLAR from } + CMD_TRIG_PULSE_POLAR, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_PULSE_CONDITION from } + CMD_TRIG_PULSE_COND, + //@brief : ʱ + //@remarks : {IO:WR}{DATA: ֵstep, 㹫ʽ(t = K * step), һK = 4} + CMD_TRIG_PULSE_TIME, + //@brief : Ƶ-Ƶʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_VIDEO_STANDARD from } + CMD_TRIG_VIDEO_STD, + //@brief : Ƶ-ͬ + //@remarks : {IO:WR}{DATA: comApiEx::E_TRIG_VIDEO_SYNC_MODE from } + CMD_TRIG_VIDEO_SYNC, + //@brief : Ƶ-ָ + //@remarks : {IO:WR}{DATA: } + CMD_TRIG_VIDEO_LINE_NUMBER, + //@brief : бʴ-б + //@remarks : {IO:WR}{DATA: comApiEx::E_SLOP_WHEN from } + CMD_TRIG_SLOPE_COND, + //@brief : бʴ-ʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_SLOPE_TIME, + //@brief : бʴ-ֵ(Ƿ/µֵ) + //@remarks : {IO:WR}{DATA: comApiEx::E_SLOP_THRESHOLD from } + CMD_TRIG_SLOPE_THRESHOLD, + //@brief : бʴ-ѹ + //@remarks : {IO:R}{DATA: ַʽȡ} + CMD_TRIG_SLOPE_VT, + + //@brief : ʱ1 CEM""><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵstep, 㹫ʽ(t = K * step), һK = 4} + CMD_TRIG_PULSE_LT_TIME, + //@brief : бʴ-ʱ2 CEM"б"><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_SLOPE_LT_TIME, + + //@brief : - + //@remarks : {IO:WR}{DATA: comApiEx::E_WINDOE_WHEN from } + CMD_TRIG_WINDOW_COND, + //@brief : -ʱ + //@remarks :{IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_WINDOW_TIME, + //@brief : Ƿ- + //@remarks : {IO:WR}{DATA: comApiEx::E_RUNT_WHEN from } + CMD_TRIG_RUNT_COND, + //@brief : Ƿ-ʱ + //@remarks :{IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_RUNT_TIME, + //@brief : Ƿ-ʱ1 CEM""><"ڶʱ + //@remarks : {IO:WR}{DATA: ֵ 㹫ʽΪt = K * step, һK = 4;} + CMD_TRIG_RUNT_LT_TIME, + //} + + + //{display + //@brief : DISPLAY + //@remarks : {IO:WR}{DATA: comApiEx::E_DISPLAY_TYPE from } + CMD_DISPLAY_TYPE = 600, + //@brief : DISPLAY ʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_DISPLAY_FORMAT from } + CMD_DISPLAY_FORMAT, + //@brief : DISPLAY դ + //@remarks : {IO:WR}{DATA: comApiEx::E_Display_Graticule from } + CMD_DISPLAY_GRID, + //@brief : DISPLAY ʱ + //@remarks : {IO:WR}{DATA: comApiEx::E_Dislay_PersistTime from } + CMD_DISPLAY_PERSIST, + //@brief : DISPLAY + //@remarks : {IO:WR}{DATA: һ 1 - 100 2000M4000M step[0,49] = curStep * 2 + 2} + CMD_DISPLAY_WAVE_LUM, + //} + + //{cursor + //@brief : Cursor + //@remarks : {IO:WR}{DATA: comApiEx::E_CURSOR_TYPE from } + CMD_CURSOR_TYPE, + //@brief : Cursor ģʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_CURSOR_MODE from } + CMD_CURSOR_MODE, + //@brief : Cursor ģʽ + //@remarks : {IO:WR}{DATA: ʱ comApiEx::E_CURSOR_V_UNIT ѹ : comApiEx::E_CURSOR_H_UNIT from } + CMD_CURSOR_UNIT, + //@brief : Cursor ׼ + //@remarks : {IO:WR}{DATA: E_CURSOR_POS from } + CMD_CURSOR_BASE, + //@brief : Cursor Aλõ + //@remarks : {IO:WR}{DATA : ˮƽߣΪ0һΪ25ֱߣΪ350һΪ50} + CMD_CURSOR_A_POS, + //@brief : Cursor Bλõ + //@remarks : {IO:WR}{DATA : ˮƽߣΪ0һΪ25ֱߣΪ350һΪ50 } + CMD_CURSOR_B_POS, + //} + + //{windows + CMD_WIN_TYPE, // (ok) + CMD_WIN_HOLDOFF, // + //} + + //{storage + //@brief : Storage + //@remarks : {IO:WR}{DATA: comApiEx::E_STORAGE_TYPE from } + CMD_STORAGE_TYPE = 700, + //@brief : Storage ļ + //@remarks : {IO:WR}{DATA: } + CMD_STORAGE_FILE_NAME, + //@brief : Storage ο-Դ + //@remarks : {IO:WR}{DATA: comApiEx::E_CHANNEL_ID from } + CMD_STORAGE_REFWAVE_SOURCE, + //@brief : Storage ο-ļʽ + //@remarks : {IO:WR}{DATA: comApiEx::E_STORAGE_REFWAVE_FILE_FORMAT from } + CMD_STORAGE_REFWAVE_FILE_FORMAT, + //@brief : ȡô洢ļб + //@remarks :{IO:WR}{DATA: comApiEx::FileList_Flash from } + CMD_STORAGE_GET_FILE_LIST_FLASH, // (ok) + //@brief : ȡô洢ļб + //@remarks :{IO:WR}{DATA: comApiEx::FileList_USB from } + CMD_STORAGE_GET_FILE_LIST_USB, + //@brief : ִSAVE浽Flash. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_SAVE, + //@brief : ִLOADFlash. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_LOAD, + //@brief : ִImportU̼. + //@remarks : {IO:W}{DATA : ļ洢λ} + CMD_STORAGE_IMPORT, + //@brief : ִExport + //@remarks : {IO:W}{DATA} + CMD_STORAGE_EXPORT, + //@brief : ѯǷѱ + //@remarks : {IO:R}{DATA : 0 ڣ 1 } + CMD_STORAGE_REFSETTING_EXIST, + //@brief : 洢λ + //@remarks : {IO:WR}{DATA : λ} + CMD_STORAGE_POS, + //} + + //{measure + MEASURE_ALL = 800, + MEASURE_CLEAR, + MEASURE_CUSTOMIZE, + MEASURE_INDICATOR, + MEASURE_DELAY_FROM, + MEASURE_DELAY_FEDGE, + MEASURE_DELAY_TO, + MEASURE_DELAY_TEGDE, + MEASURE_DELAY_OK, + MEASURE_PHASE_FROM, + + MEASURE_PHASE_TO, + MEASURE_PHASE_OK, + //} + + //for UTD2102CEX + CMD_MEASURE_SOURCE, + CMD_MEASURE_STATISTICS, + + //{utility + //@brief : ִУ + //@remarks : {IO:W}{DATA} + CMD_UTILITY_SELF_CALIBRATE = 1000, + CMD_UTILITY_SYSTEM_INFO, //(ok) + //@brief : ִClear + //@remarks : {IO:W}{DATA} + CMD_UTILITY_CLEAR_INFO, + //@brief : ִлָ + //@remarks : {IO:W}{DATA} + CMD_UTILITY_RESET_TO_FACTORY, + //@brief : Աȶ + //@remarks : {IO:WR}{DATA} + CMD_UTILITY_CONTRAST, + //@brief : л + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Language from } + CMD_UTILITY_LANGUAGE, + //@brief : + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Skin from } + CMD_UTILITY_SKIN, + //@brief : ˵ʾʱ + //@remarks : {IO:WR}{DATA: comApiEx::E_Utility_Menu_Display_Time from } + CMD_UTILITY_MENU_DISP, + //@brief : + //@remarks : {IO:WR}{DATA} + CMD_UTILITY_GRID_LUM, + //@brief : Ƶʼƿ + //@remarks : {IO:WR}{DATA:comApiEx:: E_SWITCH_STATE from } + CMD_UTILITY_CYMOMETER, + + CMD_UTILITY_AUTOSET_CHANNEL, + CMD_UTILITY_AUTOSET_ACQUIRE, + CMD_UTILITY_AUTOSET_TRIG, + CMD_UTILITY_AUTOSET_SIGNAL, + //} + + //{record + CMD_DSO_RECORD_START, + CMD_DSO_RECORD_STOP, + CMD_DSO_RECORD_REPLAY, + CMD_DSO_RECORD_CLEAR, + //} + + //{ + CMD_UTILITY_SQUARE_WAVE, + CMD_UTILITY_SLEEP_TIME, + CMD_UTILITY_MEASURE_UNIT, + //} + + //{ + CMD_SYS_TIME_SWITCH = 1100, + CMD_SYS_TIME, + //} + + //{pass fail + CMD_PASS_FAIL_ALLOW_TEST, + CMD_PASS_FAIL_OUTPUT, + CMD_PASS_FAIL_SOURCE, + CMD_PASS_FAIL_DISP_INFO, + CMD_PASS_FAIL_OPERATION, + CMD_PASS_FAIL_STOP_TYPE, + CMD_PASS_FAIL_STOP_COND, + CMD_PASS_FAIL_STOP_THRESHOLD, + CMD_PASS_FAIL_TEMPLATE_WAVEREF, + CMD_PASS_FAIL_TEMPLATE_REFLOAD, + CMD_PASS_FAIL_TEMPLATE_HRANGE, + CMD_PASS_FAIL_TEMPLATE_VRANGE, + CMD_PASS_FAIL_TEMPLATE_CREATE, + //} + + //@brief : ȡͨݰʽĵ + //@remarks : + CMD_GET_DISPLAY_DATA = 1200, //get ch1, ch2, math, ref a/b data ok + //ͬDSO״̬ͣDSOAttrStateͿͶͬ + CMD_SYNC_DSO, + + //ʱDSOݡ + CMD_PERIOD_MSG2DSO, + + //{CEX-EDUʹ + //CEX-EDUʹãͽҪȡRECݵͷ׼ + CMD_DSO_RECORD_HEADER_READY = 1400, + //CEX-EDUʹãȡRECͷ + CMD_DSO_RECORD_HEADER, + //CEX-EDUʹãͽҪȡREC׼ + CMD_DSO_RECORD_DATA_READY, + //CEX-EDUʹãȡRECݿ顣 + CMD_DSO_RECORD_DATA, + //CEX-EDUʹãжϵǰRECǷЧ + CMD_DSO_RECORD_DATA_VALID, + //} + + //{2000M-special + CMD_VARDEPTH_SAMPLE_RATE = 1420, + CMD_VARDEPTH_SAVE_DEPTH, + CMD_VARDEPTH_PRE_TRIG_TIME, + CMD_VARDEPTH_AUTO_TRIG_TIME, + //} + + // + CMD_MESSAGE = 1430, + // + CMD_DUMP_BEGIN = 1440, + CMD_DUMP_ID = CMD_DUMP_BEGIN, + CMD_DUMP_END = 1500, //#TODO:Ҫṩ룬ͽCEX2000Mıôṩͳһ롣 + }COMMON_CMD; + + //@brief : ͨ + //@remarks : + typedef enum _channel_cmd + { + CH_Invalid_CMD = -1, + //@brief : ͨ + //@remarks : {IO:WR}{DATA:E_CH_COUPLING_TYPE} + CH_ATTR_COUPLING = 0, + //@brief : + //@remarks : {IO:WR}{DATA:E_CH_BANDLIMIT} + CH_ATTR_BAND_WIDTH, + //@brief : + //@remarks : + CH_ATTR_VOLT_SCALE, + //@brief : Ŵ + //@remarks : {IO:WR}{DATA:CH_PROBE} + CH_ATTR_PROBE, + //@brief : + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_INVERT, + //@brief : ƫõѹ + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_PRE_BIAS_VOLT_SWITCH, + //@brief : ƫõѹֵ + //@remarks : {IO:W}{DATA: +1 increase; -1 decrease;} + CH_ATTR_PRE_BIAS_VOLT_VALUE, + //@brief : ƫõѹ + //@remarks : {IO:W}{DATA:null} + CH_ATTR_PRE_BIAS_VOLT_TOZERO, + + //@brief : ͨ + //@remarks : {IO:WR}{DATA:E_SWITCH_STATE} + CH_ATTR_CHANNEL_SWITCH = 100, + //@brief : ֱλ + //@remarks : {IO:WR}{DATA: UTD2000M -> ϵΪ [-100 , 100], CEX -> µ[28,128]} + CH_ATTR_VERTICAL_POS, + //@brief : ֱλù + //@remarks : {IO:W}{DATA:null} + CH_ATTR_VERTICAL_POS_TOZERO, + //@brief : Ԥλ + //@remarks : {IO:WR}{DATA: UTD2000M -> ĻмΪ350һΪ50} + CH_ATTR_TRIG_DEPTH, + //@brief : Ԥȹ + //@remarks : {IO:W}{DATA:null} + CH_ATTR_TRIG_DEPTH_TOZERO, + //@brief : ƽϢ + //@remarks : {IO:R}{DATA:comApiEx::CellBaseValue} + // ֻͨһƽ Ϊ comApiEx::CellBaseValues TrigVolt; + // бʴƽ Ϊ comApiEx::CellBaseValues TrigVolt[2]; + CH_ATTR_TRIG_LEVEL, + //@brief : ƽλ + //@remarks : {IO:WR}{DATA: ͨΪ0㣬¸ÿ25} + CH_ATTR_TRIG_LEVEL_POS, + //@brief : ƽλù + //@remarks : {IO:WR}{DATA: ͨΪ0㣬¸ÿ25} + CH_ATTR_TRIG_LEVEL_TOZERO, + //@brief : Ϣ + //@remarks : {IO:R}{DATA: CellBaseValue} + CH_ATTR_VOLT_AMPLITUDE, + //񵲵λΪshort + //@brief : 񵲵λ + //@remarks : {IO:WR}{DATA: +1 increase; -1 decrease; other : code } + CH_ATTR_VOLT_AMPLITUDE_LEVEL, + //ʱλΪshortֻã + //@brief : ʱλ + //@remarks : {IO:W}{DATA: E_TIMEBASE_LEVEL } + CH_ATTR_TIME_BASE, + //@brief : ȡʱʱ + //@remarks : {IO:R}{DATA: CellBaseValue} + CH_ATTR_TIME_BASE_VALUE, + + //@brief : MATH + //@remarks : {IO:WR}{DATA: E_MATH_TYPE } + CH_MATH_TYPE = 200, + //@brief : MATHԴ1 + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_MATH_OP1, + //MATHͣͣshort + //@brief : MATH + //@remarks : {IO:WR}{DATA: E_MATH_OP_SIGN } + CH_MATH_OP, + //@brief : MATHԴ2 + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_MATH_OP2, + //@brief : FFTԴ + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_FFT_SRC, + //@brief : FFT + //@remarks : {IO:WR}{DATA: E_FFT_WINDOW } + CH_FFT_WINDOW, + //@brief : FFTֱλ + //@remarks : {IO:WR}{DATA: E_FFT_UNIT } + CH_FFT_VSCALE, + //@brief : ȡFFTƵֵ + //@remarks : {IO:R}{DATA: SignalFreq } + CH_FFT_FREQ, + //@brief : ˲ + //@remarks : {IO:WR}{DATA: E_FILTER_TYPE } + CH_FILTER_TYPE, + //@brief : Ƶ + //@remarks : {IO:WR}{DATA: ֵƵֵҪм} + CH_FILTER_FREQ_LOW, + //@brief : Ƶ + //@remarks : {IO:WR}{DATA: ֵƵֵҪм} + CH_FILTER_FREQ_HIGH, + //@brief : ˲Դ + //@remarks : {IO:WR}{DATA: E_CHANNEL_ID } + CH_FILTER_SRC, + + //@brief : REFص() + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_LOAD_FROM_FLASH = 300, + //@brief : REF벨(USB) + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_LOAD_FROM_USB, + //@brief : REF洢λõ + //@remarks : {IO:W}{DATA: Ϊ洢λֵ } + CH_REF_POS, + //@brief : жijһλòǷڣλCH_REF_POSõģ + //@remarks : {IO:R}{DATA: Ϊ洢λֵ } + CH_REF_POS_WAVE_EXIST, + //@brief : д洢 + //@remarks : {IO:W}{DATA : null } + CH_REF_CLEAR, + + //[] + CH_DISPLAY_DATA = 400, + //[]ȡԭʼݣCH_GET_SAV_DATA + CH_ORIGIN_DATA, + + //@brief : ȡSAVļݣݸʽ [4Bytes ļ] + [ļ] + //@remarks : ʹ÷ʽĵʾ + // UTD2102CMUTD4000M ӦСΪ32768Bytes UTD2102CEX-EDUӦ32000Bytes + CH_GET_SAV_DATA, + + //{2102CM-x + CH_VARDEPTH_ENABLE = 500, + CH_VARDEPTH_SAMPLE_RATE, + + CH_VARDEPTH_DATA_READY = 510, + CH_VARDEPTH_DATA, + + CH_VOLT_AMPLITUDE_LEVEL, //ѹֵãֱӽ0~15λ + CH_PRE_BIAS_VOLT_VALUE, //ƫõѹãֱõѹȸֵ + + CH_VARDEPTH_TRIG_READY, //ͨDSO׽źŵĻ + //} + }CHAN_CMD; + +#ifdef __cplusplus +} +#endif + +#endif // CMD_COMVer2_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/include/ItemCode_COMVer2.h b/Driver/UDP5080-100/UNI-T SDK/include/ItemCode_COMVer2.h new file mode 100644 index 0000000..e5b817a --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/ItemCode_COMVer2.h @@ -0,0 +1,449 @@ +/*! + * \created : 2016/12/28 + * \author : M.Yang + * \purpose : ģUTD2000M\UTD4000M\UTD2000CEX-EDUϵлʹõѡͲѡ붨塣 + */ +#ifndef ItemCode_COMVer2_h__ +#define ItemCode_COMVer2_h__ + +#ifdef __cplusplus +namespace comApiEx +{ +#endif + +enum E_SWITCH_STATE +{ + SWITCH_OFF, + SWITCH_ON, +}; + +#pragma region Channel +typedef enum{ + CH_Invalid_ID = -1, + CH_1_ID = 0, + CH_2_ID, + CH_MATH_ID, + CH_REF_A_ID, + CH_REF_B_ID, + CH_MAX_CNT, +}E_CHANNEL_ID; + +enum E_REF_SRC +{ + REF_A = 0, + REF_B, +}; + +enum E_CH_COUPLING_TYPE +{ + CH_COUPLING_DC = 0, + CH_COUPLING_AC, + CH_COUPLING_GND, +}; + +enum E_CH_BANDLIMIT +{ + CH_BANDLIMIT_FULL, + CH_BANDLIMIT_HALF, + CH_BANDLIMIT_20MHZ, +}; + +// +typedef enum { + CH_PROBE_1X = 0, + CH_PROBE_10X, + CH_PROBE_100X, + CH_PROBE_1000X, + + //2017-3-13CEM + CH_PROBE_2X, + CH_PROBE_5X, + CH_PROBE_20X, + CH_PROBE_50X, + CH_PROBE_200X, + CH_PROBE_500X, + CH_PROBE_1MX, + CH_PROBE_2MX, + CH_PROBE_5MX, + CH_PROBE_10MX, + CH_PROBE_20MX, + CH_PROBE_50MX, + CH_PROBE_100MX, + CH_PROBE_200MX, + CH_PROBE_500MX, +}CH_PROBE; + +#pragma endregion Channel + +#pragma region Trigger +////////////////////////////Trigger/////////////////////////////////// +//2017-3-13ӴںǷ +enum E_TRIG_TYPE +{ + TRIG_TYPE_EDGE = 0, //: + TRIG_TYPE_PLUSE_WIDTH, //: + TRIG_TYPE_VIDEO, //: Ƶ + TRIG_TYPE_SLOPE, //: б + TRIG_TYPE_WINDOW, //: ڣ + TRIG_TYPE_RUNT, //: Ƿ +}; + +enum E_TRIG_SOURCE +{ + TRIG_CH1 = CH_1_ID, + TRIG_CH2 = CH_2_ID, + TRIG_EXT, + TRIG_EXT_5, //EXT/5 + TRIG_AC_LINE = 4, + TRIG_ALTER, +}; + +enum E_TIRG_COUPLING +{ + TIRG_COUPLING_DC = 0, + TIRG_COUPLING_AC, + TIRG_COUPLING_L_RESTRAIN, //trigger coupling low frequency restrain + TIRG_COUPLING_H_RESTRAIN, //trigger coupling high frequency restrain + TIRG_COUPLING_NOISE_REJ, // +}; + +enum E_TRIG_MODE +{ + TRIG_MODE_AUTO = 0, + TRIG_MODE_NORMAL, + TRIG_MODE_SINGLE, +}; + +enum E_TRIG_EDGE_SLOPE +{ + TRIG_EDGE_SLOP_RISE = 0, + TRIG_EDGE_SLOP_FALL, + TRIG_EDGE_SLOP_RISE_FALL, +}; + +enum E_PULSE_POLAR +{ + PULSE_POLAR_N = 0, + PULSE_POLAR_P , +}; + +//2017-3-13PULSE_CONDITION_GT_LT +enum E_PULSE_CONDITION +{ + PULSE_CONDITION_LT = 0, //pulse condition less than + PULSE_CONDITION_GT, //pulse condition greater than + PULSE_CONDITION_ET, //pulse condition equal to + + PULSE_CONDITION_NO_EQUAL, //pulse not equal to , add by yzz [RESERVE] + PULSE_CONDITION_GT_LT, +}; + +enum E_TRIG_VIDEO_STANDARD +{ + TRIG_Video_NTSC = 0, + TRIG_Video_PAL, +}; + +//Ƶ-ͬʽ(0)ż(1)(2)ָ(3) +enum E_TRIG_VIDEO_SYNC_MODE +{ + TRIG_Video_SyncMode_Odd = 0, + TRIG_Video_SyncMode_Even, + TRIG_Video_SyncMode_ALL, + TRIG_Video_SyncMode_Specified, +}; + +enum E_SLOP_POLARITY +{ + SLOP_POLAR_FALL = 0, + SLOP_POLAR_RISE, +}; + +//2017-3-13SLOP_WHEN_GT_LT +enum E_SLOP_WHEN +{ + SLOP_WHEN_LT = 0, + SLOP_WHEN_GT, + SLOP_WHEN_Equal, + SLOP_WHEN_GT_LT, +}; + +enum E_SLOP_THRESHOLD +{ + SLOP_THRESHOLD_LOW = 0, + SLOP_THRESHOLD_HIGH, + SLOP_THRESHOLD_LOW_HIGH, +}; + +// +enum E_WINDOE_WHEN +{ + TRIG_SCOPE_WHEN_ENTER = 0, + TRIG_SCOPE_WHEN_EXIT, + TRIG_SCOPE_WHEN_TIME, +}; +// Ƿ +enum E_RUNT_WHEN +{ + TRIG_RUNT_WHEN_NO = 0, + TRIG_RUNT_WHEN_GT, + TRIG_RUNT_WHEN_LT, + TRIG_RUNT_WHEN_GT_LT, +}; + +#pragma endregion Trigger + +#pragma region Math +/////////////////////////////Math////////////////////////////////////// +enum E_MATH_TYPE +{ + MATH_TYPE_MATH = 0, + MATH_TYPE_FFT, + MATH_TYPE_FILTER, +}; + +enum E_MATH_OP_SIGN +{ + OP_SIGN_ADD = 0, + OP_SIGN_SUB, + OP_SIGN_MULTIPLY, + OP_SIGN_DIVIDE, +}; + +enum E_FFT_WINDOW +{ + FFT_WIN_HAMMING = 0, + FFT_WIN_BLACKMAN, + FFT_WIN_RECTANGLE, + FFT_WIN_HANNING +}; + +enum E_FFT_UNIT +{ + FFT_UNIT_VRMS = 0, + FFT_UNIT_DBVRMS, +}; + +enum E_FILTER_TYPE +{ + FILTER_LOW = 0, + FILTER_HIGH, + FILTER_BAND, + FILTER_BAND_STOP, //Ӵ +}; + +enum E_MATH_ZOOM_RATE +{ + ZOOM_RATE_DIV_1, + ZOOM_RATE_DIV_10, + ZOOM_RATE_DIV_100, + ZOOM_RATE_DIV_1000, +}; +#pragma endregion Math + +#pragma region Acquire +////////////////////////////Acquire////////////////////////////////// +//2017-3-13Ӹ߷ֱ +enum E_ACQ_MODE +{ + ACQ_MODE_NORMAL = 0, + ACQ_MODE_PEAK, + ACQ_MODE_AVERAGE, + ACQ_MODE_HIGHRESOLUTION, +}; + +enum E_SAMPLE_MODE +{ + ACQ_SAMPLE_EQUIVALENT = 0, + ACQ_SAMPLE_REAL, + ACQ_SAMPLE_SCAN, +}; +//32m,3.2m,32k,3.2k +enum E_ACQ_SAV_DEPTH +{ + ACQ_DEPTH_NORMAL = 0, + ACQ_DEPTH_DEPTH, + ACQ_DEPTH_32M, + ACQ_DEPTH_3POINT2M, + ACQ_DEPTH_32K, + ACQ_DEPTH_3POINT2K, + +}; +#pragma endregion Acquire + +#pragma region Display +////////////////////////////Display////////////////////////////////// +enum E_DISPLAY_TYPE +{ + DISPLAY_TYPE_YT = 0, + DISPLAY_TYPE_XY, +}; + +enum E_DISPLAY_FORMAT +{ + DISPLAY_FORMAT_VECTOR = 0, + DISPLAY_FORMAT_DOT, +}; + +enum E_Display_Graticule +{ + Display_Graticule_Full, + Display_Graticule_Grid, + Display_Graticule_CrossHair, + Display_Graticule_Frame, +}; + +enum E_Dislay_PersistTime +{ + Display_PersistTime_Auto, + Display_PersistTime_Short, + Display_PersistTime_Long, + Display_PersistTime_Unlimited, +}; +#pragma endregion Display + +#pragma region Utility +////////////////////////////Utility////////////////////////////////// +enum E_Utility_Skin +{ + UTILITY_SKIN_CLASSIC, + UTILITY_SKIN_TRADITIONAL, + UTILITY_SKIN_MODERN, +}; + +enum E_Utility_Menu_Display_Time +{ + UTILITY_MENU_DISPLAY_T5S, + UTILITY_MENU_DISPLAY_T10S, + UTILITY_MENU_DISPLAY_T20S, + UTILITY_MENU_DISPLAY_TMANUAL, + + UTILITY_MENU_DISPLAY_T1S, + UTILITY_MENU_DISPLAY_T2S, +}; + +enum E_Utility_Language +{ + UTILITY_LANG_ZHCN, // + UTILITY_LANG_ZHTW, // + UTILITY_LANG_ENGLISH, //Ӣ + UTILITY_LANG_GERMAN, // + UTILITY_LANG_RUSSIANS, // + + UTILITY_LANG_ESPANOL, // + UTILITY_LANG_PORTUGUESE, // + UTILITY_LANG_FRENCH, // + UTILITY_LANG_DUTCH, // +}; + +enum E_Utility_AutoSet +{ + UTILITY_AUTOSET_LOCK_ON, + UTILITY_AUTOSET_LOCK_OFF, +}; + +enum E_Utility_PassFail_AllowTesting +{ + UTILITY_PF_ALLOWTEST_COLSE, + UTILITY_PF_ALLOWTEST_OPEN, +}; + +enum E_Utility_PassFail_Output +{ + UTILITY_PF_OUTPUT_PASS, + UTILITY_PF_OUTPUT_FAIL, +}; + +enum E_Utility_PassFail_DisplayInfo +{ + UTILITY_PF_DISPLAYINFO_OPEN, + UTILITY_PF_DISPLAYINFO_CLOSE, +}; + +enum E_Utility_PassFail_Operation +{ + UTILITY_PF_OPERATION_PLAY, + UTILITY_PF_OPERATION_STOP, +}; + +enum E_Utility_PassFail_StopSet_Type +{ + UTILITY_PF_STOPSET_TYPE_PASSTIMES, + UTILITY_PF_STOPSET_TYPE_FAILTIME, +}; + +enum E_Utility_PassFail_StopSet_Condition +{ + UTILITY_PF_STOPSET_CONDITION_GT_EQU, + UTILITY_PF_STOPSET_CONDITION_LT_EQU, +}; +#pragma endregion Utility + +#pragma region Storage +////////////////////////////Storage////////////////////////////////// +enum E_STORAGE_TYPE +{ + STORAGE_TYPE_SETTING, + STORAGE_TYPE_WAVE, + STORAGE_TYPE_BITMAP, +}; + + +enum E_STORAGE_REFWAVE_FILE_FORMAT +{ + STORAGE_REFWAVE_FILE_FMT_CSV, + STORAGE_REFWAVE_FILE_FMT_INNER, +}; + +#pragma endregion Storage + +#pragma region Cursor +enum E_CURSOR_TYPE +{ + CURSOR_TYPE_TIME, + CURSOR_TYPE_VOLTAGE, + CURSOR_TYPE_TRACK, + CURSOR_TYPE_DUMP, + CURSOR_TYPE_CLOSED, +}; + +enum E_CURSOR_MODE +{ + CURSOR_MODE_INDEPENDENT, + CURSOR_MODE_TRACK, +}; + +enum E_CURSOR_H_UNIT +{ + CURSOR_UNIT_H_BASE, + CURSOR_UNIT_H_PERCENT, +}; + +enum E_CURSOR_V_UNIT +{ + CURSOR_UNIT_V_SECOND, + CURSOR_UNIT_V_HERTZ, + CURSOR_UNIT_V_PERCENT, + CURSOR_UNIT_V_DEGREE, +}; + +enum E_CURSOR_POS +{ + CURSOR_POS_CURRENT = 3, + CURSOR_POS_6DIV, +}; +#pragma endregion Cursor + +enum E_Measure_Edge +{ + Measure_Edge_Fall, + Measure_Edge_Rise, +}; + + +#ifdef __cplusplus +} +#endif + + +#endif // ItemCode_COMVer2_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/include/UPO.h b/Driver/UDP5080-100/UNI-T SDK/include/UPO.h new file mode 100644 index 0000000..9be5b1b --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/UPO.h @@ -0,0 +1,222 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩʹUCIӿڵģDSOض + */ + +#ifndef DSO_UPO_h__ +#define DSO_UPO_h__ + +#ifdef __cplusplus +namespace upo2k { +#endif // __cplusplus + ////////////////////////////////////////////////////////////////////////// + // UPOλ壺 + // 16bit8λΪλͣ8λΪλ! + // ȡʽ short unit + // char unit_code = unit & 0xff; + // if((unit & UT_Time) == UT_Time) unit_code is ETime + // else if((unit & UT_Freq) == UT_Freq) unit_code is EFreq + ////////////////////////////////////////////////////////////////////////// + + //@brief : λ + //@remarks : 8λΪλͣ8λΪλ! +#ifdef __cplusplus + typedef enum _UnitType : unsigned short { +#else + typedef enum _UnitType { +#endif // __cplusplus + UT_Voltage = (0x0000), + UT_Time = (0x0100), + UT_Freq = (0x0200), + UT_Percent = (0x0300), + UT_Degree = (0x0400), + UT_DB = (0x0500), + UT_SamplePoint = (0x0600), + //@brief : + UT_Current = (0x0700), + //@brief : + UT_Watt = (0x0800), + //@brief : δ֪λ + UT_Unknown = (0x0900), + + UT_Invalid = (0x8000), + }UnitType; + + enum EFreq { + Hz = 0, + KHz, + MHz, + GHz, + THz, + }; + + enum ETime { + s = 0, + ms, + s, + ns, + ps, + }; + + enum EVoltage { + V = 0, + mV, + V, + KV + }; + + enum ECurrent { + A = 0, + mA, + A, + KA + }; + + enum EWatt { + W = 0, + mW, + W, + KW + }; + + enum EUnknown { + U = 0, + mU, + U, + KU + }; + + enum EDB { + mdB = 0, + dB, + kdB + }; + + enum EPoint { + Sa = 0, + KSa, + MSa, + GSa, + }; + + enum EPercent { + Percent = 0 + }; + + enum EDegree { + Degree = 0, + }; + + static inline char GetUnitType(short _v) { return (char)(_v >> 8); } + static inline char GetUnitCode(short _v) { return _v & 0xff; } + + //@brief : λ + //@remark: ָͨLock?ȡ64bitλǡ + typedef enum _KeyFlagsPos { + IKEY_F1, + IKEY_F2, + IKEY_F3, + IKEY_F4, + IKEY_F5, + + IKEY_CH1, + IKEY_CH2, + IKEY_CH3, + IKEY_CH4, + + IKEY_MATH, + IKEY_REF, + IKEY_HORIZON, + IKEY_TRIGGER, + IKEY_FORCE, + IKEY_HELP, + IKEY_MEASURE, + IKEY_CURSOR, + IKEY_ACQUIRE, + IKEY_DISPLAY, + IKEY_STORAGE, + IKEY_UTILITY, + IKEY_DECODE, + IKEY_DEFAULT, + IKEY_AUTOSET, + IKEY_RUNSTOP, + IKEY_SINGLE, + IKEY_CLEAR, + IKEY_PRINTSCREEN, + IKEY_MENU, + + IKEY_OFFSET_LEFT, + IKEY_OFFSET_RIGHT, + IKEY_OFFSET_OK, + + IKEY_PRETRIG_LEFT, + IKEY_PRETRIG_RIGHT, + IKEY_PRETRIG_OK, + + IKEY_TRIGLEVEL_LEFT, + IKEY_TRIGLEVEL_RIGHT, + IKEY_TRIGLEVEL_OK, + + IKEY_VOLTS_LEFT, + IKEY_VOLTS_RIGHT, + IKEY_VOLTS_OK, + + IKEY_TIMEBASE_LEFT, + IKEY_TIMEBASE_RIGHT, + IKEY_TIMEBASE_OK, + + IKEY_SELECT_LEFT, + IKEY_SELECT_RIGHT, + IKEY_SELECT, + }KeyFlagsPos; + + typedef struct _CellBaseValue { + float Value; + short Unit; + short IsLimit; // == 1,yes; =0, no! + }CellBaseValue; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + +#include //1ֽڶ + //@brief : λ + //@remark: + typedef struct _measure_param { + float value; //ЧʱֵΪ FLT_MAX + //@brief : λ + //@remark: λUnitType + short unit; //ЧʱֵΪ UT_Invalid = (0x8000) + }UValue; + + //@brief : ȡLED״̬ + //@remark: 1 - 0 δ ָLED? ȡ + typedef struct _KeyLedStat { + char CH1, CH2, CH3, CH4, MATH, REF, RUN_STOP, Single; + }KeyLedStat; + + //@brief : ݰ + typedef struct _CursorMeasurePack { + UValue Ax; + UValue Bx; + UValue Bx_Ax; + UValue Hz_Bx_Ax; + UValue Ay; + UValue By; + UValue By_Ay; + char Reserver[8]; + }CursorMeasurePack; +#include + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // DSO_UPO_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/include/UTG2025Def.h b/Driver/UDP5080-100/UNI-T SDK/include/UTG2025Def.h new file mode 100644 index 0000000..4ba8f86 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/UTG2025Def.h @@ -0,0 +1,178 @@ +/******************************************************************** + created: 2015/04/08 + author: M.Yang + purpose: ṩUTG2000A&UTG7000źԴض + *********************************************************************/ + +#ifndef UTG2025Def_h__ +#define UTG2025Def_h__ + +#ifdef __cplusplus +namespace SG62_25A { +#endif + //@brief : UTG2000A&UTG7000źԴ + typedef enum _ParamNo { + Invalid_Cmd = -1, + //@brief : ǰģʽ + CurMode = 6, + //@brief : Ⲩģʽ + ArbPlayMode = 7, + //@brief : + WaveType = 8, + //@brief : Ƶ + Freq = 9, + //@brief : + Period = 10, + //@brief : -ֵ + AmpVpp = 11, + //@brief : -Чֵ + AmpVrms = 12, + //@brief : - + AmpDbm = 13, + //@brief : ֱƫ + DCOffset = 14, + //@brief : ߵƽ + High = 15, + //@brief : ͵ƽ + Low = 16, + //@brief : λ + Phase = 17, + //@brief : ռձ + DutyCycle = 18, + //@brief : Գƶ + Symmetry = 19, + //@brief : + PulseWidth = 20, + //@brief : ʱ + PulseRisingTime = 21, + //@brief : ½ʱ + PulseFallingTime = 22, + //@brief : + ArbSampleRate = 23, + //@brief : ARBļ + ArbName = 24, + //@brief : + ArbLength = 25, + + + //@brief : + ModulateType = 40, + //@brief : Ƶ + ModulateFreq = 28, + //@brief : Դ + ModulateSource = 29, + //@brief : Ʋ + ModulateShape = 30, + //@brief : + ModulateOnOff = 31, + //@brief : + ModulateAMDeepth = 32, + //@brief : Ƶƫ + ModulateFMFreqDev = 33, + //@brief : ƫ + ModulatePMPhaseDev = 34, + //@brief : ԾƵ + ModulateFSK_HopFreq = 35, + //@brief : + ModulateFSKRate = 36, + //@brief : Ƽ-λ + ModulatePSKPhase = 37, + //@brief : ƵƼ-زƵ + ModulateFSK_CarrierFreq = 38, + //@brief : -ռձƫ + ModulatePWM_DutyDev = 39, + + //@brief : ɨƵ-ʼƵ + SweepStartFreq = 47, + //@brief : ɨƵ-ֹͣƵ + SweepStopFreq = 48, + //@brief : ɨƵ-ɨʱ + SweepTime = 49, + //@brief : ɨƵ- + SweepType = 50, + + //@brief : лƵ÷ʽ-Ƶʻ + Wave_Freq_Or_Period = 51, + //@brief : л÷ʽ-Ȼ߸ߵ͵ƽ + Wave_Amp_Or_HighLow = 52, + //@brief : лͬķʾλ + Wave_Amp_Unit = 53, + + //@brief : 崮 - ʼλ + BurstStartPhase = 57, + //@brief : 崮 - ⧷ + BurstPeriod = 58, + //@brief : 崮 - ѭ + BurstCycleCount = 59, + //@brief : 崮 - ſ- + BurstPolarity = 60, + //@brief : 崮 - + BurstType = 61, + + //@brief : Դ + TriggerSource = 68, + //@brief : + SyncType = 69, + //@brief : + TriggerEdge = 70, + //@brief : + TriggerOnOff = 71, + + //@brief : CH1 ͨʹ + OutputEnable = 77, + //@brief : CH2 ͨʹ + OutputEnable2 = 78, + //@brief : + Invert = 79, + //@brief : 迹 + OutputExtRes = 80, + //@brief : + OutputLimit = 81, + //@brief : + OutputLimitHigh = 82, + //@brief : + OutputLimitLow = 83, + //@brief : ͬ + SyncOut = 84, + //@brief : + Couple = 85, + //@brief : IPַ + IPAddrType = 101, + //@brief : IPַ + IPAddr = 102, + //@brief : + IPSubnetMask = 103, + //@brief : + IPGateway = 104, + //@brief : DNS + IPDns = 105, + //@brief : MACַ + Mac = 106, + //@brief : + Language = 107, + //@brief : ʱԴ + ClkSource = 108, + //@brief : + PowerOnParam = 109, + //@brief : + BeepOnOff = 110, + //@brief : ַָ + CharDivideInt = 111, + //@brief : + LoadSettting = 112, + //@brief : + SaveSetting = 113, + //@brief : + Backlight = 114, + //@brief : + About = 115, + //@brief : ʱ + ClkOut = 116 + }ParamNo; + +#ifdef __cplusplus +} +#endif + + +#endif // UTG2025Def_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/include/UTG4162.h b/Driver/UDP5080-100/UNI-T SDK/include/UTG4162.h new file mode 100644 index 0000000..a629417 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/UTG4162.h @@ -0,0 +1,449 @@ +/******************************************************************** + created: 2015/01/14 + author: M.Yang + purpose: UCIʹõйUTG4000&UTG8000Ķ + *********************************************************************/ +#ifndef UTG4162_h__ +#define UTG4162_h__ + +#ifdef __cplusplus +namespace uci { + namespace utg4162 { +#endif // __cplusplus + + /////////////////////////////////Key Define///////////////////////////// + + //@brief : UTG4000&UTG8000ϵл͵尴ֵ塣 + //@remark: + typedef enum _SGKeys { + Key_F1 = 0, + Key_F2, + Key_F3, + Key_F4, + Key_F5, + Key_F6, + Key_0 = '0', + Key_1, + Key_2, + Key_3, + Key_4, + Key_5, + Key_6, + Key_7, + Key_8, + Key_9, + Key_Dot, + Key_Symbol, + Key_Right, + Key_Left, + Key_Ok, + Key_Up, + Key_Down, + // + Key_User, + Key_Digital, + Key_Counter, + Key_Mod, + Key_Sweep, + Key_Bst, + Key_Sine, + Key_Noise, + Key_Square, + Key_Ramp, + Key_Pulse, + Key_Arb, + Key_Harmonic, + Key_DC, + Key_Ch1, + Key_Ch2, + Key_Trigger, + Key_SwapCh, + Key_OtherPage, + Key_Preset, + Key_Storge, + Key_StorgeL, + Key_Utility, + Key_Help, + Key_HelpL, + Key_Esc, + Key_PrScreen, + Key_Null = 0xff + }SGKeys; + + inline int GetKeyIndex(SGKeys _code) { + return (_code >= Key_F1 && _code < Key_F6) ? _code : _code - '0' + 6; + }; + + + //@brief : жϰǷ + //@param _code : ֵ + //@param _v : ǰ״̬64bitʹָ"lock?"ȡ + //@return : == 0 δ + //@remarks : + inline int IsKeyLocked(SGKeys _code, long long _v) { + return _v & ((long long)1 << GetKeyIndex(_code)); + }; + + //@brief : LED״̬ + //@remarks : 0 ʾ 1 ʾ + typedef struct _LEDStatus { + char Noise; + char UTILTY; + char STORGE; + char RAMP; + char PULSE; + char COUNTER; + char USER; + char DIGTAL; + char HARMONIC; + char DC; + char TRGGER; + char CH2; + char SWAPCH; + char ARB; + char CH1; + char SINE; + char SQUARE; + }LEDStatus; + + + /////////////////////////////////File Load///////////////////////////// + //@brief : Ⲩļطʽ + typedef enum _ARBWriteMode { + //@brief : زʽ + ARB_MODE_CARRIER = 0, + //@brief : ԵƲʽ + ARB_MODE_MOD, + }ARBWriteMode; + + //@brief : صļŽ + typedef enum _FileMedium { + //@brief : ŵRAM + FM_RAM = 0, + //@brief : ŵROM + FM_ROM, + //@brief : ŵTF + FM_TF, + //@brief : ŵU + FM_UDISK + }FileMedium; + + + /////////////////////////////////Parameters Address Define///////////////////////////// + //ģʽ + typedef enum _EWorkMode : long long { + //@brief : ģʽ + WM_BASE = 0, + //@brief : Ʋģʽ + WM_MODE, + //@brief : ɨƵģʽ + WM_SWEEP, + //@brief : ⧷ + WM_BURST, + }EWorkMode; + + // + typedef enum _EBaseWave : long long { + //@brief : Ҳ + BASE_SINE = 0, + //@brief : + BASE_SQUARE = 1, + //@brief : б + BASE_RAMP = 3, + //@brief : 岨 + BASE_PULSE = 4, + //@brief : + BASE_NOISE = 5, + //@brief : Ⲩ + BASE_ARB = 6, + //@brief : г + BASE_HARMONIC = 7, + //@brief : ֱ + BASE_DC = 8 + }EBaseWave; + + typedef enum _EModeType : long long { + MT_AM = 0, + MT_FM = 1, + MT_PM = 2, + MT_ASK = 3, + MT_FSK = 4, + MT_PSK = 5, + MT_BPSK = 6, + MT_QPSK = 7, + MT_OSK = 8, + MT_QAM = 9, + MT_PWM = 10, + MT_SUM = 11, + }EModeType; + + //Ʋ + typedef enum _EModeWaveType : long long { + MOD_WAVE_SINE = 0, + MOD_WAVE_SQUARE = 1, + MOD_WAVE_UPRAMP = 2, + MOD_WAVE_DNRAMP = 3, + MOD_WAVE_NOISE = 4, + MOD_WAVE_ARB = 5, + }EModeWaveType; + + //@brief : źԴ + //@remark: ʹrpָдʹwpָ + //@example: wp@ch:0@addr:0x8000@v:0; + // rp@ch:0@addr:0x8000; + // вĶӦ8bytesdouble + typedef enum _enumRemoteMessage { + //@brief : ģʽ + //@remark: {IO:WR}{DATA:EWorkMode} + RM_WORK_MODE = 0x8000, + + //{ + //@brief : ͨ + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_CH_SW = 0x8001, + //@brief : ͬ + //@remark: {IO:WR}{DATA: 0-OFF1-ON2-reverse} + RM_CH_SYNC_SW, + //@brief : ͨ + //@remark: {IO:WR}{DATA: 0OFF1ON} + RM_CH_REVERTSE, + //@brief : ͨ迹 + //@remark: {IO:WR}{DATA: 1~1000} + RM_CH_LOAD, + //@brief : ͨʹ + //@remark: {IO:WR}{DATA: 0OFF1ON} + RM_CH_OUTPUT_LIMIT_ENABLE, + //@brief : ͨ͵ƽ + //@remark: {IO:WR}{DATA: -10V~MAX_LEVEL} + RM_CH_OUTPUT_LIMIT_MIN_LEVEL, + //@brief : ͨߵƽ + //@remark: {IO:WR}{DATA: MIN_LEVEL~10V} + RM_CH_OUTPUT_LIMIT_MAX_LEVEL, + + //@brief : + //@remark: {IO:WR}{DATA:EBaseWave} + RM_BASE_WAVE_TYPE = 0x8008, + //@brief : Ƶ(λHz) + //@remark: {IO:WR}{DATA: 1uHz~ǰƵ} + RM_BASE_FREQ, + //@brief : λ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_BASE_PHASE = 0x800A, + //@brief : (λVPP) + //@remark: {IO:WR}{DATA: 1mVpp~10Vpp50ŷķ} + RM_BASE_AMP_VPP, + //@brief : (λVRMS) + //@remark: {IO:WR}{DATA: 1mVRMS~5Vpp50ŷķ} + RM_BASE_AMP_VRMS, + //@brief : (λVDBM) + //@remark: {IO:WR}{DATA: -53.010VDBM~26.99VDBM50ŷķ} + RM_BASE_AMP_VDBM, + //@brief : ƫ(λV) + //@remark: {IO:WR}{DATA: -5VRMS~5Vpp50ŷķ} + RM_BASE_OFFSET, + //@brief : ߵƽ(λV) + //@remark: {IO:WR}{DATA: BASE_LOW~5Vpp50ŷķ} + RM_BASE_HIGHT = 0x800F, + //@brief : ͵ƽ(λV) + //@remark: {IO:WR}{DATA: -5VRMS~BASE_HIGHT50ŷķ} + RM_BASE_LOW = 0x8010, + //@brief : ռձȶԷռձȡ岨ռձȡDzԳƶȹ + //@remark: {IO:WR}{DATA: 0~100} + RM_BASE_DUTY, + //@brief : 岨ʱ(λs) + //@remark: {IO:WR}{DATA: min ~ *0.4} + RM_BASE_RISETIME, + //@brief : 岨½ʱ(λs) + //@remark: {IO:WR}{DATA: min ~ *0.4} + RM_BASE_FALLTIME, + //@brief : Ⲩģʽ + //@remark: {IO:WR}{DATA:0OFF1ON} + RM_BASE_ARB_PLAY_ENABLE, + //@brief : г - ģʽ + //@remark: {IO:WR} + //{DATA: + //0: , + //1: ż, + //2: ȫ, + //3: USER,Զ + // } + RM_BASE_HARMOIC_TYPE = 0x8080, + //@brief :г,RM_BASE_HARMOIC_TYPE=USERʱЧ + //@remark: {IO:WR}{DATA:BIT14BIT0ֱӦ2~16гأBIT15Ӧǿƿ} + RM_BASE_HARMONIC_ONOFF, + //N(2~16)г,Կַ: + //EG:N=3(г),AMP = 1Vpp, PHASE = 90 + //1: + //1ָгRM_HARMONIC_NUM = N(2~16), + //2趨гķȺλ, + // RM_HARMONIC_SN_AMP_N = 1.0; RM_HARMONIC_SN_PHASE_N = 90.0; + //1:ֱõгķȺλ + //RM_HARMONIC_SN_AMP_3 = 1.0, RM_HARMONIC_SN_PHASE_3 = 90.0, + + //@brief : г + //@remark: {IO:WR}{DATA:1~15} + RM_HARMONIC_NUM, + //@brief : гVpp + //@remark: {IO:WR}{DATA:0~} + RM_HARMONIC_SN_AMP_N, + //@brief : гλ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_HARMONIC_SN_PHASE_N = 0x8084, + //@brief : г ͬRM_HARMONIC_SN_AMP_N + RM_HARMONIC_SN_AMP_2, + RM_HARMONIC_SN_AMP_3, + RM_HARMONIC_SN_AMP_4, + RM_HARMONIC_SN_AMP_5, + RM_HARMONIC_SN_AMP_6, + RM_HARMONIC_SN_AMP_7 = 0x808A , + RM_HARMONIC_SN_AMP_8, + RM_HARMONIC_SN_AMP_9, + RM_HARMONIC_SN_AMP_10, + RM_HARMONIC_SN_AMP_11, + RM_HARMONIC_SN_AMP_12 = 0x808F, + RM_HARMONIC_SN_AMP_13 = 0x8090, + RM_HARMONIC_SN_AMP_14, + RM_HARMONIC_SN_AMP_15, + RM_HARMONIC_SN_AMP_16, + //@brief : гλ RM_HARMONIC_SN_PHASE_N + RM_HARMONIC_SN_PHASE_2, + RM_HARMONIC_SN_PHASE_3, + RM_HARMONIC_SN_PHASE_4, + RM_HARMONIC_SN_PHASE_5, + RM_HARMONIC_SN_PHASE_6, + RM_HARMONIC_SN_PHASE_7, + RM_HARMONIC_SN_PHASE_8 = 0x809A, + RM_HARMONIC_SN_PHASE_9, + RM_HARMONIC_SN_PHASE_10, + RM_HARMONIC_SN_PHASE_11, + RM_HARMONIC_SN_PHASE_12, + RM_HARMONIC_SN_PHASE_13 = 0x809F, + RM_HARMONIC_SN_PHASE_14 = 0x80A0, + RM_HARMONIC_SN_PHASE_15, + RM_HARMONIC_SN_PHASE_16, + //} + + //{MOD + //@brief : ģʽ + //@remark: {IO:WR}{DATA:EModeType} + RM_MOD_TYPE = 0x8100, + //Ʋ + //0: MOD_SINE, + //1: MOD_SQUARE, + //2: MOD_UPRAMP, + //3: MOD_DNRAMP, + //4: MOD_NOISE, + //5: MOD_ARB, + //@brief : Ʋ + //@remark: {IO:WR}{DATA:EModeWaveType} + RM_MOD_WAVE, + //@brief : ƲƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~200KHz} + RM_MOD_FREQ, + //@brief : Ʋʣλs + //@remark: {IO:WR}{DATA: 2ms~1Ms} + RM_MOD_RATE, + //@brief : ȣλ% + //@remark: {IO:WR}{DATA: 0~120} + RM_MOD_SCOPE, + //@brief : Դ + //@remark: {IO:WR}{DATA: 0-Internal,1-External} + RM_MOD_SOURCE, + //@brief : FMƵλHz + //@remark: {IO:WR}{DATA: 0~زǰƵ} + RM_MOD_FRE_DEV, + //@brief : PM (λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_MOD_PHASE_DEV, + //@brief : FSKƵλHz + //@remark: {IO:WR}{DATA: 0~زƵ} + RM_MOD_HOP_FREQ, + //@brief : BPSKԴ + //@remark: {IO:WR} + //{DATA: + //0: PN7, + //1: PN9, + //2: PN15, + //3: PN21, + //} + RM_MOD_DATA_SOURCE = 0x8109, + //@brief : BPSKλQPSKλ1,(λ) + //@remark: {IO:WR}{DATA: -360~360}} + RM_MOD_PSK_PHASE1, + //@brief : QPSKλ2(λ) + //@remark: {IO:WR}{DATA:-360~360}} + RM_MOD_PSK_PHASE2, + //@brief : QPSKλ3(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_MOD_PSK_PHASE3, + //@brief : OSKʱ(λs) + //@remark: {IO:WR}{DATA: 8ns~200s} + RM_MOD_OSC_TIME, + //@brief : QAMIQ MAM + //@remark: {IO:WR}{DATA: 0-4QAM,1-8QAM,2-16QAM,3-32QAM,4-64QAM,5-128QAM,6-256QAM,} + RM_MOD_IQ_MAP, + //@brief : PWMռձȲֵ + //@remark: {IO:WR}{DATA: 0~PULS DUTY} + RM_MOD_DUTY_DEV, + //} + + //{SWEEP + //@brief : ɨƵ + //@remark: {IO:WR}{DATA: 0ԣ1} + RM_SWEEP_TYPE = 0x8200, + //@brief : ɨƵԴ + //@remark: {IO:WR}{DATA: 0ڲ1ⲿ2ֶ} + RM_SWEEP_SOURCE, + //@brief : ɨƵʱ(λs) + //@remark: {IO:WR}{DATA: 1ms~500s} + RM_SWEEP_TIME, + //@brief : ɨƵʼƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~زƵ} + RM_SWEEP_START_FREQ, + //@brief : ɨƵֹͣƵʣλHz + //@remark: {IO:WR}{DATA: 1uHz~زƵ} + RM_SWEEP_STOP_FREQ, + //@brief : ͬƵʣλHz + //@remark: {IO:WR}{DATA: RM_SWEEP_START_FREQ~RM_SWEEP_STOP_FREQ} + RM_SWEEP_SYNC_FREQ, + //@brief : ɨƵ + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_SWEEP_TIRG_OUT, + //} + + //{BURST + //@brief : ⧷ + //@remark: {IO:WR}{DATA: + //0: N, + //1: , + //2: ſ + //} + RM_BURST_TYPE = 0x8300, + //@brief : ⧷Դ + //@remark: {IO:WR}{DATA: 0ڲ1ⲿ2ֶ} + RM_BURST_SOURCE, + //@brief : + //@remark: {IO:WR}{DATA: 0-OFF1-ON} + RM_BURST_TIRG_OUT, + //@brief : ⧷ڣλs + //@remark: {IO:WR}{DATA: 1~500} + RM_BURST_PERIOD, + //@brief : ⧷λ(λ) + //@remark: {IO:WR}{DATA:-360~360} + RM_BURST_PHASE, + //@brief : ⧷λ + //@remark: {IO:WR}{DATA: 1~50000} + RM_BURST_CYCLES, + //@brief : + //@remark: {IO:WR}{DATA: 0-Rise1-Fall} + RM_BURST_TIRG_EDGE, + //} + }ERemoteMessage; + + +#ifdef __cplusplus + } +} +#endif // __cplusplus + +#endif // UTG4162_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/include/comApiDef.h b/Driver/UDP5080-100/UNI-T SDK/include/comApiDef.h new file mode 100644 index 0000000..5e04f7d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/comApiDef.h @@ -0,0 +1,903 @@ +#ifndef _DSOCOM_API_COMMON_DEF_H_201212281614 +#define _DSOCOM_API_COMMON_DEF_H_201212281614 + +#include "dso_base.h" + +#ifdef __cplusplus +namespace comApi +{ + using namespace comAPICommon; +#endif + //λ +#ifdef __cplusplus + namespace Units + { +#endif + const int UNIT_NULL = 0; //add by yzz + const int UNIT_PS = 1; //add by yzz + const int UNIT_NS = 2; + const int UNIT_US = 3; + const int UNIT_MS = 4; + const int UNIT_S = 5; + const int UNIT_KS = 6; + + const int UNIT_nVS = 7; + const int UNIT_uVS = 8; + const int UNIT_mVS = 9 ; + + const int UNIT_PER = 10; + + const int UNIT_UV = 11; + const int UNIT_MV = 12; + const int UNIT_V = 13; + const int UNIT_KV = 14; + + const int UNIT_pHZ = 18; + const int UNIT_nHZ = 19; + const int UNIT_uHZ =20; + const int UNIT_mHZ = 21; + const int UNIT_HZ = 22; + const int UNIT_KHZ = 23; + const int UNIT_MHZ = 24; + const int UNIT_GHZ = 25; + + //const int UNIT_VV = 52; //201452311:56:55޸ + const int UNIT_mVV = 52; + const int UNIT_VV = 53; + const int UNIT_KVV = 54; + + const int UNIT_mDB = 80; // add by yzz + const int UNIT_DB = 81; + const int UNIT_KDB = 82; // add by yzz +#ifdef __cplusplus + } +#endif + +#pragma region + enum DataCMD + { + Invalid_Data_CMD = -1, + //get data cmd + GET_DISPLAY_DATA = 150, //get ch1, ch2, math, ref a/b data + GET_CH1_DISPLAY_DATA, //get ch1 display data: + GET_CH1_ORIGIN_DATA, //get ch1 original data + GET_CH2_DISPLAY_DATA, //get ch2 display data + GET_CH2_ORIGIN_DATA, //get ch2 original data + GET_CH3_DISPLAY_DATA, + GET_CH3_ORIGIN_DATA, + GET_CH4_DISPLAY_DATA, + GET_CH4_ORIGIN_DATA, + + GET_MATH_DATA = 200, //get math data + GET_REF_A_DATA, //get ref A data + GET_REF_B_DATA, //get ref B data + + //[Notice] Get_Data_CMD_END ָ DataCMD һ + Get_Data_CMD_END = GET_REF_B_DATA, + }; + + /* Command Type */ + typedef enum _control_cmd{ + Invalid_Control_CMD = -1, + + CMD_GET_DSO_TYPE = 0, + + //special function cmd + LOCK_DSO_KEYPAD, //lock dso keypad: if set this cmd, the dso's keypad will not work + UNLOCK_DSO_KEYPAD, //unlock dso keypad: if set this cmd, the dso's keypad will work normally + SET_PROCSTATE, //PROC_STATE: control run/stop + GET_PROCSTATE, //PROC_STATE: get run/stop state + SET_AUTOSET, //set dso to do auto set + SET_TRIG_FORCE, //set dso to be force trigger state + SET_SINGLE, + SET_COARSE, + SET_PRTSC, //set dso to do print screen + GET_BITMAP_FILENAME, + GET_BITMAP_FILEDATA, + + //@brief : ָ + SET_KEY = 20, + //@brief : ѯָ + GET_KEY, + //@brief : ȡѹĻ + GET_SCREEN_SHOT, + //@brief : + GET_DEV_CONFIG, + //@brief : д + SET_DEV_CONFIG, + //@brief : ѯ豸ʾ + GET_IDN, + //@brief : ȡЭ汾 + //@remark: + GET_CVER, + + GET_SCREEN_INFO = 50, //SCREEN_INFO + GET_USB_CONNECTION_STATE, //short 1: usb connection state is ok; other: usb connection state is not ok + GET_CYMOMETER_VALUE, //SignalFreq + GET_CURRENT_ACTIVE_CHANNEL, //short 0: CH1; 1: CH2; 2: MATH; 3: RefA; 4: RefB; -1:other + GET_CURRENT_ACTIVE_MENU, //short 0: CH1 menu; 1: CH2 menu; 2: MATH or FFT menu; -1: other menu + GET_CURRENT_MENU_SHOW_STATE,//x short 0: current menu is not display; 1: current menu is display + GET_SAMPLE, //get sample + + SET_TO_ZERO = 100, //set dso to zero state + SET_CH1_VPOS_TO_ZERO, + SET_CH2_VPOS_TO_ZERO, + SET_CH3_VPOS_TO_ZERO, + SET_CH4_VPOS_TO_ZERO, + SET_HPOS_TO_ZERO, + SET_TRIG_TO_ZERO, + + GET_CH1_MEASURE_PARAM = 250,//get ch1 measure parameters + GET_CH2_MEASURE_PARAM, //get ch2 measure parameters + GET_CH3_MEASURE_PARAM, + GET_CH4_MEASURE_PARAM, + GET_MATH_MEASURE_PARAM, //get math measure parameters + + //set/get channel param cmd + SET_CH1_SWITCH = 300, //ChannelSwitch + GET_CH1_SWITCH, //ChannelSwitch + SET_CH1_ATTRIBUTE, //ChannelAttribute + GET_CH1_ATTRIBUTE, //ChannelAttribute + SET_CH1_VPOS, //ChannelVPos + GET_CH1_VPOS, //ChannelVPos + SET_CH1_VLEVEL, //ChannelVLevel + GET_CH1_VLEVEL, //ChannelVLevel + SET_CH1_TIMEBASE, //ChannelTimeBaseر + GET_CH1_TIMEBASE, //ChannelTimeBase + SET_CH1_TRIG_LEVEL, //ChannelTLevel + GET_CH1_TRIG_LEVEL, //ChannelTLevel + SET_CH1_TRIG_POS, //ChannelTPos + GET_CH1_TRIG_POS, //ChannelTPos + + SET_CH2_SWITCH = 350, //ChannelSwitch + GET_CH2_SWITCH, //ChannelSwitch + SET_CH2_ATTRIBUTE, //ChannelAttribute + GET_CH2_ATTRIBUTE, //ChannelAttribute + SET_CH2_VPOS, //ChannelVPos + GET_CH2_VPOS, //ChannelVPos + SET_CH2_VLEVEL, //ChannelVLevel + GET_CH2_VLEVEL, //ChannelVLevel + SET_CH2_TIMEBASE, //ChannelTimeBase + GET_CH2_TIMEBASE, //ChannelTimeBase ر + SET_CH2_TRIG_LEVEL, //ChannelTLevel + GET_CH2_TRIG_LEVEL, //ChannelTLevel + SET_CH2_TRIG_POS, //ChannelTPos + GET_CH2_TRIG_POS, //ChannelTPos + + //math + SET_MATH_SWITCH = 800, //ChannelSwitch + GET_MATH_SWITCH, //ChannelSwitch + SET_MATH_VPOS, //ChannelVPos + GET_MATH_VPOS, //ChannelVPos + SET_MATH_VLEVEL, //ChannelVLevel + GET_MATH_VLEVEL, //ChannelVLevel + SET_FFT_FREQ, //by change timebase + GET_FFT_FREQ, //SignalFreq + SET_MATH_TYPE, //MathType + GET_MATH_TYPE, //MathType + SET_MATH_CONFIG, //MathConfig + GET_MATH_CONFIG, //MathConfig + SET_FFT_CONFIG, //FFTConfig + GET_FFT_CONFIG, //FFTConfig + SET_FILTER_CONFIG, //FilterConfig + GET_FILTER_CONFIG, //FilterConfig + + //acquire + SET_ACQUIRE_CONFIG = 850, //AcquireConfig + GET_ACQUIRE_CONFIG, //AcquireConfig + + //trig menu + SET_TRIG_EDGE_CONFIG = 900, //EdgeTrig + GET_TRIG_EDGE_CONFIG, //EdgeTrig + SET_TRIG_PULSE_CONFIG, //PulseTrig + GET_TRIG_PULSE_CONFIG, //PulseTrig + SET_TRIG_VIDEO_CONFIG, //VideoTrig + GET_TRIG_VIDEO_CONFIG, //VideoTrig + SET_TRIG_SLOPE_CONFIG, //SlopeTrig + GET_TRIG_SLOPE_CONFIG, //SlopeTrig + + //display menu + SET_DISPLAY_CONFIG = 950, //DisplayConfig + GET_DISPLAY_CONFIG, //DisplayConfig + + //measure menu + SET_MEASURE_SOURCE = 1000, //MeasureSrc + GET_MEASURE_SOURCE, //MeasureSrc + SET_MEASURE_ALL_CONFIG, //MeasureAllConfig + GET_MEASURE_ALL_CONFIG, //MeasureAllConfig + SET_MEASUER_PART_CONFIG, //MeasurePartConfig + GET_MEASURE_PART_CONFIG, //MeasurePartConfig + + //cursor menu + SET_CURSOR_CONFIG = 1050, //CursorConfig + GET_CURSOR_CONFIG, //CursorConfig + GET_CURSOR_MEASURE_RESULT, //CurSorMeasureResult + + //storage config + SET_STORAGE_SETTING = 1100, //StorageSetting + GET_STORAGE_SETTING, //StorageSetting + SET_STORAGE_WAVE, //StorageWave + GET_STORAGE_WAVE, //StorageWave + SET_STORAGE_BITMAP, + GET_STORAGE_BITMAP, + + //reference config + SET_REF_A_SWITCH = 1200, //ChannelSwitch + GET_REF_A_SWITCH, //ChannelSwitch + SET_REF_B_SWITCH, //ChannelSwitch + GET_REF_B_SWITCH, //ChannelSwitch + SET_REF_A_VPOS, //ChannelVPos + GET_REF_A_VPOS, //ChannelVPos + SET_REF_A_VLEVEL, //ChannelVLevel + GET_REF_A_VLEVEL, //ChannelVLevel + SET_REF_A_TRIG_POS, //ChannelTPos + GET_REF_A_TRIG_POS, //ChannelTPos + SET_REF_B_VPOS, //ChannelVPos + GET_REF_B_VPOS, //ChannelVPos + SET_REF_B_VLEVEL, //ChannelVLevel + GET_REF_B_VLEVEL, //ChannelVLevel + SET_REF_B_TRIG_POS, //ChannelTPos + GET_REF_B_TRIG_POS, //ChannelTPos + GET_REF_A_TIMEBASE, //ChannelTimeBase + GET_REF_B_TIMEBASE, //ChannelTimeBase + SET_REF_CONFIG, //RefConfig + GET_REF_A_CONFIG, //RefConfig + GET_REF_B_CONFIG, //RefConfig + GET_REFWAVE_EXIST, //short 0:not exist; 1:exist + GET_REFSETTING_EXIST, //short 0:not exist; 1:exist + + //horizon menu + SET_HORIZON_CONFIG = 1300, //HorizonConfig + GET_HORIZON_CONFIG, //HorizonConfig + + //utility + SET_UTILITY_CONFIG = 1400, //UtilityConfig + GET_UTILITY_CONFIG, //UtilityConfig + + //record + SET_RECORD_CONFIG = 1500, //RecordConfig + GET_RECORD_CONFIG, //RecordConfig + + //auto calibrate + SET_SELF_CALIBRATE = 1600, //set dso to be self-calibrate + //product config + SET_RESET_CONFIG = 1700, //set dso config to product config + + //select cursor +// SET_CURSOR_INDEX = 2000, +// GET_CURSOR_INDEX, + }CONTROL_CMD; +#pragma endregion + +#pragma region öֵ + //״̬Ļȡͨ֡ݰ棬ַʽȡ + typedef enum{ + PROC_STOP = 0, + PROC_RUN, + PROC_ARMED = PROC_RUN, + PROC_READY, + PROC_TRIGED, + PROC_AUTO, + PROC_SCAN, + PROC_OVER, + + PROC_RESET, // Add by yzz, for UTD2102CEX + }E_PROC_STATE; + + typedef enum{ + CH_Invalid_ID = -1, + CH_1_ID = 0, + CH_2_ID, + CH_MATH_ID, + CH_REF_A_ID, + CH_REF_B_ID, + CH_MAX_CNT, + }E_CHANNEL_ID; + + /********************************************** + ****************Channel Attribute***************** + ***********************************************/ + typedef enum{ + CH_COUPLING_DC = 0, + CH_COUPLING_AC, + CH_COUPLING_GND, + }CH_ATTR_COUPLING; + + + typedef enum{ + SWITCH_OFF = 0, + SWITCH_ON, + }SWITCH_STATE; + + typedef enum + { + CH_VOLT_SCALE_COARSE = 0, + CH_VOLT_SCALE_FINE, + }CH_VOLT_SCALE; + + + typedef enum{ + CH_PROBE_1X = 0, + CH_PROBE_10X, + CH_PROBE_100X, + CH_PROBE_1000X, + }CH_PROBE; + + //öֵ̽ͷԣ0ࣨ1 + enum ChannelPolarity + { + CH_Polar_Normal = 0, + CH_Polar_Invert, + }; + + /***********************************************/ + /********** vertical system: channel position *********/ + /***********************************************/ + typedef enum{ + CH_VPOS_TOP = 378, + CH_VPOS_BOT = -122, + }E_CH_VPOS_LIMIT; + + /***********************************************/ + /******** vertical system: channel voltage level *******/ + /***********************************************/ + typedef enum{ + ADJUST_DECREASE = -1, + ADJUST_INCREASE = 1, + }E_ADJUST_DIR; + + /*****************************************************************/ + /* horizontal system: channel horizontal position ,ie channel pre-trigger depth */ + /*****************************************************************/ + typedef enum{ + CH_TPOS_LEFT = 0, + CH_TPOS_RIGHT = 700, + }E_CH_TPOS_LIMIT; + + enum E_CH_TriggerLevel_Limit + { + CH_TriggerLevel_Min = -327, + CH_TriggerLevel_Max = 375, + }; + + /***********************************************/ + /***************** math/fft config *****************/ + /***********************************************/ + enum E_MATH_TYPE + { + MATH_TYPE_MATH = 0, + MATH_TYPE_FFT, + + MATH_TYPE_FILTER, //add by yzz + }; + + typedef enum{ + OP_SIGN_ADD = 0, + OP_SIGN_SUB, + OP_SIGN_MULTIPLY, + OP_SIGN_DIVIDE, + }E_MATH_OP_SIGN; + + typedef enum{ + FFT_WIN_RECTANGLE = 0, + FFT_WIN_HANNING, + FFT_WIN_HAMMING, + FFT_WIN_BLACKMAN, + }E_FFT_WINDOW; + + typedef enum{ + FFT_UNIT_VRMS = 0, + FFT_UNIT_DBVRMS, + }E_FFT_UNIT; + + /***********************************************/ + /***************** acquire config *****************/ + /***********************************************/ + enum E_ACQ_MODE + { + ACQ_MODE_NORMAL = 0, + ACQ_MODE_PEAK, + ACQ_MODE_AVERAGE, + }; + + enum E_SAMPLE_MODE + { + SAMPLE_REAL = 0, + SAMPLE_EQUIVALENT, + + SAMPLE_SCAN //add by yzz + }; + + /***********************************************/ + /***************** trigger config *****************/ + /***********************************************/ + typedef enum{ + TRIG_TYPE_EDGE = 0, //: + TRIG_TYPE_NTSC, //: Ƶ + TRIG_TYPE_WIDTH, //: + }E_TRIG_TYPE; + + typedef enum{ + TRIG_CH1 = CH_1_ID, + TRIG_CH2 = CH_2_ID, + TRIG_EXT, + TRIG_EXT_5, //EXT/5 + TRIG_AC_LINE = 4, + TRIG_ALTER, + }E_TRIG_SOURCE; + + typedef enum{ + TRIG_EDGE_RISE = 0, + TRIG_EDGE_FALL, + TRIG_EDGE_RISE_FALL, + }E_TRIG_SLOPE; + + typedef enum{ + TRIG_MODE_AUTO = 0, + TRIG_MODE_NORMAL, + TRIG_MODE_SINGLE, + }E_TRIG_MODE; + + typedef enum{ + TIRG_COUPLING_DC = 0, + TIRG_COUPLING_AC, + TIRG_COUPLING_H_RESTRAIN, //trigger coupling high frequency restrain + TIRG_COUPLING_L_RESTRAIN, //trigger coupling low frequency restrain + }E_TIRG_COUPLING; + + typedef enum{ + PULSE_CONDITION_GT = 0, //pulse condition greater than + PULSE_CONDITION_LT, //pulse condition less than + PULSE_CONDITION_ET, //pulse condition equal to + + PULSE_CONDITION_NO_EQUAL, //pulse not equal to , add by yzz [RESERVE] + }E_PULSE_CONDITION; + + typedef enum{ + PULSE_POLAR_P = 0, + PULSE_POLAR_N, + }E_PULSE_POLAR; + + enum TriggerType_Video_Standard + { + TRIG_Video_PAL = 0, + TRIG_Video_NTSC, + }; + + //Ƶ-ͬʽ(0)ż(1)(2)ָ(3) + enum TriggerType_Video_SyncMode + { + TRIG_Video_SyncMode_Odd = 0, + TRIG_Video_SyncMode_Even, + TRIG_Video_SyncMode_ALL, + TRIG_Video_SyncMode_Specified, + }; + + /***********************************************/ + /***************** display config *****************/ + /***********************************************/ + typedef enum{ + DISPLAY_TYPE_VECTOR = 0, + DISPLAY_TYPE_DOT, + }E_DISPLAY_TYPE; + + + typedef enum{ + FORMAT_YT = 0, + FORMAT_XY, + }E_FORMAT; + + typedef enum{ + DISPLAY_TIME_CLOSED = 0, + DISPLAY_TIME_1S, + DISPLAY_TIME_2S, + DISPLAY_TIME_5S, + DISPLAY_TIME_INFINITE, + }E_DISPLAY_TIME; + + /***********************************************/ + /***************** horizon config *****************/ + /***********************************************/ + typedef enum{ + WIN_TYPE_MAIN = 0, + WIN_TYPE_WINDOW, + }E_WIN_TYPE; + + /***********************************************/ + /***************** utility config *****************/ + /***********************************************/ + typedef enum{ + MENU_DISPLAY_T5S = 0, + MENU_DISPLAY_T10S, + MENU_DISPLAY_T15S, + MENU_DISPLAY_TMANUAL, + }E_MENU_DISPLAY_TIME; + + typedef enum{ + LANGUAGE_ZHCN, // + LANGUAGE_ZHTW, // + LANGUAGE_ENGLISH, //Ӣ + LANGUAGE_ESPANOL, // + LANGUAGE_PORTUGUESE, // + LANGUAGE_FRENCH, // + LANGUAGE_GERMAN, // + LANGUAGE_DUTCH, // + LANGUAGE_RUSSIANS, // + LANGUAGE_Korean, // + }E_LANGUAGE; + + typedef enum{ + SKIN_GREYISH_GREEN = 0, //dzɫ + SKIN_BLUE, //ɫ + SKIN_RED, //ɫ + SKIN_BOTTLE_GREEN, //ɫ + }E_SKIN; + + /***********************************************/ + /***************** storage config *****************/ + /***********************************************/ + typedef enum{ + STORAGE_TYPE_WAVE = 0, + STORAGE_TYPE_SETTING, + }E_STORAGE_TYPE; + + typedef enum{ + STORAGE_MEDIUM_DSO = 0, + STORAGE_MEDIUM_USB, + }E_STORAGE_MEDIUM; + + typedef enum{ + SAVSRC_CH1 = CH_1_ID, + SAVSRC_CH2 = CH_2_ID, + SAVSRC_ALL, + }E_STORAGE_WAVE_SRC_CH; + + typedef enum{ + STORAGE_DEPTH_NORMAL = 0, //ͨ洢 + STORAGE_DEPTH_LONG, //洢 + }E_STORAGE_DEPTH; + + /***********************************************/ + /**************** reference config *****************/ + /***********************************************/ + typedef enum{ + REF_A = 0, + REF_B, + }E_REF_SRC; + + /***********************************************/ + /***************** Cursor config *****************/ + /***********************************************/ + typedef enum{ + CURSOR_TYPE_VOLTAGE = 0, + CURSOR_TYPE_TIME, + CURSOR_TYPE_TRACK, + CURSOR_TYPE_CLOSED, + }E_CURSOR_TYPE; + + typedef enum{ + CURSOR_ID_1 = 0, + CURSOR_ID_2, + CURSOR_ID_MAX, + }E_CURSOR_ID; + + enum Cursor_Measure_Limit + { + Screen_Scale_H_Min = 50, + Screen_Scale_H_Max = 749, + + Screen_Scale_V_Min = 28, + Screen_Scale_V_Max = 228, + }; +#pragma endregion öֵ + +#pragma region ݽṹ + //Ļ + typedef struct _measure_param_packet + { + MeasureParam freq; + MeasureParam period; + MeasureParam risetime; + MeasureParam falltime; + MeasureParam pwidth; + MeasureParam nwidth; + MeasureParam overshoot; + MeasureParam preshoot; + MeasureParam pduty; + MeasureParam nduty; + MeasureParam vmean; + MeasureParam vpp; + MeasureParam vrms; + MeasureParam vtop; + MeasureParam vbase; + MeasureParam vmid; + MeasureParam vmax; + MeasureParam vmin; + MeasureParam vamp; + }MeasureParamPacket; + + // + typedef struct + { + MeasureParam freq; + MeasureParam period; + MeasureParam risetime; + MeasureParam falltime; + MeasureParam pwidth; + MeasureParam nwidth; + MeasureParam overshoot; + MeasureParam preshoot; + MeasureParam pduty; + MeasureParam nduty; + MeasureParam vmean; + MeasureParam vpp; + MeasureParam vrms; + MeasureParam vtop; + MeasureParam vbase; + MeasureParam vmid; + MeasureParam vmax; + MeasureParam vmin; + MeasureParam vamp; + + // + char Reserve[24]; + }MeasureParamPacket_UTD2000CEX; + + // + typedef struct + { + MeasureParam freq; // + MeasureParam period; // + MeasureParam risetime; // + MeasureParam falltime; // + MeasureParam pwidth; // + MeasureParam nwidth; // + MeasureParam overshoot; // + MeasureParam preshoot; // + MeasureParam pduty; // + MeasureParam nduty; // + MeasureParam vmean; // + MeasureParam vpp; // + MeasureParam vrms; // + MeasureParam vtop; // + MeasureParam vbase; // + MeasureParam vmid; // + MeasureParam vmax; // + MeasureParam vmin; // + MeasureParam vamp; // + + // + MeasureParam area; // + MeasureParam cycleArea; // + MeasureParam cycleMean; //ƽֵ + MeasureParam cycleRms; //ھֵ + MeasureParam burstWidth; //ͻ + } MeasureParamPacket_UTD2102CM; + + //cmd: GET_PROCSTATE, SET_PROCSTATE + typedef struct _proc_state{ + //0, PROC_STOP; 1, PROC_RUN; 1, PROC_ARMED; 2, PROC_READY; 3, PROC_TRIGED; 4, PROC_AUTO; 5, PROC_SCAN; 6, PROC_OVER; + short procState; + }PROC_STATE; + + ////////////////////////////////////////////////////////////////////////// + // ϵ + // ͨGET_CH1_DISPLAY_DATAGET_DISPLAY_DATAȡIJݵϵ + // X ֵ0ʼΧǵ + // Y ȡADCΧֵ[0,255] UTD2102CEX ײ28228ΧΪ200 + ////////////////////////////////////////////////////////////////////////// + //cmd: GET_SCREEN_INFO + typedef struct _screen_info{ + short screen_width; //Ļȣֵ + short screen_height; //Ļ߶ȣֵ + short x_grid_count; // + short y_grid_count; // + short x_grid_pixels; //Ԫ + short y_grid_pixels; //Ԫ + short y_min; //ϵy귶Χ[y_min y_max] + short t_min; //ϵx귶Χ[t_min t_max]0ʼ + short y_max; //ϵy귶Χ[y_min y_max] + short t_max; //ϵx귶Χ[t_min t_max]0ʼ + }ScreenInfo; + + /********************************************** + *************** Channel Switch ****************** + ***********************************************/ + typedef struct _channel_switch{ + short ch_switch; + }ChannelSwitch; + + /* channel attribute configuration : cmd = SET_CH1_ATTRIBUTE, GET_CH1_ATTRIBUTE */ + typedef struct _channel_attribute{ + short coupling; //CH_COUPLING + short bwlimited; //SWITCH_STATE + short voltscale; //CH_VOLT_SCALE + short probe; //CH_PROBE + short inverted; //SWITCH_STATE + }ChannelAttribute; + + /* channel attribute configuration : cmd = SET_CH1_ATTRIBUTE, GET_CH1_ATTRIBUTE */ + typedef struct _pre_offset_volt{ + short preOffsetSwitch; //0, STATE_CLOSED; 1, STATE_OPEN + short coarseValue; // + short fineValue; // + short toZero; //0, don't set to zero; 1, set to zero + }PreOffsetVolt; + + typedef struct _channel_vpos{ + short vpos; //[(TOP: 378), (Middle: 128), (BOTTOM: -122)] + }ChannelVPos; + + typedef struct _channel_volt_level{ + short voltLevel; //when set cmd, para: 1 or -1, when get cmd, voltage level value + float voltValue; //ȡ̽ͷΪX1ǵķֵ + short voltUnit; + short IsLimit; + }ChannelVLevel; + + /***********************************************/ + /******** horizontal system: channel time base *******/ + /***********************************************/ + typedef struct _channel_timebase{ + short timeBase; + }ChannelTimeBase; + + typedef struct _channel_tpos{ + short tpos; //[(Left: 0), (Middle: 350), (Right: 700)] + }ChannelTPos; + + /***********************************************/ + /******** tigger system: channel trigger position ******/ + /***********************************************/ + typedef struct _channel_trig_level{ + short trigLevel; //[-375, 0(middle), 375] + float trigValue; + short trigUnit; + short isLimited; + }ChannelTLevel; + + typedef struct _math_type{ + int mathType; + }MathType; + + typedef struct _fft_freq{ + float freqValue; + int freqUnit; + int IsLimit; // == 1,yes; =0, no! + }SignalFreq; + + typedef struct _math_config{ + short mathOpA; + short mathOpB; + short mathOpSign; + }MathConfig; + + typedef struct _fft_config{ + short fftSource; + short fftWindow; + short fftUnit; + }FFTConfig; + + typedef struct _acquire_config{ + short acquireMode; + short averageNum; //2^(averageNum + 1), ie: {(0: 2), (1: 4), (2: 8), (3: 16), (4: 32), (5: 64), (6: 128), (7: 256)} + short sampleMode; + short fastAcquire; + }AcquireConfig; + + typedef struct _trig_config{ + short trigType; + short trigSource; + short trigMode; + short trigCoupling; + }TriggerConfig; + + typedef struct _trig_edge_config{ + TriggerConfig trigConfig; + short trigSlope; + }TrigEdgeConfig; + + typedef struct _trig_pulse_config{ + TriggerConfig trigConfig; + short pulseCondition; + UINT pulseWidth; + short pulsePolar; + }TrigPulseConfig; + + typedef struct _display_config{ + short displayType; + short displayFormat; + short displayTime; + short displayLum; + }DisplayConfig; + + typedef struct _horizon_config{ + short windowType; //E_WIN_TYPE + unsigned int holdOff; //[10, 187500000] + }HorizonConfig; + + typedef struct _utility_config{ + short autoCalibrate; //0, not do auto calibrate; 1, do auto calibrate + short menuDisplayTime; //E_MENU_DISPLAY_TIME + short language; //E_LANGUAGE + short defaultSetting; //0, not do default setting; 1 do default setting + short skin; //E_SKIN + short gridBrightness; //[1, 100] + short sysInfo; //0, not display system info; 1, display system info; + short cymometer; //0: close; 1: open + }UtilityConfig; + + typedef struct _storage_setting{ + short saveType; //STORAGE_TYPE_SETTING + short savePos; //[1, 20] + + short save; //1, save, 0, not save + short recall; //1, recall, 0, not recall + }StorageSetting; + + typedef struct _storage_wave{ + short saveType; //STORAGE_TYPE_WAVE + short saveSource; + short savePos; + short saveMedium; + short saveDepth; + short save; + }StorageWave; + + /***********************************************/ + /***************** measure config *****************/ + /***********************************************/ + typedef struct _measure_config{ + short measureSrc; + }MeasureConfig; + + typedef struct _ref_timebase{ + float ref_TValue; + int ref_Tunit; + }RefTimeBase; + + + typedef struct _ref_config + { + short refSrc; //REF_A, REF_B + short pos; //[1, 20] + short medium; //MEDIUM_DSO, MEDIUM_USB + + short onoff; //1, on; 0, off; + }RefConfig; + + typedef struct _cursor_measure_result{ + MeasureParam Va; + MeasureParam Vb; + MeasureParam deltaV; + MeasureParam TaFa;// when ch1, ch2, Ta; when math channel, Fa; + MeasureParam TbFb;// when ch1, ch2, Tb; when math channel, Fb; + MeasureParam deltaT; + MeasureParam deltaF; + char Reserve[56]; + }CursorMeasureResult; + + typedef struct _cursor_config{ + short cursorType; + short iActiveCursor; + //Ҫӻʶ + short voltCursorPos[CURSOR_ID_MAX];//[28(top), 428(bottom)] + short timeCursorPos[CURSOR_ID_MAX];//[50(left), 749(right)] + short autoCursorPos[CURSOR_ID_MAX];//[51(left), 749(right)] + }CursorConfig; + + + /***********************************************/ + /***************** measure config *****************/ + /***********************************************/ + typedef struct _measure_src + { + short measureSrc; + }MeasureSrc; +#pragma endregion ݽṹ + +#ifdef __cplusplus +} +#endif + +#endif//end of #ifndef _DSOCOM_API_COMMON_DEF_H_201212281614 \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/include/dso_base.h b/Driver/UDP5080-100/UNI-T SDK/include/dso_base.h new file mode 100644 index 0000000..7801310 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/dso_base.h @@ -0,0 +1,171 @@ +/*! + * \created : 2016/12/27 + * \author : M.Yang + * \purpose : ṩUCIӿʹõģDSOͨö塣 + */ +#ifndef dso_base_h__ +#define dso_base_h__ + +#ifdef __cplusplus +namespace comAPICommon { +#endif + //ʱλлһ£˲ͬıԵ +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + TLEVEL_1NS = 0, + TLEVEL_2NS, + TLEVEL_5NS, + TLEVEL_10NS, + TLEVEL_20NS, + TLEVEL_50NS, + TLEVEL_100NS, + TLEVEL_200NS, + TLEVEL_500NS, + TLEVEL_1US, + TLEVEL_2US, + TLEVEL_5US, + TLEVEL_10US, + TLEVEL_20US, + TLEVEL_50US, + TLEVEL_100US, + TLEVEL_200US, + TLEVEL_500US, + TLEVEL_1MS, + TLEVEL_2MS, + TLEVEL_5MS, + TLEVEL_10MS, + TLEVEL_20MS, + TLEVEL_50MS, + TLEVEL_100MS, + TLEVEL_200MS, + TLEVEL_500MS, + TLEVEL_1S, + TLEVEL_2S, + TLEVEL_5S, + TLEVEL_10S, + TLEVEL_20S, + TLEVEL_50S, + TLEVEL_100S, + TLEVEL_200S, + }E_TIMEBASE_LEVEL; + +#ifdef __cplusplus + typedef enum : short { +#else + typedef enum { +#endif // __cplusplus + VLEVEL_1MV = 0, + VLEVEL_2MV, + VLEVEL_5MV, + + VLEVEL_10MV, + VLEVEL_20MV, + VLEVEL_50MV, + + VLEVEL_100MV, + VLEVEL_200MV, + VLEVEL_500MV, + + VLEVEL_1V, + VLEVEL_2V, + VLEVEL_5V, + + VLEVEL_10V, + VLEVEL_20V, + } E_VOLTAGEBASE_LEVEL; + + typedef struct _measure_param { + float value; + int unit; + }MeasureParam; + + typedef struct _time { + unsigned short Year; + unsigned short Month; + unsigned short Day; + unsigned short Hour; + unsigned short Minute; + unsigned short Second; + }Time; + + typedef struct _UnitParam { + char Type; //λͣTimeFreqȡ嶨ĵ + char Scale; //knpMȡ嶨ĵ + }UnitParam; + + //@brief : ֵ + //@remark: 4Byte align -> 8Bytes + typedef struct _MeaValue { + float Value; + UnitParam Unit; + char IsValid; //ǷЧ 0 ʾЧ 1ʾЧ + char IsExist; //Ƿڡ 0 ʾڣ 1ʾڡ + }MeaValue; + + //@brief : ݰͨö塣 + //@remark: + typedef enum _EMeaParam { + MP_MAX = 0, //ֵ + MP_MIN, //Сֵ + MP_HIGH, //High(Top)-ߵƽ(ֵ) + MP_MIDDLE, //Middle-мֵ + MP_LOW, //Low(Bottom) - ͵ƽ(׶ֵ) + + MP_PKPK, //VPP-ֵ + MP_AMP, //Сֵ + MP_MEAN, //ƽֵ + MP_CYCMEAN, // + MP_RMS, // + + MP_CYCRMS, //ھֵ + MP_AREA, // + MP_CYCAREA, // + MP_OVERSHOOT,// + MP_PRESHOOT, //Ԥ + + MP_PERIOD, // + MP_FREQ, //Ƶ + MP_RISE_TIME,//ʱ + MP_FALL_TIME,//½ʱ + MP_PWIDTH, // + + MP_NWIDTH, // + MP_PDUTY, //ռձ + MP_NDUTY, //ռձ + MP_RISEDELAY,//ʱ + MP_FALLDELAY,//ʱ + + MP_PHASE, //λ + MP_FRR, // + MP_FRF, + MP_FFR, + MP_FFF, + + MP_LRF, + MP_LRR, + MP_LFR, + MP_LFF, + + MP_BURST_WIDTH, //ͻ + + // + //reserve section + // ²׷ + // + // + //̶λ50 + MP_MAX_COUNT = 50, + }EMeaParam; + +#ifdef __cplusplus + } + namespace uci { + using namespace comAPICommon; + namespace cb = comAPICommon;//comAPICommon alias + } +#endif + +#endif // dso_base_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/include/uci.h b/Driver/UDP5080-100/UNI-T SDK/include/uci.h new file mode 100644 index 0000000..6c73e78 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/uci.h @@ -0,0 +1,228 @@ +/******************************************************************** + created: 2014/12/22 + author: M.Yang + purpose: UCI(united communicate interface) +*********************************************************************/ + +#ifndef uci_h__ +#define uci_h__ + +#include "ucidef.h" + +////////////////////////////////////////////////////////////////////////// +// ڽӿڷص״ֵ̬ +// < 0 : ʾ +// ӦĴϢͨuci_GetLastErrorȡ,Ķucidef.hļС +// < UCI_ERRĴΪlibusbĴ롣 +////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +namespace uci { +extern "C"{ +#endif + //@brief : ִỰ޹صIJѯ + //@param PRParams _params : ѯIJ + //@param u_byte * _data : ݵĻַ + //@param u_size _dataCount : ݵĻСBytes + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_Query(_in_out PRParams _params, _in_out u_byte* _data, _in u_size _dataCount); + + //@brief : ѯͨŽڵ + //@param _in const QParams * _params : ѯ + //@param _out Node * _outBuf : ŲѯĽڵ + //@param _in_out u_size * _nodeCnt : ΪҪȡĽڵΪʵʶȡĽڵ + //@param _in u_size _timeOut : ѯʱ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_QueryNodes(_in const QParams* _params, _out Node* _outBuf, + _in_out u_size* _nodeCnt, _in u_size _timeOut); + + //@brief : ѯͨŽڵ + //@param _msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _nodes : ŲѯĽڵ + //@param _node_count : ҪѯĽڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX(u_cstring _msg, Node* _nodes, u_size _node_count, _in u_size _timeout); + + /*21-7-2017 15:51 by M.J Created <򻯰汾ѯͨѶڵ㲢ͨŵַ>*/ + //@brief : ѯͨŽڵ + //@param _addr_msg : ѯַʽ磺 "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + //@param _addr_msg_len : յַַbufferij + //@param _node_type : ڵ + //@param _timeout : ѯʱ + //@return : < 0 룻 >=0 ѯĽڵ㣨豸 + //@remarks : + u_status _UCIAPI uci_QueryNodesX_Simple(u_tchar* _addr_msg, u_size _addr_msg_len, u_size _node_type, _in u_size _timeout); + + //@brief : 豸 + //@param u_cstring _addr : 豸ַ '\0'β + //@param u_session * _session : ѽĻỰID. + //@param u_uint32 _timeOut : ӳʱʱ ms + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + // UCI_SUCCESS + // UCI_ERR_ARGS_WRONG; + // UCI_ERR_RES_INIT_ERROR; + // UCI_ERR_CONNECT_ADDR_WRONG; + // UCI_ERR_CONNECT_FAILED; + // UCI_ERR_CONNECT_TIMEOUT] + //@remarks : ĵ + u_status _UCIAPI uci_Open(u_cstring _addr, u_session* _session, u_uint32 _timeOut); + + //@brief : 豸 + //@param _addr : 豸ַ '\0'β + //@param _timeOut : ӳʱʱ ms + //@return : < 0 룻 >=0 ỰID + //@remarks : ӿuci_Openļ򻯰汾 + u_status _UCIAPI uci_OpenX(u_cstring _addr, u_uint32 _timeOut); + + //@brief : ִ + //@param u_session _session : ỰID + //@param PCommandParams _params : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SendCommand(u_session _session, PCommandParams _params); + + //@brief : UCI¼ + //@param uciNotify _pNotify : ӦUCI¼Ļص + //@return u_status _UCIAPI : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_SetNotify(UCIMSGProc _pNotify); + + //@brief : + //@param _msg : ַ + //@param _obj : ݻַ + //@param _objSize : ݻС + //@return : 鿴ļеġڽӿڷص״ֵ̬˵s + //@remarks : Ŀǰֻ֧л԰汾Ͷ豸ͷĵ¼鿴ĵ + u_status _UCIAPI uci_SetAttribute(u_session _sesn, u_cstring _msg, const u_object* _obj, u_size _objSize); + + //@brief : ѯ + //@param u_session _sesn : + //@param u_attr _name : + //@param u_attr_v * _value : + //@return u_status _UCIAPI : + //@remarks : + u_status _UCIAPI uci_GetAttribute(u_session _sesn, u_cstring _msg, u_object* _obj, u_size _objSize); + + //@brief : д + //@param u_session _session : ỰID + //@param PWParam _params : д + //@param const u_byte * _data : Ҫдݻַ ΪNULL + //@param u_size _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_params.CMDStringѾҪдֶˣʹuci_FormatWriteӿڣ + // _data != NULLַ_params.CMDStringֻܰһ䡣 + u_status _UCIAPI uci_Write(u_session _session, PWParams _params, const u_byte* _data, u_size _len); + + //@brief : д + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@param _data : Ҫдݻַ ΪNULL + //@param _len : Ҫдݻijȣ _buf == NULL,_lenᱻԿΪκֵ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : _dataΪnullʾ_msgѾҪдֶˣ + // _data != NULLַ_msgֻܰһ䡣 + u_status _UCIAPI uci_WriteX(u_session _session, u_cstring _msg, + u_uint32 _timeout, const u_byte* _data, u_size _len); + + //@brief : ֻдַָдָӿ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteSimple(u_session _session, u_cstring _msg, u_uint32 _timeout); + + //@brief : ʽд + //@param u_session _sesn : ỰID + //@param u_uint32 _timeOut : дʱ(λms) + //@param const u_tchar * format : ַ'\0'β. ʽĵ + //@param ... : + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_FormatWrite(u_session _sesn, u_uint32 _timeOut, const u_tchar *format, ...); + + //@brief : ȡ + //@param u_session _session : ỰID + //@param PRParams _params : + //@param u_byte * _data : ݵĻ + //@param u_size _dataLen : ݵĻССЭ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ʹuci_ReadX汾 + u_status _UCIAPI uci_Read(u_session _session, PRParams _params, u_byte* _data, u_size _dataLen); + + //@brief : ȡ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _timeout : ȡʱ + //@param _data : նȡݵĻַ + //@param _dataLen : _dataָĻȣBytes + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_Readļ򻯰汾 + u_status _UCIAPI uci_ReadX(u_session _session, u_cstring _msg, + u_uint32 _timeout, u_byte* _data, u_size _dataLen); + + //@brief : дļ + //@param u_session _session : ỰID + //@param WFileParams * _info : ļϢ + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_WriteFromFile(u_session _session, WFileParams* _info); + + //@brief : дļ + //@param _session : ỰID + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : Ҫдļ·ļ + //@param _timeout : дʱ(λms) + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_WriteFromFileļ򻯰汾 + u_status _UCIAPI uci_WriteFromFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout); + + //@brief : Read data synchronously and store the transferred data in a file. + //@param u_session _session : ỰID + //@param RFileParams _params : Ҫݵļ· + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : + u_status _UCIAPI uci_ReadToFile(u_session _session, RFileParams* _params); + + //@brief : ȡļ + //@param _session : ỰID. + //@param _msg : ַ'\0'β. ʽĵ + //@param _filePath : ݵش̵ļ·ļͺ׺ + //Ǿ·Ҳ··ͨ_filePathFinalȡ· + //@param _timeout : ʱ + //@param _filePathFinal : 嵽صļľ· + //@param _filePathFinalLength : _filePathFinalijȣַ + //@return : 鿴ļеġڽӿڷص״ֵ̬˵ + //@remarks : ӿuci_ReadToFileķǷװ汾 + u_status _UCIAPI uci_ReadToFileX(u_session _session, u_cstring _msg, + u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength); + + //@brief : رջỰ + //@param u_session _session : ҪرյĻỰID + //@return u_status : 鿴ļеġڽӿڷص״ֵ̬˵ + u_status _UCIAPI uci_Close(u_session _session); + + //@brief : һβӦĴ״̬Ϣ + //@return u_cstring : Ϣ + //@remarks : ͨuci_SetAttributeôϢ԰汾 + u_cstring _UCIAPI uci_GetLastError(void); + + //@brief : ˳UCIʵʱá + //@remarks : ˳ʱãͷڲԴ + // ӿڲһҪʹá ֻ.NETйܻ£ + // ͨuci_SetAttribute uci_SetNotifyӿ + // 豸Ƴ¼ʱ˳ʱʹá + void _UCIAPI uci_ExInstance(void); +#ifdef __cplusplus +} + +} +#endif +#endif // uci_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/include/uci_cpp.h b/Driver/UDP5080-100/UNI-T SDK/include/uci_cpp.h new file mode 100644 index 0000000..79751d8 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/uci_cpp.h @@ -0,0 +1,60 @@ +/*! + * \created : 2017/3/17 + * \author : M.Yang + * \purpose : ṩUCIC++汾ӿ + */ +#ifndef uci_cpp_h__ +#define uci_cpp_h__ +#include "uci.h" + +namespace uci { + class Session; +} + +//@brief : UCI Ự +//@remark: uci_ǰ׺CԹ淶Ľӿ򵥷װĺôǣ +// 1SessionʱԶرջỰǣʹõʹʱעʹ߼Ǵ߼ +// 2ÿһӿϣʡȥһSession IDΣҿ趨βεĬֵijЩCԱ֧֣ʹýӿڸ򵥣 +// ע⣺ +// ಻ȫӿڵ䣬Ҫ䡣 +class uci::Session { +public: + Session() : m_Session(INVALID_SESSION) {} + virtual ~Session() { + if (m_Session != INVALID_SESSION) { + uci_Close(m_Session); + m_Session = INVALID_SESSION; + } + } + + u_status Open(u_cstring _addr, u_uint32 _timeout = 2000) { + u_status r = uci_OpenX(_addr, _timeout); + if (UCISUCCESS(r)) + m_Session = (u_session)r; + return r; + } + + u_status Write(u_cstring _msg,u_uint32 _timeout = 1000, const u_byte* _data = NULL, u_size _len = 0) { + return uci_WriteX(m_Session, _msg, _timeout, _data, _len); + } + + u_status Read(u_cstring _msg,u_uint32 _timeout, u_byte* _data, u_size _dataLen) { + return uci_ReadX(m_Session, _msg, _timeout, _data, _dataLen); + } + + u_status WriteFromFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout) { + return uci_WriteFromFileX(m_Session, _msg, _filePath, _timeout); + } + + u_status ReadToFile(u_cstring _msg, u_cstring _filePath, u_uint32 _timeout, + u_tchar *_filePathFinal, u_int32 _filePathFinalLength) { + return uci_ReadToFileX(m_Session, _msg, _filePath, _timeout, _filePathFinal, _filePathFinalLength); + } + + u_status Close() { return uci_Close(m_Session); } + u_session GetSession() const { return m_Session; } +protected: + u_session m_Session; +}; + +#endif // uci_cpp_h__ diff --git a/Driver/UDP5080-100/UNI-T SDK/include/ucidef.h b/Driver/UDP5080-100/UNI-T SDK/include/ucidef.h new file mode 100644 index 0000000..f5bf38d --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/ucidef.h @@ -0,0 +1,571 @@ +/******************************************************************** + created: 2014/12/23 + author: M.Yang + purpose: UCIȫֶļ + modify: + *********************************************************************/ +#ifndef ucidef_h__ +#define ucidef_h__ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) +#define _UCIAPI __stdcall +#define _UCICallBack __stdcall +#endif + +#define _in +#define _out +#define _in_out + +#ifdef __cplusplus +namespace uci { +#endif // __cplusplus + +#ifdef _CVI_ +#define u_inline static +#else +#define u_inline inline +#endif // _CVI_ + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif // !MAX_PATH + + ////////////////////////////////////////////////////////////////////////// + //{ Ͷ +#ifdef _UNICODE + //@brief : ʾһ Unicode ַ +#define u_tchar wchar_t +#else + //@brief : ʾһ ASCII ַ +#define u_tchar char +#endif // _UNICODE + +#if defined(_WIN64) + typedef unsigned __int64 u_unit_ptr; + typedef __int64 u_long_ptr; +#else + typedef unsigned int u_unit_ptr; + typedef long u_long_ptr; +#endif + + //@brief : Boolean +#define u_bool bool + //@brief : 8λ޷ +#define u_byte unsigned char + //@brief : 8λз +#define u_char char + //@brief : ָ͵Ļָ +#define u_buf void* + //@brief : ͵ij +#define u_object void + //@brief : ʾ 16 λз +#define u_short short + //@brief : ʾ 16 λ޷ +#define u_ushort unsigned short + //@brief : ʾ 16 λз +#define u_int16 u_short + //@brief : ʾ 16 λ޷ +#define u_uint16 u_ushort + //@brief : ʾ 32 λз +#define u_int32 int + //@brief : ʾ 32 λ޷ +#define u_uint32 unsigned int + //@brief : ʾUCIӿڷص״ֵ̬(32λз) +#define u_status u_int32 + //@brief : ʾС32λ޷ +#define u_size u_uint32 + //@brief : ʾỰID32λ޷ +#define u_session u_uint32 + //@brief : ʾַ +#define u_string u_tchar* + //@brief : ʾַֻ +#define u_cstring const u_tchar* + //@brief : ʾIDͣ32λ޷ +#define u_attr u_int32 + //@brief : ʾֵͣ32λ޷ +#define u_attr_v u_int32 + //@brief : ʾһ16λ޷͵ĵ +#define u_word u_ushort + //@brief : ʾһ32λ޷͵˫ +#define u_dword u_uint32 + //@brief : Ϣ +#define u_wparam u_unit_ptr + //@brief : Ϣ +#define u_lparam u_long_ptr + //} + + ////////////////////////////////////////////////////////////////////////// + //{ ӿڷ״ֵ̬ + //@brief : ɹ +#define UCI_SUCCESS (0) + //@brief : ʼֵ +#define UCI_ERR (-1000) + //@brief : жϵǰӿǷִʧ + //@brief : жϵǰӿǷִгɹ +#define UCIERR(r) (r < 0) +#define UCISUCCESS(r) (!UCIERR(r)) + + //@brief : + typedef enum _UCIErr { + NoError = 0, + + //@brief : Դʼ + InitResourceError = UCI_ERR - 20, + //@brief : ЧĻỰ + Invalid_Session, + //@brief : ʱ + Timeout, + //@brief : ʧ + Failed, + //@brief : ֵ֧IJ + Unsupported, + //@brief : ڴռ䲻 + Insufficient_Memory, + //@brief : ϵͳæ޷Ӧ + Busy, + //@brief : ͨ쳣棡 + COMExpection, + //@brief : ͨδ򿪣 + ChannelNotOpened, + //@brief : WinAPI + API_Failed, + + //@brief : δ֪Ĵ + Unknown = UCI_ERR - 40 - 1, + + //@brief : ӵַַʽ + Connect_InvalidAddress = UCI_ERR - 40, + //@brief : ӻδ + Connect_NotBuild, + //@brief : ѶϿ + Connect_Break, + //@brief : ֵ֧ͨŷʽ + Connect_Unsupported_COMType, + + //@brief : δָ豸 + Device_NoFound = UCI_ERR - 60, + //@brief : ֵ֧豸 + Device_Unsupported, + //@brief : Ҫִвѯ豸IJ + Device_QueryFirst, + //@brief : Ͳƥ + Device_NotMatch, + + //@brief : ѯ豸ʧ + Query_LANNodesFailed, + + //@brief : USB豸ִַֻвѯ豸Ч + //@remarks : UCI⵼USB豸ַֻһб豸ַ + AddrValid_AfterQueryDeviceOper, + + //@brief : δU̽ + UDisk_NotFound, + //@brief : Ѿ + Key_Locked, + + //@brief : ַʽ + CMD_Invalid_StringFormat = UCI_ERR - 80, + //@brief : ֵֻ֧ + CMD_OnlySupportSingle, + //@brief : һֻ֧һ + CMD_OnlySupportSingleAttr, + //@brief : ֵ֧ + CMD_Unsupported, + //@brief : ʧ + CMD_SendFailed, + //@brief : Эݸʽ + CMD_Invalid_ProtocolFormat, + //@brief : 豸дļflashʧܣ + CMD_WriteFileToFlash_Failed, + //@brief : δЧĻظ + CMD_NoFound_Valid_Reply_Data, + //@brief : Ϣ鿴ǷЭ + CMD_Error_Message, + //@brief : Чıʽ + CMD_Invalid_Expression, + //@brief : ڵǰģʽ²ԼⲨļ + CMD_Cannot_LoadARB_InCurrent_MOD_Mode, + + //@brief : + Args_Invalid = UCI_ERR - 100, + //@brief : ṩĿռ̫С + Args_MemoryTooSmall, + //@brief : ṩļ̫(50ֽ) + Args_FileNameTooLong, + //@brief : ݴСЭ鲻ƥ(ֹݴ) + Args_DataLenNotMatch, + + //@brief : + Data_Overflow = UCI_ERR - 120, + //@brief : Χ + Data_OutRange, + //@brief : δȫȡ + Data_NotReadEnoughLenth, + //@brief : Уʧ + Data_ECC_Failed, + //@brief : Ч + Data_Invalid, + //@brief : ѹʧ + Data_Zip_Error, + //@brief : ݽѹʧ + Data_UnZip_Error, + //@brief : ݴʧ + Data_Transfer_Error, + //@brief : ݴʧ + Data_Transfer_Break, + //@brief : Чݿɶȡ + Data_No_Data_Incoming, + + //@brief : + File_AccessDenied = UCI_ERR - 140, + //@brief : An unspecified error occurred. + File_GenericException, + //@brief : The file could not be located. + File_NotFound, + //@brief : All or part of the path is invalid. + File_BadPath, + //@brief : The permitted number of open files was exceeded. + File_TooManyOpenFiles, + //@brief : There was an attempt to use an invalid file handle + // or The file format is unsupported! + // or The file data is error! + File_InvalidFile, + //@brief : The current working directory cannot be removed + File_RemoveCurrentDir, + //@brief : There are no more directory entries + File_DirectoryFull, + //@brief : There was an error trying to set the file pointer + File_BadSeek, + //@brief : There was a hardware error + File_HardIO, + //@brief : SHARE.EXE was not loaded, or a shared region was locked + File_SharingViolation, + //@brief : There was an attempt to lock a region that was already locked + File_LockViolation, + //@brief : The disk is full + File_DiskFull, + //@brief : The end of file was reached + File_EndOfFile, + //@brief : дļʧ + File_SaveToDiskFailed, + //@brief : ļȳΧ + File_Length_OutOfRange, + }UErr; + //} + ////////////////////////////////////////////////////////////////////////// + + //@brief : ĻỰID +#define INVALID_SESSION ((u_uint32)(-1)) + + ////////////////////////////////////////////////////////////////////////// + //{ + //лӢģ "lang:zh-hans" or "lang:en-us" + //ʹUSB豸ƳӼ "devchange:1" +//} + + +#define CACHE_LINE 1 +#define CACHE_ALIGN __declspec(align(CACHE_LINE)) + + //@brief : ýṹĶ뷽ʽ +#define PACK_ALIGN(n) __declspec(align(n)) + + +#ifdef __cplusplus + extern "C"{ +#endif // __cplusplus + + //one Word is 2 bytes + u_inline u_word UCI_HIWORD(u_dword _dw) { return ((u_word)((_dw >> 16) & 0xffff)); } + u_inline u_word UCI_LOWORD(u_dword _dw) { return ((u_word)(_dw & 0xffff)); } + + //#pragma pack(show)// C4810 + //ensure byte-packed structures1ֽڶ룩 +#include //뻷ûиļ滻Ϊǰƽֽ̨ڶ䡣 + + //@brief : ݽӿڵIJ + //@remarks : ͨͨuci_CreateRParamsӿڴ + typedef struct _RParams { + //@brief : ַ'\0'β. ʽЭĵ + u_cstring CMDString; + //@brief : ҪصӾͨҪȡ\ѯǶӦģ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + //@brief : + //@remarks : ͨʹãɿ;ڲѯ豸ʱõ + //ΪQParamsĵΪ׼ + u_buf ExtraData; //reserve + //@brief : ݵij + u_size ExtraDataLen; + }RParams, *PRParams; + +#ifdef __cplusplus + inline RParams* uci_CreateRParams(RParams& _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + _p.ExtraData = _ExtraData; + _p.ExtraDataLen = _ExtraDataLen; + return &_p; + } +#else + u_inline RParams* uci_CreateRParams(RParams* _p, u_cstring _cmd, + u_uint32 _timeout, u_buf _ExtraData, + u_size _ExtraDataLen) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + _p->ExtraData = _ExtraData; + _p->ExtraDataLen = _ExtraDataLen; + return _p; + } +#endif + + typedef struct _DeviceIOParams { + u_int32 Count; + u_int32* Data; + }DeviceIOParams; + + typedef struct _QParams { + //@brief : ҪѯͨŽڵ + //@remarks : enum NodeType ȡֵ ͨ־λֵ + //@eg NodeType::USB | NodeType::LAN + u_int32 Type; + //@brief : ˿ڼ˿ + u_int32 PortCount; + //@brief : ˿ڼ + u_int32* Ports; + //@brief : PVIDPVIDĸ + //@remarks : + u_int32 PVIDCount; + //@brief : PID VID + //@remarks : ʹMakePVIDGetPIDGetVIDȡ + u_int32* PVID; + //@brief : ѯַnullptrʱʾѯ豸ѯָ豸豸 + u_cstring Msg; + }QParams, *PQParams;//@brief : ѯ豸ʱò + + u_inline u_int32 MakePVID(u_ushort _pid, u_ushort _vid) { return ((_pid << 16) | (_vid)); }; + + u_inline u_ushort GetPID(u_int32 _pvid) { return UCI_HIWORD(_pvid); } + + u_inline u_ushort GetVID(u_int32 _pvid) { return UCI_LOWORD(_pvid); } + +#ifdef __cplusplus + inline QParams* UCI_CreateQParam(QParams& _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(&_qp, 0, sizeof(_qp)); + _qp.Type = _type; + _qp.Ports = _ports; + _qp.PortCount = _port_cnt; + _qp.PVID = _pvid; + _qp.PVIDCount = _pvid_cnt; + _qp.Msg = _msg; + return &_qp; + } +#else + u_inline QParams* UCI_CreateQParam(QParams* _qp, u_int32 _type, + u_int32* _ports, u_int32 _port_cnt, + u_int32* _pvid, u_int32 _pvid_cnt, u_cstring _msg) { + memset(_qp, 0, sizeof(*_qp)); + _qp->Type = _type; + _qp->Ports = _ports; + _qp->PortCount = _port_cnt; + _qp->PVID = _pvid; + _qp->PVIDCount = _pvid_cnt; + _qp->Msg = _msg; + return _qp; + } +#endif + //@brief : дݽӿڲ + //@remarks : ͨӿuci_CreateWParams + typedef struct _WParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : صݣӾ + u_uint32 RetCount; + //@brief : ʱ + u_uint32 Timeout; + }WParams, *PWParams; + +#ifdef __cplusplus + u_inline WParams* uci_CreateWParams(WParams& _p, u_cstring _cmd, u_uint32 _timeout) { + memset(&_p, 0, sizeof(_p)); + _p.CMDString = _cmd; + _p.Timeout = _timeout; + return &_p; + } +#else + u_inline WParams* uci_CreateWParams(WParams* _p, u_cstring _cmd, u_uint32 _timeout) { + memset(_p, 0, sizeof(*_p)); + _p->CMDString = _cmd; + _p->Timeout = _timeout; + return _p; + } +#endif + typedef struct _CommandParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : 1 + u_uint32 Param1; + //@brief : 1 + u_uint32 Param2; + //@brief : ʱ + u_uint32 Timeout; + }CommandParams, *PCommandParams; + + //@brief : дļIJ + typedef struct _WFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : Ҫдļ·ļ + u_cstring FilePath; + //@brief : дʱ(λms) + u_uint32 Timeout; + }WFileParams, *PWFileParams; + + //@brief : ļӿڵIJ + typedef struct _RFileParams { + //@brief : ַ'\0'β. ʽĵ + u_cstring CMDString; + //@brief : ݵش̵ļ·ļͺ׺ + u_cstring FilePath; + //@brief : ʱ(λms) + u_uint32 Timeout; + //@brief : ļ· + u_tchar FilePathFinal[MAX_PATH]; + }RFileParams, *PRFileParams; + + //@brief : ͨŽڵ + //@remarks : QParamsǰλ룬Nodeȡenumֵ + typedef enum _NodeType{ + LAN = 0x0001, + USB = 0x0010, + }NodeType; + + //@brief : USB豸 + //@remarks : + typedef struct _USBDescriptor { + //@brief : PID + u_ushort PID; + //@brief : VID + u_ushort VID; + //@brief : ַ + u_ushort Addr; + }USBDescriptor; + + //@brief : IPַ + //@remarks : ˳Ϊ f1(192).f2(168).f3(1).f4(253) - Сģʽ + typedef union _IPAddr { + struct { u_byte f1, f2, f3, f4; } Field; + u_int32 Addr; + }u_IPAddr; + + //@brief : LANͨŵ豸 + //@remarks : + typedef struct _LANDescriptor { + //@brief : IPַַͣ + u_tchar IP[16]; + //@brief : IPַ + u_IPAddr Addr; + //@brief : ˿ + //@remarks : TCPIPõĶ˿ں + u_ushort Port; + }LANDescriptor; + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _Node { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµƣ + // ѳδͳһʱUCIڲԶƥΪUCIЭõ֣ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }Node, *PNode; + + + //@brief : ѯ豸ڵIJ + //@remarks : + typedef struct _NodeEx { + //@brief : ͨŽӿڷʽ + NodeType Type; + //@brief : 豸() + //@remarks : ڱUCI⵼ʱΪUCIЭһµơ + u_tchar Name[50]; + //@brief : 豸 + //@remarks : źԴ = SG, ʾ = DSO; + u_tchar DevType[10]; + //@brief : LANڲ + LANDescriptor LAN; + //@brief : USBӿڲ + USBDescriptor USB; + //@brief : ַ + u_tchar UCIAddr[256]; + //@brief : к + u_tchar SN[50]; + //@brief : 豸״̬ + u_status Status; + //@brief : 豸ʵʾ + u_tchar IDN[20]; + }NodeEx, *PNodeEx; + + typedef struct _UCIMSG { + u_session Session; + u_uint32 Message; + u_wparam wParams; + u_lparam lParams; + u_byte Reserved[240]; + }UCIMSG;//256Bytes + + ////////////////////////////////////////////////////////////////////////// + typedef enum _uci_msg { + //@brief : 豸ѾϿ + //@remarks : Ŀǰֻ֧LANڷʵӵ + // wParams LAN : ˿ں(ʮ) + // Reserved LAN : IP ַ + UMSG_CONNECT_CLOSED = 1, + //@brief : ļϢ + //@remarks : + // wParams ֡ + // lParams ֡ -1 ʼ䣻 [0,wParams)У wParams + //-> UCIMSGProc return -1 ʾжϴ. + UMSG_FILE_TRANSFER = 2, + //@brief : USBϢ + //@remarks : + // wParams : ʹõ16λУ8λΪpid8λΪvid + // lParams : ¼ͣ Ƴ = 0 = 1 + UMSG_DEVICE_NOTIFY = 3, + }EUCIMSG; + + typedef int(__stdcall *UCIMSGProc)(UCIMSG* _msg); +#include + +#ifdef __cplusplus + } +#endif//__cplusplus + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // ucidef_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/include/unit.h b/Driver/UDP5080-100/UNI-T SDK/include/unit.h new file mode 100644 index 0000000..da0fc1f --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/include/unit.h @@ -0,0 +1,117 @@ +/*! +* \created : 2016/10/10 +* \author : M.Yang +* \purpose : ṩλı׼ +* \remarks : еλĶ嶼Ա׼λΪ0Сڱ׼λΪݼڱ׼λʱΪ +* ĺôǣԱ֤Ա׼λΪ׼չ +*/ + +#ifndef Unit_h__ +#define Unit_h__ + +#ifdef __cplusplus +namespace unit { + extern "C"{ +#endif +#ifdef __cplusplus + typedef enum _EScale : char { +#else + typedef enum _EScale { +#endif // DEBUG + SCALE_p = -4, + SCALE_n, + SCALE_u, + SCALE_m, + SCALE_STD = 0, + SCALE_K, + SCALE_M, + SCALE_G, + SCALE_T, + }EScale; + +#ifdef __cplusplus + typedef enum _EType : char{ +#else + typedef enum _EType { +#endif // __cplusplus + TYPE_INVALID = -1, + TYPE_FREQ, + TYPE_TIME, + TYPE_AREA, //(Vs) + TYPE_SAMPLERATE,//ʣSa/s + TYPE_POINT, //Sa + TYPE_VPP, //ֵ + TYPE_VOLTAGE,//ѹ + TYPE_CURRENT,// + TYPE_DB, //DB + TYPE_VV, // + TYPE_PERCENT,//ٷֱ + TYPE_DEGREE, // + TYPE_WATT, //أ + TYPE_UNKNOWN,// δ֪λ + }EType; + + typedef struct _CodeName { + char Code; + char Name[5]; + }CodeName; + + static const CodeName ScaleTabel[] = { + { SCALE_p, "p" }, + { SCALE_n, "n" }, + { SCALE_u, "u" }, + { SCALE_m, "m" }, + { SCALE_STD,"" }, + { SCALE_K, "K" }, + { SCALE_M, "M" }, + { SCALE_G, "G" }, + { SCALE_T, "T" } + }; + + static const CodeName TypeTabel[] = { + { TYPE_FREQ, "Hz" }, + { TYPE_TIME, "s" }, + { TYPE_AREA, "Vs" }, + { TYPE_SAMPLERATE, "Sa/s" }, + { TYPE_POINT, "Sa" }, + { TYPE_VPP, "Vpp" }, + { TYPE_VOLTAGE, "V" }, + { TYPE_CURRENT, "A" }, + { TYPE_DB, "dB" }, + { TYPE_VV, "VV" }, + { TYPE_PERCENT, "%" }, + { TYPE_DEGREE, "" }, + { TYPE_WATT, "W" }, + { TYPE_UNKNOWN, "U" }, + }; + + const char* _UCIAPI uci_UnitFindTypeName(char _code); + + const char* _UCIAPI uci_UnitFindScaleName(char _code); + //@brief : ǰλֵתָĵλ + //@param _cur_value : ǰֵ + //@param _cur_unit : ǰλ + //@param _des_unit : Ҫתĵλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@return : תֵ2.3KHz תΪHz2300Hz + //@remarks : עⵥλEScaleģ + double _UCIAPI uci_UnitConvertTo(double _cur_value, int _cur_unit, int _des_unit, double _scale); + + typedef struct _UVale { + double Value; + long long Unit; + }UVale; + + //@brief : ǰλֵԶתʵĵλͣʹֵСڽơ2300Hzת2.3KHzs + //@param _value : ǰֵ + //@param _unit : ǰλ + //@param _scale : ƣһΪ1000ƵʵĽ1000 + //@remarks : עⵥλEScaleģ + UVale _UCIAPI uci_UnitRefresh(double _value, char _unit, double _scale); + +#ifdef __cplusplus + } +} +#endif + +#endif // Unit_h__ \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/lib/C#/ucics.XML b/Driver/UDP5080-100/UNI-T SDK/lib/C#/ucics.XML new file mode 100644 index 0000000..26824f3 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/lib/C#/ucics.XML @@ -0,0 +1,2253 @@ + + + + ucics + + + + + 物理单位信息 + + + + + 单位类型,比如Time、Freq等。具体定义见文档。 + + + + + 量级,比如k、n,p,M等。具体定义见文档。 + + + + + 物理单位量级 + + + + + + + + + + / + + + + + + + + + + + + + + + 标准单位 + + + + + K + + + + + + + + + + + + + + + + + + + + 物理单位类型 + + + + + 无效的类型 + + + + + 频率(Hz) + + + + + 时间(s) + + + + + 面积(Vs) + + + + + 采样率(Sa/s) + + + + + 点数(Sa) + + + + + 峰峰值(V) + + + + + 电压 + + + + + 电流(A) + + + + + db(dB) + + + + + VV (VV) + + + + + 百分比(%) + + + + + 度数(°) + + + + + 瓦特,功率(W) + + + + + 未知单位(U) + + + + + 物理量数值 + + + 4Byte align -> 8Bytes, + 所有示波器都通过指令"mea:all?;"读取参数测量数据。 + 读取到的就是 MeaValue v[50] (固定长度), + 各参数的位置索引由定义。 + + + + + 测量值 + + + + + 物理单位 + + + + + 是否有效。 0 表示无效; 1表示有效。 + + + + + 是否存在。 0 表示存在; 1表示不存在。 + + + + + 参数测量数据包的通用定义。 + + + + + 最大值 + + + + + 最小值 + + + + + High(Top)-高电平(顶端值) + + + + + Middle-中间值 + + + + + Low(Bottom) - 低电平(底端值) + + + + + VPP-峰峰值 + + + + + 幅度值 + + + + + 平均值 + + + + + 周期平均值 + + + + + 均方根 + + + + + 周期均方值 + + + + + 面积 + + + + + 周期面积 + + + + + 过冲 + + + + + 预冲 + + + + + 周期 + + + + + 频率 + + + + + 上升时间 + + + + + 下降时间 + + + + + 正脉宽 + + + + + 负脉宽 + + + + + 正占空比 + + + + + 负占空比 + + + + + 上升延时 + + + + + 下升延时 + + + + + 相位 + + + + + FRR + + + + + FRF + + + + + FFR + + + + + FFF + + + + + LRF + + + + + LRR + + + + + LFR + + + + + LFF + + + + + 突发脉冲 + + + + + 固定位50个参数 + + + + + b0 : SYNC; b1 : channel(CH1); b2 : Trigger + + + + + SYNC Key + + + + + Channel Key + + + + + Trigger Key + + + + + 模拟C/C++的堆内存的操作:申请、释放、转换 + + + + + 创建指定大小(bytes)的非托管内存空间 + + + + + + 创建基于所给字节数组的非托管内存空间。默认数据会被拷贝到非托管内存空间。 + + 托管字节数组 + + + + 创建基于所给整形数据的非托管内存空间。默认数据会被拷贝到非托管内存空间。 + + 托管整形数组 + 起始拷贝位置 needCopy = true 时有效 + 拷贝数量 + + + + allocate storage for count elements of type ty + + + + + + + 创建基于所给对象数据的非托管内存空间 + + 托管对象数据 + true : 拷贝托管字节数组的数据到非托管内存空间; false : 不拷贝 + + + + 提供Pointer到IntPtr的运算符。 + + Pointer类型对象 + IntPtr + + + + 析构器 + + + + + 将内存数据转换所给的结构体类型数据。 + + 要转换的结构体 + 要转换的结构体 + + + + 指向非托管内存的指针 + + + + + 非托管内存空间的地址 + + + + + 非托管内存空间的大小(bytes) + + + + + 通信方式 + + + + + USB通信 + + + + + LAN通信 + + + + + 串口通信 + + + + + 信号源的通道号 + + + + + 通道1的编号 + + + + + 通道2的编号 + + + + + 代表所有通道的编号 + + + + + 非通道编号 + + + + + 开关状态,占用1个字节。 + + + + + 关闭状态 + + + + + 打开状态 + + + + + UCI所有接口返回的状态编码。如果小于0,则代表发生错误;反之,代表正确。 + #TODO:检查完整性 + + + + + 没有任何错误 + + + + + 错误(基础编码,所有错误码都在这个编码基础上定义) + + + + + 资源初始化错误 + + + + + 无效的会话 + + + + + 操作超时 + + + + + 操作失败 + + + + + 不支持的操作 + + + + + 内存空间不足 + + + + + 系统繁忙,无法响应 + + + + + 通信异常,不可逆! + + + + + 未知的错误 + + + + + 建立连接的字符串地址格式错误 + + + + + 连接还未建立 + + + + + 连接已断开 + + + + + 不支持的通信方式 + + + + + 未发现指定的设备 + + + + + 不支持的设备 + + + + + 需要先执行查询设备的操作 + + + + + 查询网络设备失败 + + + + + USB设备地址只在执行查询设备操作后才有效, + + + 从UCI库导出的USB设备地址,只是一个列表索引,不是真正的设备地址。 + + + + + 未发现U盘接入 + + + + + 按键已经锁定 + + + + + 命令格式错误 + + + + + 只支持单条命令 + + + + + 一条命令只支持一个属性 + + + + + 不支持的命令 + + + + + 发送命令失败 + + + + + 协议数据格式错误 + + + + + 设备端写文件到flash失败! + + + + + 未发现有效数据 + + + + + 命令消息错误,请命令参数是否符合协议 + + + + + 无效的表达式 + + + + + 参数错误 + + + + + 参数提供的空间太小 + + + + + 所提供的文件名太长(最长50个字节) + + + + + 参数所给的数据大小与协议不匹配(防止数据错误) + + + + + 数字溢出 + + + + + 超出范围 + + + + + 数据未全部读取完 + + + + + 数据校验失败 + + + + + 无效的数据 + + + + + 数据压缩失败 + + + + + 数据解压缩失败 + + + + + 数据传输失败 + + + + + 数据传输失败 + + + + + 拒绝访问 + + + + + An unspecified error occurred. + + + + + The file could not be located. + + + + + All or part of the path is invalid + + + + + The permitted number of open files was exceeded. + + + + + There was an attempt to use an invalid file handle + + + + + The current working directory cannot be removed + + + + + There are no more directory entries + + + + + There was an error trying to set the file pointer + + + + + There was a hardware error + + + + + SHARE.EXE was not loaded, or a shared region was locked + + + + + There was an attempt to lock a region that was already locked + + + + + The disk is full + + + + + The end of file was reached + + + + + 写文件到磁盘失败 + + + + + 信号源任意波下载方式 + + + + + 以载波方式加载 + + + + + 以调制波方式加载 + + + + + 将ARB文件写到Flash. + + + + + UCI读接口()用的读参数。 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + (废弃)返回的数据量数据,具体意义视具体命令而定; + 返回的数据量由接口的返回值确定。 + + + + + 读超时,单位ms,1000 = 1s + + + + + 附加数据,大多数情况下是不需要的,可设置为IntPtr.Zero. + + + + + 附加数据大小 + + + + + UCI写接口的写参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 返回的数据量数据,具体意义视具体命令而定; + + + + + 超时 + + + + + 接口SendCommand使用的参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 命令参数1 + + + + + 命令参数2 + + + + + 超时 + + + + + 写任意波文件的参数 + + + + + 通道号,一般CH1=0,依次类推 + + + + + 任意波(ARB)加载方式 + + + + + 写文件的参数,2个Bytes.(模拟C中的联合体) + + + + + 预留的数据段 + + + + + 任意波(ARB)文件参数 + + + + + 接口WriteFromFile的接口参数。 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 文件路径 + + + + + 指令执行超时,在该时间内指令为完成,就返回! + + + + + 接口ReadToFile使用的参数 + + + + + 命令字符串,以'\0'结尾. 具体格式见文档; + + + + + 文件路径 + + + + + 指令执行超时,在该时间内指令为完成,就返回! + + + + + 最终输出文件的路径 + + + + + 设备按键LED状态数据 + + + + + Noise按键LED开关状态 + + + + + UTILTY按键LED开关状态 + + + + + STORGE按键LED开关状态 + + + + + RAMP按键LED开关状态 + + + + + PULSE按键LED开关状态 + + + + + COUNTER按键LED开关状态 + + + + + USER按键LED开关状态 + + + + + DIGTAL按键LED开关状态 + + + + + HARMONIC按键LED开关状态 + + + + + DC按键LED开关状态 + + + + + TRGGER按键LED开关状态 + + + + + CH2按键LED开关状态 + + + + + SWAPCH按键LED开关状态 + + + + + ARB按键LED开关状态 + + + + + CH1按键LED开关状态 + + + + + SINE按键LED开关状态 + + + + + SQUARE按键LED开关状态 + + + + + 通信节点类型 + + + 在QParams中是按位与,在Node中取的是enum值。 + + + + + 网络设备类型 + + + + + USB设备类型 + + + + + USB设备的描述符 + + + + + PID + + + + + VID + + + + + 地址 + + + + + 4字段数据类型 + + + + + 字段1 + + + + + 字段2 + + + + + 字段3 + + + + + 字段4 + + + + + IP地址 + + + 填充顺序为 f1(192).f2(168).f3(1).f4(253) - 小端模式 + + + + + 分字段存取 + + + + + 32为整数表示的IP地址 + + + + + LAN口通信的设备描述符 + + + + + IP地址(字符串类型) + + + + + IP地址 + + + + + 网络端口(TCPIP连接用的端口号) + + + + + 查询到的设备节点的参数 + + + + + 通信接口方式 + + + + + 设备名 + + + + + 设备类型( 信号源 = SG, 示波器 = DSO, UPO = UPO;) + + + + + LAN口参数 + + + + + USB接口参数 + + + + + 连接字符串 + + + + + 序列号 + + + + + 设备状态 + + + + + 设备显示名称 + + + + + 串口描述 + + + + + 友好名称 + + + + + 端口号 + + + + + 查询参数 + + + + + 要查询的节点类型,按位与,数据取自QueryNodeType定义 + eg: QueryNodeType.USB | QueryNodeType.LAN + + + + + Ports的长度 + + + + + 端口集,指向int类型; + + + + + PVID数据的长度 + + + + + 存放PID和VID信息的指向INT类型的缓冲区地址, + int 类型对应的格式 :PID(高16bit) + VID(低16bit) + + + + + 查询字符串,nullptr时表示查询所有设备,否则查询指定设备名的设备。 + + + + + UCI使用的消息类型 + + + + + 与设备建立的连接已经断开 + + + 目前只支持LAN口访问的连接的侦测 + wParams LAN : 端口号(十进制); + Reserved LAN : IP 地址 + + + + + 文件传输消息 + + + wParams 总帧数; + lParams 帧计数; -1 : 开始传输; [0,wParams)传输中, 等于wParams传输结束-> + UCIMSGProc return -1 : 表示中断传输. + + + + + USB插拔消息 + + + wParams : 使用低16位,其中,高8位为pid,低8位为vid; + lParams : 事件类型, 移除 = 0, 插入 = 1; + Reserved : USB插入移除事件的设备的设备名 + + + + + USB设备事件 + + + + + USB 设备移除事件 + + + + + USB 设备接入事件 + + + + + UCI 消息数据 + + + + + 发送消息的会话ID + + + + + UCI消息,按解析 + + + + + 消息参数,每个消息的使用意义不一样 + + + + + 消息参数,每个消息的使用意义不一样 + + + + + 保留字段,每个消息的使用意义不一样 + + + + + 带单位的数值 + + + + + 数值 + + + + + 单位量级 + + + + + 带单位的数值 + + + + + 数值 + + + + + 单位量级 + + + + + 万用表和毫伏表数据帧 + + + + + 主显字符串(20个字符) + + + + + 副显字符串或(20个字符) + + + + + 主显数值(8Bytes) + + + + + 副显数值(8Bytes) + + + + + 标记位(8Bytes) + + + + + UCI会话(与设备建立会话) + 本接口是的面向对象封装版本。 + 会在UCISession对象释放时自动关闭会话,并做所有资源清理,且提供若干 + 实用接口。 + + + + + 构造器 + + 一般设置为true,在程序退出时会调用 + UCIInterop.ExInstance()进行资源清除。 + + + + + 析构器 + + + + + 打开设备,建立会话。 + + + 设备地址。获取方式:
+ 1、可以通过查询接口获取;
+ 2、也可以通过查看文档获取。
+ 3、使用提供的示例程序查询获取
+ + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + + static Session _com = new Session(true); + //... + var r = _com.Open("[C:DSO][D:DSO-E][T:USB][PID:0x5537][VID:0x4348][EI:0x82][EO:0x2][CFG:1][I:0][addr:0]"); + if (!OutputResult(r, "打开设备")){return false;} + //... + static bool OutputResult(int r, string msg) + { + string s = "[" + msg + "]"; + if (Session.Error(r)) + { + s += string.Format("失败,错误码:{0},错误信息:{1}", + r, _com.GetLastError()); + } + else + { + s += "成功!"; + } + Console.WriteLine(s); + return r >= 0; + } + + +
+ + + 打开交换机 + + 交换机地址 + 超时。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 内部使用接口 + + + + + 关闭会话 + + + 在设备未打开时调用不会执行任何操作。 + + + + + 获取最近一次调用UCI接口后的反馈信息。 + + + 反馈的文本字符串,与此描述对应的状态码可以查看。 + + + 返回的描述信息,可以设置中文和英文两个版本,设置方式如下: + + //设置为中文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession,"lang:zh-Hans;", null, 0); + + + //设置为英文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:en-US;", null, 0); + + 示例代码参见 + + + + + 写数据(字节流,基础接口) + + + 指令字符串,请查阅各机型编程手册获取 + + 要写到设备的字节流数据,如果是内置类型(如int等), + 可以使用转换: + + int v = 10; + byte[] arrayV = BitConverter.GetBytes(v); + + + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(纯指令文本) + + + 指令字符串,请查阅各机型编程手册获取 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(short类型) + + + 指令字符串,请查阅各机型编程手册获取 + short 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(double类型) + + + 指令字符串,请查阅各机型编程手册获取 + double 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(int类型) + + + 指令字符串,请查阅各机型编程手册获取 + int 类型数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + + + 写数据(任何类型) + + + 数据类型,struct 或者内置类型 + 指令字符串,请查阅各机型编程手册获取 + 写入的数据 + 指令执行超时,在该时间内指令为完成,就返回! + + 查看说明。 + + + 适用于结构体等类型数据的写操作。 + 也可以使用,但必须先使用 + 将结构体转换为Byte[] + + + + + 读数据(基础接口) + + 指令字符串,请查阅各机型编程手册获取 + 接收数据的缓冲区 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 如果需要将读取到的字节流转换为其它常见的数据类型,请使用 + 类提供的方法进行转换。 + + + + //打包读取所有参数测量结果--适用于所有示波器 + //... + static Session _com = new Session(true); + //... + //固定的50个参数,一个参数8Bytes,共400Bytes + byte[] allMeaBytes = new byte[50 * 8]; + r = _com.Read("mea:all?;", allMeaBytes); + if (r > 0) + { + //转换为结构体 + uci.Model.mea.MeaValue[] allMea = new uci.Model.mea.MeaValue[50]; + uci.Utility.ByteArrayToStructArray(allMeaBytes, ref allMea, 50); + } + + + + + + 读数据(dobule类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的double类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToDouble(byte[], 0) 将Byte[]转换为double + + + + + 读数据(int类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的int类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToInt32(byte[], 0) 将Byte[]转换为int + + + + + 读数据(short类型) + + + 指令字符串,请查阅各机型编程手册获取 + 要读取的short类型数据 + 超时。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + 内部使用了BitConverter.ToInt16(byte[], 0) 将Byte[]转换为short + + + + + 读取数据(泛型版本,支持内置类型、结构体数据)(结构体大小必须是确定的) + + + 内置类型或结构体类型,必须是确定的已经序列化的结构体(大小是确定的)。 + 指令字符串,请查阅各机型编程手册获取 + 要读取的数据 + 超时。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 适用于读取结构体数据,比如的大小就是确定的。 + + + + + 写文件 + + 指令字符串 + 要发送的文件路径 + 指令执行超时(ms),在该时间内指令为完成,就返回! + 具体描述,请查看说明。 + + + + 读文件 + + 读文件参数 + 具体描述,请查看说明。 + + + + 判断接口返回值是否错误 + + 接口返回值 + true : 正确; false : 错误 + + + + 判断接口返回值是否正确 + + 接口返回值 + true : 正确; false : 错误 + + + + (内部)制作远程访问指令文本 + + 通用UCI指令文本,与具体机型对应。 + 远程访问的类型 + 超时。在该时间内指令未完成,就返回超时错误! + 数据长度 + 返回制作好的指令文本 + + + + 获取会话ID + + + + + 设备地址,只有设备被打开时,才会存在。 + + + + + 当前设备是否已经打开 + + + + + 是否时交换机通信模式(普通设备通信无需理会) + + + + + UCIInterop类是对uci.dll导出的C语言接口的适配。
+ 基本会话接口请结合 使用
+ +
+
+ + + 无效的会话ID + + + + + 打开设备,建立会话。 + + 设备地址。获取方式:
+ 1、可以通过查询接口获取;
+ 2、也可以通过查看文档获取。
+ 3、使用提供的示例程序查询获取
+ + 返回的会话ID + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 具体描述,请查看说明。 + + 请参考 + +
+ + + 查询设备(私有,不公开,因为参数类型对于CS环境而言过于抽象,此即可与C接口直接对应) + + 查询操作的参数 + 输出数据的缓冲区地址 + 输出数据的缓冲区大小(Bytes) + 具体描述,请查看说明。 + + + + 查询设备 + + + + 要查询的设备信息 + 接收查询结果的节点数组 + _nodes的个数 + 超时 + + 小于0:错误; >=0 查询到的设备个数。 + + + 查询文本串的格式是:“{通信类型名称 : 设备参数 ;}”
+ 每个通信类型数据以';'结尾;':'之前是节点名,节点名是内置的,网络通信是"LAN",USB通信是"USB"。
+ LAN通信的参数是端口号,以','分割.
+ USB通信的参数是PID(第一个)和VID(第二个),每组数据以','号分割,PID和VID以'&'分割。
+ 示例:
+ + string msg = "LAN:4162,5000;USB:0x1234&0x5345,0x7777&0x5345;" + + UCI接口查询是要指定要查询的设备信息后,才可查询!
+ 目前支持的全部USB设备:
+ 示波器、信号源和电源:
+ "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348;"
+ 万用表(HID)
+ "USB:0xE008&0x1A86,0xEA80&0x10C4;"
+ 目前支持的LAN口设备:
+ 8000 : UTG2000A&UTG7000B 系列;
+ 5000 : UPO2000S&UPO7000Z 系列;
+ 4162 : UTG4000A&UTG8000D 系列
+ 18191: UTP3000C&UTP8000M 系列
+ "LAN:5000,4162,8000,18191;"
+ 请注意:串口需要使用接口: 单独查询。
+
+ + + string queryMsg = "USB:0x1234&0x5345,0x7777&0x5345,0x0834&0x5656,0x5537&0x4348"; //查询USB设备 + //queryMsg += ";LAN:4162,5000";//查询网络设备 + queryMsg += ";"; + uci.Node[] nodes = new uci.Node[10]; + int count = UCIInterop.QueryNodesX(queryMsg, nodes, nodes.Length, 2000); + if (count > 0) + { + Console.WriteLine("查询到的满足条件的USB设备数量:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("[{0}]:{1}", i, nodes[i].UCIAddr); + } + } + else + { + OutputResult(count, "查询设备"); + } + + +
+ + + 查找串口 + + 接收端口描述的数据地址,调用者只需要做初始化即可。 + _nodes的个数 + 具体描述,请查看说明。 + + 此查询不包括任何的协议,只是查询串口。如果要查询指定协议的设备,请遍历打开串口 + 并使用指定协议进行验证。 + + uci.COMPort[] comPorts = new uci.COMPort[10]; + count = UCIInterop.QueryCOMPort(comPorts, comPorts.Length); + if (count > 0) + { + Console.WriteLine("Ports:{0}", count); + for (int i = 0; i < count; i++) + { + Console.WriteLine("{0} - COM{1} : {2}", i, comPorts[i].Port, comPorts[i].FriendlyName); + } + } + else if (count == 0) + { + Console.WriteLine("未查询到任何串口设备"); + } + else + { + OutputResult(count, "查询串口设备"); + } + //* Ports:1 + //* 0 - COM3 : Silicon Labs CP210x USB to UART Bridge (COM3) + + + + + + + 写数据。 可以使用简化版本的接口: + + 会话ID,由获得 + 接口参数 + 要写入的数据 + 数据长度 + 具体描述,请查看说明。 + + + + 写数据。 是的非封装版本。 + + 会话ID,由获得 + 指令字符串 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 要写入的数据 + 数据长度 + 具体描述,请查看说明。 + + + + 发送指令 + + 会话ID,由获得 + 指令参数 + 具体描述,请查看说明。 + + 具体哪些指令支持此接口,请参考各机型文档。 + + + + + 读参数。请使用 + + 会话ID,由获得 + 读接口参数 + 接收数据的缓冲区 + 接收数据的缓冲区的长度 + 具体描述,请查看说明。 + + + + 读参数(的参数未封装版本) + + 会话ID,由获得 + 读指令文本 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + 接收数据的缓冲区 + 接收数据的缓冲区的长度 + 具体描述,请查看说明。 + + 可参考 + + + + + 关闭会话 + + 会话ID,由获得 + 具体描述,请查看说明。 + + + + 写文件到设备 + + 会话ID,由获得 + 写文件参数 + 具体描述,请查看说明。 + + + + 写文件到设备,是参数非封装接口 + + 会话ID,由获得 + 指令字符串 + 要发送的文件路径 + 指令执行超时(ms),在该时间内指令为完成,就返回! + 具体描述,请查看说明。 + + + + 读文件 + + 会话ID,由获得 + 读文件参数 + 具体描述,请查看说明。 + + + + 写属性。 + + 会话ID,由获得, + 如果使用表示写的是全局属性。 + 属性指令文本 + 属性参数数据 + 属性参数数据长度(字节) + 具体描述,请查看说明。 + + 返回的描述信息,可以设置中文和英文两个版本,设置方式如下: + + //设置为中文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession,"lang:zh-Hans;", null, 0); + //设置为英文: + UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:en-US;", null, 0); + + 订阅设备更改通知。设备在接入和移除时会触发改通知。 + + uci_SetAttribute(UCIInterop.InvalidSession, "devchange:1;", null, 0); + + 注意:需要使用 订阅通知。 + + + + + 添加事件订阅 + + 委托签名请见 + 目前默认返回0. + + + + 获取最近一次调用UCI接口后的反馈信息。 + 详细描述请参考: + + + 反馈的文本字符串,与此描述对应的状态码可以查看。 + + + + + (内部使用) 得到错误描述。原始接口,不要直接使用。 请使用。 + + + + + + (内部)获取单位类型编码对应的单位名 + + 单位类型编码,编码定义见 + 物理单位名,也可以参考的定义自己建表查找。 + + + + 将当前单位的数值自动转换到合适的单位类型,以使数值小于进制。比如2300Hz,转换后就是2.3kHz + + 当前值 + 当前单位编码 + 进制,一般为1000,比如频率的进制是1000 + 返回物理量(数值+单位量级) + + + + 将当前单位的数值转换到指定的单位。 + + 当前数值 + 当前单位编码 + 要转换到的单位编码 + 进制,一般为1000,比如频率的进制是1000 + 返回转换后的数值,比如2.3KHz 转换为Hz就是2300Hz + 注意单位编码必须如EScale定义的,连续递增的量。 + + + + 获取单位类型编码对应的单位名 + + 单位类型编码,编码定义见 + 物理单位名,也可以参考的定义自己建表查找。 + + + + 在主程序退出之前调用本接口以清除uci.dll内部资源。 + 本接口只是针对C#接口使用。否则在退出时会有异常出现。 + + + + + 转换PID和VID为32位整数。 + + USB PID + USB VID + 转换好的PVID : 高16位为pid,低16位为vid. + + + + 判断接口返回值是否代表错误,辅助接口。 + 内部代码: return (r < 0); + + 接口返回值 + false :接口返回的状态码代表发生错误,反正,执行成功! + + + + 判断接口返回值是否代表正确,辅助接口 + 内部代码: return (r >= 0); + + 接口返回值 + false :接口返回的状态码代表发生错误,反正,执行成功! + + + + 查询在线的设备(建议不再使用该接口,可用代替) + + 查询参数 + 输出设备信息的缓冲区 + 入参是要查询的设备数量,出参是已经查询到的设备数量 + 超时(ms)。在该时间内指令未完成,就返回超时错误! + + 具体描述,请查看说明。 + + + + + 对压缩像素数据进行解压缩(适用于UTG4000A系列\UTG2025A NEW) + + 压缩之后的数据地址(按32bit寻址) + 压缩的数据大小,注意是int类型。 + 存放解压缩后的像素数据缓冲区 + 像素点数 + 小于0 错误,错误码见UnZipError, >=0解压缩后的大小(像素数) + + _dst缓冲区大小是屏幕宽度 * 屏幕高度, 比如800*480的屏幕, + 解压缩后就是 800*480 = 384000.即_dst_size = 384000. + + + + + alg_UnCompressPixels 接口的另一版本, 缓冲区全部是字节流 + + 压缩之后的数据地址,字节流 + 字节流长度 + 接收解压缩后的数据的字节流缓冲区 + _dst缓冲区的长度(Bytes) + 参考 + + + + 对压缩像素数据进行解压缩(适用于UTG2025A和UTG2062A) + + 压缩之后的数据地址 + 压缩的数据大小,字节数 + 存放解压缩后的像素数据缓冲区 + 像素点数*3, 24bit + 小于 0 错误,错误码见UnZipError, >=0解压缩后的大小(字节数) + + _des缓冲区大小应该是480*272*3 + + + + + 1000A信号源使用的图像数据的解压算法 + + 从设备端读取到的完整数据包 + _src 指向的数据大小Bytes + 输出的32bit的像素数据的缓冲区 + 图像的宽度 + 图像的高度 + 小于 0 错误,错误码见UnZipError, >=0解压缩后的像素个数 + + + + 使用ZBMP算法压缩的位图数据的解压缩算法 + + 原始数据 + 原始数据长度 + 接收解压后数据的缓冲区 + _des的长度 + 小于0 : 错误,请查看 + + + + 通知事件的委托函数,由使用。 + + 通知附带的消息参数 + 视消息协议而定 + + + + 解压缩返回算法返回的错误码 + + + + + 参数错误 + + + + + 接收非压缩数据的缓冲区大小不够 + + + + + alg_UnZipBMP接口返回的错误码 + + + + + 参数错误 + 地址不能为空,长度不能为0,接收解压缩的缓冲区不能被存放压缩数据的缓冲区小 + + + + + 存储空间不足 + + + + + 错误的窗大小 + + + + + 压缩数据格式错误 + + + + + 压缩数据有误 + + + + + 提供一些做跨平台数据转换时的常用接口 + + + + + 将字节数组转换为结构体数组 + + 结构体类型 + 被转换的字节数组 + 用于数据的结构体数组 + 要转换的结构体数量 + + + + + + byte数组转结构体 + + byte数组 + 结构体类型 + 转换后的结构体, 转换失败返回null + + + + 结构体转byte数组 + + 要转换的结构体 + 转换后的byte数组 + +
+
diff --git a/Driver/UDP5080-100/UNI-T SDK/lib/C#/ucics.dll b/Driver/UDP5080-100/UNI-T SDK/lib/C#/ucics.dll new file mode 100644 index 0000000..005c0af Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/lib/C#/ucics.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/lib/C/ASCII/uci.dll b/Driver/UDP5080-100/UNI-T SDK/lib/C/ASCII/uci.dll new file mode 100644 index 0000000..ca316b2 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/lib/C/ASCII/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/lib/C/ASCII/uci.lib b/Driver/UDP5080-100/UNI-T SDK/lib/C/ASCII/uci.lib new file mode 100644 index 0000000..cdc2ffe Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/lib/C/ASCII/uci.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/lib/C/Unicode/uci.dll b/Driver/UDP5080-100/UNI-T SDK/lib/C/Unicode/uci.dll new file mode 100644 index 0000000..178f088 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/lib/C/Unicode/uci.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/lib/C/Unicode/uci.lib b/Driver/UDP5080-100/UNI-T SDK/lib/C/Unicode/uci.lib new file mode 100644 index 0000000..a59db53 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/lib/C/Unicode/uci.lib differ diff --git a/Driver/UDP5080-100/UNI-T SDK/lib/VB/ucivb.dll b/Driver/UDP5080-100/UNI-T SDK/lib/VB/ucivb.dll new file mode 100644 index 0000000..e17e640 Binary files /dev/null and b/Driver/UDP5080-100/UNI-T SDK/lib/VB/ucivb.dll differ diff --git a/Driver/UDP5080-100/UNI-T SDK/lib/VB/ucivb.xml b/Driver/UDP5080-100/UNI-T SDK/lib/VB/ucivb.xml new file mode 100644 index 0000000..c32df04 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/lib/VB/ucivb.xml @@ -0,0 +1,219 @@ + + + + +ucivb + + + + + +通信接口方式。 + + + +设备名。 + + + +设备类型( 信号源 = SG, 示波器 = DSO, UPO = UPO;)。 + + + +LAN口参数。 + + + +USB口参数。 + + + +连接字符串。 + + + +序列号。 + + + +设备状态。 + + + +设备显示名称。 + + + +查询到的设备节点的参数。 + + + +命令字符串,以'\0'结尾. 具体格式见文档; + + + +文件路径 + + + +超时 + + + +最终输出文件的路径 + + + +接口ReadToFile使用的参数。 + + + +命令字符串,以'\0'结尾. 具体格式见文档; + + + +文件路径 + + + +超时 + + + +接口WriteFromFile的接口参数。 + + + +查询设备 + + 要查询的设备信息, + 接收查询结果的节点数组 + _nodes的个数 + 超时 + +小于0:错误; >=0 查询到的设备个数。 + + + + + +简单版查询设备 + + 要查询的设备信息,以逗号形式隔开每一个设备地址,{设备地址1,设备地址2,设备地址3......} + 所有设备信息总长度 + 设备接口类型,16表示USB,1表示LAN + 超时 + +小于0:错误; >=0 查询到的设备个数。 + + + + + +打开设备,建立会话。 + + + + + + + +简单版打开设备,返回会话。 + + + + session + + +关闭会话。 + + + + + +写数据。 是的非封装版本。 + + 会话ID,由获得 + 指令字符串 + 超时 + 要写入的数据 + 数据长度 + + + +简单版写字符串数据。 是的非封装版本。 + + 会话ID,由获得 + 指令字符串 + 超时 + + + +读参数(Read的参数未封装版本) + + 会话ID,由获得 + 写入的指令 + 超时 + 接收数据缓存 + 想要读的数据长度 + 读到的数据长度 + + +写文件到设备 + + 会话ID,由获得 + 文件信息 + + + +简单版写文件到设备,不需定义结构体 + + 会话ID,由获得 + 指令 + 文件路径 + 超时 + + + +读文件 + + 会话ID,由获得 + 文件信息 + + + +简单版读文件,不需定义结构体 + + 会话ID,由获得 + 指令 + 文件路径 + 超时 + 输出文件的最后全路径 + 全路径长度 + + + +得到错误描述。原始接口,不要直接使用。 请使用。 + + + + +得到错误描述字符串。接口错误码小于0 + + + + + Returns the cached ResourceManager instance used by this class. + + + + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + + + + A strongly-typed resource class, for looking up localized strings, etc. + + + + \ No newline at end of file diff --git a/Driver/UDP5080-100/UNI-T SDK/使用说明.txt b/Driver/UDP5080-100/UNI-T SDK/使用说明.txt new file mode 100644 index 0000000..3745689 --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/使用说明.txt @@ -0,0 +1,17 @@ +ʹãȰװ +1UTP3305SϵлʹUSBתʹUCIӿ +2UPO3000CSϵлʹVISAʹVISAӿ +3ʹlibusbʹUCIӿڣdriver\DriverPack_Libusb\Installer.batļղ谴ռɡ + +ȻֱӴexamples\UCIDemoProjʾ̣УȻȶ +ͶӦЭĵϤ򵥵ָͨ + +鿴UCIDemoProjԴļȡ뼶Ŀʾ + +Ŀ¼˵ + ĵ + װ + ļ + VCVBC#CVILabViewʾ̡ + UCIӿڿ⣨CC#VBӿڰ汾 + diff --git a/Driver/UDP5080-100/UNI-T SDK/更新说明.txt b/Driver/UDP5080-100/UNI-T SDK/更新说明.txt new file mode 100644 index 0000000..c1d2dac --- /dev/null +++ b/Driver/UDP5080-100/UNI-T SDK/更新说明.txt @@ -0,0 +1,9 @@ +汾V2.2 +ڣ20181228 +޸ģ +1uci.dll UTD2000CEX\UTD7000BGϵʾеBUG +2x64汾uci.dll.\lib\C\x64 +3x64汾UCI_DEMO (.\examples\VC\UCIDEMO\x64\UNICODE +4޸UTP3000C&\UTP8000MϵеԴĵʾ룻 +5UPO3000CSϵл͵VISAؽӿʾ +6UTP3305Sϵл͵ʾ \ No newline at end of file diff --git a/Driver/UDP5080-100/info.txt b/Driver/UDP5080-100/info.txt new file mode 100644 index 0000000..0203799 --- /dev/null +++ b/Driver/UDP5080-100/info.txt @@ -0,0 +1,16 @@ +Description +Model number UDP5080-100 +Serial number AWPK225300032 +Firmware version 1.03.0513 +Power version 1.03.0513 +Description Uni-Trend DC Power UDP5080-100_AWPK225300032 + Enable front panel identification indicator + +VISA instrument infomation +mDNS hostname UDP5080_5300032.local +IPv4 address 192.168.6.5 +Ethernet MAC 00-80-E1-5C-CB-CD +Auto-MDIX Yes +VXI-11 LAN protocol TCPIP0::192.168.6.5::INSTR +TCP/IP SOCKET protocol TCPIP0::192.168.6.5::5025::SOCKET +USB (USBTMC) USB0::0x0483::0x5740::AWPK225300032::INSTR \ No newline at end of file diff --git a/Driver/UDP5080-100/驱动接口开发指导文档.md b/Driver/UDP5080-100/驱动接口开发指导文档.md new file mode 100644 index 0000000..b5e9d47 --- /dev/null +++ b/Driver/UDP5080-100/驱动接口开发指导文档.md @@ -0,0 +1,505 @@ +# UDP5080-100 驱动接口开发指导文档 + +本文档用于指导 AI 在主项目中接入 UNI-T UDP5080-100 可编程直流电源。主项目技术栈为 C# + WPF + .NET 8。将本文档与 `UNI-T SDK` 目录一起拷贝到主项目后,AI 应优先按本文档实现驱动层,不要直接照搬 SDK 示例里的旧机型命令。 + +## 1. 接入结论 + +UDP5080-100 当前推荐接入方式是 `SCPI over TCP Socket`: + +- 默认设备 IP:`192.168.6.5` +- 默认端口:`5025` +- 默认终止符:`\n` +- 默认连接超时:`2s` +- 默认采样周期:`0.5s` +- VISA 资源参考:`TCPIP0::192.168.6.5::INSTR` +- Socket 资源参考:`TCPIP0::192.168.6.5::5025::SOCKET` + +推荐主项目直接用 .NET 的 `TcpClient` / `NetworkStream` 实现 TCP 5025 通信。`UNI-T SDK` 中的 `uci.dll`、`ucics.dll` 和 C# 示例主要面向 UCI 协议设备、USB/libusb 设备、示波器、旧款电源等,不应作为 UDP5080-100 的首选依赖。 + +## 2. 现场网络准备 + +设备通过网线连接电脑。电脑有线网卡需设置为与设备同网段,例如: + +- 电脑 IP:`192.168.6.10` +- 子网掩码:`255.255.255.0` +- 网关:`192.168.1.1` + +接入前先确认: + +```powershell +ping 192.168.6.5 +``` + +MAC 地址 `00-80-E1-5C-CB-CD` 仅用于核对设备身份,不作为驱动连接参数。 + +## 3. 推荐项目结构 + +在主项目中增加独立驱动目录,避免把 UI 逻辑和设备通信混在一起: + +```text +MainProject/ + Drivers/ + UniT/ + Udp5080/ + IUdp5080PowerSupply.cs + Udp5080Options.cs + Udp5080Reading.cs + Udp5080Exception.cs + Udp5080TcpClient.cs + Udp5080Simulator.cs + UNI-T SDK/ +``` + +WPF ViewModel 只依赖 `IUdp5080PowerSupply`,不要直接依赖 `TcpClient`、SDK DLL 或 SCPI 字符串。 + +## 4. 驱动接口设计 + +建议接口如下: + +```csharp +public interface IUdp5080PowerSupply : IAsyncDisposable +{ + bool IsConnected { get; } + + Task ConnectAsync(CancellationToken cancellationToken = default); + Task DisconnectAsync(CancellationToken cancellationToken = default); + + Task QueryIdAsync(CancellationToken cancellationToken = default); + Task ReadVoltageAsync(CancellationToken cancellationToken = default); + Task ReadCurrentAsync(CancellationToken cancellationToken = default); + Task ReadOutputAsync(CancellationToken cancellationToken = default); + + Task WriteAsync(string command, CancellationToken cancellationToken = default); + Task QueryAsync(string command, CancellationToken cancellationToken = default); +} +``` + +数据模型: + +```csharp +public sealed record Udp5080Options( + string Host = "192.168.6.5", + int Port = 5025, + TimeSpan Timeout = default, + string Terminator = "\n", + string VoltageCommand = "MEASure:VOLTage?", + string CurrentCommand = "MEASure:CURRent?"); + +public sealed record Udp5080Reading( + DateTimeOffset Timestamp, + double Voltage, + double Current) +{ + public double Power => Voltage * Current; +} +``` + +注意:`TimeSpan Timeout = default` 在构造后应转换为 `TimeSpan.FromSeconds(2)`。 + +## 5. SCPI 命令约定 + +已验证/调试工具默认使用的基础命令: + +| 功能 | 命令 | +| --- | --- | +| 设备标识 | `*IDN?` | +| 读取输出电压 | `MEASure:VOLTage?` | +| 读取输出电流 | `MEASure:CURRent?` | + +设备响应中可能包含单位或前缀,解析时应提取第一个浮点数,支持科学计数法。例如: + +- `48.125` +- `+1.25E+01 V` +- `VOLT: 48.000 V` + +不要把 SDK 文档或示例中的 `:SOURce1:VOLTage?` 直接当作实时测量命令。该类命令可能查询的是设定值,不一定是 UDP5080-100 的实时输出值。 + +## 6. TCP 实现要点 + +实现 `Udp5080TcpClient` 时遵守以下规则: + +- 每条命令发送 ASCII 文本,并追加 `\n`。 +- `QueryAsync` 发送命令后读取到换行符为止。 +- 单次响应设置上限,例如 `1 MB`,避免异常设备导致内存无限增长。 +- 同一个设备连接必须串行化读写,使用 `SemaphoreSlim` 保护 `WriteAsync` 和 `QueryAsync`。 +- 网络异常、超时、解析失败统一包装成 `Udp5080Exception`。 +- 断线后 `IsConnected` 置为 `false`,上层决定是否重连。 +- UI 线程不得直接执行网络 I/O。 + +最小实现示例: + +```csharp +using System.Globalization; +using System.IO; +using System.Net.Sockets; +using System.Text; +using System.Text.RegularExpressions; + +public sealed class Udp5080TcpClient : IUdp5080PowerSupply +{ + private readonly Udp5080Options _options; + private readonly SemaphoreSlim _gate = new(1, 1); + private TcpClient? _client; + private NetworkStream? _stream; + + public bool IsConnected => _client?.Connected == true && _stream is not null; + + public Udp5080TcpClient(Udp5080Options options) + { + var timeout = options.Timeout == default ? TimeSpan.FromSeconds(2) : options.Timeout; + _options = options with { Timeout = timeout }; + } + + public async Task ConnectAsync(CancellationToken cancellationToken = default) + { + await DisconnectAsync(cancellationToken); + + var client = new TcpClient { NoDelay = true }; + using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + cts.CancelAfter(_options.Timeout); + + await client.ConnectAsync(_options.Host, _options.Port, cts.Token); + _client = client; + _stream = client.GetStream(); + } + + public Task DisconnectAsync(CancellationToken cancellationToken = default) + { + _stream?.Dispose(); + _client?.Dispose(); + _stream = null; + _client = null; + return Task.CompletedTask; + } + + public Task QueryIdAsync(CancellationToken cancellationToken = default) + => QueryAsync("*IDN?", cancellationToken); + + public async Task ReadVoltageAsync(CancellationToken cancellationToken = default) + => ParseNumber(await QueryAsync(_options.VoltageCommand, cancellationToken)); + + public async Task ReadCurrentAsync(CancellationToken cancellationToken = default) + => ParseNumber(await QueryAsync(_options.CurrentCommand, cancellationToken)); + + public async Task ReadOutputAsync(CancellationToken cancellationToken = default) + { + var voltage = await ReadVoltageAsync(cancellationToken); + var current = await ReadCurrentAsync(cancellationToken); + return new Udp5080Reading(DateTimeOffset.Now, voltage, current); + } + + public async Task WriteAsync(string command, CancellationToken cancellationToken = default) + { + await _gate.WaitAsync(cancellationToken); + try + { + var stream = RequireStream(); + var payload = Encoding.ASCII.GetBytes(command.TrimEnd('\r', '\n') + _options.Terminator); + await stream.WriteAsync(payload, cancellationToken); + await stream.FlushAsync(cancellationToken); + } + catch (Exception ex) when (ex is IOException or SocketException or OperationCanceledException) + { + throw new Udp5080Exception($"发送命令失败:{command}", ex); + } + finally + { + _gate.Release(); + } + } + + public async Task QueryAsync(string command, CancellationToken cancellationToken = default) + { + await _gate.WaitAsync(cancellationToken); + try + { + var stream = RequireStream(); + var payload = Encoding.ASCII.GetBytes(command.TrimEnd('\r', '\n') + _options.Terminator); + + using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + cts.CancelAfter(_options.Timeout); + + await stream.WriteAsync(payload, cts.Token); + await stream.FlushAsync(cts.Token); + + var buffer = new byte[4096]; + using var memory = new MemoryStream(); + + while (memory.Length < 1024 * 1024) + { + var read = await stream.ReadAsync(buffer, cts.Token); + if (read <= 0) + throw new Udp5080Exception("设备已关闭连接。"); + + memory.Write(buffer, 0, read); + if (Array.IndexOf(buffer, (byte)'\n', 0, read) >= 0) + break; + } + + return Encoding.ASCII.GetString(memory.ToArray()).Trim(); + } + catch (Udp5080Exception) + { + throw; + } + catch (Exception ex) when (ex is IOException or SocketException or OperationCanceledException) + { + throw new Udp5080Exception($"查询命令失败:{command}", ex); + } + finally + { + _gate.Release(); + } + } + + private NetworkStream RequireStream() + { + if (_stream is null) + throw new Udp5080Exception("设备尚未连接。"); + + return _stream; + } + + private static double ParseNumber(string response) + { + var match = Regex.Match( + response.Trim(), + @"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?"); + + if (!match.Success) + throw new Udp5080Exception($"响应中没有数值:{response}"); + + var value = double.Parse(match.Value, CultureInfo.InvariantCulture); + if (!double.IsFinite(value)) + throw new Udp5080Exception($"响应数值无效:{response}"); + + return value; + } + + public async ValueTask DisposeAsync() + { + await DisconnectAsync(); + _gate.Dispose(); + } +} +``` + +异常类型: + +```csharp +public sealed class Udp5080Exception : Exception +{ + public Udp5080Exception(string message) : base(message) { } + public Udp5080Exception(string message, Exception innerException) : base(message, innerException) { } +} +``` + +## 7. WPF 集成要求 + +ViewModel 中建议使用后台轮询任务: + +- `ConnectCommand`:调用 `ConnectAsync`,成功后调用 `QueryIdAsync` 显示设备标识。 +- `StartSamplingCommand`:启动后台采样循环。 +- `StopSamplingCommand`:取消采样 `CancellationTokenSource`。 +- `DisconnectCommand`:先停止采样,再断开设备。 +- 采样循环中调用 `ReadOutputAsync`,将结果通过 UI Dispatcher 或 MVVM 框架的主线程调度更新到绑定属性。 +- 连续通信失败 3 次后自动停止采样,并提示用户检查网线/IP/设备电源。 + +采样伪代码: + +```csharp +private async Task SamplingLoopAsync(CancellationToken token) +{ + var failures = 0; + + while (!token.IsCancellationRequested) + { + try + { + var reading = await _powerSupply.ReadOutputAsync(token); + failures = 0; + + await _dispatcher.InvokeAsync(() => + { + Voltage = reading.Voltage; + Current = reading.Current; + Power = reading.Power; + Samples.Add(reading); + }); + } + catch (Exception ex) when (ex is Udp5080Exception or IOException or SocketException) + { + failures++; + LogCommunicationError(ex); + + if (failures >= 3) + { + await StopSamplingAsync(); + break; + } + } + + await Task.Delay(TimeSpan.FromMilliseconds(500), token); + } +} +``` + +## 8. 模拟驱动 + +主项目应保留模拟驱动,便于无实机开发、UI 调试和自动化测试: + +```csharp +public sealed class Udp5080Simulator : IUdp5080PowerSupply +{ + private readonly DateTimeOffset _started = DateTimeOffset.Now; + public bool IsConnected { get; private set; } + + public Task ConnectAsync(CancellationToken cancellationToken = default) + { + IsConnected = true; + return Task.CompletedTask; + } + + public Task DisconnectAsync(CancellationToken cancellationToken = default) + { + IsConnected = false; + return Task.CompletedTask; + } + + public Task QueryIdAsync(CancellationToken cancellationToken = default) + => Task.FromResult("UNI-T,UDP5080-100,SIM0001,1.0"); + + public Task ReadVoltageAsync(CancellationToken cancellationToken = default) + { + var seconds = (DateTimeOffset.Now - _started).TotalSeconds; + return Task.FromResult(48.0 + 1.5 * Math.Sin(seconds / 4)); + } + + public Task ReadCurrentAsync(CancellationToken cancellationToken = default) + { + var seconds = (DateTimeOffset.Now - _started).TotalSeconds; + return Task.FromResult(8.0 + 0.8 * Math.Sin(seconds / 2.7)); + } + + public async Task ReadOutputAsync(CancellationToken cancellationToken = default) + { + var voltage = await ReadVoltageAsync(cancellationToken); + var current = await ReadCurrentAsync(cancellationToken); + return new Udp5080Reading(DateTimeOffset.Now, voltage, current); + } + + public Task WriteAsync(string command, CancellationToken cancellationToken = default) + => Task.CompletedTask; + + public async Task QueryAsync(string command, CancellationToken cancellationToken = default) + { + var upper = command.ToUpperInvariant(); + if (upper.Contains("*IDN?")) + return await QueryIdAsync(cancellationToken); + if (upper.Contains("VOLT")) + return (await ReadVoltageAsync(cancellationToken)).ToString("F5", CultureInfo.InvariantCulture); + if (upper.Contains("CURR")) + return (await ReadCurrentAsync(cancellationToken)).ToString("F5", CultureInfo.InvariantCulture); + return command.TrimEnd().EndsWith("?") ? "0" : string.Empty; + } + + public ValueTask DisposeAsync() + { + IsConnected = false; + return ValueTask.CompletedTask; + } +} +``` + +## 9. UNI-T SDK 使用边界 + +`UNI-T SDK` 目录内容: + +- `doc/`:各机型编程手册、UCI API 帮助文档。 +- `driver/`:USB 转串口、libusb 等驱动安装程序。 +- `include/`:C/C++ 头文件。 +- `lib/C#/ucics.dll`:C# UCI 封装。 +- `lib/C/Unicode/uci.dll`、`lib/C/x64/Unicode/uci.dll`:UCI 原生 DLL。 +- `examples/`:VC、VB、C#、CVI、LabView 示例。 + +只有在确认 UDP5080-100 现场固件要求 UCI 或 VISA,而 TCP 5025 不可用时,才考虑 SDK 路线: + +1. C# 项目引用 `UNI-T SDK/lib/C#/ucics.dll`。 +2. 将匹配位数和编码的 `uci.dll` 复制到程序输出目录。 +3. .NET 8 WPF 主程序建议强制 `x64`,避免 AnyCPU 与原生 DLL 位数不一致。 +4. C# 示例入口是 `UNI-T SDK/examples/UCI/C#/SimpleIO/Program.cs`。 +5. UCI 接口返回值 `< 0` 表示错误,通过 `Session.GetLastError()` 或 `UCIInterop.GetLastError()` 获取错误描述。 +6. 如果 `Open` 返回 `-1040` 一类连接字符串格式错误,常见原因是 C# 工程与 `uci.dll` 字符编码版本不一致,C# 通常使用 Unicode 版本。 + +UCI C# 示例中的典型调用: + +```csharp +using uci; + +var session = new Session(true); +UCIInterop.SetAttribute(UCIInterop.InvalidSession, "lang:zh-Hans;", null, 0); + +var nodes = new uci.Node[10]; +var count = UCIInterop.QueryNodesX("LAN:5000,4162,8000,18191;", nodes, nodes.Length, 2000); + +if (count > 0) +{ + var result = session.Open(nodes[0].UCIAddr); + if (Session.Error(result)) + throw new Exception(session.GetLastError()); +} +``` + +再次强调:SDK/UCI 是备选路径,不是本项目 UDP5080-100 TCP 接入的默认路径。 + +## 10. 配置建议 + +将设备连接参数放入主项目配置,例如 `appsettings.json` 或项目已有配置系统: + +```json +{ + "Udp5080": { + "Mode": "Tcp", + "Host": "192.168.6.5", + "Port": 5025, + "TimeoutSeconds": 2, + "SampleIntervalMs": 500, + "VoltageCommand": "MEASure:VOLTage?", + "CurrentCommand": "MEASure:CURRent?" + } +} +``` + +UI 应允许现场修改 IP、端口、超时、采样周期、测量命令,并持久化保存。 + +## 11. 测试与验收清单 + +无实机测试: + +- 使用 `Udp5080Simulator` 验证连接、采样、曲线、日志、停止采样。 +- 单元测试 `ParseNumber`,覆盖普通小数、科学计数法、带单位文本、无效响应。 +- 验证连续 3 次异常后采样停止。 +- 验证断开连接时后台任务能被取消,不阻塞 WPF 关闭。 + +实机测试: + +- 电脑网卡与设备处于 `192.168.6.x` 同网段。 +- `ping 192.168.6.5` 成功。 +- `ConnectAsync` 成功,`*IDN?` 有响应。 +- `MEASure:VOLTage?` 返回合理电压。 +- `MEASure:CURRent?` 返回合理电流。 +- 采样 5 分钟无 UI 卡顿、无内存持续增长。 +- 拔网线后能提示通信失败,且不会卡死 UI。 +- 恢复网线后可手动重新连接。 + +## 12. AI 开发注意事项 + +后续 AI 在主项目中开发时必须遵守: + +- 不要在 WPF code-behind 中直接写 socket 通信。 +- 不要在 UI 线程中阻塞等待 `.Result` 或 `.Wait()`。 +- 不要把 SDK 示例里的示波器命令、UTP3000C 命令直接套到 UDP5080-100。 +- 不要默认安装 NI-VISA、libusb 或 USB 转串口驱动;TCP 5025 不需要这些驱动。 +- 不要把 `UNI-T SDK` 下的 exe、示例 bin/obj 全部复制到输出目录,只复制实际依赖项。 +- 驱动层要可替换,至少提供 TCP 实现和 Simulator 实现。 +- 所有设备异常都应转成清晰的中文错误信息,供 UI 日志和用户提示使用。 diff --git a/SSPCTester.Devices/Config/DaqChannelOptionsNormalizer.cs b/SSPCTester.Devices/Config/DaqChannelOptionsNormalizer.cs new file mode 100644 index 0000000..38b7b15 --- /dev/null +++ b/SSPCTester.Devices/Config/DaqChannelOptionsNormalizer.cs @@ -0,0 +1,38 @@ +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Config; + +public static class DaqChannelOptionsNormalizer +{ + public const int ChannelSlots = 8; + + public static List Normalize(IEnumerable? channels) + { + var byPhysicalChannel = (channels ?? Enumerable.Empty()) + .Where(x => x.PhysicalChannel is >= 0 and < ChannelSlots) + .GroupBy(x => x.PhysicalChannel) + .ToDictionary(x => x.Key, x => x.First()); + + var normalized = new List(ChannelSlots); + for (int physicalChannel = 0; physicalChannel < ChannelSlots; physicalChannel++) + { + byPhysicalChannel.TryGetValue(physicalChannel, out var source); + normalized.Add(new DaqChannelOptions + { + PhysicalChannel = physicalChannel, + Role = NormalizeRole(source?.Role), + Name = string.IsNullOrWhiteSpace(source?.Name) ? $"CH{physicalChannel}" : source.Name, + Scale = source?.Scale ?? 1, + Offset = source?.Offset ?? 0, + IsCalibrated = source?.IsCalibrated ?? false + }); + } + + return normalized; + } + + public static string NormalizeRole(string? role) => + Enum.TryParse(role, ignoreCase: true, out var parsed) + ? parsed.ToString() + : nameof(DaqChannelRole.Unconfigured); +} diff --git a/SSPCTester.Devices/Config/DeviceOptions.cs b/SSPCTester.Devices/Config/DeviceOptions.cs new file mode 100644 index 0000000..6d31787 --- /dev/null +++ b/SSPCTester.Devices/Config/DeviceOptions.cs @@ -0,0 +1,122 @@ +namespace SSPCTester.Devices.Config; + +/// +/// 根设备配置节点。对应 appsettings.json 中的 "Devices" 段。 +/// +public sealed class DeviceOptions +{ + public const string SectionName = "Devices"; + + /// 旧版全局开关,仅用于兼容读取旧配置。 + public bool MockMode { get; set; } + + public SspcOptions Sspc { get; set; } = new(); + public PowerSupplyOptions PowerSupply { get; set; } = new(); + public LoadOptions Load { get; set; } = new(); + public DaqOptions Daq { get; set; } = new(); +} + +/// +/// SSPC(24 路 = 3 模块 × 8 路)的串口与 Modbus 配置。 +/// +public sealed class SspcOptions +{ + public bool UseMock { get; set; } + public bool AutoConnect { get; set; } = true; + public string PortName { get; set; } = "COM1"; + public int BaudRate { get; set; } = 9600; + public int DataBits { get; set; } = 8; + public string Parity { get; set; } = "None"; + public string StopBits { get; set; } = "One"; + + public int ReadTimeoutMs { get; set; } = 500; + public int Retry { get; set; } = 2; + public string DeviceProfilePath { get; set; } = "Config/device-profile.json"; + public bool CloseAllRelaysOnDisconnect { get; set; } + public bool LogRawFrames { get; set; } = true; + + // 旧字段保留用于兼容历史 appsettings,业务通道数固定为 24。 + public byte[] ModuleAddresses { get; set; } = new byte[] { 1, 2, 3 }; + public int ChannelsPerModule { get; set; } = 8; +} + +public sealed class PowerSupplyOptions +{ + public bool UseMock { get; set; } + public bool AutoConnect { get; set; } = true; + public string PortName { get; set; } = "COM2"; + public int BaudRate { get; set; } = 9600; + public string Host { get; set; } = "192.168.6.5"; + public int Port { get; set; } = 5025; + public double TimeoutSeconds { get; set; } = 2; + public bool RequirePingBeforeConnect { get; set; } = true; + public string Terminator { get; set; } = "\n"; + public string IdnCommand { get; set; } = "*IDN?"; + public string VoltageCommand { get; set; } = "MEASure:VOLTage?"; + public string CurrentCommand { get; set; } = "MEASure:CURRent?"; +} + +public enum LoadQueryMode +{ + Combined, + Separate +} + +public sealed class LoadOptions +{ + public bool UseMock { get; set; } + public bool AutoConnect { get; set; } = true; + public string PortName { get; set; } = "COM3"; + public int BaudRate { get; set; } = 9600; + public string Host { get; set; } = "192.168.200.100"; + public int Port { get; set; } = 30000; + public double TimeoutSeconds { get; set; } = 3; + public string Terminator { get; set; } = "\n"; + public int Channel { get; set; } = 1; + public bool UseFetch { get; set; } = true; + public LoadQueryMode QueryMode { get; set; } = LoadQueryMode.Combined; +} + +public sealed class DaqOptions +{ + public bool UseMock { get; set; } + public bool AutoConnect { get; set; } = true; + public int LogicalDeviceId { get; set; } + public int ChannelCount { get; set; } = 1; + public string InputRange { get; set; } = "PlusMinus5V"; + public int ClockDivider { get; set; } = 1_000; + public double PreTriggerMs { get; set; } = 10; + public double PostTriggerMs { get; set; } = 40; + public List Channels { get; set; } = + Enumerable.Range(0, 8).Select(i => new DaqChannelOptions + { + PhysicalChannel = i, + Name = $"CH{i}" + }).ToList(); + + [System.Text.Json.Serialization.JsonIgnore] + public int DeviceIndex { get => LogicalDeviceId; set => LogicalDeviceId = value; } + [System.Text.Json.Serialization.JsonIgnore] + public int SampleRateHz + { + get => (int)Math.Round(ActualSampleRateHz); + set => ClockDivider = value > 0 + ? Math.Max(1, (int)Math.Round(100_000_000.0 / value)) + : 1_000; + } + [System.Text.Json.Serialization.JsonIgnore] + public double DurationSec => (PreTriggerMs + PostTriggerMs) / 1_000.0; + + [System.Text.Json.Serialization.JsonIgnore] + public double ActualSampleRateHz => 100_000_000.0 / Math.Max(1, ClockDivider); +} + +public sealed class DaqChannelOptions +{ + public int PhysicalChannel { get; set; } + public string Role { get; set; } = "Unconfigured"; + public string Name { get; set; } = ""; + public double Scale { get; set; } = 1; + public double Offset { get; set; } + public bool IsCalibrated { get; set; } +} diff --git a/SSPCTester.Devices/Config/ModbusDeviceProfile.cs b/SSPCTester.Devices/Config/ModbusDeviceProfile.cs new file mode 100644 index 0000000..b86467c --- /dev/null +++ b/SSPCTester.Devices/Config/ModbusDeviceProfile.cs @@ -0,0 +1,150 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace SSPCTester.Devices.Config; + +public sealed class ModbusDeviceProfile +{ + public string SchemaVersion { get; set; } = ""; + public string ProfileId { get; set; } = ""; + public string ProfileName { get; set; } = ""; + public SerialDefaults SerialDefaults { get; set; } = new(); + public FrameOptions Frame { get; set; } = new(); + public RelayProtocol Relay { get; set; } = new(); + public MeasurementProtocol Voltage { get; set; } = new(); + public MeasurementProtocol Current { get; set; } = new(); + public List Channels { get; set; } = new(); +} + +public sealed class SerialDefaults +{ + public int BaudRate { get; set; } = 9600; + public int DataBits { get; set; } = 8; + public string Parity { get; set; } = "None"; + public int StopBits { get; set; } = 1; + public int ReadTimeoutMs { get; set; } = 500; + public int Retry { get; set; } = 2; + public string Protocol { get; set; } = "ModbusRTU"; +} + +public sealed class FrameOptions +{ + public int RegisterBytes { get; set; } = 2; + public string DataByteOrder { get; set; } = "BigEndian"; + public string Crc { get; set; } = "CRC16Modbus"; + public string CrcByteOrder { get; set; } = "LittleEndian"; +} + +public sealed class RelayProtocol +{ + public byte FunctionCodeWrite { get; set; } = 5; + public string OnValue { get; set; } = "0xFF00"; + public string OffValue { get; set; } = "0x0000"; + public bool VerifyEchoResponse { get; set; } = true; + + [JsonIgnore] public ushort OnValueNumber => ParseHex(OnValue); + [JsonIgnore] public ushort OffValueNumber => ParseHex(OffValue); + private static ushort ParseHex(string value) => + Convert.ToUInt16(value.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? value[2..] : value, 16); +} + +public sealed class MeasurementProtocol +{ + public byte Slave { get; set; } + public byte FunctionCodeRead { get; set; } = 3; + public ushort StartRegister { get; set; } + public ushort RegisterCount { get; set; } + public double Range { get; set; } + public string Unit { get; set; } = ""; + public string Formula { get; set; } = ""; + public bool Signed { get; set; } + public int DataStartOffset { get; set; } = 3; + public int ChannelBytes { get; set; } = 2; + public string DataByteOrder { get; set; } = "BigEndian"; +} + +public sealed class ChannelMapping +{ + public int PhysicalSlot { get; set; } + public RelayMapping Relay { get; set; } = new(); + public RegisterMapping Voltage { get; set; } = new(); + public RegisterMapping Current { get; set; } = new(); +} + +public sealed class RelayMapping +{ + public byte Slave { get; set; } + public ushort Coil { get; set; } +} + +public sealed class RegisterMapping +{ + public int SourceDisplayChannel { get; set; } + public int RegisterOffset { get; set; } +} + +public static class ModbusDeviceProfileLoader +{ + private static readonly JsonSerializerOptions JsonOptions = new() + { + PropertyNameCaseInsensitive = true + }; + + public static ModbusDeviceProfile Load(string path) + { + string resolved = Path.IsPathRooted(path) ? path : Path.Combine(AppContext.BaseDirectory, path); + if (!File.Exists(resolved)) + throw new FileNotFoundException($"找不到 Modbus 设备配置:{resolved}", resolved); + + var profile = JsonSerializer.Deserialize(File.ReadAllText(resolved), JsonOptions) + ?? throw new InvalidDataException("Modbus 设备配置为空。"); + Validate(profile); + return profile; + } + + public static void Validate(ModbusDeviceProfile p) + { + var errors = new List(); + if (p.SchemaVersion != "1.0") errors.Add($"不支持 schemaVersion '{p.SchemaVersion}'"); + if (p.Channels.Count != 24) errors.Add("channels 必须恰好包含 24 项"); + + var slots = p.Channels.Select(x => x.PhysicalSlot).OrderBy(x => x).ToArray(); + if (!slots.SequenceEqual(Enumerable.Range(1, 24))) errors.Add("physicalSlot 必须完整覆盖 1~24 且不能重复"); + if (p.Channels.GroupBy(x => (x.Relay.Slave, x.Relay.Coil)).Any(g => g.Count() > 1)) + errors.Add("继电器 slave/coil 组合存在重复"); + + ValidateMeasurement("voltage", p.Voltage, p.Channels.Select(x => x.Voltage.RegisterOffset), errors); + ValidateMeasurement("current", p.Current, p.Channels.Select(x => x.Current.RegisterOffset), errors); + + foreach (var slave in p.Channels.Select(x => x.Relay.Slave).Append(p.Voltage.Slave).Append(p.Current.Slave)) + if (slave is < 1 or > 247) errors.Add($"从站地址 {slave} 超出 1~247"); + + if (p.Frame.RegisterBytes != 2) errors.Add("frame.registerBytes 仅支持 2"); + if (p.Frame.DataByteOrder != "BigEndian") errors.Add("frame.dataByteOrder 仅支持 BigEndian"); + if (p.Frame.Crc != "CRC16Modbus") errors.Add("frame.crc 仅支持 CRC16Modbus"); + if (p.Frame.CrcByteOrder != "LittleEndian") errors.Add("frame.crcByteOrder 仅支持 LittleEndian"); + if (p.Relay.FunctionCodeWrite != 5) errors.Add("relay.functionCodeWrite 必须为 5"); + try { _ = p.Relay.OnValueNumber; _ = p.Relay.OffValueNumber; } + catch { errors.Add("relay.onValue/offValue 必须是有效十六进制值"); } + + if (errors.Count > 0) + throw new InvalidDataException("Modbus 设备配置无效:" + string.Join(";", errors.Distinct())); + } + + private static void ValidateMeasurement( + string name, MeasurementProtocol protocol, IEnumerable offsets, List errors) + { + if (protocol.FunctionCodeRead != 3) errors.Add($"{name}.functionCodeRead 必须为 3"); + if (protocol.RegisterCount != 24) errors.Add($"{name}.registerCount 必须为 24"); + if (protocol.ChannelBytes != 2) errors.Add($"{name}.channelBytes 仅支持 2"); + if (protocol.DataStartOffset != 3) errors.Add($"{name}.dataStartOffset 必须为 3"); + if (protocol.DataByteOrder != "BigEndian") errors.Add($"{name}.dataByteOrder 仅支持 BigEndian"); + if (protocol.Formula is not ("A" or "B")) errors.Add($"{name}.formula 只能是 A 或 B"); + if (protocol.Range <= 0) errors.Add($"{name}.range 必须大于 0"); + var values = offsets.ToArray(); + if (values.Any(x => x < 0 || x >= protocol.RegisterCount)) + errors.Add($"{name}.registerOffset 超出寄存器范围"); + if (values.Distinct().Count() != values.Length) + errors.Add($"{name}.registerOffset 存在重复"); + } +} diff --git a/SSPCTester.Devices/Drivers/ConfigurableDevices.cs b/SSPCTester.Devices/Drivers/ConfigurableDevices.cs new file mode 100644 index 0000000..f0a1b8b --- /dev/null +++ b/SSPCTester.Devices/Drivers/ConfigurableDevices.cs @@ -0,0 +1,126 @@ +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Drivers.Mock; +using SSPCTester.Devices.Drivers.Real; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Drivers; + +/// 根据可变设置在 Mock 与真实 SSPC 间切换。 +public sealed class ConfigurableSspc : ISspc +{ + private readonly DeviceOptions _options; + private readonly MockSspc _mock; + private readonly SspcModbus _real; + + public ConfigurableSspc(IOptions options, MockSspc mock, SspcModbus real) + { + _options = options.Value; + _mock = mock; + _real = real; + _mock.ConnectionChanged += Forward; + _real.ConnectionChanged += Forward; + } + + private ISspc Current => _options.Sspc.UseMock ? _mock : _real; + public int ChannelCount => 24; + public bool IsConnected => Current.IsConnected; + public string DisplayName => Current.DisplayName; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => Current.ConnectAsync(ct); + public async Task DisconnectAsync() + { + await _mock.DisconnectAsync().ConfigureAwait(false); + await _real.DisconnectAsync().ConfigureAwait(false); + } + public Task TurnOnAsync(int physicalSlot, CancellationToken ct = default) => Current.TurnOnAsync(physicalSlot, ct); + public Task TurnOffAsync(int physicalSlot, CancellationToken ct = default) => Current.TurnOffAsync(physicalSlot, ct); + public Task FlashAsync(int physicalSlot, int milliseconds, CancellationToken ct = default) => Current.FlashAsync(physicalSlot, milliseconds, ct); + public Task GetChannelStateAsync(int physicalSlot, CancellationToken ct = default) => Current.GetChannelStateAsync(physicalSlot, ct); + public Task ReadMeasurementAsync(int physicalSlot, CancellationToken ct = default) => Current.ReadMeasurementAsync(physicalSlot, ct); + public Task> ReadMeasurementsAsync(CancellationToken ct = default) => Current.ReadMeasurementsAsync(ct); + private void Forward(object? sender, bool connected) => ConnectionChanged?.Invoke(this, connected); +} + +public sealed class ConfigurablePowerSupply : IPowerSupply +{ + private readonly DeviceOptions _options; + private readonly MockPowerSupply _mock; + private readonly Udp5080 _real; + public ConfigurablePowerSupply(IOptions options, MockPowerSupply mock, Udp5080 real) + { + _options = options.Value; _mock = mock; _real = real; + _mock.ConnectionChanged += Forward; _real.ConnectionChanged += Forward; + } + private IPowerSupply Current => _options.PowerSupply.UseMock ? _mock : _real; + public bool IsConnected => Current.IsConnected; + public string DisplayName => Current.DisplayName; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => Current.ConnectAsync(ct); + public async Task DisconnectAsync() { await _mock.DisconnectAsync(); await SafeDisconnect(_real); } + public Task SetVoltageAsync(double volts, CancellationToken ct = default) => Current.SetVoltageAsync(volts, ct); + public Task SetCurrentLimitAsync(double amps, CancellationToken ct = default) => Current.SetCurrentLimitAsync(amps, ct); + public Task OutputAsync(bool on, CancellationToken ct = default) => Current.OutputAsync(on, ct); + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) => Current.ReadAsync(ct); + public Task QueryIdentityAsync(CancellationToken ct = default) => Current.QueryIdentityAsync(ct); + private void Forward(object? sender, bool connected) => ConnectionChanged?.Invoke(this, connected); + private static async Task SafeDisconnect(IDeviceConnection device) { try { await device.DisconnectAsync(); } catch (NotImplementedException) { } } +} + +public sealed class ConfigurableLoad : ILoad +{ + private readonly DeviceOptions _options; + private readonly MockLoad _mock; + private readonly It87xxLoad _real; + public ConfigurableLoad(IOptions options, MockLoad mock, It87xxLoad real) + { + _options = options.Value; _mock = mock; _real = real; + _mock.ConnectionChanged += Forward; _real.ConnectionChanged += Forward; + } + private ILoad Current => _options.Load.UseMock ? _mock : _real; + public bool IsConnected => Current.IsConnected; + public string DisplayName => Current.DisplayName; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => Current.ConnectAsync(ct); + public async Task DisconnectAsync() { await _mock.DisconnectAsync(); await SafeDisconnect(_real); } + public Task SetModeAsync(LoadMode mode, CancellationToken ct = default) => Current.SetModeAsync(mode, ct); + public Task SetValueAsync(double value, CancellationToken ct = default) => Current.SetValueAsync(value, ct); + public Task InputAsync(bool on, CancellationToken ct = default) => Current.InputAsync(on, ct); + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) => Current.ReadAsync(ct); + public Task ReadPowerAsync(CancellationToken ct = default) => Current.ReadPowerAsync(ct); + public Task QueryIdentityAsync(CancellationToken ct = default) => Current.QueryIdentityAsync(ct); + private void Forward(object? sender, bool connected) => ConnectionChanged?.Invoke(this, connected); + private static async Task SafeDisconnect(IDeviceConnection device) { try { await device.DisconnectAsync(); } catch (NotImplementedException) { } } +} + +public sealed class ConfigurableDaq : IDaq +{ + private readonly DeviceOptions _options; + private readonly MockDaq _mock; + private readonly Pcie8586Daq _real; + public ConfigurableDaq(IOptions options, MockDaq mock, Pcie8586Daq real) + { + _options = options.Value; _mock = mock; _real = real; + _mock.ConnectionChanged += Forward; _real.ConnectionChanged += Forward; + _mock.SampleReceived += ForwardSample; _real.SampleReceived += ForwardSample; + } + private IDaq Current => _options.Daq.UseMock ? _mock : _real; + public bool IsConnected => Current.IsConnected; + public string DisplayName => Current.DisplayName; + public event EventHandler? ConnectionChanged; + public event EventHandler? SampleReceived; + public Task> EnumerateDevicesAsync(CancellationToken ct = default) => + Current.EnumerateDevicesAsync(ct); + public Task ConnectAsync(CancellationToken ct = default) => Current.ConnectAsync(ct); + public async Task DisconnectAsync() { await _mock.DisconnectAsync(); await SafeDisconnect(_real); } + public Task CaptureAsync(int[] channels, int sampleRateHz, double durationSec, CancellationToken ct = default) => + Current.CaptureAsync(channels, sampleRateHz, durationSec, ct); + public Task ReadInstantAsync(int[] channels, CancellationToken ct = default) => Current.ReadInstantAsync(channels, ct); + public Task CaptureAroundActionAsync( + DaqActionCaptureRequest request, + Func action, + CancellationToken ct = default) => Current.CaptureAroundActionAsync(request, action, ct); + private void Forward(object? sender, bool connected) => ConnectionChanged?.Invoke(this, connected); + private void ForwardSample(object? sender, CurveSample sample) => SampleReceived?.Invoke(this, sample); + private static async Task SafeDisconnect(IDeviceConnection device) { try { await device.DisconnectAsync(); } catch (NotImplementedException) { } } +} diff --git a/SSPCTester.Devices/Drivers/Mock/MockDaq.cs b/SSPCTester.Devices/Drivers/Mock/MockDaq.cs new file mode 100644 index 0000000..f11a93c --- /dev/null +++ b/SSPCTester.Devices/Drivers/Mock/MockDaq.cs @@ -0,0 +1,176 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Drivers.Real; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Drivers.Mock; + +/// +/// 模拟数据采集卡。 +/// 生成逼真的电压上升 / 下降波形:V(t) = Vmax * (1 - exp(-t/τ)) + 噪声。 +/// +public sealed class MockDaq : MockDeviceBase, IDaq +{ + private readonly Random _rng = new(1024); + private readonly DaqOptions _opts; + private double? _nextTriggerSec; + + /// 满量程电压(V)。 + public double NominalVoltage { get; set; } = 28.0; + + /// 满量程电流(A)。 + public double NominalCurrent { get; set; } = 1.0; + + /// 开启延时(秒),用于模拟"控制信号 → 开始上升"的延时。 + public double OnDelaySec { get; set; } = 0.0003; + + /// 关断延时(秒)。 + public double OffDelaySec { get; set; } = 0.0003; + + /// RC 时间常数(秒)。 + public double TauSec { get; set; } = 0.0005; + + /// 下一次 CaptureAsync 的模式:true=上升曲线,false=下降曲线。 + public bool NextCaptureIsRising { get; set; } = true; + + public MockDaq(IOptions options, ILogger logger) + : base(logger, "PCIe8586 高速采集卡 (Mock)") + { + _opts = options.Value.Daq; + } + + public event EventHandler? SampleReceived; + + public Task> EnumerateDevicesAsync(CancellationToken ct = default) => + Task.FromResult>( + new[] { new DaqDeviceDescriptor(0, 0, "模拟 PCIe8586", true) }); + + public async Task CaptureAsync( + int[] channels, int sampleRateHz, double durationSec, CancellationToken ct = default) + { + if (sampleRateHz <= 0) throw new ArgumentOutOfRangeException(nameof(sampleRateHz)); + if (durationSec <= 0) throw new ArgumentOutOfRangeException(nameof(durationSec)); + + // 模拟采集耗时(不全等比例,避免阻塞太久) + int simulatedDelayMs = (int)Math.Min(durationSec * 1000.0 * 0.05, 400); + await Task.Delay(simulatedDelayMs, ct).ConfigureAwait(false); + + int n = (int)Math.Round(sampleRateHz * durationSec); + var v = new double[n]; + var i = new double[n]; + double dt = 1.0 / sampleRateHz; + + bool rising = NextCaptureIsRising; + double delay = rising ? OnDelaySec : OffDelaySec; + // 触发时刻设在 1/4 处,便于前后查看 + double triggerSec = _nextTriggerSec ?? durationSec * 0.25; + _nextTriggerSec = null; + + for (int k = 0; k < n; k++) + { + double t = k * dt; + double tRel = t - triggerSec - delay; // 相对于"开始上升/下降"的时间 + double voltage; + if (rising) + { + voltage = tRel <= 0 ? 0 : NominalVoltage * (1 - Math.Exp(-tRel / TauSec)); + } + else + { + voltage = tRel <= 0 ? NominalVoltage : NominalVoltage * Math.Exp(-tRel / TauSec); + } + voltage += NextGaussian() * NominalVoltage * 0.005; + v[k] = voltage; + + double current; + if (rising) + current = tRel <= 0 ? 0 : NominalCurrent * (1 - Math.Exp(-tRel / TauSec)); + else + current = tRel <= 0 ? NominalCurrent : NominalCurrent * Math.Exp(-tRel / TauSec); + current += NextGaussian() * NominalCurrent * 0.01; + i[k] = current; + } + + return new CurveData + { + SampleRateHz = sampleRateHz, + TriggerTimeSec = triggerSec, + Voltage = v, + Current = i + }; + } + + public Task ReadInstantAsync(int[] channels, CancellationToken ct = default) + { + var result = new double[channels.Length]; + for (int k = 0; k < channels.Length; k++) + { + int physical = channels[k]; + var cfg = _opts.Channels.FirstOrDefault(x => x.PhysicalChannel == physical); + var role = cfg is null + ? DaqChannelRole.Unconfigured + : Pcie8586Daq.ParseRole(cfg.Role); + + result[k] = role switch + { + DaqChannelRole.OutputVoltage or DaqChannelRole.InputVoltage => + NominalVoltage * (1 + (_rng.NextDouble() - 0.5) * 0.004), + DaqChannelRole.OutputCurrent or DaqChannelRole.InputCurrent => + NominalCurrent * (1 + (_rng.NextDouble() - 0.5) * 0.02), + _ => 0 + }; + } + return Task.FromResult(result); + } + + public async Task CaptureAroundActionAsync( + DaqActionCaptureRequest request, + Func action, + CancellationToken ct = default) + { + // Mock 下也遵循“先采前置窗口,再执行动作”的时序,避免与真卡行为不一致。 + await Task.Delay((int)Math.Max(1, request.PreTriggerMs * 0.2), ct).ConfigureAwait(false); + + double durationSec = (request.PreTriggerMs + request.PostTriggerMs) / 1_000.0; + int sampleRate = _opts.SampleRateHz; + NextCaptureIsRising = request.IsRising; + await action(ct).ConfigureAwait(false); + _nextTriggerSec = request.PreTriggerMs / 1_000.0; + var curve = await CaptureAsync(new[] { 0 }, sampleRate, durationSec, ct).ConfigureAwait(false); + int triggerIndex = (int)Math.Round(sampleRate * request.PreTriggerMs / 1_000.0); + return new CurveData + { + SampleRateHz = curve.SampleRateHz, + TriggerSampleIndex = triggerIndex, + TriggerTimeSec = triggerIndex / (double)curve.SampleRateHz, + Voltage = curve.Voltage, + Current = curve.Current, + EngineeringChannels = new[] + { + new CurveChannelData(0, DaqChannelRole.OutputVoltage, "模拟输出电压", "V", 1, 0, curve.Voltage), + new CurveChannelData(1, DaqChannelRole.OutputCurrent, "模拟输出电流", "A", 1, 0, curve.Current!) + } + }; + } + + /// 由 ReadInstantAsync 衍生的"电流读数"接口(基础测试页用)。 + public (double volts, double amps) ReadVoltageCurrent(int channel, bool channelOn) + { + if (!channelOn) return (0.0, 0.0); + double v = NominalVoltage * (1 + (_rng.NextDouble() - 0.5) * 0.004); + double a = NominalCurrent * (1 + (_rng.NextDouble() - 0.5) * 0.02); + return (v, a); + } + + /// Box-Muller 生成高斯噪声。 + private double NextGaussian() + { + double u1 = 1.0 - _rng.NextDouble(); + double u2 = 1.0 - _rng.NextDouble(); + return Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Cos(2.0 * Math.PI * u2); + } + + /// 仅用于编译期消除"事件未使用"警告。 + private void RaiseSample(CurveSample s) => SampleReceived?.Invoke(this, s); +} diff --git a/SSPCTester.Devices/Drivers/Mock/MockLoad.cs b/SSPCTester.Devices/Drivers/Mock/MockLoad.cs new file mode 100644 index 0000000..0cb75f2 --- /dev/null +++ b/SSPCTester.Devices/Drivers/Mock/MockLoad.cs @@ -0,0 +1,60 @@ +using Microsoft.Extensions.Logging; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Drivers.Mock; + +/// +/// 模拟可编程负载。 +/// +public sealed class MockLoad : MockDeviceBase, ILoad +{ + private readonly Random _rng = new(4096); + private LoadMode _mode = LoadMode.CC; + private double _value = 1.0; + private bool _input = true; + + public MockLoad(ILogger logger) + : base(logger, "负载:IT8702P+IT8733P (Mock)") + { + } + + public async Task SetModeAsync(LoadMode mode, CancellationToken ct = default) + { + await Task.Delay(10, ct).ConfigureAwait(false); + _mode = mode; + } + + public async Task SetValueAsync(double value, CancellationToken ct = default) + { + await Task.Delay(10, ct).ConfigureAwait(false); + _value = value; + } + + public async Task InputAsync(bool on, CancellationToken ct = default) + { + await Task.Delay(10, ct).ConfigureAwait(false); + _input = on; + } + + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) + { + if (!_input) return Task.FromResult((0.0, 0.0)); + // CC 模式下电流接近设定值;其他模式简化处理 + double i = _mode == LoadMode.CC ? _value : 1.0; + double v = 27.4 + (_rng.NextDouble() - 0.5) * 0.1; + i *= 1 + (_rng.NextDouble() - 0.5) * 0.01; + return Task.FromResult((v, i)); + } + + public Task ReadPowerAsync(CancellationToken ct = default) + { + if (!_input) return Task.FromResult(new PowerReading(0.0, 0.0, 0.0)); + double i = _mode == LoadMode.CC ? _value : 1.0; + double v = 27.4 + (_rng.NextDouble() - 0.5) * 0.1; + i *= 1 + (_rng.NextDouble() - 0.5) * 0.01; + return Task.FromResult(new PowerReading(v, i, v * i)); + } + + public Task QueryIdentityAsync(CancellationToken ct = default) => + Task.FromResult("ITECH,IT8702P,MOCK,1.0"); +} diff --git a/SSPCTester.Devices/Drivers/Mock/MockPowerSupply.cs b/SSPCTester.Devices/Drivers/Mock/MockPowerSupply.cs new file mode 100644 index 0000000..70e5409 --- /dev/null +++ b/SSPCTester.Devices/Drivers/Mock/MockPowerSupply.cs @@ -0,0 +1,49 @@ +using Microsoft.Extensions.Logging; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Drivers.Mock; + +/// +/// 模拟程控电源:保存设定值,读取时返回带噪声的设定值。 +/// +public sealed class MockPowerSupply : MockDeviceBase, IPowerSupply +{ + private readonly Random _rng = new(2026); + private double _setVolts = 28.0; + private double _setAmps = 5.0; + private bool _output; + + public MockPowerSupply(ILogger logger) + : base(logger, "电源 UDP5080 (Mock)") + { + } + + public async Task SetVoltageAsync(double volts, CancellationToken ct = default) + { + await Task.Delay(10, ct).ConfigureAwait(false); + _setVolts = volts; + } + + public async Task SetCurrentLimitAsync(double amps, CancellationToken ct = default) + { + await Task.Delay(10, ct).ConfigureAwait(false); + _setAmps = amps; + } + + public async Task OutputAsync(bool on, CancellationToken ct = default) + { + await Task.Delay(10, ct).ConfigureAwait(false); + _output = on; + } + + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) + { + if (!_output) return Task.FromResult((0.0, 0.0)); + double v = _setVolts * (1 + (_rng.NextDouble() - 0.5) * 0.004); + double i = Math.Min(_setAmps, 1.5) * (1 + (_rng.NextDouble() - 0.5) * 0.01); + return Task.FromResult((v, i)); + } + + public Task QueryIdentityAsync(CancellationToken ct = default) => + Task.FromResult("UNI-T,UDP5080-100,MOCK,1.0"); +} diff --git a/SSPCTester.Devices/Drivers/Mock/MockSspc.cs b/SSPCTester.Devices/Drivers/Mock/MockSspc.cs new file mode 100644 index 0000000..57cdd9b --- /dev/null +++ b/SSPCTester.Devices/Drivers/Mock/MockSspc.cs @@ -0,0 +1,117 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Drivers.Mock; + +/// +/// 所有 Mock 驱动的公共基类:实现 IDeviceConnection 的连接状态机。 +/// +public abstract class MockDeviceBase : IDeviceConnection +{ + private readonly ILogger _logger; + protected MockDeviceBase(ILogger logger, string displayName) + { + _logger = logger; + DisplayName = displayName; + } + + public bool IsConnected { get; private set; } + public string DisplayName { get; } + + public event EventHandler? ConnectionChanged; + + public virtual async Task ConnectAsync(CancellationToken ct = default) + { + await Task.Delay(200, ct).ConfigureAwait(false); + IsConnected = true; + _logger.LogInformation("[Mock] {Device} 已连接。", DisplayName); + ConnectionChanged?.Invoke(this, true); + return true; + } + + public virtual Task DisconnectAsync() + { + if (IsConnected) + { + IsConnected = false; + _logger.LogInformation("[Mock] {Device} 已断开。", DisplayName); + ConnectionChanged?.Invoke(this, false); + } + return Task.CompletedTask; + } +} + +/// +/// 模拟固态功率控制器:内部维护 24 路开关状态。 +/// +public sealed class MockSspc : MockDeviceBase, ISspc +{ + private readonly bool[] _states; + + public MockSspc(IOptions options, ILogger logger) + : base(logger, "SSPC (Mock)") + { + ChannelCount = 24; + _states = new bool[ChannelCount]; + } + + public int ChannelCount { get; } + + public async Task TurnOnAsync(int physicalSlot, CancellationToken ct = default) + { + await Task.Delay(20, ct).ConfigureAwait(false); + ValidateChannel(physicalSlot); + _states[physicalSlot - 1] = true; + } + + public async Task TurnOffAsync(int physicalSlot, CancellationToken ct = default) + { + await Task.Delay(20, ct).ConfigureAwait(false); + ValidateChannel(physicalSlot); + _states[physicalSlot - 1] = false; + } + + public async Task FlashAsync(int physicalSlot, int milliseconds, CancellationToken ct = default) + { + await TurnOnAsync(physicalSlot, ct).ConfigureAwait(false); + await Task.Delay(milliseconds, ct).ConfigureAwait(false); + await TurnOffAsync(physicalSlot, ct).ConfigureAwait(false); + } + + public Task GetChannelStateAsync(int physicalSlot, CancellationToken ct = default) + { + ValidateChannel(physicalSlot); + return Task.FromResult(_states[physicalSlot - 1]); + } + + public Task ReadMeasurementAsync(int physicalSlot, CancellationToken ct = default) + { + ValidateChannel(physicalSlot); + bool on = _states[physicalSlot - 1]; + return Task.FromResult(new ChannelMeasurement + { + PhysicalSlot = physicalSlot, + Voltage = on ? 28.0 : 0.0, + Current = on ? 1.0 : 0.0, + VoltageRaw = on ? (ushort)2800 : (ushort)0, + CurrentRaw = on ? (short)167 : (short)0, + Timestamp = DateTimeOffset.Now + }); + } + + public async Task> ReadMeasurementsAsync(CancellationToken ct = default) + { + var values = new ChannelMeasurement[ChannelCount]; + for (int slot = 1; slot <= ChannelCount; slot++) + values[slot - 1] = await ReadMeasurementAsync(slot, ct).ConfigureAwait(false); + return values; + } + + private void ValidateChannel(int physicalSlot) + { + if (physicalSlot < 1 || physicalSlot > ChannelCount) + throw new ArgumentOutOfRangeException(nameof(physicalSlot), physicalSlot, $"通道范围 1..{ChannelCount}"); + } +} diff --git a/SSPCTester.Devices/Drivers/Real/It87xxLoad.cs b/SSPCTester.Devices/Drivers/Real/It87xxLoad.cs new file mode 100644 index 0000000..a42e704 --- /dev/null +++ b/SSPCTester.Devices/Drivers/Real/It87xxLoad.cs @@ -0,0 +1,222 @@ +using System.Globalization; +using System.IO; +using System.Net.Sockets; +using System.Text; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Drivers.Real; + +public sealed class It87xxLoad : ILoad +{ + private const int MaxResponseBytes = 1024 * 1024; + private readonly LoadOptions _options; + private readonly ILogger _logger; + private readonly SemaphoreSlim _gate = new(1, 1); + private TcpClient? _client; + private NetworkStream? _stream; + private bool _isConnected; + + public It87xxLoad(IOptions options, ILogger logger) + { + _options = options.Value.Load; + _logger = logger; + } + + public bool IsConnected => _isConnected && _client?.Connected == true && _stream is not null; + public string DisplayName => "IT8702P electronic load"; + public event EventHandler? ConnectionChanged; + + public async Task ConnectAsync(CancellationToken ct = default) + { + await DisconnectAsync().ConfigureAwait(false); + + var client = new TcpClient { NoDelay = true }; + try + { + using var cts = CancellationTokenSource.CreateLinkedTokenSource(ct); + cts.CancelAfter(Timeout); + await client.ConnectAsync(_options.Host, _options.Port, cts.Token).ConfigureAwait(false); + _client = client; + _stream = client.GetStream(); + SetConnected(true); + + string idn = await QueryIdentityAsync(ct).ConfigureAwait(false); + if (!idn.Contains("IT87", StringComparison.OrdinalIgnoreCase)) + throw new InvalidOperationException($"Unexpected IT8702P identity: {idn}"); + + await SendAsync("SYST:REM", ct).ConfigureAwait(false); + await SendAsync($"CHAN {Math.Clamp(_options.Channel, 1, 8)}", ct).ConfigureAwait(false); + _logger.LogInformation("IT8702P connected to {Host}:{Port}, channel {Channel}.", _options.Host, _options.Port, _options.Channel); + return true; + } + catch (Exception ex) when (ex is SocketException or IOException or OperationCanceledException or InvalidOperationException) + { + client.Dispose(); + _stream = null; + _client = null; + SetConnected(false); + throw new InvalidOperationException($"IT8702P connection failed: {_options.Host}:{_options.Port}, {ex.Message}", ex); + } + } + + public async Task DisconnectAsync() + { + if (IsConnected) + { + try { await SendAsync("SYST:LOC", CancellationToken.None).ConfigureAwait(false); } + catch { } + } + + _stream?.Dispose(); + _client?.Dispose(); + _stream = null; + _client = null; + SetConnected(false); + } + + public Task SetModeAsync(LoadMode mode, CancellationToken ct = default) => + throw new NotSupportedException("IT8702P load control commands are not enabled; this driver only reads V/I/P."); + + public Task SetValueAsync(double value, CancellationToken ct = default) => + throw new NotSupportedException("IT8702P load control commands are not enabled; this driver only reads V/I/P."); + + public Task InputAsync(bool on, CancellationToken ct = default) => + throw new NotSupportedException("IT8702P load input commands are not enabled; this driver only reads V/I/P."); + + public async Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) + { + var reading = await ReadPowerAsync(ct).ConfigureAwait(false); + return (reading.Volts, reading.Amps); + } + + public async Task ReadPowerAsync(CancellationToken ct = default) + { + try + { + string prefix = _options.UseFetch ? "FETC" : "MEAS"; + if (_options.QueryMode == LoadQueryMode.Combined) + { + string response = await QueryAsync($"{prefix}:VOLT?;:{prefix}:CURR?;:{prefix}:POW?", ct).ConfigureAwait(false); + var parts = response.Split(';', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); + if (parts.Length < 3) + throw new FormatException($"IT8702P combined response has {parts.Length} parts: {response}"); + + return CreateReading(parts[0], parts[1], parts[2]); + } + + string volts = await QueryAsync($"{prefix}:VOLT?", ct).ConfigureAwait(false); + string amps = await QueryAsync($"{prefix}:CURR?", ct).ConfigureAwait(false); + string watts = await QueryAsync($"{prefix}:POW?", ct).ConfigureAwait(false); + return CreateReading(volts, amps, watts); + } + catch (FormatException ex) + { + SetConnected(false); + throw new InvalidOperationException($"IT8702P response parse failed: {ex.Message}", ex); + } + } + + public Task QueryIdentityAsync(CancellationToken ct = default) => QueryAsync("*IDN?", ct); + + public async Task QueryAsync(string command, CancellationToken ct = default) + { + await _gate.WaitAsync(ct).ConfigureAwait(false); + try + { + var stream = RequireStream(); + using var cts = CancellationTokenSource.CreateLinkedTokenSource(ct); + cts.CancelAfter(Timeout); + await WriteLineAsync(stream, command, cts.Token).ConfigureAwait(false); + return await ReadLineAsync(stream, cts.Token).ConfigureAwait(false); + } + catch (Exception ex) when (ex is SocketException or IOException or OperationCanceledException) + { + SetConnected(false); + throw new InvalidOperationException($"IT8702P query failed: {command}, {ex.Message}", ex); + } + finally + { + _gate.Release(); + } + } + + private async Task SendAsync(string command, CancellationToken ct = default) + { + await _gate.WaitAsync(ct).ConfigureAwait(false); + try + { + var stream = RequireStream(); + using var cts = CancellationTokenSource.CreateLinkedTokenSource(ct); + cts.CancelAfter(Timeout); + await WriteLineAsync(stream, command, cts.Token).ConfigureAwait(false); + } + catch (Exception ex) when (ex is SocketException or IOException or OperationCanceledException) + { + SetConnected(false); + throw new InvalidOperationException($"IT8702P command failed: {command}, {ex.Message}", ex); + } + finally + { + _gate.Release(); + } + } + + private static PowerReading CreateReading(string volts, string amps, string watts) + { + var reading = new PowerReading(ParseNumber(volts), Math.Abs(ParseNumber(amps)), ParseNumber(watts)); + if (!double.IsFinite(reading.Volts) || !double.IsFinite(reading.Amps) || !double.IsFinite(reading.Watts)) + throw new FormatException("IT8702P response contains a non-finite value."); + return reading; + } + + private static double ParseNumber(string value) => + double.Parse(value.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture); + + private async Task WriteLineAsync(NetworkStream stream, string command, CancellationToken ct) + { + var payload = Encoding.ASCII.GetBytes(command.TrimEnd('\r', '\n') + Terminator); + await stream.WriteAsync(payload, ct).ConfigureAwait(false); + await stream.FlushAsync(ct).ConfigureAwait(false); + } + + private static async Task ReadLineAsync(NetworkStream stream, CancellationToken ct) + { + var buffer = new byte[256]; + using var memory = new MemoryStream(); + while (memory.Length < MaxResponseBytes) + { + int read = await stream.ReadAsync(buffer, ct).ConfigureAwait(false); + if (read <= 0) + throw new IOException("Device closed the connection."); + + int newline = Array.IndexOf(buffer, (byte)'\n', 0, read); + memory.Write(buffer, 0, newline >= 0 ? newline : read); + if (newline >= 0) break; + } + + if (memory.Length >= MaxResponseBytes) + throw new IOException("Device response exceeded 1 MB."); + + return Encoding.ASCII.GetString(memory.ToArray()).Trim(); + } + + private TimeSpan Timeout => TimeSpan.FromSeconds(_options.TimeoutSeconds > 0 ? _options.TimeoutSeconds : 3); + private string Terminator => string.IsNullOrEmpty(_options.Terminator) ? "\n" : _options.Terminator; + + private NetworkStream RequireStream() + { + if (!IsConnected || _stream is null) + throw new InvalidOperationException("IT8702P is not connected."); + return _stream; + } + + private void SetConnected(bool connected) + { + if (_isConnected == connected) return; + _isConnected = connected; + ConnectionChanged?.Invoke(this, connected); + } +} diff --git a/SSPCTester.Devices/Drivers/Real/Pcie8586Daq.cs b/SSPCTester.Devices/Drivers/Real/Pcie8586Daq.cs new file mode 100644 index 0000000..058c2cd --- /dev/null +++ b/SSPCTester.Devices/Drivers/Real/Pcie8586Daq.cs @@ -0,0 +1,291 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Pcie8586Probe.Hardware; +using Pcie8586Probe.Models; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using DriverInputRange = Pcie8586Probe.Models.InputRange; + +namespace SSPCTester.Devices.Drivers.Real; + +/// PCIe8586 高速采集卡适配器。原生句柄仅由 IDigitizer 持有。 +public sealed class Pcie8586Daq : IDaq, IDisposable +{ + private readonly DaqOptions _options; + private readonly ILogger _logger; + private readonly IDigitizer _digitizer; + private readonly SemaphoreSlim _operationLock = new(1, 1); + private bool _connected; + + public Pcie8586Daq(IOptions options, ILogger logger) + : this(options.Value.Daq, logger, new Pcie8586Digitizer()) + { + } + + internal Pcie8586Daq(DaqOptions options, ILogger logger, IDigitizer digitizer) + { + _options = options; + _logger = logger; + _digitizer = digitizer; + } + + public bool IsConnected => _connected && _digitizer.IsOpen; + public string DisplayName => "PCIe8586 高速采集卡"; + public event EventHandler? ConnectionChanged; + public event EventHandler? SampleReceived; + + public async Task> EnumerateDevicesAsync(CancellationToken ct = default) + { + try + { + var devices = await _digitizer.EnumerateDevicesAsync(ct); + return devices.Select(x => new DaqDeviceDescriptor( + x.LogicalId, x.PhysicalId, x.Description, x.IsSimulated)).ToArray(); + } + catch (DllNotFoundException ex) + { + throw new InvalidOperationException("找不到 ACTS1000_64.dll。请安装厂商驱动并将 x64 运行库放到程序目录。", ex); + } + catch (BadImageFormatException ex) + { + throw new InvalidOperationException("ACTS1000_64.dll 位数不匹配,程序和运行库必须都是 x64。", ex); + } + } + + public async Task ConnectAsync(CancellationToken ct = default) + { + await _operationLock.WaitAsync(ct); + try + { + if (IsConnected) return true; + var devices = await EnumerateDevicesAsync(ct); + var selected = devices.SingleOrDefault(x => x.LogicalId == _options.LogicalDeviceId) + ?? throw new InvalidOperationException($"未发现逻辑 ID {_options.LogicalDeviceId} 的 PCIe8586。"); + await _digitizer.OpenAsync( + new DeviceInfo(selected.LogicalId, selected.PhysicalId, selected.Description, selected.IsSimulated), ct); + _connected = true; + ConnectionChanged?.Invoke(this, true); + return true; + } + finally + { + _operationLock.Release(); + } + } + + public async Task DisconnectAsync() + { + await _operationLock.WaitAsync(); + try + { + await _digitizer.StopAsync(); + await _digitizer.CloseAsync(); + if (_connected) + { + _connected = false; + ConnectionChanged?.Invoke(this, false); + } + } + finally + { + _operationLock.Release(); + } + } + + public async Task CaptureAroundActionAsync( + DaqActionCaptureRequest request, + Func action, + CancellationToken ct = default) + { + ValidateOptions(requireOutputVoltage: true); + await _operationLock.WaitAsync(ct); + try + { + if (!IsConnected) await ConnectWithoutLockAsync(ct); + var config = CreateDriverConfig(); + await _digitizer.ConfigureAsync(config, ct); + + int preSamples = Math.Max(1, (int)Math.Round(config.SampleRateHz * request.PreTriggerMs / 1_000.0)); + int postSamples = Math.Max(1, (int)Math.Round(config.SampleRateHz * request.PostTriggerMs / 1_000.0)); + int targetSamples = checked(preSamples + postSamples); + var collected = Enumerable.Range(0, config.ChannelCount) + .Select(_ => new List(targetSamples)).ToArray(); + bool actionInvoked = false; + int triggerIndex = 0; + var preTriggerTimeout = TimeSpan.FromMilliseconds(Math.Max(3_000, request.PreTriggerMs * 5)); + using var acquisitionCts = CancellationTokenSource.CreateLinkedTokenSource(ct); + acquisitionCts.CancelAfter(preTriggerTimeout); + + try + { + await foreach (var block in _digitizer.StartAcquisitionAsync(acquisitionCts.Token)) + { + if (!actionInvoked) + { + int take = Math.Min(preSamples - collected[0].Count, block.SamplesPerChannel); + for (int channel = 0; channel < config.ChannelCount; channel++) + collected[channel].AddRange(block.Channels[channel].AsSpan(0, take).ToArray()); + if (collected[0].Count >= preSamples) + { + triggerIndex = collected[0].Count; + actionInvoked = true; + acquisitionCts.CancelAfter(Timeout.InfiniteTimeSpan); + await action(ct); + } + // 动作发生在本次 DMA 读取完成之后;当前块未使用余量仍属于动作前数据,必须丢弃。 + continue; + } + + int remaining = targetSamples - collected[0].Count; + int postTake = Math.Min(remaining, block.SamplesPerChannel); + for (int channel = 0; channel < config.ChannelCount; channel++) + collected[channel].AddRange(block.Channels[channel].AsSpan(0, postTake).ToArray()); + if (collected[0].Count >= targetSamples) break; + } + } + catch (OperationCanceledException ex) when (!ct.IsCancellationRequested && !actionInvoked) + { + string message = + $"PCIe8586 did not provide enough pre-trigger samples within {preTriggerTimeout.TotalMilliseconds:F0}ms; control action was not executed. " + + $"sampleRate={config.SampleRateHz:F0}Hz, channels={config.ChannelCount}, " + + $"preTrigger={request.PreTriggerMs:F1}ms, postTrigger={request.PostTriggerMs:F1}ms, " + + $"samples={collected[0].Count}/{preSamples}."; + _logger.LogWarning(message); + throw new InvalidOperationException(message, ex); + } + finally + { + await _digitizer.StopAsync(); + } + + if (!actionInvoked) + throw new InvalidOperationException( + $"PCIe8586 acquisition ended before enough pre-trigger samples were collected; control action was not executed. " + + $"sampleRate={config.SampleRateHz:F0}Hz, channels={config.ChannelCount}, " + + $"preTrigger={request.PreTriggerMs:F1}ms, postTrigger={request.PostTriggerMs:F1}ms, " + + $"samples={collected[0].Count}/{preSamples}."); + if (collected[0].Count < targetSamples) + throw new InvalidOperationException("PCIe8586 采集提前结束,后置波形不完整。"); + + return BuildCurve(collected.Select(x => x.ToArray()).ToArray(), config.SampleRateHz, triggerIndex); + } + finally + { + _operationLock.Release(); + } + } + + public async Task CaptureAsync( + int[] channels, int sampleRateHz, double durationSec, CancellationToken ct = default) + { + double preMs = Math.Max(1, durationSec * 1_000 * 0.2); + double postMs = Math.Max(1, durationSec * 1_000 - preMs); + return await CaptureAroundActionAsync( + new DaqActionCaptureRequest(preMs, postMs, true), _ => Task.CompletedTask, ct); + } + + public async Task ReadInstantAsync(int[] channels, CancellationToken ct = default) + { + var curve = await CaptureAroundActionAsync( + new DaqActionCaptureRequest(1, 2, true), _ => Task.CompletedTask, ct); + return channels.Select(channel => + { + var data = curve.EngineeringChannels.SingleOrDefault(x => x.PhysicalChannel == channel); + return data?.Samples.Average() ?? double.NaN; + }).ToArray(); + } + + public void ValidateOptions(bool requireOutputVoltage) + { + if (_options.ChannelCount is not (1 or 2 or 4 or 8)) + throw new InvalidOperationException("PCIe8586 启用通道数只能为 1、2、4 或 8。"); + if (_options.ClockDivider < 1) + throw new InvalidOperationException("PCIe8586 时钟分频必须大于 0。"); + if (_options.PreTriggerMs <= 0 || _options.PostTriggerMs <= 0) + throw new InvalidOperationException("前置和后置采集窗口必须大于 0。"); + + var enabled = _options.Channels.Where(x => x.PhysicalChannel < _options.ChannelCount).ToArray(); + foreach (var channel in enabled.Where(x => ParseRole(x.Role) != DaqChannelRole.Unconfigured)) + { + if (!channel.IsCalibrated) + throw new InvalidOperationException($"PCIe8586 CH{channel.PhysicalChannel}({channel.Name})尚未标定。"); + if (!double.IsFinite(channel.Scale) || channel.Scale == 0 || !double.IsFinite(channel.Offset)) + throw new InvalidOperationException($"PCIe8586 CH{channel.PhysicalChannel} 标定比例或偏置无效。"); + } + + if (requireOutputVoltage && + enabled.Count(x => ParseRole(x.Role) == DaqChannelRole.OutputVoltage && x.IsCalibrated) != 1) + throw new InvalidOperationException("曲线测试必须配置且只能配置一个已标定的“输出电压”通道。"); + } + + private async Task ConnectWithoutLockAsync(CancellationToken ct) + { + var devices = await EnumerateDevicesAsync(ct); + var selected = devices.SingleOrDefault(x => x.LogicalId == _options.LogicalDeviceId) + ?? throw new InvalidOperationException($"未发现逻辑 ID {_options.LogicalDeviceId} 的 PCIe8586。"); + await _digitizer.OpenAsync( + new DeviceInfo(selected.LogicalId, selected.PhysicalId, selected.Description, selected.IsSimulated), ct); + _connected = true; + ConnectionChanged?.Invoke(this, true); + } + + private AcquisitionConfig CreateDriverConfig() => new( + _options.ChannelCount, + string.Equals(_options.InputRange, "PlusMinus1V", StringComparison.OrdinalIgnoreCase) + ? DriverInputRange.PlusMinus1V + : DriverInputRange.PlusMinus5V, + _options.ClockDivider, + AcquisitionMode.Continuous, + 10_000); + + private CurveData BuildCurve(double[][] cardVolts, double sampleRateHz, int triggerIndex) + { + var engineering = new List(); + for (int channel = 0; channel < cardVolts.Length; channel++) + { + var cfg = _options.Channels.FirstOrDefault(x => x.PhysicalChannel == channel) + ?? new DaqChannelOptions { PhysicalChannel = channel, Name = $"CH{channel}" }; + var role = ParseRole(cfg.Role); + var values = cardVolts[channel].Select(x => x * cfg.Scale + cfg.Offset).ToArray(); + engineering.Add(new CurveChannelData( + channel, role, cfg.Name, UnitFor(role), cfg.Scale, cfg.Offset, values)); + } + + var voltage = engineering.Single(x => x.Role == DaqChannelRole.OutputVoltage).Samples; + var current = engineering.SingleOrDefault(x => x.Role == DaqChannelRole.OutputCurrent)?.Samples; + if (voltage.Length > 0) + { + int sample = Math.Clamp(triggerIndex, 0, voltage.Length - 1); + SampleReceived?.Invoke(this, new CurveSample( + sample / sampleRateHz, + voltage[sample], + current is { Length: > 0 } ? current[Math.Min(sample, current.Length - 1)] : 0)); + } + return new CurveData + { + SampleRateHz = (int)Math.Round(sampleRateHz), + TriggerSampleIndex = triggerIndex, + TriggerTimeSec = triggerIndex / sampleRateHz, + Voltage = voltage, + Current = current, + EngineeringChannels = engineering + }; + } + + internal static DaqChannelRole ParseRole(string? role) => + Enum.TryParse(role, true, out var value) ? value : DaqChannelRole.Unconfigured; + + internal static string UnitFor(DaqChannelRole role) => role switch + { + DaqChannelRole.OutputVoltage or DaqChannelRole.InputVoltage => "V", + DaqChannelRole.OutputCurrent or DaqChannelRole.InputCurrent => "A", + _ => "V" + }; + + public void Dispose() + { + try { DisconnectAsync().GetAwaiter().GetResult(); } catch { } + _digitizer.Dispose(); + _operationLock.Dispose(); + } +} diff --git a/SSPCTester.Devices/Drivers/Real/RealDrivers.cs b/SSPCTester.Devices/Drivers/Real/RealDrivers.cs new file mode 100644 index 0000000..0c9e148 --- /dev/null +++ b/SSPCTester.Devices/Drivers/Real/RealDrivers.cs @@ -0,0 +1,35 @@ +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Drivers.Real; + +/// 真实电源 UDP5080 驱动占位。 +public sealed class Udp5080Placeholder : IPowerSupply +{ + public bool IsConnected => false; + public string DisplayName => "电源 UDP5080"; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => throw new NotImplementedException("Real 驱动待硬件到货后实现。"); + public Task DisconnectAsync() => throw new NotImplementedException(); + public Task SetVoltageAsync(double volts, CancellationToken ct = default) => throw new NotImplementedException(); + public Task SetCurrentLimitAsync(double amps, CancellationToken ct = default) => throw new NotImplementedException(); + public Task OutputAsync(bool on, CancellationToken ct = default) => throw new NotImplementedException(); + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) => throw new NotImplementedException(); + public Task QueryIdentityAsync(CancellationToken ct = default) => throw new NotImplementedException(); + private void Raise(bool s) => ConnectionChanged?.Invoke(this, s); +} + +/// 真实负载 IT8733P/IT8702P 驱动占位。 +internal sealed class It87xxLoadPlaceholder +{ + public bool IsConnected => false; + public string DisplayName => "负载:IT8702P+IT8733P"; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => throw new NotImplementedException("Real 驱动待硬件到货后实现。"); + public Task DisconnectAsync() => throw new NotImplementedException(); + public Task SetModeAsync(LoadMode mode, CancellationToken ct = default) => throw new NotImplementedException(); + public Task SetValueAsync(double value, CancellationToken ct = default) => throw new NotImplementedException(); + public Task InputAsync(bool on, CancellationToken ct = default) => throw new NotImplementedException(); + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) => throw new NotImplementedException(); + private void Raise(bool s) => ConnectionChanged?.Invoke(this, s); +} + diff --git a/SSPCTester.Devices/Drivers/Real/SspcModbus.cs b/SSPCTester.Devices/Drivers/Real/SspcModbus.cs new file mode 100644 index 0000000..e8d7752 --- /dev/null +++ b/SSPCTester.Devices/Drivers/Real/SspcModbus.cs @@ -0,0 +1,246 @@ +using System.Diagnostics; +using System.IO.Ports; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Devices.Protocol; + +namespace SSPCTester.Devices.Drivers.Real; + +/// 按实测 Profile 实现的 24 路 Modbus-RTU SSPC 驱动。 +public sealed class SspcModbus : ISspc, IDisposable +{ + private readonly DeviceOptions _rootOptions; + private readonly ILogger _logger; + private readonly SemaphoreSlim _busLock = new(1, 1); + private readonly bool[] _states = new bool[24]; + private SerialPort? _port; + private ModbusDeviceProfile? _profile; + + public SspcModbus(IOptions options, ILogger logger) + { + _rootOptions = options.Value; + _logger = logger; + } + + public int ChannelCount => 24; + public bool IsConnected => _port?.IsOpen == true; + public string DisplayName => "SSPC (Modbus-RTU)"; + public event EventHandler? ConnectionChanged; + + public Task ConnectAsync(CancellationToken ct = default) + { + ct.ThrowIfCancellationRequested(); + if (IsConnected) return Task.FromResult(true); + + var options = _rootOptions.Sspc; + _profile = ModbusDeviceProfileLoader.Load(options.DeviceProfilePath); + var defaults = _profile.SerialDefaults; + _port = new SerialPort( + options.PortName, + options.BaudRate > 0 ? options.BaudRate : defaults.BaudRate, + ParseParity(options.Parity), + options.DataBits > 0 ? options.DataBits : defaults.DataBits, + ParseStopBits(options.StopBits)) + { + ReadTimeout = options.ReadTimeoutMs > 0 ? options.ReadTimeoutMs : defaults.ReadTimeoutMs, + WriteTimeout = options.ReadTimeoutMs > 0 ? options.ReadTimeoutMs : defaults.ReadTimeoutMs, + Handshake = Handshake.None + }; + _port.Open(); + _logger.LogInformation("Modbus 已连接:{Port} {BaudRate}bps", _port.PortName, _port.BaudRate); + ConnectionChanged?.Invoke(this, true); + return Task.FromResult(true); + } + + public async Task DisconnectAsync() + { + if (!IsConnected) return; + if (_rootOptions.Sspc.CloseAllRelaysOnDisconnect) + { + for (int slot = 1; slot <= ChannelCount; slot++) + { + try { await TurnOffAsync(slot).ConfigureAwait(false); } + catch (Exception ex) { _logger.LogWarning(ex, "断开前关闭 CH{Slot} 失败。", slot); } + } + } + _port?.Close(); + _port?.Dispose(); + _port = null; + ConnectionChanged?.Invoke(this, false); + _logger.LogInformation("Modbus 已断开。"); + } + + public Task TurnOnAsync(int physicalSlot, CancellationToken ct = default) => + SetRelayAsync(physicalSlot, true, ct); + + public Task TurnOffAsync(int physicalSlot, CancellationToken ct = default) => + SetRelayAsync(physicalSlot, false, ct); + + public async Task FlashAsync(int physicalSlot, int milliseconds, CancellationToken ct = default) + { + await TurnOnAsync(physicalSlot, ct).ConfigureAwait(false); + try { await Task.Delay(milliseconds, ct).ConfigureAwait(false); } + finally { await TurnOffAsync(physicalSlot, CancellationToken.None).ConfigureAwait(false); } + } + + public Task GetChannelStateAsync(int physicalSlot, CancellationToken ct = default) + { + ValidateSlot(physicalSlot); + return Task.FromResult(_states[physicalSlot - 1]); + } + + public async Task ReadMeasurementAsync(int physicalSlot, CancellationToken ct = default) + { + ValidateSlot(physicalSlot); + var all = await ReadMeasurementsAsync(ct).ConfigureAwait(false); + return all[physicalSlot - 1]; + } + + public async Task> ReadMeasurementsAsync(CancellationToken ct = default) + { + EnsureConnected(); + var profile = _profile!; + var voltageFrame = await ReadRegistersAsync(profile.Voltage, ct).ConfigureAwait(false); + var currentFrame = await ReadRegistersAsync(profile.Current, ct).ConfigureAwait(false); + var timestamp = DateTimeOffset.Now; + + return profile.Channels.OrderBy(x => x.PhysicalSlot).Select(mapping => + { + ushort vRaw = ReadUInt16(voltageFrame, profile.Voltage, mapping.Voltage.RegisterOffset); + ushort currentBits = ReadUInt16(currentFrame, profile.Current, mapping.Current.RegisterOffset); + short iRaw = unchecked((short)currentBits); + return new ChannelMeasurement + { + PhysicalSlot = mapping.PhysicalSlot, + VoltageRaw = vRaw, + CurrentRaw = iRaw, + Voltage = ModbusValueConverter.ConvertRaw( + vRaw, profile.Voltage.Signed, profile.Voltage.Formula, profile.Voltage.Range), + Current = Math.Abs(ModbusValueConverter.ConvertRaw( + currentBits, profile.Current.Signed, profile.Current.Formula, profile.Current.Range)), + Timestamp = timestamp + }; + }).ToArray(); + } + + private async Task SetRelayAsync(int physicalSlot, bool isOn, CancellationToken ct) + { + ValidateSlot(physicalSlot); + EnsureConnected(); + var mapping = _profile!.Channels.Single(x => x.PhysicalSlot == physicalSlot); + ushort value = isOn ? _profile.Relay.OnValueNumber : _profile.Relay.OffValueNumber; + byte[] request = ModbusRtuProtocol.BuildRequest( + mapping.Relay.Slave, _profile.Relay.FunctionCodeWrite, mapping.Relay.Coil, value); + byte[] response = await TransactAsync(request, 8, ct).ConfigureAwait(false); + if (_profile.Relay.VerifyEchoResponse && !response.SequenceEqual(request)) + throw new InvalidDataException($"继电器 CH{physicalSlot} 回显与请求不一致。"); + _states[physicalSlot - 1] = isOn; + } + + private async Task ReadRegistersAsync(MeasurementProtocol protocol, CancellationToken ct) + { + byte[] request = ModbusRtuProtocol.BuildRequest( + protocol.Slave, protocol.FunctionCodeRead, protocol.StartRegister, protocol.RegisterCount); + int expectedLength = 3 + protocol.RegisterCount * 2 + 2; + byte[] response = await TransactAsync(request, expectedLength, ct).ConfigureAwait(false); + if (response[0] != protocol.Slave) throw new InvalidDataException("Modbus 响应从站地址错误。"); + if (response[1] != protocol.FunctionCodeRead) throw new InvalidDataException("Modbus 响应功能码错误。"); + if (response[2] != protocol.RegisterCount * 2) throw new InvalidDataException("Modbus 响应字节数错误。"); + return response; + } + + private async Task TransactAsync(byte[] request, int expectedLength, CancellationToken ct) + { + await _busLock.WaitAsync(ct).ConfigureAwait(false); + try + { + int retry = Math.Max(0, _rootOptions.Sspc.Retry); + Exception? last = null; + for (int attempt = 0; attempt <= retry; attempt++) + { + ct.ThrowIfCancellationRequested(); + try + { + var sw = Stopwatch.StartNew(); + _port!.DiscardInBuffer(); + _port.Write(request, 0, request.Length); + byte[] response = ReadResponse(expectedLength, ct); + ModbusRtuProtocol.ValidateCrc(response); + if (response[0] != request[0]) throw new InvalidDataException("Modbus 响应从站与请求不一致。"); + if ((response[1] & 0x80) != 0) + throw new InvalidDataException($"Modbus 异常响应,异常码 0x{response[2]:X2}。"); + LogFrame(request, response, sw.ElapsedMilliseconds, null); + return response; + } + catch (Exception ex) when (ex is TimeoutException or InvalidDataException or IOException) + { + last = ex; + LogFrame(request, null, 0, ex); + try { _port?.DiscardInBuffer(); } catch { } + } + } + throw new IOException($"Modbus 请求失败,已尝试 {retry + 1} 次。", last); + } + finally { _busLock.Release(); } + } + + private byte[] ReadResponse(int normalLength, CancellationToken ct) + { + var bytes = new List(normalLength); + while (bytes.Count < 3) + { + ct.ThrowIfCancellationRequested(); + bytes.Add((byte)_port!.ReadByte()); + } + int length = (bytes[1] & 0x80) != 0 ? 5 : normalLength; + while (bytes.Count < length) + { + ct.ThrowIfCancellationRequested(); + bytes.Add((byte)_port!.ReadByte()); + } + return bytes.ToArray(); + } + + private void LogFrame(byte[] request, byte[]? response, long elapsedMs, Exception? error) + { + if (!_rootOptions.Sspc.LogRawFrames && error == null) return; + string tx = Convert.ToHexString(request); + string rx = response == null ? "-" : Convert.ToHexString(response); + if (error == null) + _logger.LogInformation("Modbus TX={Tx} RX={Rx} {Elapsed}ms", tx, rx, elapsedMs); + else + _logger.LogWarning(error, "Modbus TX={Tx} RX={Rx} 失败", tx, rx); + } + + private static ushort ReadUInt16(byte[] frame, MeasurementProtocol p, int registerOffset) + { + int position = p.DataStartOffset + registerOffset * p.ChannelBytes; + if (position + 1 >= frame.Length - 2) throw new InvalidDataException("寄存器映射超出响应数据区。"); + return (ushort)((frame[position] << 8) | frame[position + 1]); + } + + private void EnsureConnected() + { + if (!IsConnected || _profile == null) throw new InvalidOperationException("Modbus 尚未连接。"); + } + + private static void ValidateSlot(int slot) + { + if (slot is < 1 or > 24) + throw new ArgumentOutOfRangeException(nameof(slot), slot, "物理通道范围必须为 1~24。"); + } + + private static Parity ParseParity(string value) => + Enum.TryParse(value, true, out var result) ? result : Parity.None; + + private static StopBits ParseStopBits(string value) => + Enum.TryParse(value, true, out var result) ? result : StopBits.One; + + public void Dispose() + { + try { _port?.Dispose(); } catch { } + _busLock.Dispose(); + } +} diff --git a/SSPCTester.Devices/Drivers/Real/Udp5080.cs b/SSPCTester.Devices/Drivers/Real/Udp5080.cs new file mode 100644 index 0000000..145d64b --- /dev/null +++ b/SSPCTester.Devices/Drivers/Real/Udp5080.cs @@ -0,0 +1,212 @@ +using System.Globalization; +using System.IO; +using System.Net; +using System.Net.NetworkInformation; +using System.Net.Sockets; +using System.Text; +using System.Text.RegularExpressions; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Devices.Drivers.Real; + +/// Real UDP5080-100 power supply driver over SCPI TCP socket. +public sealed class Udp5080 : IPowerSupply +{ + private const int MaxResponseBytes = 1024 * 1024; + private readonly PowerSupplyOptions _options; + private readonly ILogger _logger; + private readonly SemaphoreSlim _gate = new(1, 1); + private TcpClient? _client; + private NetworkStream? _stream; + private bool _isConnected; + + public Udp5080(IOptions options, ILogger logger) + { + _options = options.Value.PowerSupply; + _logger = logger; + } + + public bool IsConnected => _isConnected && _client?.Connected == true && _stream is not null; + public string DisplayName => "电源 UDP5080"; + public event EventHandler? ConnectionChanged; + + public async Task ConnectAsync(CancellationToken ct = default) + { + await DisconnectAsync().ConfigureAwait(false); + + var client = new TcpClient { NoDelay = true }; + try + { + using var cts = CancellationTokenSource.CreateLinkedTokenSource(ct); + cts.CancelAfter(Timeout); + await EnsureHostReachableAsync(cts.Token).ConfigureAwait(false); + await client.ConnectAsync(_options.Host, _options.Port, cts.Token).ConfigureAwait(false); + _client = client; + _stream = client.GetStream(); + + string idn = await QueryRawAsync(_stream, _options.IdnCommand, ct).ConfigureAwait(false); + if (!idn.Contains("UDP5080", StringComparison.OrdinalIgnoreCase)) + throw new InvalidOperationException($"Unexpected UDP5080 identity: {idn}"); + + SetConnected(true); + _logger.LogInformation("UDP5080 connected to {Host}:{Port}. Identity: {Identity}", _options.Host, _options.Port, idn); + return true; + } + catch (Exception ex) when (ex is SocketException or IOException or OperationCanceledException or InvalidOperationException) + { + _stream = null; + _client = null; + client.Dispose(); + SetConnected(false); + throw new InvalidOperationException($"UDP5080 连接失败:{_options.Host}:{_options.Port},{ex.Message}", ex); + } + } + + public Task DisconnectAsync() + { + _stream?.Dispose(); + _client?.Dispose(); + _stream = null; + _client = null; + SetConnected(false); + return Task.CompletedTask; + } + + public Task SetVoltageAsync(double volts, CancellationToken ct = default) => + throw new NotSupportedException("UDP5080 当前仅接入实时测量,未启用未验证的电压设置 SCPI 命令。"); + + public Task SetCurrentLimitAsync(double amps, CancellationToken ct = default) => + throw new NotSupportedException("UDP5080 当前仅接入实时测量,未启用未验证的电流限制 SCPI 命令。"); + + public Task OutputAsync(bool on, CancellationToken ct = default) => + throw new NotSupportedException("UDP5080 当前仅接入实时测量,未启用未验证的输出开关 SCPI 命令。"); + + public async Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) + { + try + { + double volts = ParseNumber(await QueryAsync(_options.VoltageCommand, ct).ConfigureAwait(false)); + double amps = ParseNumber(await QueryAsync(_options.CurrentCommand, ct).ConfigureAwait(false)); + return (volts, amps); + } + catch (FormatException ex) + { + SetConnected(false); + throw new InvalidOperationException($"UDP5080 response parse failed: {ex.Message}", ex); + } + } + + public Task QueryIdentityAsync(CancellationToken ct = default) => QueryAsync(_options.IdnCommand, ct); + + public async Task QueryAsync(string command, CancellationToken ct = default) + { + await _gate.WaitAsync(ct).ConfigureAwait(false); + try + { + var stream = RequireStream(); + return await QueryRawAsync(stream, command, ct).ConfigureAwait(false); + } + catch (Exception ex) when (ex is SocketException or IOException or OperationCanceledException) + { + SetConnected(false); + throw new InvalidOperationException($"UDP5080 查询失败:{command},{ex.Message}", ex); + } + finally + { + _gate.Release(); + } + } + + public static double ParseNumber(string response) + { + var match = Regex.Match( + response.Trim(), + @"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?"); + if (!match.Success) + throw new FormatException($"UDP5080 响应中没有数值:{response}"); + + var value = double.Parse(match.Value, CultureInfo.InvariantCulture); + if (!double.IsFinite(value)) + throw new FormatException($"UDP5080 响应数值无效:{response}"); + return value; + } + + private TimeSpan Timeout => TimeSpan.FromSeconds(_options.TimeoutSeconds > 0 ? _options.TimeoutSeconds : 2); + private string Terminator => string.IsNullOrEmpty(_options.Terminator) ? "\n" : _options.Terminator; + + private async Task EnsureHostReachableAsync(CancellationToken ct) + { + if (!_options.RequirePingBeforeConnect || IsLoopbackHost(_options.Host)) + return; + + int timeoutMs = Math.Clamp((int)Math.Round(Timeout.TotalMilliseconds), 500, 10_000); + try + { + using var ping = new Ping(); + var reply = await ping.SendPingAsync(_options.Host, timeoutMs).WaitAsync(ct).ConfigureAwait(false); + if (reply.Status != IPStatus.Success) + throw new IOException($"UDP5080 host ping failed: {_options.Host}, status={reply.Status}"); + } + catch (PingException ex) + { + throw new IOException($"UDP5080 host ping failed: {_options.Host}, {ex.Message}", ex); + } + catch (TimeoutException ex) + { + throw new IOException($"UDP5080 host ping timed out: {_options.Host}", ex); + } + } + + private static bool IsLoopbackHost(string host) + { + if (string.Equals(host, "localhost", StringComparison.OrdinalIgnoreCase)) + return true; + return IPAddress.TryParse(host, out var address) && IPAddress.IsLoopback(address); + } + + private async Task QueryRawAsync(NetworkStream stream, string command, CancellationToken ct) + { + using var cts = CancellationTokenSource.CreateLinkedTokenSource(ct); + cts.CancelAfter(Timeout); + + var payload = Encoding.ASCII.GetBytes(command.TrimEnd('\r', '\n') + Terminator); + await stream.WriteAsync(payload, cts.Token).ConfigureAwait(false); + await stream.FlushAsync(cts.Token).ConfigureAwait(false); + + var buffer = new byte[4096]; + using var memory = new MemoryStream(); + while (memory.Length < MaxResponseBytes) + { + int read = await stream.ReadAsync(buffer, cts.Token).ConfigureAwait(false); + if (read <= 0) + throw new IOException("Device closed the connection."); + + int newline = Array.IndexOf(buffer, (byte)'\n', 0, read); + memory.Write(buffer, 0, newline >= 0 ? newline : read); + if (newline >= 0) + break; + } + + if (memory.Length >= MaxResponseBytes) + throw new IOException("Device response exceeded 1 MB."); + + return Encoding.ASCII.GetString(memory.ToArray()).Trim(); + } + + private NetworkStream RequireStream() + { + if (!IsConnected || _stream is null) + throw new InvalidOperationException("UDP5080 尚未连接。"); + return _stream; + } + + private void SetConnected(bool connected) + { + if (_isConnected == connected) return; + _isConnected = connected; + ConnectionChanged?.Invoke(this, connected); + } +} diff --git a/SSPCTester.Devices/Interfaces/ChannelMeasurement.cs b/SSPCTester.Devices/Interfaces/ChannelMeasurement.cs new file mode 100644 index 0000000..8aefe5c --- /dev/null +++ b/SSPCTester.Devices/Interfaces/ChannelMeasurement.cs @@ -0,0 +1,14 @@ +namespace SSPCTester.Devices.Interfaces; + +/// 一个物理插位的 Modbus 电压、电流测量结果。 +public sealed record ChannelMeasurement +{ + public int PhysicalSlot { get; init; } + public double Voltage { get; init; } + public double Current { get; init; } + public ushort VoltageRaw { get; init; } + public short CurrentRaw { get; init; } + public DateTimeOffset Timestamp { get; init; } + public string VoltageQuality { get; init; } = "Good"; + public string CurrentQuality { get; init; } = "Good"; +} diff --git a/SSPCTester.Devices/Interfaces/CurveData.cs b/SSPCTester.Devices/Interfaces/CurveData.cs new file mode 100644 index 0000000..25ef28e --- /dev/null +++ b/SSPCTester.Devices/Interfaces/CurveData.cs @@ -0,0 +1,68 @@ +namespace SSPCTester.Devices.Interfaces; + +/// +/// 一段高速采集得到的电压波形。 +/// +public sealed class CurveData +{ + /// 采样率(Hz)。 + public int SampleRateHz { get; init; } + + /// 触发时刻(相对于采样起点,单位:秒)。 + public double TriggerTimeSec { get; init; } + public int TriggerSampleIndex { get; init; } + + /// 电压样点数组(V)。索引 i 对应时间 i / SampleRateHz。 + public required double[] Voltage { get; init; } + + /// 电流样点数组(A),可选。 + public double[]? Current { get; init; } + public IReadOnlyList EngineeringChannels { get; init; } = Array.Empty(); + + /// 样点数。 + public int Length => Voltage.Length; + + /// 总时长(s)。 + public double DurationSec => SampleRateHz > 0 ? (double)Voltage.Length / SampleRateHz : 0; + + /// 给定索引对应的时间(s)。 + public double TimeAt(int index) => SampleRateHz > 0 ? (double)index / SampleRateHz : 0; +} + +public sealed record CurveChannelData( + int PhysicalChannel, + DaqChannelRole Role, + string Name, + string Unit, + double Scale, + double Offset, + double[] Samples); + +public enum DaqChannelRole +{ + Unconfigured, + OutputVoltage, + OutputCurrent, + InputVoltage, + InputCurrent, + Auxiliary +} + +public sealed record DaqDeviceDescriptor( + int LogicalId, + int? PhysicalId, + string Description, + bool IsSimulated) +{ + public override string ToString() => + PhysicalId.HasValue + ? $"{Description}(逻辑 {LogicalId} / 物理 {PhysicalId})" + : $"{Description}(逻辑 {LogicalId})"; +} + +public sealed record DaqActionCaptureRequest(double PreTriggerMs, double PostTriggerMs, bool IsRising); + +/// +/// 单个采样点(流式推送时使用)。 +/// +public readonly record struct CurveSample(double TimeSec, double Voltage, double Current); diff --git a/SSPCTester.Devices/Interfaces/IDaq.cs b/SSPCTester.Devices/Interfaces/IDaq.cs new file mode 100644 index 0000000..54381bd --- /dev/null +++ b/SSPCTester.Devices/Interfaces/IDaq.cs @@ -0,0 +1,35 @@ +namespace SSPCTester.Devices.Interfaces; + +/// +/// 高速数据采集卡(PCIe8586)抽象接口。 +/// +public interface IDaq : IDeviceConnection +{ + Task> EnumerateDevicesAsync(CancellationToken ct = default); + + /// + /// 高速采集一段波形。 + /// + /// 采集通道索引数组。 + /// 采样率(Hz)。 + /// 总时长(秒)。 + Task CaptureAsync( + int[] channels, + int sampleRateHz, + double durationSec, + CancellationToken ct = default); + + /// + /// 读取瞬时值(功率损耗页/基础测试页用)。 + /// 返回数组与传入 channels 一一对应。 + /// + Task ReadInstantAsync(int[] channels, CancellationToken ct = default); + + Task CaptureAroundActionAsync( + DaqActionCaptureRequest request, + Func action, + CancellationToken ct = default); + + /// 流式采集事件(可选实现)。 + event EventHandler? SampleReceived; +} diff --git a/SSPCTester.Devices/Interfaces/IDeviceConnection.cs b/SSPCTester.Devices/Interfaces/IDeviceConnection.cs new file mode 100644 index 0000000..cda1b2c --- /dev/null +++ b/SSPCTester.Devices/Interfaces/IDeviceConnection.cs @@ -0,0 +1,22 @@ +namespace SSPCTester.Devices.Interfaces; + +/// +/// 所有设备的公共连接接口。 +/// +public interface IDeviceConnection +{ + /// 当前是否处于已连接状态。 + bool IsConnected { get; } + + /// 设备的人类可读名称(用于 UI 显示与日志)。 + string DisplayName { get; } + + /// 建立连接,返回是否成功。 + Task ConnectAsync(CancellationToken ct = default); + + /// 断开连接。 + Task DisconnectAsync(); + + /// 连接状态变化事件。bool 参数为新的 IsConnected。 + event EventHandler? ConnectionChanged; +} diff --git a/SSPCTester.Devices/Interfaces/ILoad.cs b/SSPCTester.Devices/Interfaces/ILoad.cs new file mode 100644 index 0000000..569ad42 --- /dev/null +++ b/SSPCTester.Devices/Interfaces/ILoad.cs @@ -0,0 +1,40 @@ +namespace SSPCTester.Devices.Interfaces; + +/// +/// 可编程负载(IT8733P / IT8702P)的工作模式。 +/// +public enum LoadMode +{ + /// 恒流。 + CC, + /// 恒压。 + CV, + /// 恒阻。 + CR, + /// 恒功率。 + CP +} + +public readonly record struct PowerReading(double Volts, double Amps, double Watts); + +/// +/// 可编程负载抽象接口。 +/// +public interface ILoad : IDeviceConnection +{ + /// 切换工作模式。 + Task SetModeAsync(LoadMode mode, CancellationToken ct = default); + + /// 设定目标值(含义取决于当前模式:A / V / Ω / W)。 + Task SetValueAsync(double value, CancellationToken ct = default); + + /// 开启 / 关闭负载输入。 + Task InputAsync(bool on, CancellationToken ct = default); + + /// 读取实际电压、电流。 + Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default); + + Task ReadPowerAsync(CancellationToken ct = default); + + Task QueryIdentityAsync(CancellationToken ct = default); +} diff --git a/SSPCTester.Devices/Interfaces/IPowerSupply.cs b/SSPCTester.Devices/Interfaces/IPowerSupply.cs new file mode 100644 index 0000000..378f2d4 --- /dev/null +++ b/SSPCTester.Devices/Interfaces/IPowerSupply.cs @@ -0,0 +1,22 @@ +namespace SSPCTester.Devices.Interfaces; + +/// +/// 程控电源(UDP5080-100)抽象接口。 +/// +public interface IPowerSupply : IDeviceConnection +{ + /// 设定输出电压(V)。 + Task SetVoltageAsync(double volts, CancellationToken ct = default); + + /// 设定输出电流上限(A)。 + Task SetCurrentLimitAsync(double amps, CancellationToken ct = default); + + /// 开启 / 关闭输出。 + Task OutputAsync(bool on, CancellationToken ct = default); + + /// 读取当前实际电压、电流。 + Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default); + + /// Query instrument identity for connection diagnostics. + Task QueryIdentityAsync(CancellationToken ct = default); +} diff --git a/SSPCTester.Devices/Interfaces/ISspc.cs b/SSPCTester.Devices/Interfaces/ISspc.cs new file mode 100644 index 0000000..f898a39 --- /dev/null +++ b/SSPCTester.Devices/Interfaces/ISspc.cs @@ -0,0 +1,29 @@ +namespace SSPCTester.Devices.Interfaces; + +/// +/// 固态功率控制器(SSPC,被测设备)抽象接口。 +/// 提供 24 路开关控制。 +/// +public interface ISspc : IDeviceConnection +{ + /// 通道总数(本项目为 24)。 + int ChannelCount { get; } + + /// 导通指定物理插位(1~24)。 + Task TurnOnAsync(int physicalSlot, CancellationToken ct = default); + + /// 关断指定通道。 + Task TurnOffAsync(int physicalSlot, CancellationToken ct = default); + + /// 短暂导通(闪开),指定毫秒后自动关断。 + Task FlashAsync(int physicalSlot, int milliseconds, CancellationToken ct = default); + + /// 查询指定通道当前是否导通。 + Task GetChannelStateAsync(int physicalSlot, CancellationToken ct = default); + + /// 读取指定物理插位的电压和电流。 + Task ReadMeasurementAsync(int physicalSlot, CancellationToken ct = default); + + /// 整帧读取并返回物理插位 1~24 的电压和电流。 + Task> ReadMeasurementsAsync(CancellationToken ct = default); +} diff --git a/SSPCTester.Devices/Properties/AssemblyInfo.cs b/SSPCTester.Devices/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ca15cc1 --- /dev/null +++ b/SSPCTester.Devices/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("SSPCTester.Tests")] diff --git a/SSPCTester.Devices/Protocol/ModbusRtuProtocol.cs b/SSPCTester.Devices/Protocol/ModbusRtuProtocol.cs new file mode 100644 index 0000000..c6ad803 --- /dev/null +++ b/SSPCTester.Devices/Protocol/ModbusRtuProtocol.cs @@ -0,0 +1,54 @@ +namespace SSPCTester.Devices.Protocol; + +public static class ModbusRtuProtocol +{ + public static ushort ComputeCrc(ReadOnlySpan data) + { + ushort crc = 0xFFFF; + foreach (byte value in data) + { + crc ^= value; + for (int i = 0; i < 8; i++) + crc = (ushort)((crc & 1) != 0 ? (crc >> 1) ^ 0xA001 : crc >> 1); + } + return crc; + } + + public static byte[] BuildRequest(byte slave, byte function, ushort address, ushort valueOrCount) + { + var frame = new byte[8]; + frame[0] = slave; + frame[1] = function; + frame[2] = (byte)(address >> 8); + frame[3] = (byte)address; + frame[4] = (byte)(valueOrCount >> 8); + frame[5] = (byte)valueOrCount; + ushort crc = ComputeCrc(frame.AsSpan(0, 6)); + frame[6] = (byte)crc; + frame[7] = (byte)(crc >> 8); + return frame; + } + + public static void ValidateCrc(ReadOnlySpan frame) + { + if (frame.Length < 5) throw new InvalidDataException("Modbus 响应长度不足。"); + ushort expected = ComputeCrc(frame[..^2]); + ushort actual = (ushort)(frame[^2] | frame[^1] << 8); + if (expected != actual) + throw new InvalidDataException($"Modbus CRC 错误,期望 {expected:X4},实际 {actual:X4}。"); + } +} + +public static class ModbusValueConverter +{ + public static double ConvertRaw(ushort rawBits, bool signed, string formula, double range) + { + double raw = signed ? unchecked((short)rawBits) : rawBits; + return formula switch + { + "A" => raw / 10000.0 * range, + "B" => raw / range, + _ => throw new InvalidDataException($"不支持换算公式 {formula}") + }; + } +} diff --git a/SSPCTester.Devices/SSPCTester.Devices.csproj b/SSPCTester.Devices/SSPCTester.Devices.csproj new file mode 100644 index 0000000..b43a4cf --- /dev/null +++ b/SSPCTester.Devices/SSPCTester.Devices.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + x64 + x64 + enable + enable + + + + + + + + + + + + + + diff --git a/SSPCTester.Logic/Calculation/CurveMetrics.cs b/SSPCTester.Logic/Calculation/CurveMetrics.cs new file mode 100644 index 0000000..1b12112 --- /dev/null +++ b/SSPCTester.Logic/Calculation/CurveMetrics.cs @@ -0,0 +1,80 @@ +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Logic.Calculation; + +/// +/// 曲线指标计算(纯函数,可单测)。 +/// 覆盖开发文档 §6.4 中 1.1-1.6 指标。 +/// +public static class CurveMetrics +{ + /// 查找第一个达到 vTarget 的样点索引;找不到返回 -1。 + public static int FirstReachIndex(double[] v, double vTarget, bool rising = true, int startIndex = 0) + { + if (v == null || v.Length == 0) return -1; + if (startIndex < 0) startIndex = 0; + for (int i = startIndex; i < v.Length; i++) + { + if (rising ? v[i] >= vTarget : v[i] <= vTarget) return i; + } + return -1; + } + + /// + /// 开启时间(ms):控制信号发出(curve.TriggerTimeSec)到电压达到 Vmax 的 thresholdRatio。 + /// + public static double OnTimeMs(CurveData curve, double vMax, double thresholdRatio = 0.9) + { + int idx = FirstReachIndex(curve.Voltage, vMax * thresholdRatio, rising: true); + if (idx < 0) return double.NaN; + double t = curve.TimeAt(idx) - curve.TriggerTimeSec; + return t * 1000.0; + } + + /// + /// 关闭时间(ms):控制信号撤销到电压降到 Vmax 的 thresholdRatio(如 10%)。 + /// + public static double OffTimeMs(CurveData curve, double vMax, double thresholdRatio = 0.1) + { + int idx = FirstReachIndex(curve.Voltage, vMax * thresholdRatio, rising: false); + if (idx < 0) return double.NaN; + double t = curve.TimeAt(idx) - curve.TriggerTimeSec; + return t * 1000.0; + } + + /// + /// 上升时间(ms):电压从 Vmax * low 到 Vmax * high 的时间(默认 10% → 90%)。 + /// + public static double RiseTimeMs(CurveData curve, double vMax, double lowRatio = 0.1, double highRatio = 0.9) + { + int iLow = FirstReachIndex(curve.Voltage, vMax * lowRatio, rising: true); + if (iLow < 0) return double.NaN; + int iHigh = FirstReachIndex(curve.Voltage, vMax * highRatio, rising: true, startIndex: iLow); + if (iHigh < 0) return double.NaN; + return (curve.TimeAt(iHigh) - curve.TimeAt(iLow)) * 1000.0; + } + + /// + /// 下降时间(ms):电压从 Vmax * high 到 Vmax * low 的时间(默认 90% → 10%)。 + /// + public static double FallTimeMs(CurveData curve, double vMax, double highRatio = 0.9, double lowRatio = 0.1) + { + int iHigh = FirstReachIndex(curve.Voltage, vMax * highRatio, rising: false); + if (iHigh < 0) return double.NaN; + int iLow = FirstReachIndex(curve.Voltage, vMax * lowRatio, rising: false, startIndex: iHigh); + if (iLow < 0) return double.NaN; + return (curve.TimeAt(iLow) - curve.TimeAt(iHigh)) * 1000.0; + } + + /// 从波形最大值估算 Vmax(去掉前后噪声,取 95 百分位以上的均值)。 + public static double EstimateVMax(double[] v) + { + if (v == null || v.Length == 0) return 0; + var sorted = (double[])v.Clone(); + Array.Sort(sorted); + int from = (int)(sorted.Length * 0.95); + double sum = 0; int n = 0; + for (int i = from; i < sorted.Length; i++) { sum += sorted[i]; n++; } + return n > 0 ? sum / n : sorted[^1]; + } +} diff --git a/SSPCTester.Logic/Calculation/PowerLoss.cs b/SSPCTester.Logic/Calculation/PowerLoss.cs new file mode 100644 index 0000000..f132225 --- /dev/null +++ b/SSPCTester.Logic/Calculation/PowerLoss.cs @@ -0,0 +1,22 @@ +namespace SSPCTester.Logic.Calculation; + +/// +/// 功率损耗 / 效率计算(纯函数)。 +/// 覆盖开发文档 §6.5 中 1.7-1.10 指标。 +/// +public static class PowerLoss +{ + /// 电压降(V) = Vin - Vout。 + public static double VoltageDrop(double vIn, double vOut) => vIn - vOut; + + /// 功率损耗(W) = Pin - Pout。 + public static double LossWatts(double vIn, double iIn, double vOut, double iOut) + => vIn * iIn - vOut * iOut; + + /// 效率(百分比) = Pout / Pin × 100。 + public static double EfficiencyPct(double vIn, double iIn, double vOut, double iOut) + { + double pin = vIn * iIn; + return pin > 0 ? vOut * iOut / pin * 100.0 : 0; + } +} diff --git a/SSPCTester.Logic/Models/Enums.cs b/SSPCTester.Logic/Models/Enums.cs new file mode 100644 index 0000000..c33dbf8 --- /dev/null +++ b/SSPCTester.Logic/Models/Enums.cs @@ -0,0 +1,25 @@ +namespace SSPCTester.Logic.Models; + +/// 测试结果四态。 +public enum TestStatus +{ + /// 未测试。 + Untested = 0, + /// 测试中。 + Running = 1, + /// 合格。 + Pass = 2, + /// 不合格。 + Fail = 3, + /// 已完成测量,但无性能合格判据。 + Measured = 4 +} + +/// 应用状态:浏览 / 测试。 +public enum AppState +{ + /// 浏览态:左侧树显示全部项目。 + Browsing, + /// 测试态:左侧树只显示当前项目,设备被独占。 + Testing +} diff --git a/SSPCTester.Logic/Models/Project.cs b/SSPCTester.Logic/Models/Project.cs new file mode 100644 index 0000000..baf4368 --- /dev/null +++ b/SSPCTester.Logic/Models/Project.cs @@ -0,0 +1,66 @@ +namespace SSPCTester.Logic.Models; + +using System.Collections.ObjectModel; + +/// 被测件 / 测试信息。 +public sealed class DutInfo +{ + public string ProductName { get; set; } = ""; + public string Model { get; set; } = ""; + public string SerialNumber { get; set; } = ""; + public string Manufacturer { get; set; } = ""; +} + +public sealed class TestSiteInfo +{ + public string Tester { get; set; } = ""; + public DateTime TestDate { get; set; } = DateTime.Today; + public double TemperatureC { get; set; } = 25.0; + public double HumidityPct { get; set; } = 60.0; + public double PressureKpa { get; set; } = 101.3; + public string Remark { get; set; } = ""; +} + +/// 一个测试项目:信息 + 选择 + 各模块结果。 +public sealed class Project +{ + public string Name { get; set; } = "新项目"; + public DateTime CreatedAt { get; set; } = DateTime.Now; + public DateTime LastTestedAt { get; set; } + + public DutInfo Dut { get; set; } = new(); + public TestSiteInfo Site { get; set; } = new(); + public TestSelection Selection { get; set; } = new(); + public ReportSelection Report { get; set; } = new(); + public TestFunctionNotes TestFunction { get; set; } = new(); + public CurveThresholds CurveThresholds { get; set; } = new(); + + public ObservableCollection BasicResults { get; set; } = new(); + public ObservableCollection CurveResults { get; set; } = new(); + public ObservableCollection PowerResults { get; set; } = new(); + public ObservableCollection ProtectResults { get; set; } = new(); + + /// 项目根目录(含 project.json、curves/、report.pdf)。运行时填充,不持久化。 + [System.Text.Json.Serialization.JsonIgnore] + public string FolderPath { get; set; } = ""; + + /// 综合判定(取所有结果中最差状态)。 + public TestStatus OverallStatus + { + get + { + var all = BasicResults.Select(r => r.Status) + .Concat(CurveResults.Select(r => r.Status)) + .Concat(PowerResults.Select(r => r.Status)) + .Concat(ProtectResults.Select(r => r.Status)) + .ToList(); + if (all.Count == 0) return TestStatus.Untested; + if (all.Any(s => s == TestStatus.Fail)) return TestStatus.Fail; + if (all.Any(s => s == TestStatus.Running)) return TestStatus.Running; + if (all.All(s => s == TestStatus.Pass)) return TestStatus.Pass; + if (all.All(s => s is TestStatus.Pass or TestStatus.Measured) && + all.Any(s => s == TestStatus.Measured)) return TestStatus.Measured; + return TestStatus.Untested; + } + } +} diff --git a/SSPCTester.Logic/Models/Results.cs b/SSPCTester.Logic/Models/Results.cs new file mode 100644 index 0000000..342c7e7 --- /dev/null +++ b/SSPCTester.Logic/Models/Results.cs @@ -0,0 +1,100 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace SSPCTester.Logic.Models; + +/// 基础测试单通道结果。 +public partial class ChannelResult : ObservableObject +{ + [ObservableProperty] private int _channel; + [ObservableProperty] private double _voltageOn; + [ObservableProperty] private double _currentOn; + [ObservableProperty] private double _voltageOff; + [ObservableProperty] private TestStatus _status = TestStatus.Untested; +} + +/// 曲线测试单通道结果(覆盖指标 1.1-1.6)。 +public partial class CurveResultRow : ObservableObject +{ + [ObservableProperty] private int _channel; + /// 开启时间(ms)。 + [ObservableProperty] private double _onTimeMs; + /// 上升时间(ms)。 + [ObservableProperty] private double _riseTimeMs; + /// 关闭时间(ms)。 + [ObservableProperty] private double _offTimeMs; + /// 下降时间(ms)。 + [ObservableProperty] private double _fallTimeMs; + [ObservableProperty] private string? _risingWaveformPath; + [ObservableProperty] private string? _fallingWaveformPath; + /// 开启曲线显示起点(ms,null 表示全曲线)。 + [ObservableProperty] private double? _risingViewStartMs; + /// 开启曲线显示终点(ms,null 表示全曲线)。 + [ObservableProperty] private double? _risingViewEndMs; + /// 关断曲线显示起点(ms,null 表示全曲线)。 + [ObservableProperty] private double? _fallingViewStartMs; + /// 关断曲线显示终点(ms,null 表示全曲线)。 + [ObservableProperty] private double? _fallingViewEndMs; + /// 兼容旧项目的共享曲线显示起点(ms,null 表示全曲线)。 + [ObservableProperty] private double? _viewStartMs; + /// 兼容旧项目的共享曲线显示终点(ms,null 表示全曲线)。 + [ObservableProperty] private double? _viewEndMs; + [ObservableProperty] private TestStatus _status = TestStatus.Untested; +} + +/// 曲线测试阈值(合格判定)。 +public sealed class CurveThresholds +{ + public double MaxOnTimeMs { get; set; } = 5.0; + public double MaxRiseTimeMs { get; set; } = 3.0; + public double MaxOffTimeMs { get; set; } = 5.0; + public double MaxFallTimeMs { get; set; } = 3.0; +} + +/// 功率损耗单通道结果(覆盖指标 1.7-1.10)。 +public partial class PowerLossRow : ObservableObject +{ + [ObservableProperty] private int _channel; + [ObservableProperty] private double _vin; + [ObservableProperty] private double _iin; + [ObservableProperty] private double _vout; + [ObservableProperty] private double _iout; + [ObservableProperty] private double? _measuredPowerOut; + [ObservableProperty] private TestStatus _status = TestStatus.Untested; + + public double VoltageDrop => Vin - Vout; + public double PowerIn => Vin * Iin; + public double PowerOut => MeasuredPowerOut ?? Vout * Iout; + public double CalculatedPowerOut => Vout * Iout; + public double PowerLossW => PowerIn - PowerOut; + public double PowerLossPct => PowerIn > 0 ? (PowerIn - CalculatedPowerOut) / PowerIn * 100.0 : 0; + public double EfficiencyRatio => PowerIn > 0 ? CalculatedPowerOut / PowerIn : 0; + public double EfficiencyPct => PowerIn > 0 ? PowerOut / PowerIn * 100.0 : 0; + public double OutputPower => PowerOut; + + partial void OnVinChanged(double value) => RaiseDerived(); + partial void OnIinChanged(double value) => RaiseDerived(); + partial void OnVoutChanged(double value) => RaiseDerived(); + partial void OnIoutChanged(double value) => RaiseDerived(); + partial void OnMeasuredPowerOutChanged(double? value) => RaiseDerived(); + private void RaiseDerived() + { + OnPropertyChanged(nameof(VoltageDrop)); + OnPropertyChanged(nameof(PowerIn)); + OnPropertyChanged(nameof(PowerOut)); + OnPropertyChanged(nameof(CalculatedPowerOut)); + OnPropertyChanged(nameof(PowerLossW)); + OnPropertyChanged(nameof(PowerLossPct)); + OnPropertyChanged(nameof(EfficiencyRatio)); + OnPropertyChanged(nameof(EfficiencyPct)); + OnPropertyChanged(nameof(OutputPower)); + } +} + +/// 保护功能单项结果。 +public partial class ProtectRow : ObservableObject +{ + [ObservableProperty] private string _protectType = ""; + [ObservableProperty] private string _trigger = ""; + [ObservableProperty] private double _tripTimeMs; + [ObservableProperty] private TestStatus _status = TestStatus.Untested; +} diff --git a/SSPCTester.Logic/Models/TestSelection.cs b/SSPCTester.Logic/Models/TestSelection.cs new file mode 100644 index 0000000..f253393 --- /dev/null +++ b/SSPCTester.Logic/Models/TestSelection.cs @@ -0,0 +1,38 @@ +namespace SSPCTester.Logic.Models; + +/// 用户在项目信息页选择的要执行的测试模块。 +public sealed class TestSelection +{ + public bool Basic { get; set; } = true; + public bool Curve { get; set; } = true; + public bool Power { get; set; } = true; + public bool Protect { get; set; } = true; + + public IEnumerable EnumerateEnabled() + { + if (Basic) yield return "基础测试"; + if (Curve) yield return "开启与关断曲线"; + if (Power) yield return "功率损耗"; + if (Protect) yield return "保护功能"; + } +} + +/// 报告页勾选的章节。 +public sealed class ReportSelection +{ + public bool Cover { get; set; } = true; + public bool Basic { get; set; } = true; + public bool Curve { get; set; } = true; + public bool Power { get; set; } = true; + public bool Protect { get; set; } = true; + public string FileName { get; set; } = "report_{yyyyMMdd_HHmmss}.pdf"; +} + +/// 四个测试页“测试说明”手动记录内容。 +public sealed class TestFunctionNotes +{ + public string Basic { get; set; } = ""; + public string Curve { get; set; } = ""; + public string Power { get; set; } = ""; + public string Protect { get; set; } = ""; +} diff --git a/SSPCTester.Logic/Report/CurveImageRenderer.cs b/SSPCTester.Logic/Report/CurveImageRenderer.cs new file mode 100644 index 0000000..e108d09 --- /dev/null +++ b/SSPCTester.Logic/Report/CurveImageRenderer.cs @@ -0,0 +1,103 @@ +using ScottPlot; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Calculation; + +namespace SSPCTester.Logic.Report; + +public static class CurveImageRenderer +{ + public static byte[] RenderChannel( + int channel, + CurveData rising, + CurveData falling, + double? viewStartMs = null, + double? viewEndMs = null, + int width = 900, + int height = 360) + { + var plot = new Plot(); + double start = viewStartMs ?? 0; + double end = viewEndMs ?? 0; + bool hasWindow = IsValidWindow(viewStartMs, viewEndMs); + plot.Title(hasWindow + ? $"CH{channel:00} ON / OFF Curve ({start:F3}-{end:F3} ms)" + : $"CH{channel:00} ON / OFF Curve"); + plot.XLabel("t (ms)"); + plot.YLabel("V"); + plot.FigureBackground.Color = Color.FromHex("#FBFCFD"); + plot.DataBackground.Color = Color.FromHex("#FBFCFD"); + plot.Grid.MajorLineColor = Color.FromHex("#DFE4EA"); + + AddCurve(plot, rising, Color.FromHex("#1A73C4"), "ON", viewStartMs, viewEndMs); + AddCurve(plot, falling, Color.FromHex("#D23B3B"), "OFF", viewStartMs, viewEndMs); + + double vMax = CurveMetrics.EstimateVMax(rising.Voltage); + AddThreshold(plot, vMax * 0.9, "90%"); + AddThreshold(plot, vMax * 0.1, "10%"); + + if (!hasWindow || (start <= 0 && end >= 0)) + { + var trigger = plot.Add.VerticalLine(0); + trigger.Color = Color.FromHex("#98A1AD"); + trigger.LinePattern = LinePattern.Dotted; + trigger.LineWidth = 1; + } + + plot.ShowLegend(); + plot.Axes.AutoScale(); + return plot.GetImageBytes(width, height, ImageFormat.Png); + } + + private static void AddCurve(Plot plot, CurveData curve, Color color, string label, double? viewStartMs, double? viewEndMs) + { + if (curve.Voltage.Length == 0) return; + + var points = BuildViewPoints(curve, viewStartMs, viewEndMs); + if (points.Count == 0) return; + + var xs = new double[points.Count]; + var ys = new double[points.Count]; + for (int i = 0; i < points.Count; i++) + { + xs[i] = points[i].TimeMs; + ys[i] = points[i].Voltage; + } + + var signal = plot.Add.ScatterLine(xs, ys, color); + signal.LineWidth = 2; + signal.MarkerSize = 0; + signal.LegendText = label; + } + + private static List<(double TimeMs, double Voltage)> BuildViewPoints(CurveData curve, double? viewStartMs, double? viewEndMs) + { + var points = new List<(double TimeMs, double Voltage)>(curve.Voltage.Length); + double start = viewStartMs ?? 0; + double end = viewEndMs ?? 0; + bool hasWindow = IsValidWindow(viewStartMs, viewEndMs); + + for (int i = 0; i < curve.Voltage.Length; i++) + { + double timeMs = (curve.TimeAt(i) - curve.TriggerTimeSec) * 1000.0; + if (!hasWindow || (timeMs >= start && timeMs <= end)) + points.Add((timeMs, curve.Voltage[i])); + } + + return points; + } + + private static bool IsValidWindow(double? viewStartMs, double? viewEndMs) => + viewStartMs is double start && viewEndMs is double end + && double.IsFinite(start) && double.IsFinite(end) && end > start; + + private static void AddThreshold(Plot plot, double volts, string label) + { + if (!double.IsFinite(volts)) return; + + var line = plot.Add.HorizontalLine(volts); + line.Color = Color.FromHex("#98A1AD"); + line.LinePattern = LinePattern.Dashed; + line.LineWidth = 1; + line.LegendText = label; + } +} diff --git a/SSPCTester.Logic/Report/ProfessionalReportGenerator.cs b/SSPCTester.Logic/Report/ProfessionalReportGenerator.cs new file mode 100644 index 0000000..e2b6bb6 --- /dev/null +++ b/SSPCTester.Logic/Report/ProfessionalReportGenerator.cs @@ -0,0 +1,505 @@ +using QuestPDF.Fluent; +using QuestPDF.Helpers; +using QuestPDF.Infrastructure; +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Report; + +/// 专业版固态功率控制器动态参数测试报告。 +public sealed class ReportGenerator +{ + private const string Navy = "#17324D"; + private const string Blue = "#245B82"; + private const string PaleBlue = "#EAF1F6"; + private const string Line = "#CBD5DF"; + private const string Muted = "#667585"; + private const string Text = "#1E2933"; + private const string Success = "#287A4B"; + private const string SuccessBg = "#E8F3EC"; + private const string Danger = "#A53232"; + private const string DangerBg = "#F8EAEA"; + private const string Warning = "#98651A"; + private const string WarningBg = "#FAF1DE"; + private const string NeutralBg = "#F1F3F5"; + + static ReportGenerator() => QuestPDF.Settings.License = LicenseType.Community; + + public Dictionary CurveImages { get; set; } = new(); + + public void Generate(Project project, string outputPath) + { + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)!); + string reportNo = BuildReportNumber(project); + + Document.Create(document => + { + if (project.Report.Cover) + document.Page(page => ComposeCover(page, project, reportNo)); + document.Page(page => ComposeBody(page, project, reportNo)); + }).GeneratePdf(outputPath); + } + + private static void ComposeCover(PageDescriptor page, Project p, string reportNo) + { + page.Size(PageSizes.A4); + page.MarginHorizontal(2.1f, Unit.Centimetre); + page.MarginVertical(1.8f, Unit.Centimetre); + page.DefaultTextStyle(x => x.FontFamily("Microsoft YaHei").FontSize(10).FontColor(Text)); + + page.Header().AlignRight().Text("SPC-DynaTest 测试系统") + .FontSize(9).FontColor(Muted).LetterSpacing(0.05f); + + page.Content().Column(column => + { + //column.Item().Height(34).Background(Navy); + column.Item().PaddingTop(54).AlignCenter().Text("固态功率控制器") + .FontSize(22).Bold().FontColor(Navy); + column.Item().PaddingTop(8).AlignCenter().Text("动态参数测试报告") + .FontSize(30).Bold().FontColor(Navy).LetterSpacing(0.08f); + // column.Item().PaddingTop(16).AlignCenter().Width(110) + // .LineHorizontal(2).LineColor(Blue); + + column.Item().PaddingTop(45).Element(container => CoverIdentity(container, p, reportNo)); + column.Item().PaddingTop(34).Element(container => OverallPanel(container, p)); + column.Item().ExtendVertical(); + column.Item().PaddingBottom(18).BorderTop(1).BorderColor(Line).PaddingTop(14).Table(table => + { + table.ColumnsDefinition(columns => + { + columns.RelativeColumn(); + columns.RelativeColumn(); + columns.RelativeColumn(); + }); + CoverSignCell(table, "编制", p.Site.Tester); + CoverSignCell(table, "审核", ""); + CoverSignCell(table, "批准", ""); + }); + }); + + page.Footer().Row(row => + { + row.RelativeItem().Text("本报告仅对所检样品及记录数据负责").FontSize(8).FontColor(Muted); + row.ConstantItem(180).AlignRight().Text($"生成时间:{DateTime.Now:yyyy-MM-dd HH:mm}") + .FontSize(8).FontColor(Muted); + }); + } + + private static void CoverIdentity(IContainer container, Project p, string reportNo) + { + container.Border(1).BorderColor(Line).Table(table => + { + table.ColumnsDefinition(columns => + { + columns.ConstantColumn(105); + columns.RelativeColumn(); + }); + IdentityRow(table, "报告编号", reportNo, true); + IdentityRow(table, "项目名称", ValueOrDash(p.Name)); + IdentityRow(table, "设备名称", ValueOrDash(p.Dut.ProductName)); + IdentityRow(table, "设备型号", ValueOrDash(p.Dut.Model)); + IdentityRow(table, "委托/生产单位", ValueOrDash(p.Dut.Manufacturer)); + IdentityRow(table, "测试日期", p.Site.TestDate.ToString("yyyy年MM月dd日")); + }); + } + + private static void IdentityRow(TableDescriptor table, string label, string value, bool mono = false) + { + table.Cell().BorderBottom(1).BorderColor(Line).Background(PaleBlue) + .PaddingVertical(8).PaddingHorizontal(10).Text(label).SemiBold().FontColor(Navy); + var text = table.Cell().BorderBottom(1).BorderColor(Line) + .PaddingVertical(8).PaddingHorizontal(12).Text(value); + if (mono) text.FontFamily("Consolas"); + } + + private static void CoverSignCell(TableDescriptor table, string label, string value) + { + table.Cell().PaddingRight(14).Column(column => + { + column.Item().Text(label).FontSize(9).FontColor(Muted); + column.Item().PaddingTop(16).BorderBottom(1).BorderColor(Line) + .PaddingBottom(4).Text(ValueOrDash(value)).FontSize(10); + }); + } + + private void ComposeBody(PageDescriptor page, Project p, string reportNo) + { + page.Size(PageSizes.A4); + page.MarginHorizontal(1.5f, Unit.Centimetre); + page.MarginVertical(1.3f, Unit.Centimetre); + page.DefaultTextStyle(x => x.FontFamily("Microsoft YaHei").FontSize(8.7f).FontColor(Text)); + page.Header().Element(container => BodyHeader(container, p, reportNo)); + page.Content().PaddingVertical(10).Element(container => BodyContent(container, p)); + page.Footer().Element(container => Footer(container, reportNo)); + } + + private static void BodyHeader(IContainer container, Project p, string reportNo) + { + container.BorderBottom(1).BorderColor(Navy).PaddingBottom(7).Row(row => + { + row.RelativeItem().Column(column => + { + column.Item().Text("固态功率控制器动态参数测试报告") + .FontSize(12).Bold().FontColor(Navy); + column.Item().Text(ValueOrDash(p.Name)).FontSize(8).FontColor(Muted); + }); + row.ConstantItem(175).AlignRight().Column(column => + { + column.Item().AlignRight().Text($"报告编号:{reportNo}") + .FontFamily("Consolas").FontSize(8).FontColor(Muted); + column.Item().AlignRight().Text($"样品编号:{ValueOrDash(p.Dut.SerialNumber)}") + .FontSize(8).FontColor(Muted); + }); + }); + } + + private static void Footer(IContainer container, string reportNo) + { + container.BorderTop(0.7f).BorderColor(Line).PaddingTop(6).Row(row => + { + row.RelativeItem().Text($"SPC-DynaTest · {reportNo}").FontSize(7.5f).FontColor(Muted); + row.RelativeItem().AlignCenter().Text("未经授权不得部分复制本报告") + .FontSize(7.5f).FontColor(Muted); + row.RelativeItem().AlignRight() + .DefaultTextStyle(style => style.FontSize(7.5f).FontColor(Muted)) + .Text(text => + { + text.Span("第 "); + text.CurrentPageNumber(); + text.Span(" 页 / 共 "); + text.TotalPages(); + text.Span(" 页"); + }); + }); + } + + private void BodyContent(IContainer container, Project p) + { + container.Column(column => + { + column.Spacing(12); + int section = 1; + + if (p.Report.Cover) + { + Section(column, section++, "测试概况", "TEST OVERVIEW"); + column.Item().Element(x => Overview(x, p)); + Section(column, section++, "结果摘要", "RESULT SUMMARY"); + column.Item().Element(x => ResultSummary(x, p)); + } + + if (p.Report.Basic && (p.BasicResults.Count > 0 || HasNote(p.TestFunction?.Basic))) + { + Section(column, section++, "基础测试", "BASIC FUNCTION TEST"); + if (p.BasicResults.Count > 0) + { + column.Item().Element(x => ModuleSummary(x, "通道开合、电压、电流与关后残压", p.BasicResults.Select(r => r.Status))); + column.Item().Element(x => BasicTable(x, p)); + } + ManualNote(column, p.TestFunction?.Basic); + } + + if (p.Report.Curve && (p.CurveResults.Count > 0 || HasNote(p.TestFunction?.Curve))) + { + Section(column, section++, "开启与关断曲线", "SWITCHING CHARACTERISTICS"); + if (p.CurveResults.Count > 0) + { + string criteria = $"判据:开启≤{p.CurveThresholds.MaxOnTimeMs:F1}ms,上升≤{p.CurveThresholds.MaxRiseTimeMs:F1}ms,关断≤{p.CurveThresholds.MaxOffTimeMs:F1}ms,下降≤{p.CurveThresholds.MaxFallTimeMs:F1}ms"; + column.Item().Element(x => ModuleSummary(x, criteria, p.CurveResults.Select(r => r.Status))); + column.Item().Element(x => CurveTable(x, p)); + } + ManualNote(column, p.TestFunction?.Curve); + foreach (var (channel, png) in CurveImages.OrderBy(x => x.Key)) + { + column.Item().ShowEntire().Border(1).BorderColor(Line).Padding(8).Column(imageColumn => + { + imageColumn.Item().Text($"CH{channel:00} ON / OFF Curve").SemiBold().FontColor(Navy); + imageColumn.Item().PaddingTop(6).Image(png).FitWidth(); + }); + } + } + + if (p.Report.Power && (p.PowerResults.Count > 0 || HasNote(p.TestFunction?.Power))) + { + Section(column, section++, "功率损耗", "POWER LOSS"); + if (p.PowerResults.Count > 0) + { + column.Item().Element(x => ModuleSummary(x, "采集输入/输出两端电压与电流,计算功率损耗与效率", p.PowerResults.Select(r => r.Status))); + column.Item().Element(x => PowerTable(x, p)); + } + ManualNote(column, p.TestFunction?.Power); + } + + if (p.Report.Protect && (p.ProtectResults.Count > 0 || HasNote(p.TestFunction?.Protect))) + { + Section(column, section++, "保护功能", "PROTECTION FUNCTION"); + if (p.ProtectResults.Count > 0) + { + column.Item().Element(x => ModuleSummary(x, "跳闸、短路、过温、过压、欠压及限流保护", p.ProtectResults.Select(r => r.Status))); + column.Item().Element(x => ProtectTable(x, p)); + } + ManualNote(column, p.TestFunction?.Protect); + } + + column.Item().PaddingTop(12).Element(x => Conclusion(x, p)); + }); + } + + private static void Section(ColumnDescriptor column, int number, string title, string english) + { + column.Item().PaddingTop(4).BorderBottom(1.3f).BorderColor(Navy).PaddingBottom(5).Row(row => + { + row.ConstantItem(34).Height(25).Background(Navy).AlignCenter().AlignMiddle() + .Text(number.ToString("00")).Bold().FontColor(Colors.White).FontFamily("Consolas"); + row.RelativeItem().PaddingLeft(10).AlignMiddle().Text(title) + .FontSize(13).Bold().FontColor(Navy); + row.ConstantItem(180).AlignRight().AlignMiddle().Text(english) + .FontSize(7.5f).FontColor(Muted).LetterSpacing(0.05f); + }); + } + + private static void Overview(IContainer container, Project p) + { + container.Table(table => + { + table.ColumnsDefinition(columns => + { + columns.ConstantColumn(82); columns.RelativeColumn(); + columns.ConstantColumn(82); columns.RelativeColumn(); + }); + OverviewCell(table, "设备名称", p.Dut.ProductName); + OverviewCell(table, "设备型号", p.Dut.Model); + OverviewCell(table, "设备编号", p.Dut.SerialNumber); + OverviewCell(table, "生产厂家", p.Dut.Manufacturer); + OverviewCell(table, "测试人员", p.Site.Tester); + OverviewCell(table, "测试日期", p.Site.TestDate.ToString("yyyy-MM-dd")); + OverviewCell(table, "环境温度", $"{p.Site.TemperatureC:F1} ℃"); + OverviewCell(table, "相对湿度", $"{p.Site.HumidityPct:F1} %RH"); + OverviewCell(table, "环境气压", $"{p.Site.PressureKpa:F1} kPa"); + OverviewCell(table, "项目创建", p.CreatedAt.ToString("yyyy-MM-dd HH:mm")); + table.Cell().Border(0.6f).BorderColor(Line).Background(PaleBlue).Padding(6) + .Text("测试备注").SemiBold().FontColor(Navy); + table.Cell().ColumnSpan(3).Border(0.6f).BorderColor(Line).Padding(6) + .Text(ValueOrDash(p.Site.Remark)); + }); + } + + private static void OverviewCell(TableDescriptor table, string label, string? value) + { + table.Cell().Border(0.6f).BorderColor(Line).Background(PaleBlue) + .Padding(6).Text(label).SemiBold().FontColor(Navy); + table.Cell().Border(0.6f).BorderColor(Line).Padding(6).Text(ValueOrDash(value)); + } + + private static void ResultSummary(IContainer container, Project p) + { + var statuses = p.BasicResults.Select(x => x.Status) + .Concat(p.CurveResults.Select(x => x.Status)) + .Concat(p.PowerResults.Select(x => x.Status)) + .Concat(p.ProtectResults.Select(x => x.Status)).ToArray(); + + container.Row(row => + { + row.RelativeItem().Element(x => SummaryCard(x, "测试项目", statuses.Length.ToString(), Navy, PaleBlue)); + row.RelativeItem().PaddingLeft(7).Element(x => SummaryCard(x, "合格", statuses.Count(s => s == TestStatus.Pass).ToString(), Success, SuccessBg)); + row.RelativeItem().PaddingLeft(7).Element(x => SummaryCard(x, "不合格", statuses.Count(s => s == TestStatus.Fail).ToString(), Danger, DangerBg)); + row.RelativeItem().PaddingLeft(7).Element(x => SummaryCard(x, "已测", statuses.Count(s => s == TestStatus.Measured).ToString(), Blue, PaleBlue)); + row.RelativeItem().PaddingLeft(7).Element(x => SummaryCard(x, "未测试", statuses.Count(s => s == TestStatus.Untested).ToString(), Muted, NeutralBg)); + row.RelativeItem().PaddingLeft(7).Element(x => SummaryCard(x, "综合判定", StatusText(p.OverallStatus), StatusColor(p.OverallStatus), StatusBackground(p.OverallStatus))); + }); + } + + private static void SummaryCard(IContainer container, string title, string value, string color, string background) + { + container.MinHeight(58).Border(0.8f).BorderColor(color).Background(background) + .Padding(8).Column(column => + { + column.Item().Text(title).FontSize(7.5f).FontColor(Muted); + column.Item().PaddingTop(4).Text(value).FontSize(13).Bold().FontColor(color); + }); + } + + private static void ModuleSummary(IContainer container, string description, IEnumerable source) + { + var statuses = source.ToArray(); + container.Background(PaleBlue).BorderLeft(3).BorderColor(Blue).Padding(7).Row(row => + { + row.RelativeItem().Text(description).FontSize(8).FontColor(Muted); + row.ConstantItem(190).AlignRight() + .DefaultTextStyle(style => style.FontSize(8)) + .Text(text => + { + text.Span($"合格 {statuses.Count(x => x == TestStatus.Pass)}").FontColor(Success).SemiBold(); + text.Span(" "); + text.Span($"不合格 {statuses.Count(x => x == TestStatus.Fail)}").FontColor(Danger).SemiBold(); + text.Span(" "); + text.Span($"已测 {statuses.Count(x => x == TestStatus.Measured)}").FontColor(Blue).SemiBold(); + text.Span(" "); + text.Span($"未测 {statuses.Count(x => x == TestStatus.Untested)}").FontColor(Muted); + }); + }); + } + + private static void BasicTable(IContainer container, Project p) => + DataTable(container, new[] { 0.65f, 1f, 1f, 1.15f, 0.8f }, + new[] { "通道", "导通电压\nV", "导通电流\nA", "关后电压\nV", "判定" }, + p.BasicResults.Select(r => new ReportRow(r.Status, new[] + { + $"CH{r.Channel:00}", Format(r.VoltageOn, "F2"), Format(r.CurrentOn, "F3"), + Format(r.VoltageOff, "F2"), StatusText(r.Status) + }))); + + private static void CurveTable(IContainer container, Project p) => + DataTable(container, new[] { 0.62f, 1f, 1f, 1f, 1f, 0.76f }, + new[] { "通道", "开启时间\nms", "上升时间\nms", "关断时间\nms", "下降时间\nms", "判定" }, + p.CurveResults.Select(r => new ReportRow(r.Status, new[] + { + $"CH{r.Channel:00}", Format(r.OnTimeMs, "F3"), Format(r.RiseTimeMs, "F3"), + Format(r.OffTimeMs, "F3"), Format(r.FallTimeMs, "F3"), StatusText(r.Status) + }))); + + private static void PowerTable(IContainer container, Project p) => + DataTable(container, new[] { 0.62f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.9f, 0.76f }, + new[] { "通道", "输入电压\nV", "输入电流\nA", "输出电压\nV", "输出电流\nA", "功率损耗\nW", "效率\n%", "状态" }, + p.PowerResults.Select(r => new ReportRow(r.Status, new[] + { + $"CH{r.Channel:00}", Format(r.Vin, "F2"), Format(r.Iin, "F3"), + Format(r.Vout, "F2"), Format(r.Iout, "F3"), + Format(r.PowerLossW, "F2"), Format(r.EfficiencyPct, "F1"), StatusText(r.Status) + }))); + + private static void ProtectTable(IContainer container, Project p) => + DataTable(container, new[] { 1.2f, 1.6f, 1f, 0.72f }, + new[] { "保护类型", "触发条件", "关断时间 ms", "判定" }, + p.ProtectResults.Select(r => new ReportRow(r.Status, new[] + { + ValueOrDash(r.ProtectType), ValueOrDash(r.Trigger), + Format(r.TripTimeMs, "F2"), StatusText(r.Status) + }))); + + private static void DataTable(IContainer container, IReadOnlyList widths, + IReadOnlyList headers, IEnumerable source) + { + var rows = source.ToArray(); + container.Table(table => + { + table.ColumnsDefinition(columns => + { + foreach (float width in widths) columns.RelativeColumn(width); + }); + table.Header(header => + { + foreach (string text in headers) + header.Cell().Background(Navy).BorderRight(0.5f).BorderColor(Colors.White) + .PaddingVertical(6).PaddingHorizontal(4).AlignCenter().AlignMiddle() + .Text(text).FontSize(7.6f).SemiBold().FontColor(Colors.White); + }); + + for (int rowIndex = 0; rowIndex < rows.Length; rowIndex++) + { + var row = rows[rowIndex]; + string background = row.Status == TestStatus.Fail ? DangerBg + : rowIndex % 2 == 0 ? Colors.White : "#F7F9FB"; + for (int columnIndex = 0; columnIndex < row.Values.Length; columnIndex++) + { + var text = table.Cell().Background(background).BorderBottom(0.55f).BorderColor(Line) + .PaddingVertical(4.5f).PaddingHorizontal(4).AlignCenter().AlignMiddle() + .Text(row.Values[columnIndex]).FontSize(7.8f); + if (columnIndex == row.Values.Length - 1) + text.SemiBold().FontColor(StatusColor(row.Status)); + else if (columnIndex == 0) + text.FontFamily("Consolas").SemiBold().FontColor(Navy); + } + } + }); + } + + private static void ManualNote(ColumnDescriptor column, string? note) + { + if (!HasNote(note)) return; + column.Item().ShowEntire().Border(0.8f).BorderColor(Line).Background("#F8FAFC") + .Padding(8).Column(noteColumn => + { + noteColumn.Item().Text("测试说明 / 现场记录").FontSize(8).SemiBold().FontColor(Navy); + noteColumn.Item().PaddingTop(5).Text(note!.Trim()).FontSize(8.2f).LineHeight(1.35f); + }); + } + + private static void Conclusion(IContainer container, Project p) + { + container.ShowEntire().Border(1.2f).BorderColor(StatusColor(p.OverallStatus)) + .Background(StatusBackground(p.OverallStatus)).Padding(12).Column(column => + { + column.Item().Row(row => + { + row.RelativeItem().Text("测试结论").FontSize(11).Bold().FontColor(Navy); + row.ConstantItem(120).AlignRight().Text(StatusText(p.OverallStatus)) + .FontSize(13).Bold().FontColor(StatusColor(p.OverallStatus)); + }); + column.Item().PaddingTop(8).Text(ConclusionText(p.OverallStatus)) + .FontSize(8.5f).FontColor(Text).LineHeight(1.4f); + column.Item().PaddingTop(18).Row(row => + { + row.RelativeItem().Text($"测试:{ValueOrDash(p.Site.Tester)}").FontSize(8).FontColor(Muted); + row.RelativeItem().Text("复核:________________").FontSize(8).FontColor(Muted); + row.RelativeItem().AlignRight().Text("日期:____年__月__日").FontSize(8).FontColor(Muted); + }); + }); + } + + private static void OverallPanel(IContainer container, Project p) + { + container.Border(1.2f).BorderColor(StatusColor(p.OverallStatus)) + .Background(StatusBackground(p.OverallStatus)).Padding(14).Row(row => + { + row.RelativeItem().Column(column => + { + column.Item().Text("综合测试结论").FontSize(9).FontColor(Muted); + column.Item().PaddingTop(4).Text(ConclusionText(p.OverallStatus)).FontSize(9); + }); + row.ConstantItem(110).AlignRight().AlignMiddle().Text(StatusText(p.OverallStatus)) + .FontSize(18).Bold().FontColor(StatusColor(p.OverallStatus)); + }); + } + + private static string BuildReportNumber(Project p) + { + string serial = new(p.Dut.SerialNumber.Where(char.IsLetterOrDigit).ToArray()); + if (string.IsNullOrWhiteSpace(serial)) serial = "UNKNOWN"; + if (serial.Length > 14) serial = serial[^14..]; + return $"SPC-{p.Site.TestDate:yyyyMMdd}-{serial.ToUpperInvariant()}"; + } + + private static string ConclusionText(TestStatus status) => status switch + { + TestStatus.Pass => "本次所选测试项目均满足当前判定要求,综合结论为合格。", + TestStatus.Fail => "本次测试存在不合格项目,综合结论为不合格;请结合异常通道记录进行复核与处置。", + TestStatus.Running => "测试尚未结束,当前结果仅供过程参考,不作为最终判定依据。", + TestStatus.Measured => "功率损耗已完成测量,报告基于输入/输出两端数据计算损耗与效率。", + _ => "测试数据尚不完整,暂不具备出具最终合格判定的条件。" + }; + + private static string Format(double value, string format) => + double.IsNaN(value) || double.IsInfinity(value) ? "—" : value.ToString(format); + private static bool HasNote(string? value) => !string.IsNullOrWhiteSpace(value); + private static string ValueOrDash(string? value) => string.IsNullOrWhiteSpace(value) ? "—" : value.Trim(); + private static string StatusText(TestStatus status) => status switch + { + TestStatus.Pass => "合格", TestStatus.Fail => "不合格", + TestStatus.Running => "测试中", TestStatus.Measured => "已测", + _ => "未测试" + }; + private static string StatusColor(TestStatus status) => status switch + { + TestStatus.Pass => Success, TestStatus.Fail => Danger, + TestStatus.Running => Warning, TestStatus.Measured => Blue, + _ => Muted + }; + private static string StatusBackground(TestStatus status) => status switch + { + TestStatus.Pass => SuccessBg, TestStatus.Fail => DangerBg, + TestStatus.Running => WarningBg, TestStatus.Measured => PaleBlue, + _ => NeutralBg + }; + + private sealed record ReportRow(TestStatus Status, string[] Values); +} diff --git a/SSPCTester.Logic/Report/ReportFileHelper.cs b/SSPCTester.Logic/Report/ReportFileHelper.cs new file mode 100644 index 0000000..f3ee66b --- /dev/null +++ b/SSPCTester.Logic/Report/ReportFileHelper.cs @@ -0,0 +1,165 @@ +using SSPCTester.Logic.Models; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace SSPCTester.Logic.Report; + +public enum ReportOutputFormat +{ + Pdf, + Word, + Both +} + +public static class ReportFileHelper +{ + public const string DefaultTemplate = "report_{yyyyMMdd_HHmmss}.pdf"; + private static readonly JsonSerializerOptions JsonOptions = new() + { + WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull + }; + + public static string ResolveFileName(Project project, DateTime now) + => ResolveFileName(project, now, ".pdf"); + + public static string ResolveFileName(Project project, DateTime now, string extension) + { + string template = string.IsNullOrWhiteSpace(project.Report.FileName) + ? DefaultTemplate + : project.Report.FileName.Trim(); + extension = NormalizeExtension(extension); + + string date = now.ToString("yyyyMMdd"); + string dateTime = now.ToString("yyyyMMdd_HHmmss"); + string value = template + .Replace("{ProjectName}", project.Name ?? "", StringComparison.OrdinalIgnoreCase) + .Replace("{ProductName}", project.Dut.ProductName ?? "", StringComparison.OrdinalIgnoreCase) + .Replace("{Model}", project.Dut.Model ?? "", StringComparison.OrdinalIgnoreCase) + .Replace("{SerialNumber}", project.Dut.SerialNumber ?? "", StringComparison.OrdinalIgnoreCase) + .Replace("{yyyyMMdd_HHmmss}", dateTime, StringComparison.OrdinalIgnoreCase) + .Replace("{DateTime}", dateTime, StringComparison.OrdinalIgnoreCase) + .Replace("{yyyyMMdd}", date, StringComparison.OrdinalIgnoreCase) + .Replace("{Date}", date, StringComparison.OrdinalIgnoreCase); + + value = MakeSafeFileName(value); + if (string.IsNullOrWhiteSpace(value)) + value = $"report_{dateTime}{extension}"; + value = Path.ChangeExtension(value, extension); + + return value; + } + + public static ReportOutputFormat ParseFormat(string? value) + { + if (Enum.TryParse(value, ignoreCase: true, out var format)) + return format; + return ReportOutputFormat.Pdf; + } + + public static IReadOnlyList EnumerateReportFiles( + string? directory, + ReportOutputFormat format) + { + if (string.IsNullOrWhiteSpace(directory) || !Directory.Exists(directory)) + return Array.Empty(); + + string[] patterns = format switch + { + ReportOutputFormat.Word => new[] { "*.docx" }, + ReportOutputFormat.Both => new[] { "*.pdf", "*.docx" }, + _ => new[] { "*.pdf" } + }; + + return patterns + .SelectMany(pattern => Directory.EnumerateFiles(directory, pattern, SearchOption.TopDirectoryOnly)) + .Select(path => new FileInfo(path)) + .OrderByDescending(file => file.LastWriteTime) + .Select(file => new ReportFileDescriptor( + file.FullName, + file.Name, + file.LastWriteTime, + file.Extension.Equals(".pdf", StringComparison.OrdinalIgnoreCase) + ? ReportFileKind.Pdf + : ReportFileKind.Word)) + .ToArray(); + } + + public static IReadOnlyList EnumeratePdfFiles(string? directory) + { + return EnumerateReportFiles(directory, ReportOutputFormat.Pdf); + } + + public static string BuildInfoPath(string outputPath) => + Path.Combine( + Path.GetDirectoryName(outputPath) ?? "", + Path.GetFileNameWithoutExtension(outputPath) + ".reportinfo.json"); + + public static void SaveInfo(ReportInfo info, string infoPath) + { + Directory.CreateDirectory(Path.GetDirectoryName(infoPath)!); + File.WriteAllText(infoPath, JsonSerializer.Serialize(info, JsonOptions)); + } + + public static ReportInfo? LoadInfoForReport(string reportPath) + { + string infoPath = BuildInfoPath(reportPath); + if (!File.Exists(infoPath)) return null; + return JsonSerializer.Deserialize(File.ReadAllText(infoPath), JsonOptions); + } + + private static string MakeSafeFileName(string value) + { + var invalid = Path.GetInvalidFileNameChars(); + var chars = value + .Select(c => invalid.Contains(c) ? '_' : c) + .ToArray(); + return new string(chars).Trim(' ', '.'); + } + + private static string NormalizeExtension(string extension) + { + if (string.IsNullOrWhiteSpace(extension)) return ".pdf"; + extension = extension.Trim(); + return extension.StartsWith('.') ? extension : "." + extension; + } +} + +public enum ReportFileKind +{ + Pdf, + Word +} + +public sealed record ReportFileDescriptor( + string FullPath, + string DisplayName, + DateTime LastWriteTime, + ReportFileKind Kind = ReportFileKind.Pdf) +{ + public bool IsPdf => Kind == ReportFileKind.Pdf; + public bool IsWord => Kind == ReportFileKind.Word; +} + +public sealed class ReportInfo +{ + public string ProjectName { get; set; } = ""; + public string ProductName { get; set; } = ""; + public string Model { get; set; } = ""; + public string SerialNumber { get; set; } = ""; + public DateTime GeneratedAt { get; set; } + public string Format { get; set; } = ""; + public string? PdfPath { get; set; } + public string? WordPath { get; set; } + public string OverallStatus { get; set; } = ""; + public ReportSectionInfo Sections { get; set; } = new(); +} + +public sealed class ReportSectionInfo +{ + public bool Cover { get; set; } + public bool Basic { get; set; } + public bool Curve { get; set; } + public bool Power { get; set; } + public bool Protect { get; set; } +} diff --git a/SSPCTester.Logic/Report/ReportGenerator.cs b/SSPCTester.Logic/Report/ReportGenerator.cs new file mode 100644 index 0000000..0578859 --- /dev/null +++ b/SSPCTester.Logic/Report/ReportGenerator.cs @@ -0,0 +1,289 @@ +using QuestPDF.Fluent; +using QuestPDF.Helpers; +using QuestPDF.Infrastructure; +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Report; + +/// +/// 用 QuestPDF 生成测试报告 PDF。按 Project.Report 勾选拼装章节。 +/// +internal sealed class LegacyReportGenerator +{ + static LegacyReportGenerator() + { + QuestPDF.Settings.License = LicenseType.Community; + } + + /// 外部传入曲线图 PNG,键 = 通道号。 + public Dictionary CurveImages { get; set; } = new(); + + public void Generate(Project project, string outputPath) + { + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)!); + var sel = project.Report; + Document.Create(container => + { + container.Page(page => + { + page.Size(PageSizes.A4); + page.Margin(2, Unit.Centimetre); + page.DefaultTextStyle(t => t.FontFamily("Microsoft YaHei").FontSize(10)); + + page.Header().Element(h => Header(h, project)); + page.Content().Element(c => Content(c, project, sel)); + page.Footer().AlignCenter().Text(t => + { + t.Span("第 "); + t.CurrentPageNumber(); + t.Span(" / "); + t.TotalPages(); + t.Span(" 页"); + }); + }); + }).GeneratePdf(outputPath); + } + + private static void Header(IContainer h, Project p) + { + h.Column(col => + { + col.Item().Text($"固态功率控制器动态参数测试报告").FontSize(16).Bold(); + col.Item().Text($"项目:{p.Name} 生成时间:{DateTime.Now:yyyy-MM-dd HH:mm}").FontSize(9).FontColor(Colors.Grey.Darken2); + col.Item().PaddingTop(4).LineHorizontal(0.5f).LineColor(Colors.Grey.Lighten2); + }); + } + + private void Content(IContainer c, Project p, ReportSelection sel) + { + c.Column(col => + { + col.Spacing(14); + + if (sel.Cover) + { + Section(col, "1. 被测件信息"); + col.Item().Element(e => DutTable(e, p)); + Section(col, "2. 测试信息"); + col.Item().Element(e => SiteTable(e, p)); + Section(col, "3. 综合判定"); + col.Item().Element(e => OverallBadge(e, p.OverallStatus)); + } + + if (sel.Basic && (p.BasicResults.Count > 0 || HasManualNote(p.TestFunction?.Basic))) + { + Section(col, "4. 基础测试结果(24 路)"); + if (p.BasicResults.Count > 0) col.Item().Element(e => BasicTable(e, p)); + ManualNote(col, p.TestFunction?.Basic); + } + + if (sel.Curve && (p.CurveResults.Count > 0 || HasManualNote(p.TestFunction?.Curve))) + { + Section(col, "5. 开启与关断曲线(1.1–1.6)"); + if (p.CurveResults.Count > 0) col.Item().Element(e => CurveTable(e, p)); + ManualNote(col, p.TestFunction?.Curve); + foreach (var (ch, png) in CurveImages.OrderBy(x => x.Key)) + { + col.Item().PaddingTop(6).Text($"CH{ch} Curve").Bold(); + col.Item().Image(png).FitWidth(); + } + } + + if (sel.Power && (p.PowerResults.Count > 0 || HasManualNote(p.TestFunction?.Power))) + { + Section(col, "6. 功率损耗"); + if (p.PowerResults.Count > 0) col.Item().Element(e => PowerTable(e, p)); + ManualNote(col, p.TestFunction?.Power); + } + + if (sel.Protect && (p.ProtectResults.Count > 0 || HasManualNote(p.TestFunction?.Protect))) + { + Section(col, "7. 保护功能(框架占位)"); + if (p.ProtectResults.Count > 0) col.Item().Element(e => ProtectTable(e, p)); + ManualNote(col, p.TestFunction?.Protect); + } + }); + } + + private static void Section(ColumnDescriptor col, string title) + { + col.Item().PaddingTop(6).Text(title).FontSize(13).Bold().FontColor(Colors.Blue.Darken2); + } + + private static bool HasManualNote(string? text) => !string.IsNullOrWhiteSpace(text); + + private static void ManualNote(ColumnDescriptor col, string? note) + { + if (!HasManualNote(note)) return; + + col.Item().PaddingTop(8).Text("测试说明").FontSize(11).Bold(); + col.Item() + .Border(1) + .BorderColor(Colors.Grey.Lighten2) + .Background(Colors.Grey.Lighten4) + .Padding(6) + .Column(lines => + { + foreach (var line in NormalizeLines(note!)) + lines.Item().Text(string.IsNullOrEmpty(line) ? " " : line).FontSize(9); + }); + } + + private static IEnumerable NormalizeLines(string text) + => text.Replace("\r\n", "\n").Replace('\r', '\n').Split('\n'); + + private static void DutTable(IContainer c, Project p) + { + c.Table(t => + { + t.ColumnsDefinition(cd => { cd.ConstantColumn(120); cd.RelativeColumn(); }); + Row(t, "设备名称", p.Dut.ProductName); + Row(t, "设备型号", p.Dut.Model); + Row(t, "设备编号", p.Dut.SerialNumber); + Row(t, "生产厂家", p.Dut.Manufacturer); + }); + } + + private static void SiteTable(IContainer c, Project p) + { + c.Table(t => + { + t.ColumnsDefinition(cd => { cd.ConstantColumn(120); cd.RelativeColumn(); }); + Row(t, "测试人员", p.Site.Tester); + Row(t, "测试日期", p.Site.TestDate.ToString("yyyy-MM-dd")); + Row(t, "环境", $"温度 {p.Site.TemperatureC}℃ 湿度 {p.Site.HumidityPct}% 气压 {p.Site.PressureKpa}kPa"); + Row(t, "备注", p.Site.Remark); + }); + } + + private static void Row(TableDescriptor t, string k, string? v) + { + t.Cell().Background(Colors.Grey.Lighten4).Padding(4).Text(k).SemiBold(); + t.Cell().Padding(4).Text(v ?? ""); + } + + private static void OverallBadge(IContainer c, TestStatus s) + { + (string text, string color) = s switch + { + TestStatus.Pass => ("综合判定:合格", Colors.Green.Darken1), + TestStatus.Fail => ("综合判定:不合格", Colors.Red.Darken1), + TestStatus.Running => ("综合判定:测试中", Colors.Blue.Darken1), + TestStatus.Measured => ("综合判定:已测(无性能判据)", Colors.Blue.Darken1), + _ => ("综合判定:未测试", Colors.Grey.Darken1), + }; + c.Padding(6).Background(color).Padding(10).Text(text).FontColor(Colors.White).FontSize(14).Bold(); + } + + private static void BasicTable(IContainer c, Project p) + { + c.Table(t => + { + t.ColumnsDefinition(cd => + { + cd.ConstantColumn(60); cd.RelativeColumn(); cd.RelativeColumn(); cd.RelativeColumn(); cd.ConstantColumn(70); + }); + HeaderRow(t, "通道", "电压(V)", "电流(A)", "关后电压(V)", "结果"); + foreach (var r in p.BasicResults) + { + t.Cell().Padding(3).Text($"CH{r.Channel}"); + t.Cell().Padding(3).Text(r.VoltageOn.ToString("F2")); + t.Cell().Padding(3).Text(r.CurrentOn.ToString("F3")); + t.Cell().Padding(3).Text(r.VoltageOff.ToString("F2")); + t.Cell().Padding(3).Text(StatusText(r.Status)).FontColor(StatusColor(r.Status)); + } + }); + } + + private static void CurveTable(IContainer c, Project p) + { + c.Table(t => + { + t.ColumnsDefinition(cd => + { + cd.ConstantColumn(50); cd.RelativeColumn(); cd.RelativeColumn(); cd.RelativeColumn(); cd.RelativeColumn(); cd.ConstantColumn(60); + }); + HeaderRow(t, "通道", "开启(ms)", "上升(ms)", "关断(ms)", "下降(ms)", "结果"); + foreach (var r in p.CurveResults) + { + t.Cell().Padding(3).Text($"CH{r.Channel}"); + t.Cell().Padding(3).Text(FormatMs(r.OnTimeMs)); + t.Cell().Padding(3).Text(FormatMs(r.RiseTimeMs)); + t.Cell().Padding(3).Text(FormatMs(r.OffTimeMs)); + t.Cell().Padding(3).Text(FormatMs(r.FallTimeMs)); + t.Cell().Padding(3).Text(StatusText(r.Status)).FontColor(StatusColor(r.Status)); + } + }); + } + + private static void PowerTable(IContainer c, Project p) + { + c.Table(t => + { + t.ColumnsDefinition(cd => + { + cd.ConstantColumn(50); + cd.RelativeColumn(); cd.RelativeColumn(); cd.RelativeColumn(); + cd.RelativeColumn(); cd.RelativeColumn(); cd.RelativeColumn(); + cd.ConstantColumn(60); + }); + HeaderRow(t, "通道", "Vin(V)", "Iin(A)", "Vout(V)", "Iout(A)", "损耗(W)", "效率(%)", "状态"); + foreach (var r in p.PowerResults) + { + t.Cell().Padding(3).Text($"CH{r.Channel}"); + t.Cell().Padding(3).Text(r.Vin.ToString("F2")); + t.Cell().Padding(3).Text(r.Iin.ToString("F3")); + t.Cell().Padding(3).Text(r.Vout.ToString("F2")); + t.Cell().Padding(3).Text(r.Iout.ToString("F3")); + t.Cell().Padding(3).Text(r.PowerLossW.ToString("F2")); + t.Cell().Padding(3).Text(r.EfficiencyPct.ToString("F1")); + t.Cell().Padding(3).Text(StatusText(r.Status)).FontColor(StatusColor(r.Status)); + } + }); + } + + private static void ProtectTable(IContainer c, Project p) + { + c.Table(t => + { + t.ColumnsDefinition(cd => + { + cd.RelativeColumn(); cd.RelativeColumn(); cd.RelativeColumn(); cd.ConstantColumn(60); + }); + HeaderRow(t, "保护类型", "触发条件", "关断时间(ms)", "结果"); + foreach (var r in p.ProtectResults) + { + t.Cell().Padding(3).Text(r.ProtectType); + t.Cell().Padding(3).Text(r.Trigger); + t.Cell().Padding(3).Text(r.TripTimeMs.ToString("F2")); + t.Cell().Padding(3).Text(StatusText(r.Status)).FontColor(StatusColor(r.Status)); + } + }); + } + + private static void HeaderRow(TableDescriptor t, params string[] cols) + { + foreach (var col in cols) + t.Cell().Background(Colors.Grey.Lighten3).Padding(4).Text(col).SemiBold(); + } + + private static string FormatMs(double v) => double.IsNaN(v) ? "—" : v.ToString("F3"); + + private static string StatusText(TestStatus s) => s switch + { + TestStatus.Pass => "合格", + TestStatus.Fail => "不合格", + TestStatus.Running => "测试中", + TestStatus.Measured => "已测", + _ => "未测试" + }; + + private static string StatusColor(TestStatus s) => s switch + { + TestStatus.Pass => Colors.Green.Darken1, + TestStatus.Fail => Colors.Red.Darken1, + TestStatus.Running => Colors.Blue.Darken1, + TestStatus.Measured => Colors.Blue.Darken1, + _ => Colors.Grey.Darken1 + }; +} diff --git a/SSPCTester.Logic/Report/WordReportGenerator.cs b/SSPCTester.Logic/Report/WordReportGenerator.cs new file mode 100644 index 0000000..899ef74 --- /dev/null +++ b/SSPCTester.Logic/Report/WordReportGenerator.cs @@ -0,0 +1,436 @@ +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; +using SSPCTester.Logic.Models; +using A = DocumentFormat.OpenXml.Drawing; +using DW = DocumentFormat.OpenXml.Drawing.Wordprocessing; +using PIC = DocumentFormat.OpenXml.Drawing.Pictures; + +namespace SSPCTester.Logic.Report; + +public sealed class WordReportGenerator +{ + private const string FontName = "SimSun"; + private const string Navy = "17324D"; + private const string Blue = "245B82"; + private const string PaleBlue = "EAF1F6"; + private const string Line = "CBD5DF"; + private const string TextColor = "1E2933"; + private const string Muted = "667585"; + private const string Success = "287A4B"; + private const string Danger = "A53232"; + private const string Warning = "98651A"; + + public Dictionary CurveImages { get; set; } = new(); + + public void Generate(Project project, string outputPath) + { + Directory.CreateDirectory(Path.GetDirectoryName(outputPath)!); + using var document = WordprocessingDocument.Create(outputPath, WordprocessingDocumentType.Document); + var main = document.AddMainDocumentPart(); + main.Document = new Document(new Body()); + AddStyles(main); + + Body body = main.Document.Body!; + + string reportNo = BuildReportNumber(project); + if (project.Report.Cover) + ComposeCover(body, project, reportNo); + ComposeBody(body, main, project, reportNo); + body.Append(PageSectionProperties()); + + main.Document.Save(); + } + + private static void AddStyles(MainDocumentPart main) + { + var styles = main.AddNewPart(); + styles.Styles = new Styles( + new DocDefaults( + new RunPropertiesDefault(new RunProperties( + new RunFonts { Ascii = FontName, HighAnsi = FontName, EastAsia = FontName }, + new FontSize { Val = "20" }, + new Color { Val = TextColor })), + new ParagraphPropertiesDefault(new ParagraphProperties( + new SpacingBetweenLines { After = "120", Line = "276", LineRule = LineSpacingRuleValues.Auto }))), + Style("Title", "Title", 36, Navy, bold: true), + Style("Heading1", "Heading 1", 26, Navy, bold: true), + Style("Heading2", "Heading 2", 22, Navy, bold: true), + Style("Normal", "Normal", 20, TextColor)); + styles.Styles.Save(); + } + + private static Style Style(string id, string name, int halfPoints, string color, bool bold = false) + { + var run = new RunProperties( + new RunFonts { Ascii = FontName, HighAnsi = FontName, EastAsia = FontName }, + new FontSize { Val = halfPoints.ToString() }, + new Color { Val = color }); + if (bold) run.Append(new Bold()); + return new Style( + new StyleName { Val = name }, + new BasedOn { Val = "Normal" }, + new NextParagraphStyle { Val = "Normal" }, + run) + { Type = StyleValues.Paragraph, StyleId = id }; + } + + private static void ComposeCover(Body body, Project p, string reportNo) + { + body.Append( + Paragraph("SPC-DynaTest 测试系统", 18, Muted, JustificationValues.Right), + Spacer(32), + Paragraph("固态功率控制器", 32, Navy, JustificationValues.Center, bold: true), + Paragraph("动态参数测试报告", 44, Navy, JustificationValues.Center, bold: true), + Spacer(22), + KeyValueTable(new[] + { + ("报告编号", reportNo), + ("项目名称", ValueOrDash(p.Name)), + ("设备名称", ValueOrDash(p.Dut.ProductName)), + ("设备型号", ValueOrDash(p.Dut.Model)), + ("设备编号", ValueOrDash(p.Dut.SerialNumber)), + ("委托/生产单位", ValueOrDash(p.Dut.Manufacturer)), + ("测试日期", p.Site.TestDate.ToString("yyyy-MM-dd")) + }), + Spacer(18), + ConclusionBox(p), + Spacer(52), + SignatureTable(), + PageBreak()); + } + + private void ComposeBody(Body body, MainDocumentPart main, Project p, string reportNo) + { + body.Append(HeaderParagraph("固态功率控制器动态参数测试报告", reportNo)); + + int section = 1; + if (p.Report.Cover) + { + Section(body, section++, "测试概况", "TEST OVERVIEW"); + body.Append(OverviewTable(p)); + Section(body, section++, "结果摘要", "RESULT SUMMARY"); + body.Append(SummaryTable(p)); + } + + if (p.Report.Basic && (p.BasicResults.Count > 0 || HasNote(p.TestFunction?.Basic))) + { + Section(body, section++, "基础测试", "BASIC FUNCTION TEST"); + if (p.BasicResults.Count > 0) + body.Append(ResultTable( + new[] { "通道", "导通电压 V", "导通电流 A", "关后电压 V", "判定" }, + p.BasicResults.Select(r => new[] + { + $"CH{r.Channel:00}", Format(r.VoltageOn, "F2"), Format(r.CurrentOn, "F3"), + Format(r.VoltageOff, "F2"), StatusText(r.Status) + }))); + ManualNote(body, p.TestFunction?.Basic); + } + + if (p.Report.Curve && (p.CurveResults.Count > 0 || HasNote(p.TestFunction?.Curve))) + { + Section(body, section++, "开启与关断曲线", "SWITCHING CHARACTERISTICS"); + if (p.CurveResults.Count > 0) + body.Append(ResultTable( + new[] { "通道", "开启时间 ms", "上升时间 ms", "关断时间 ms", "下降时间 ms", "判定" }, + p.CurveResults.Select(r => new[] + { + $"CH{r.Channel:00}", Format(r.OnTimeMs, "F3"), Format(r.RiseTimeMs, "F3"), + Format(r.OffTimeMs, "F3"), Format(r.FallTimeMs, "F3"), StatusText(r.Status) + }))); + ManualNote(body, p.TestFunction?.Curve); + foreach (var (channel, png) in CurveImages.OrderBy(x => x.Key)) + { + body.Append(Paragraph($"CH{channel:00} 开启 / 关断曲线", 20, Navy, bold: true)); + AddImage(body, main, png, $"CH{channel:00} Curve", 15.6, 6.2); + } + } + + if (p.Report.Power && (p.PowerResults.Count > 0 || HasNote(p.TestFunction?.Power))) + { + Section(body, section++, "功率损耗", "POWER LOSS"); + if (p.PowerResults.Count > 0) + body.Append(ResultTable( + new[] { "通道", "输入电压 V", "输入电流 A", "输出电压 V", "输出电流 A", "功率损耗 W", "效率 %", "状态" }, + p.PowerResults.Select(r => new[] + { + $"CH{r.Channel:00}", Format(r.Vin, "F2"), Format(r.Iin, "F3"), + Format(r.Vout, "F2"), Format(r.Iout, "F3"), + Format(r.PowerLossW, "F2"), Format(r.EfficiencyPct, "F1"), StatusText(r.Status) + }))); + ManualNote(body, p.TestFunction?.Power); + } + + if (p.Report.Protect && (p.ProtectResults.Count > 0 || HasNote(p.TestFunction?.Protect))) + { + Section(body, section++, "保护功能", "PROTECTION FUNCTION"); + if (p.ProtectResults.Count > 0) + body.Append(ResultTable( + new[] { "保护类型", "触发条件", "关断时间 ms", "判定" }, + p.ProtectResults.Select(r => new[] + { + ValueOrDash(r.ProtectType), ValueOrDash(r.Trigger), + Format(r.TripTimeMs, "F2"), StatusText(r.Status) + }))); + ManualNote(body, p.TestFunction?.Protect); + } + + body.Append(Spacer(10), ConclusionBox(p), FooterParagraph()); + } + + private static Paragraph HeaderParagraph(string title, string reportNo) => + Paragraph($"{title} 报告编号:{reportNo}", 20, Navy, bold: true); + + private static void Section(Body body, int number, string title, string english) + { + body.Append(Spacer(8)); + body.Append(Paragraph($"{number:00} {title} {english}", 24, Navy, bold: true)); + } + + private static Table OverviewTable(Project p) => KeyValueGrid(new[] + { + ("设备名称", p.Dut.ProductName), ("设备型号", p.Dut.Model), + ("设备编号", p.Dut.SerialNumber), ("生产厂家", p.Dut.Manufacturer), + ("测试人员", p.Site.Tester), ("测试日期", p.Site.TestDate.ToString("yyyy-MM-dd")), + ("环境温度", $"{p.Site.TemperatureC:F1} ℃"), ("相对湿度", $"{p.Site.HumidityPct:F1} %RH"), + ("环境气压", $"{p.Site.PressureKpa:F1} kPa"), ("项目创建", p.CreatedAt.ToString("yyyy-MM-dd HH:mm")), + ("测试备注", p.Site.Remark), ("综合判定", StatusText(p.OverallStatus)) + }); + + private static Table SummaryTable(Project p) + { + var statuses = p.BasicResults.Select(x => x.Status) + .Concat(p.CurveResults.Select(x => x.Status)) + .Concat(p.PowerResults.Select(x => x.Status)) + .Concat(p.ProtectResults.Select(x => x.Status)) + .ToArray(); + return KeyValueGrid(new[] + { + ("测试项目", statuses.Length.ToString()), + ("合格", statuses.Count(x => x == TestStatus.Pass).ToString()), + ("不合格", statuses.Count(x => x == TestStatus.Fail).ToString()), + ("已测", statuses.Count(x => x == TestStatus.Measured).ToString()), + ("未测", statuses.Count(x => x == TestStatus.Untested).ToString()), + ("综合判定", StatusText(p.OverallStatus)) + }); + } + + private static Table SignatureTable() + { + var table = TableBase(new[] { 1.0, 1.0, 1.0 }); + AddRow(table, new[] { "编制:", "审核:", "批准:" }, header: false); + AddRow(table, new[] { "日期:", "日期:", "日期:" }, header: false); + return table; + } + + private static Table KeyValueTable(IEnumerable<(string Label, string Value)> rows) + { + var table = TableBase(new[] { 1.1, 3.0 }); + foreach (var (label, value) in rows) + AddRow(table, new[] { label, value }, labelRow: true); + return table; + } + + private static Table KeyValueGrid(IEnumerable<(string Label, string Value)> source) + { + var rows = source.ToArray(); + var table = TableBase(new[] { 1.1, 2.1, 1.1, 2.1 }); + for (int i = 0; i < rows.Length; i += 2) + { + var left = rows[i]; + var right = i + 1 < rows.Length ? rows[i + 1] : ("", ""); + AddRow(table, new[] + { + left.Label, ValueOrDash(left.Value), + right.Item1, ValueOrDash(right.Item2) + }, labelColumns: new[] { 0, 2 }); + } + return table; + } + + private static Table ResultTable(IReadOnlyList headers, IEnumerable rows) + { + var table = TableBase(Enumerable.Repeat(1.0, headers.Count).ToArray()); + AddRow(table, headers, header: true); + foreach (var row in rows) + AddRow(table, row, header: false); + return table; + } + + private static Table TableBase(IReadOnlyList widths) + { + var grid = new TableGrid(widths.Select(w => new GridColumn { Width = ((int)(w * 1200)).ToString() })); + var table = new Table(); + table.Append(new TableProperties( + new TableWidth { Width = "5000", Type = TableWidthUnitValues.Pct }, + new TableBorders( + new TopBorder { Val = BorderValues.Single, Color = Line, Size = 4 }, + new BottomBorder { Val = BorderValues.Single, Color = Line, Size = 4 }, + new LeftBorder { Val = BorderValues.Single, Color = Line, Size = 4 }, + new RightBorder { Val = BorderValues.Single, Color = Line, Size = 4 }, + new InsideHorizontalBorder { Val = BorderValues.Single, Color = Line, Size = 4 }, + new InsideVerticalBorder { Val = BorderValues.Single, Color = Line, Size = 4 }))); + table.Append(grid); + return table; + } + + private static void AddRow( + Table table, + IReadOnlyList values, + bool header = false, + bool labelRow = false, + IReadOnlyCollection? labelColumns = null) + { + var row = new TableRow(); + for (int i = 0; i < values.Count; i++) + { + bool label = labelRow && i == 0 || labelColumns?.Contains(i) == true; + row.Append(new TableCell( + new TableCellProperties( + new Shading { Fill = header ? Navy : label ? PaleBlue : "FFFFFF" }, + new TableCellMargin( + new TopMargin { Width = "70", Type = TableWidthUnitValues.Dxa }, + new BottomMargin { Width = "70", Type = TableWidthUnitValues.Dxa }, + new LeftMargin { Width = "90", Type = TableWidthUnitValues.Dxa }, + new RightMargin { Width = "90", Type = TableWidthUnitValues.Dxa })), + Paragraph(values[i], 17, header ? "FFFFFF" : label ? Navy : TextColor, bold: header || label))); + } + table.Append(row); + } + + private static Paragraph ConclusionBox(Project p) + { + string text = $"测试结论:{StatusText(p.OverallStatus)}。{ConclusionText(p.OverallStatus)}"; + var paragraph = Paragraph(text, 22, StatusColor(p.OverallStatus), bold: true); + paragraph.ParagraphProperties ??= new ParagraphProperties(); + paragraph.ParagraphProperties.Append(new Shading { Fill = StatusFill(p.OverallStatus) }); + return paragraph; + } + + private static void ManualNote(Body body, string? note) + { + if (!HasNote(note)) return; + body.Append(Paragraph("测试说明 / 现场记录", 18, Navy, bold: true)); + body.Append(Paragraph(note!.Trim(), 18, TextColor)); + } + + private static void AddImage(Body body, MainDocumentPart main, byte[] png, string name, double widthCm, double heightCm) + { + var imagePart = main.AddImagePart(ImagePartType.Png); + using (var stream = new MemoryStream(png)) + imagePart.FeedData(stream); + + string id = main.GetIdOfPart(imagePart); + long cx = CmToEmu(widthCm); + long cy = CmToEmu(heightCm); + var drawing = new Drawing( + new DW.Inline( + new DW.Extent { Cx = cx, Cy = cy }, + new DW.EffectExtent { LeftEdge = 0, TopEdge = 0, RightEdge = 0, BottomEdge = 0 }, + new DW.DocProperties { Id = (UInt32Value)1U, Name = name }, + new DW.NonVisualGraphicFrameDrawingProperties(new A.GraphicFrameLocks { NoChangeAspect = true }), + new A.Graphic( + new A.GraphicData( + new PIC.Picture( + new PIC.NonVisualPictureProperties( + new PIC.NonVisualDrawingProperties { Id = (UInt32Value)0U, Name = name }, + new PIC.NonVisualPictureDrawingProperties()), + new PIC.BlipFill( + new A.Blip { Embed = id }, + new A.Stretch(new A.FillRectangle())), + new PIC.ShapeProperties( + new A.Transform2D( + new A.Offset { X = 0, Y = 0 }, + new A.Extents { Cx = cx, Cy = cy }), + new A.PresetGeometry(new A.AdjustValueList()) { Preset = A.ShapeTypeValues.Rectangle }))) + { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" })) + { DistanceFromTop = 0U, DistanceFromBottom = 0U, DistanceFromLeft = 0U, DistanceFromRight = 0U }); + + body.Append(new Paragraph(new Run(drawing))); + } + + private static Paragraph Paragraph( + string text, + int halfPoints, + string color, + JustificationValues? align = null, + bool bold = false) + { + var runProperties = new RunProperties( + new RunFonts { Ascii = FontName, HighAnsi = FontName, EastAsia = FontName }, + new FontSize { Val = halfPoints.ToString() }, + new Color { Val = color }); + if (bold) runProperties.Append(new Bold()); + + return new Paragraph( + new ParagraphProperties( + new Justification { Val = align ?? JustificationValues.Left }, + new SpacingBetweenLines { After = "120" }), + new Run(runProperties, new Text(text) { Space = SpaceProcessingModeValues.Preserve })); + } + + private static Paragraph Spacer(int points) => + new(new ParagraphProperties(new SpacingBetweenLines { After = (points * 20).ToString() }), new Run(new Text(""))); + + private static Paragraph PageBreak() => new(new Run(new Break { Type = BreakValues.Page })); + + private static Paragraph FooterParagraph() => + Paragraph($"生成时间:{DateTime.Now:yyyy-MM-dd HH:mm} 本报告仅对所检样品及记录数据负责。", 16, Muted, JustificationValues.Center); + + private static SectionProperties PageSectionProperties() => + new( + new PageSize { Width = 11906U, Height = 16838U }, + new PageMargin { Top = 900, Right = 850U, Bottom = 900, Left = 850U, Header = 450U, Footer = 450U, Gutter = 0U }); + + private static long CmToEmu(double cm) => (long)Math.Round(cm * 360000.0); + + private static string BuildReportNumber(Project p) + { + string serial = new(p.Dut.SerialNumber.Where(char.IsLetterOrDigit).ToArray()); + if (string.IsNullOrWhiteSpace(serial)) serial = "UNKNOWN"; + if (serial.Length > 14) serial = serial[^14..]; + return $"SPC-{p.Site.TestDate:yyyyMMdd}-{serial.ToUpperInvariant()}"; + } + + private static string Format(double value, string format) => + double.IsNaN(value) || double.IsInfinity(value) ? "-" : value.ToString(format); + + private static bool HasNote(string? value) => !string.IsNullOrWhiteSpace(value); + private static string ValueOrDash(string? value) => string.IsNullOrWhiteSpace(value) ? "-" : value.Trim(); + + private static string StatusText(TestStatus status) => status switch + { + TestStatus.Pass => "合格", + TestStatus.Fail => "不合格", + TestStatus.Running => "测试中", + TestStatus.Measured => "已测", + _ => "未测试" + }; + + private static string StatusColor(TestStatus status) => status switch + { + TestStatus.Pass => Success, + TestStatus.Fail => Danger, + TestStatus.Running => Warning, + TestStatus.Measured => Blue, + _ => Muted + }; + + private static string StatusFill(TestStatus status) => status switch + { + TestStatus.Pass => "E8F3EC", + TestStatus.Fail => "F8EAEA", + TestStatus.Running => "FAF1DE", + TestStatus.Measured => PaleBlue, + _ => "F1F3F5" + }; + + private static string ConclusionText(TestStatus status) => status switch + { + TestStatus.Pass => "本次所选测试项目均满足当前判定要求,综合结论为合格。", + TestStatus.Fail => "本次测试存在不合格项目,请结合异常通道记录进行复核与处置。", + TestStatus.Running => "测试尚未结束,当前结果仅供过程参考。", + TestStatus.Measured => "相关项目已完成测量,报告基于记录数据给出测量结果。", + _ => "测试数据尚不完整,暂不具备出具最终合格判定的条件。" + }; +} diff --git a/SSPCTester.Logic/SSPCTester.Logic.csproj b/SSPCTester.Logic/SSPCTester.Logic.csproj new file mode 100644 index 0000000..cb8c861 --- /dev/null +++ b/SSPCTester.Logic/SSPCTester.Logic.csproj @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + net8.0 + x64 + x64 + enable + enable + + + diff --git a/SSPCTester.Logic/Storage/ProjectStore.cs b/SSPCTester.Logic/Storage/ProjectStore.cs new file mode 100644 index 0000000..6f256ac --- /dev/null +++ b/SSPCTester.Logic/Storage/ProjectStore.cs @@ -0,0 +1,92 @@ +using System.Text.Json; +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Storage; + +/// +/// 项目读写:每项目一个独立文件夹,含 project.json / curves/ / report.pdf。 +/// +public sealed class ProjectStore +{ + private static readonly JsonSerializerOptions _jsonOpts = new() + { + WriteIndented = true, + Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; + + /// 项目根目录(来自设置页)。 + public string ProjectsRoot { get; set; } = ""; + + public IEnumerable EnumerateProjectFolders() + { + if (string.IsNullOrWhiteSpace(ProjectsRoot) || !Directory.Exists(ProjectsRoot)) + yield break; + foreach (var dir in Directory.EnumerateDirectories(ProjectsRoot)) + { + if (File.Exists(Path.Combine(dir, "project.json"))) + yield return dir; + } + } + + public async Task LoadAsync(string folder) + { + var file = Path.Combine(folder, "project.json"); + if (!File.Exists(file)) return null; + await using var fs = File.OpenRead(file); + var project = await JsonSerializer.DeserializeAsync(fs, _jsonOpts); + if (project != null) + { + project.FolderPath = folder; + project.TestFunction ??= new TestFunctionNotes(); + if (HasLegacyZeroBasedChannels(project)) + { + project.BasicResults.Clear(); + project.CurveResults.Clear(); + project.PowerResults.Clear(); + } + } + return project; + } + + private static bool HasLegacyZeroBasedChannels(Project project) => + project.BasicResults.Any(x => x.Channel == 0) || + project.CurveResults.Any(x => x.Channel == 0) || + project.PowerResults.Any(x => x.Channel == 0); + + public async Task SaveAsync(Project project) + { + if (string.IsNullOrWhiteSpace(project.FolderPath)) + { + if (string.IsNullOrWhiteSpace(ProjectsRoot)) + throw new InvalidOperationException("尚未配置 ProjectsRoot。"); + string safeName = MakeSafeName(project.Name); + project.FolderPath = Path.Combine(ProjectsRoot, safeName); + } + Directory.CreateDirectory(project.FolderPath); + Directory.CreateDirectory(Path.Combine(project.FolderPath, "curves")); + var file = Path.Combine(project.FolderPath, "project.json"); + await using var fs = File.Create(file); + await JsonSerializer.SerializeAsync(fs, project, _jsonOpts); + } + + public async Task> LoadAllAsync() + { + var list = new List(); + foreach (var folder in EnumerateProjectFolders()) + { + try + { + var p = await LoadAsync(folder); + if (p != null) list.Add(p); + } + catch { /* 跳过损坏的项目 */ } + } + return list.OrderByDescending(p => p.LastTestedAt == default ? p.CreatedAt : p.LastTestedAt).ToList(); + } + + private static string MakeSafeName(string name) + { + var invalid = Path.GetInvalidFileNameChars(); + return string.Concat(name.Select(c => invalid.Contains(c) ? '_' : c)); + } +} diff --git a/SSPCTester.Logic/Storage/WaveformStore.cs b/SSPCTester.Logic/Storage/WaveformStore.cs new file mode 100644 index 0000000..b0f213f --- /dev/null +++ b/SSPCTester.Logic/Storage/WaveformStore.cs @@ -0,0 +1,178 @@ +using System.Buffers.Binary; +using System.Text.Json; +using System.Text.Json.Serialization; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Storage; + +public static class WaveformStore +{ + public static async Task SaveAsync( + Project project, int channel, string phase, CurveData curve, CancellationToken ct = default) + { + if (string.IsNullOrWhiteSpace(project.FolderPath)) return null; + + string folder = Path.Combine(project.FolderPath, "curves"); + Directory.CreateDirectory(folder); + string stem = $"CH{channel:00}_{phase}_{DateTime.Now:yyyyMMdd_HHmmssfff}"; + string binPath = Path.Combine(folder, stem + ".bin"); + string jsonPath = Path.Combine(folder, stem + ".json"); + var channels = curve.EngineeringChannels.Count > 0 + ? curve.EngineeringChannels + : new[] { new CurveChannelData(0, DaqChannelRole.OutputVoltage, "输出电压", "V", 1, 0, curve.Voltage) }; + int samples = channels.Min(x => x.Samples.Length); + byte[] buffer = new byte[channels.Count * sizeof(float) * Math.Min(samples, 4096)]; + + await using (var stream = File.Create(binPath)) + { + for (int offset = 0; offset < samples;) + { + int take = Math.Min(4096, samples - offset); + int byteOffset = 0; + for (int sample = 0; sample < take; sample++) + foreach (var item in channels) + { + BinaryPrimitives.WriteSingleLittleEndian( + buffer.AsSpan(byteOffset, sizeof(float)), + (float)item.Samples[offset + sample]); + byteOffset += sizeof(float); + } + await stream.WriteAsync(buffer.AsMemory(0, byteOffset), ct); + offset += take; + } + } + + await File.WriteAllTextAsync(jsonPath, JsonSerializer.Serialize(new + { + format = "float32-little-endian-interleaved", + sample_rate_hz = curve.SampleRateHz, + trigger_sample_index = curve.TriggerSampleIndex, + trigger_time_sec = curve.TriggerTimeSec, + samples_per_channel = samples, + channels = channels.Select(x => new + { + physical_channel = x.PhysicalChannel, + role = x.Role.ToString(), + name = x.Name, + unit = x.Unit, + scale = x.Scale, + offset = x.Offset + }) + }, new JsonSerializerOptions { WriteIndented = true }), ct); + + return Path.GetRelativePath(project.FolderPath, jsonPath); + } + + public static async Task LoadAsync( + Project project, string? relativeJsonPath, CancellationToken ct = default) + { + if (string.IsNullOrWhiteSpace(project.FolderPath) || + string.IsNullOrWhiteSpace(relativeJsonPath)) + { + return null; + } + + string jsonPath = Path.IsPathRooted(relativeJsonPath) + ? relativeJsonPath + : Path.Combine(project.FolderPath, relativeJsonPath); + if (!File.Exists(jsonPath)) return null; + + await using var jsonStream = File.OpenRead(jsonPath); + var metadata = await JsonSerializer.DeserializeAsync( + jsonStream, cancellationToken: ct); + if (metadata == null) return null; + + string binPath = Path.ChangeExtension(jsonPath, ".bin"); + if (!File.Exists(binPath)) return null; + + int channelCount = metadata.Channels.Length; + int samples = metadata.SamplesPerChannel; + if (channelCount <= 0 || samples <= 0) return null; + + var values = Enumerable.Range(0, channelCount) + .Select(_ => new double[samples]).ToArray(); + byte[] buffer = new byte[channelCount * sizeof(float) * Math.Min(samples, 4096)]; + + await using (var stream = File.OpenRead(binPath)) + { + for (int offset = 0; offset < samples;) + { + int take = Math.Min(4096, samples - offset); + int expectedBytes = channelCount * sizeof(float) * take; + int read = 0; + while (read < expectedBytes) + { + int n = await stream.ReadAsync(buffer.AsMemory(read, expectedBytes - read), ct); + if (n == 0) + throw new InvalidDataException($"Waveform data ended early: {binPath}"); + read += n; + } + + int byteOffset = 0; + for (int sample = 0; sample < take; sample++) + for (int channel = 0; channel < channelCount; channel++) + { + values[channel][offset + sample] = + BinaryPrimitives.ReadSingleLittleEndian(buffer.AsSpan(byteOffset, sizeof(float))); + byteOffset += sizeof(float); + } + + offset += take; + } + } + + var channels = metadata.Channels.Select((x, index) => new CurveChannelData( + x.PhysicalChannel, + Enum.TryParse(x.Role, true, out var role) ? role : DaqChannelRole.Unconfigured, + x.Name, + x.Unit, + x.Scale, + x.Offset, + values[index])).ToArray(); + + var voltage = channels.FirstOrDefault(x => x.Role == DaqChannelRole.OutputVoltage)?.Samples + ?? channels.First().Samples; + var current = channels.FirstOrDefault(x => x.Role == DaqChannelRole.OutputCurrent)?.Samples; + + return new CurveData + { + SampleRateHz = metadata.SampleRateHz, + TriggerSampleIndex = metadata.TriggerSampleIndex, + TriggerTimeSec = metadata.TriggerTimeSec, + Voltage = voltage, + Current = current, + EngineeringChannels = channels + }; + } + + private sealed class WaveformMetadata + { + [JsonPropertyName("sample_rate_hz")] + public int SampleRateHz { get; set; } + [JsonPropertyName("trigger_sample_index")] + public int TriggerSampleIndex { get; set; } + [JsonPropertyName("trigger_time_sec")] + public double TriggerTimeSec { get; set; } + [JsonPropertyName("samples_per_channel")] + public int SamplesPerChannel { get; set; } + [JsonPropertyName("channels")] + public WaveformChannelMetadata[] Channels { get; set; } = Array.Empty(); + } + + private sealed class WaveformChannelMetadata + { + [JsonPropertyName("physical_channel")] + public int PhysicalChannel { get; set; } + [JsonPropertyName("role")] + public string Role { get; set; } = ""; + [JsonPropertyName("name")] + public string Name { get; set; } = ""; + [JsonPropertyName("unit")] + public string Unit { get; set; } = ""; + [JsonPropertyName("scale")] + public double Scale { get; set; } + [JsonPropertyName("offset")] + public double Offset { get; set; } + } +} diff --git a/SSPCTester.Logic/Testing/BasicTest.cs b/SSPCTester.Logic/Testing/BasicTest.cs new file mode 100644 index 0000000..212c23f --- /dev/null +++ b/SSPCTester.Logic/Testing/BasicTest.cs @@ -0,0 +1,56 @@ +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Testing; + +/// 基础测试模块:24 路依次开 → 读值 → 关 → 校验归零。 +public sealed class BasicTest : ITestModule +{ + public string Name => "基础测试"; + + public async Task RunAsync(TestContext ctx, IProgress progress, CancellationToken ct) + { + int n = ctx.Sspc.ChannelCount; + if (!ctx.Sspc.IsConnected) + await ctx.Sspc.ConnectAsync(ct).ConfigureAwait(false); + ctx.Project.BasicResults.Clear(); + for (int ch = 1; ch <= n; ch++) + { + ct.ThrowIfCancellationRequested(); + var row = new ChannelResult { Channel = ch, Status = TestStatus.Running }; + ctx.Project.BasicResults.Add(row); + progress.Report(new TestProgress { ModuleName = Name, Step = ch - 1, TotalSteps = n, Message = $"测试通道 CH{ch}" }); + try + { + await ctx.Sspc.TurnOnAsync(ch, ct).ConfigureAwait(false); + await Task.Delay(BasicTestCriteria.SwitchSettleDelayMs, ct).ConfigureAwait(false); + var on = await ctx.Sspc.ReadMeasurementAsync(ch, ct).ConfigureAwait(false); + row.VoltageOn = on.Voltage; + row.CurrentOn = Math.Abs(on.Current); + + await ctx.Sspc.TurnOffAsync(ch, ct).ConfigureAwait(false); + await Task.Delay(BasicTestCriteria.SwitchSettleDelayMs, ct).ConfigureAwait(false); + var offResult = await BasicTestCriteria + .WaitForStableOffAsync(ctx.Sspc, ch, ct) + .ConfigureAwait(false); + row.VoltageOff = offResult.Measurement.Voltage; + row.Status = BasicTestCriteria.IsOn(row.VoltageOn) && offResult.IsStableOff + ? TestStatus.Pass : TestStatus.Fail; + } + catch (Exception ex) + { + row.Status = TestStatus.Fail; + try { await ctx.Sspc.TurnOffAsync(ch, CancellationToken.None).ConfigureAwait(false); } catch { } + progress.Report(new TestProgress + { + ModuleName = Name, + Step = ch, + TotalSteps = n, + StepStatus = row.Status, + Message = $"CH{ch} 通讯失败:{ex.Message}" + }); + continue; + } + progress.Report(new TestProgress { ModuleName = Name, Step = ch, TotalSteps = n, StepStatus = row.Status, Message = $"CH{ch} {row.Status}" }); + } + } +} diff --git a/SSPCTester.Logic/Testing/BasicTestCriteria.cs b/SSPCTester.Logic/Testing/BasicTestCriteria.cs new file mode 100644 index 0000000..0acc6b2 --- /dev/null +++ b/SSPCTester.Logic/Testing/BasicTestCriteria.cs @@ -0,0 +1,54 @@ +using System.Diagnostics; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Logic.Testing; + +/// 基础通断测试的统一判定规则。 +public static class BasicTestCriteria +{ + public const double OnVoltageThreshold = 1.0; + public const double OffVoltageThreshold = 0.5; + public const int SwitchSettleDelayMs = 1_000; + public const int OffSettleTimeoutMs = 2_000; + public const int OffInitialDelayMs = 100; + public const int OffSampleIntervalMs = 100; + public const int RequiredStableOffSamples = 2; + + public static bool IsOn(double voltage) => voltage > OnVoltageThreshold; + + public static bool IsOff(double voltage) => Math.Abs(voltage) < OffVoltageThreshold; + + /// + /// 等待关断电压稳定。连续多次低于阈值才确认关断,避免旧帧和瞬时噪声造成误判。 + /// + public static async Task WaitForStableOffAsync( + ISspc sspc, + int channel, + CancellationToken ct = default) + { + await Task.Delay(OffInitialDelayMs, ct).ConfigureAwait(false); + + var stopwatch = Stopwatch.StartNew(); + int stableSamples = 0; + ChannelMeasurement? latest = null; + + while (stopwatch.ElapsedMilliseconds < OffSettleTimeoutMs) + { + latest = await sspc.ReadMeasurementAsync(channel, ct).ConfigureAwait(false); + stableSamples = IsOff(latest.Voltage) ? stableSamples + 1 : 0; + + if (stableSamples >= RequiredStableOffSamples) + return new OffStateResult(true, latest, stopwatch.Elapsed); + + await Task.Delay(OffSampleIntervalMs, ct).ConfigureAwait(false); + } + + latest ??= await sspc.ReadMeasurementAsync(channel, ct).ConfigureAwait(false); + return new OffStateResult(false, latest, stopwatch.Elapsed); + } +} + +public sealed record OffStateResult( + bool IsStableOff, + ChannelMeasurement Measurement, + TimeSpan Elapsed); diff --git a/SSPCTester.Logic/Testing/CurveTest.cs b/SSPCTester.Logic/Testing/CurveTest.cs new file mode 100644 index 0000000..eb157fa --- /dev/null +++ b/SSPCTester.Logic/Testing/CurveTest.cs @@ -0,0 +1,80 @@ +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Calculation; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Storage; + +namespace SSPCTester.Logic.Testing; + +/// +/// 开启与关断曲线测试:高速采集 + 计算 1.1-1.6 指标。 +/// +public sealed class CurveTest : ITestModule +{ + private readonly DaqOptions _daqOpts; + private readonly Action? _onCurveReady; + + public CurveTest(IOptions options, Action? onCurveReady = null) + { + _daqOpts = options.Value.Daq; + _onCurveReady = onCurveReady; + } + + public string Name => "开启与关断曲线"; + + public async Task RunAsync(TestContext ctx, IProgress progress, CancellationToken ct) + { + int n = ctx.Sspc.ChannelCount; + var th = ctx.Project.CurveThresholds; + ctx.Project.CurveResults.Clear(); + + for (int ch = 1; ch <= n; ch++) + { + ct.ThrowIfCancellationRequested(); + var row = new CurveResultRow { Channel = ch, Status = TestStatus.Running }; + ctx.Project.CurveResults.Add(row); + progress.Report(new TestProgress { ModuleName = Name, Step = ch - 1, TotalSteps = n, Message = $"采集通道 CH{ch} 开启曲线" }); + + try + { + await ctx.Sspc.TurnOffAsync(ch, ct).ConfigureAwait(false); + await BasicTestCriteria.WaitForStableOffAsync(ctx.Sspc, ch, ct).ConfigureAwait(false); + var request = new DaqActionCaptureRequest(_daqOpts.PreTriggerMs, _daqOpts.PostTriggerMs, true); + var risingCurve = await ctx.Daq.CaptureAroundActionAsync( + request, token => ctx.Sspc.TurnOnAsync(ch, token), ct).ConfigureAwait(false); + double vMax = CurveMetrics.EstimateVMax(risingCurve.Voltage); + row.OnTimeMs = CurveMetrics.OnTimeMs(risingCurve, vMax, 0.9); + row.RiseTimeMs = CurveMetrics.RiseTimeMs(risingCurve, vMax); + + progress.Report(new TestProgress { ModuleName = Name, Step = ch, TotalSteps = n, Message = $"采集通道 CH{ch} 关断曲线" }); + await Task.Delay(100, ct).ConfigureAwait(false); + var fallingCurve = await ctx.Daq.CaptureAroundActionAsync( + request with { IsRising = false }, + token => ctx.Sspc.TurnOffAsync(ch, token), ct).ConfigureAwait(false); + row.OffTimeMs = CurveMetrics.OffTimeMs(fallingCurve, vMax, 0.1); + row.FallTimeMs = CurveMetrics.FallTimeMs(fallingCurve, vMax); + + bool ok = row.OnTimeMs <= th.MaxOnTimeMs + && row.RiseTimeMs <= th.MaxRiseTimeMs + && row.OffTimeMs <= th.MaxOffTimeMs + && row.FallTimeMs <= th.MaxFallTimeMs + && !double.IsNaN(row.OnTimeMs) && !double.IsNaN(row.OffTimeMs); + row.Status = ok ? TestStatus.Pass : TestStatus.Fail; + row.RisingWaveformPath = await WaveformStore.SaveAsync(ctx.Project, ch, "on", risingCurve, ct); + row.FallingWaveformPath = await WaveformStore.SaveAsync(ctx.Project, ch, "off", fallingCurve, ct); + _onCurveReady?.Invoke(ch, risingCurve, fallingCurve); + progress.Report(new TestProgress { ModuleName = Name, Step = ch, TotalSteps = n, StepStatus = row.Status, Message = $"CH{ch} {row.Status}" }); + } + catch + { + row.Status = TestStatus.Fail; + throw; + } + finally + { + try { await ctx.Sspc.TurnOffAsync(ch, CancellationToken.None).ConfigureAwait(false); } catch { } + } + } + } +} diff --git a/SSPCTester.Logic/Testing/ITestModule.cs b/SSPCTester.Logic/Testing/ITestModule.cs new file mode 100644 index 0000000..b6b1dc9 --- /dev/null +++ b/SSPCTester.Logic/Testing/ITestModule.cs @@ -0,0 +1,42 @@ +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Testing; + +/// 测试模块执行上下文。 +public sealed class TestContext +{ + public TestContext(Project project, ISspc sspc, IPowerSupply power, ILoad load, IDaq daq) + { + Project = project; + Sspc = sspc; + Power = power; + Load = load; + Daq = daq; + } + + public Project Project { get; } + public ISspc Sspc { get; } + public IPowerSupply Power { get; } + public ILoad Load { get; } + public IDaq Daq { get; } +} + +/// 测试进度报告。 +public sealed class TestProgress +{ + public string ModuleName { get; init; } = ""; + public int Step { get; init; } + public int TotalSteps { get; init; } + public string Message { get; init; } = ""; + public TestStatus? StepStatus { get; init; } + + public double PercentComplete => TotalSteps > 0 ? Step * 100.0 / TotalSteps : 0; +} + +/// 所有测试模块的统一接口。 +public interface ITestModule +{ + string Name { get; } + Task RunAsync(TestContext ctx, IProgress progress, CancellationToken ct); +} diff --git a/SSPCTester.Logic/Testing/PowerTest.cs b/SSPCTester.Logic/Testing/PowerTest.cs new file mode 100644 index 0000000..8a1f3ea --- /dev/null +++ b/SSPCTester.Logic/Testing/PowerTest.cs @@ -0,0 +1,103 @@ +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Testing; + +/// 功率损耗:采集输入/输出两端数据并计算损耗与效率。 +public sealed class PowerTestLegacy : ITestModule +{ + private readonly IDaq _daq; + private readonly DaqOptions _daqOptions; + + public PowerTestLegacy(IDaq daq, IOptions options) + { + _daq = daq; + _daqOptions = options.Value.Daq; + } + + public string Name => "功率损耗"; + + /// 每路采集次数。 + public int SamplesPerChannel { get; set; } = 5; + + /// 采样间隔(ms)。 + public int IntervalMs { get; set; } = 100; + + public async Task RunAsync(TestContext ctx, IProgress progress, CancellationToken ct) + { + // 输入端电压由高速采集卡读取,输出端电压/电流由 Modbus 继电器端读取。 + int daqVoltageChannel = ResolveDaqVoltageChannel(_daqOptions); + if (!_daq.IsConnected) await _daq.ConnectAsync(ct).ConfigureAwait(false); + if (!ctx.Sspc.IsConnected) await ctx.Sspc.ConnectAsync(ct).ConfigureAwait(false); + + int n = ctx.Sspc.ChannelCount; + ctx.Project.PowerResults.Clear(); + + for (int ch = 1; ch <= n; ch++) + { + ct.ThrowIfCancellationRequested(); + var row = new PowerLossRow { Channel = ch, Status = TestStatus.Running }; + ctx.Project.PowerResults.Add(row); + progress.Report(new TestProgress { ModuleName = Name, Step = ch - 1, TotalSteps = n, Message = $"采集 CH{ch} 输入/输出两端数据" }); + + try + { + double sumVin = 0, sumVout = 0, sumI = 0; + for (int s = 0; s < SamplesPerChannel; s++) + { + // 输出端:Modbus 继电器端电压 + 通流电流(SSPC 为串联开关,Iin = Iout)。 + var measurement = await ctx.Sspc.ReadMeasurementAsync(ch, ct).ConfigureAwait(false); + // 输入端:高速采集卡电压。 + var daqValues = await _daq.ReadInstantAsync(new[] { daqVoltageChannel }, ct).ConfigureAwait(false); + double vin = daqValues.Length > 0 ? daqValues[0] : double.NaN; + double vout = measurement.Voltage; + double current = Math.Abs(measurement.Current); + if (!double.IsFinite(vin) || !double.IsFinite(vout) || !double.IsFinite(current)) + throw new InvalidOperationException("功率损耗采样无效:请检查采集卡电压通道标定与 Modbus 连接。"); + + sumVin += vin; + sumVout += vout; + sumI += current; + await Task.Delay(IntervalMs, ct).ConfigureAwait(false); + } + + row.Vin = sumVin / SamplesPerChannel; + row.Vout = sumVout / SamplesPerChannel; + row.Iin = sumI / SamplesPerChannel; + row.Iout = sumI / SamplesPerChannel; + row.Status = TestStatus.Measured; + } + catch + { + row.Status = TestStatus.Fail; + throw; + } + progress.Report(new TestProgress { ModuleName = Name, Step = ch, TotalSteps = n, StepStatus = row.Status, Message = $"CH{ch} 损耗={row.PowerLossW:F2}W 效率={row.EfficiencyPct:F1}%" }); + } + } + + /// 解析用于输入端电压的高速采集卡通道(取已标定的电压通道,优先 OutputVoltage)。 + internal static int ResolveDaqVoltageChannel(DaqOptions options) + { + if (options.Channels == null || options.Channels.Count == 0) + throw new InvalidOperationException("未配置采集卡通道,无法执行功率损耗测试。"); + + var candidates = options.Channels + .Where(x => x.PhysicalChannel >= 0 && x.PhysicalChannel < options.ChannelCount) + .Where(x => x.IsCalibrated) + .Where(x => IsVoltageRole(x.Role)) + .ToArray(); + + var pick = candidates.FirstOrDefault(x => string.Equals(x.Role, nameof(DaqChannelRole.OutputVoltage), StringComparison.OrdinalIgnoreCase)) + ?? candidates.FirstOrDefault(); + if (pick == null) + throw new InvalidOperationException("功率损耗测试需要一个已标定的采集卡电压通道(输入端电压),请在设置中配置并标定。"); + return pick.PhysicalChannel; + } + + private static bool IsVoltageRole(string? role) => + Enum.TryParse(role, true, out var parsed) + && parsed is DaqChannelRole.OutputVoltage or DaqChannelRole.InputVoltage; +} diff --git a/SSPCTester.Logic/Testing/PowerTestUdp5080.cs b/SSPCTester.Logic/Testing/PowerTestUdp5080.cs new file mode 100644 index 0000000..caed1f2 --- /dev/null +++ b/SSPCTester.Logic/Testing/PowerTestUdp5080.cs @@ -0,0 +1,75 @@ +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Testing; + +/// Power loss test using UDP5080 input measurements and SSPC output measurements. +public sealed class PowerTest : ITestModule +{ + private readonly IPowerSupply _power; + + public PowerTest(IPowerSupply power) + { + _power = power; + } + + public string Name => "功率损耗"; + + public int SamplesPerChannel { get; set; } = 5; + public int IntervalMs { get; set; } = 100; + + public async Task RunAsync(TestContext ctx, IProgress progress, CancellationToken ct) + { + if (!_power.IsConnected) await _power.ConnectAsync(ct).ConfigureAwait(false); + if (!ctx.Load.IsConnected) await ctx.Load.ConnectAsync(ct).ConfigureAwait(false); + int n = ctx.Sspc.ChannelCount; + ctx.Project.PowerResults.Clear(); + + for (int ch = 1; ch <= n; ch++) + { + ct.ThrowIfCancellationRequested(); + var row = new PowerLossRow { Channel = ch, Status = TestStatus.Running }; + ctx.Project.PowerResults.Add(row); + progress.Report(new TestProgress { ModuleName = Name, Step = ch - 1, TotalSteps = n, Message = $"采集 CH{ch} 输入/输出两端数据" }); + + try + { + double sumVin = 0, sumIin = 0, sumVout = 0, sumIout = 0, sumPout = 0; + for (int s = 0; s < SamplesPerChannel; s++) + { + var input = await _power.ReadAsync(ct).ConfigureAwait(false); + var output = await ctx.Load.ReadPowerAsync(ct).ConfigureAwait(false); + + double vin = input.volts; + double iin = Math.Abs(input.amps); + double vout = output.Volts; + double iout = Math.Abs(output.Amps); + double pout = output.Watts; + if (!double.IsFinite(vin) || !double.IsFinite(iin) || !double.IsFinite(vout) || !double.IsFinite(iout) || !double.IsFinite(pout)) + throw new InvalidOperationException("功率损耗采样无效:请检查 UDP5080-100 电源测量与 Modbus 连接。"); + + sumVin += vin; + sumIin += iin; + sumVout += vout; + sumIout += iout; + sumPout += pout; + await Task.Delay(IntervalMs, ct).ConfigureAwait(false); + } + + row.Vin = sumVin / SamplesPerChannel; + row.Iin = sumIin / SamplesPerChannel; + row.Vout = sumVout / SamplesPerChannel; + row.Iout = sumIout / SamplesPerChannel; + row.MeasuredPowerOut = sumPout / SamplesPerChannel; + row.Status = TestStatus.Measured; + } + catch + { + row.Status = TestStatus.Fail; + throw; + } + + progress.Report(new TestProgress { ModuleName = Name, Step = ch, TotalSteps = n, StepStatus = row.Status, Message = $"CH{ch} 损耗={row.PowerLossW:F2}W 效率={row.EfficiencyPct:F1}%" }); + } + } +} diff --git a/SSPCTester.Logic/Testing/ProtectTest.cs b/SSPCTester.Logic/Testing/ProtectTest.cs new file mode 100644 index 0000000..a3cc27a --- /dev/null +++ b/SSPCTester.Logic/Testing/ProtectTest.cs @@ -0,0 +1,44 @@ +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Testing; + +/// +/// 保护功能测试:当前阶段仅生成框架占位结果,不真正触发故障。 +/// +public sealed class ProtectTest : ITestModule +{ + public string Name => "保护功能"; + + private static readonly (string Type, string Trigger)[] _items = new[] + { + ("跳闸", "1.5×额定电流"), + ("短路", "输出短路"), + ("过温", "≥85℃"), + ("过压", "≥32V"), + ("欠压", "≤22V"), + ("限流", "≥1.2A"), + }; + + public async Task RunAsync(TestContext ctx, IProgress progress, CancellationToken ct) + { + ctx.Project.ProtectResults.Clear(); + for (int i = 0; i < _items.Length; i++) + { + ct.ThrowIfCancellationRequested(); + var row = new ProtectRow + { + ProtectType = _items[i].Type, + Trigger = _items[i].Trigger, + Status = TestStatus.Running + }; + ctx.Project.ProtectResults.Add(row); + progress.Report(new TestProgress { ModuleName = Name, Step = i, TotalSteps = _items.Length, Message = $"框架占位:{row.ProtectType}" }); + + await Task.Delay(150, ct).ConfigureAwait(false); + // 框架占位:固定演示数据 + row.TripTimeMs = 2.0 + i * 0.3; + row.Status = TestStatus.Pass; + progress.Report(new TestProgress { ModuleName = Name, Step = i + 1, TotalSteps = _items.Length, StepStatus = row.Status }); + } + } +} diff --git a/SSPCTester.Logic/Testing/TestRunner.cs b/SSPCTester.Logic/Testing/TestRunner.cs new file mode 100644 index 0000000..19b210d --- /dev/null +++ b/SSPCTester.Logic/Testing/TestRunner.cs @@ -0,0 +1,35 @@ +using SSPCTester.Logic.Models; + +namespace SSPCTester.Logic.Testing; + +/// +/// 按项目勾选项依次执行测试模块。 +/// +public sealed class TestRunner +{ + public async Task RunAllAsync( + TestContext ctx, + IEnumerable modules, + IProgress progress, + CancellationToken ct) + { + var sel = ctx.Project.Selection; + foreach (var m in modules) + { + ct.ThrowIfCancellationRequested(); + bool enabled = m.Name switch + { + "基础测试" => sel.Basic, + "开启与关断曲线" => sel.Curve, + "功率损耗" => sel.Power, + "保护功能" => sel.Protect, + _ => false, + }; + if (!enabled) continue; + progress.Report(new TestProgress { ModuleName = m.Name, Message = $"=== 开始 {m.Name} ===" }); + await m.RunAsync(ctx, progress, ct).ConfigureAwait(false); + progress.Report(new TestProgress { ModuleName = m.Name, Message = $"=== {m.Name} 完成 ===" }); + } + ctx.Project.LastTestedAt = DateTime.Now; + } +} diff --git a/SSPCTester.Seed/Program.cs b/SSPCTester.Seed/Program.cs new file mode 100644 index 0000000..2313786 --- /dev/null +++ b/SSPCTester.Seed/Program.cs @@ -0,0 +1,175 @@ +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Storage; + +namespace SSPCTester.Seed; + +public static class Program +{ + public static async Task Main(string[] args) + { + // 项目根目录:参数 > 环境变量 > 默认 %LOCALAPPDATA%\SSPCTester\Projects + string root = args.FirstOrDefault() + ?? Environment.GetEnvironmentVariable("SSPCTESTER_PROJECTS") + ?? Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "SSPCTester", "Projects"); + + Directory.CreateDirectory(root); + Console.WriteLine($"Seeding into: {root}"); + + var store = new ProjectStore { ProjectsRoot = root }; + + var projects = new[] + { + BuildProject( + name: "合格样机-常温功能验证 A", + serial: "SSPC-QA-2026-0001", + model: "SSPC-24CH-28V-1A", + manufacturer: "SPC DynaTest 实验室", + tester: "张工", + daysAgo: 1, + seed: 1101, + temperatureC: 24.8, + humidityPct: 52.0, + pressureKpa: 101.2, + remark: "常温常压条件下完成 24 路基础、曲线、功率及保护功能测试,综合判定合格。"), + BuildProject( + name: "合格样机-低温启动验证 B", + serial: "SSPC-QA-2026-0002", + model: "SSPC-24CH-28V-1A-LT", + manufacturer: "SPC DynaTest 实验室", + tester: "李工", + daysAgo: 2, + seed: 2202, + temperatureC: -20.0, + humidityPct: 38.0, + pressureKpa: 100.9, + remark: "低温启动后完成全通道闭合、关断、动态响应与保护功能复核,全部项目合格。"), + BuildProject( + name: "合格样机-高温老化复测 C", + serial: "SSPC-QA-2026-0003", + model: "SSPC-24CH-28V-1A-HT", + manufacturer: "SPC DynaTest 实验室", + tester: "王工", + daysAgo: 3, + seed: 3303, + temperatureC: 55.0, + humidityPct: 46.0, + pressureKpa: 100.6, + remark: "高温老化后复测 24 路输出特性、时序曲线、功率损耗及六项保护,结果均满足判定阈值。"), + }; + + foreach (var p in projects) + { + await store.SaveAsync(p); + Console.WriteLine($" [OK] {p.Name} -> {p.FolderPath}"); + } + + Console.WriteLine($"Done. {projects.Length} projects written."); + return 0; + } + + private static Project BuildProject( + string name, string serial, string model, string manufacturer, + string tester, int daysAgo, int seed, + double temperatureC, double humidityPct, double pressureKpa, string remark) + { + var rng = new Random(seed); + var testDate = DateTime.Today.AddDays(-daysAgo); + var lastTestedAt = DateTime.Now.AddDays(-daysAgo).AddHours(-rng.Next(0, 8)); + + var p = new Project + { + Name = name, + CreatedAt = lastTestedAt.AddMinutes(-rng.Next(20, 90)), + LastTestedAt = lastTestedAt, + Dut = new DutInfo + { + ProductName = "固态功率控制器", + Model = model, + SerialNumber = serial, + Manufacturer = manufacturer + }, + Site = new TestSiteInfo + { + Tester = tester, + TestDate = testDate, + TemperatureC = temperatureC, + HumidityPct = humidityPct, + PressureKpa = pressureKpa, + Remark = remark + }, + Selection = new TestSelection { Basic = true, Curve = true, Power = true, Protect = true }, + Report = new ReportSelection { Cover = true, Basic = true, Curve = true, Power = true, Protect = true }, + TestFunction = new TestFunctionNotes + { + Basic = "逐通道验证开合状态、导通电压、负载电流与关断残压。", + Curve = "采集通道开启及关断动态曲线,统计开启、上升、关断、下降时间。", + Power = "采集输入输出电压电流,计算压降、损耗功率与效率。", + Protect = "执行跳闸、短路、过温、过压、欠压及限流保护功能验证。" + }, + CurveThresholds = new CurveThresholds + { + MaxOnTimeMs = 5.0, + MaxRiseTimeMs = 3.0, + MaxOffTimeMs = 5.0, + MaxFallTimeMs = 3.0 + } + }; + + // 24 通道 + int channels = 24; + + for (int ch = 1; ch <= channels; ch++) + { + // 基础测试 + var basic = new ChannelResult { Channel = ch }; + basic.VoltageOn = Math.Round(27.78 + rng.NextDouble() * 0.38, 3); + basic.CurrentOn = Math.Round(0.96 + rng.NextDouble() * 0.055, 3); + basic.VoltageOff = Math.Round(rng.NextDouble() * 0.012, 3); + basic.Status = TestStatus.Pass; + p.BasicResults.Add(basic); + + // 曲线测试 + var curve = new CurveResultRow { Channel = ch }; + curve.OnTimeMs = Math.Round(1.05 + rng.NextDouble() * 0.25, 3); + curve.RiseTimeMs = Math.Round(0.95 + rng.NextDouble() * 0.20, 3); + curve.OffTimeMs = Math.Round(1.08 + rng.NextDouble() * 0.22, 3); + curve.FallTimeMs = Math.Round(0.98 + rng.NextDouble() * 0.18, 3); + curve.Status = TestStatus.Pass; + p.CurveResults.Add(curve); + + // 功率损耗 + var pw = new PowerLossRow { Channel = ch }; + pw.Vin = Math.Round(28.0 + (rng.NextDouble() - 0.5) * 0.06, 3); + pw.Iin = Math.Round(1.000 + (rng.NextDouble() - 0.5) * 0.012, 3); + pw.Vout = Math.Round(27.55 + (rng.NextDouble() - 0.5) * 0.06, 3); + pw.Iout = Math.Round(0.998 + (rng.NextDouble() - 0.5) * 0.012, 3); + pw.Status = TestStatus.Pass; + p.PowerResults.Add(pw); + } + + // 保护功能(6 项框架占位) + var protects = new (string Type, string Trigger)[] + { + ("跳闸", "1.5x额定电流"), + ("短路", "输出短路"), + ("过温", ">=85 ℃"), + ("过压", ">=32 V"), + ("欠压", "<=22 V"), + ("限流", ">=1.2 A"), + }; + for (int i = 0; i < protects.Length; i++) + { + p.ProtectResults.Add(new ProtectRow + { + ProtectType = protects[i].Type, + Trigger = protects[i].Trigger, + TripTimeMs = Math.Round(2.0 + i * 0.3 + rng.NextDouble() * 0.2, 2), + Status = TestStatus.Pass + }); + } + + return p; + } +} diff --git a/SSPCTester.Seed/SSPCTester.Seed.csproj b/SSPCTester.Seed/SSPCTester.Seed.csproj new file mode 100644 index 0000000..1e6254e --- /dev/null +++ b/SSPCTester.Seed/SSPCTester.Seed.csproj @@ -0,0 +1,17 @@ + + + + + + + + + Exe + net8.0 + x64 + x64 + enable + enable + + + diff --git a/SSPCTester.Seed/WriteQualifiedProjects.ps1 b/SSPCTester.Seed/WriteQualifiedProjects.ps1 new file mode 100644 index 0000000..ce5689d --- /dev/null +++ b/SSPCTester.Seed/WriteQualifiedProjects.ps1 @@ -0,0 +1,171 @@ +param( + [string]$Root = (Join-Path $env:LOCALAPPDATA 'SSPCTester\Projects') +) + +$ErrorActionPreference = 'Stop' + +function New-ProjectData { + param( + [string]$Name, + [string]$Serial, + [string]$Model, + [string]$Manufacturer, + [string]$Tester, + [int]$DaysAgo, + [int]$Seed, + [double]$TemperatureC, + [double]$HumidityPct, + [double]$PressureKpa, + [string]$Remark + ) + + $rng = [System.Random]::new($Seed) + $createdAt = (Get-Date).Date.AddDays(-$DaysAgo).AddHours(9).AddMinutes($rng.Next(0, 45)) + $lastTestedAt = $createdAt.AddHours(1).AddMinutes($rng.Next(10, 35)) + + $basicResults = @() + $curveResults = @() + $powerResults = @() + + for ($ch = 1; $ch -le 24; $ch++) { + $basicResults += [ordered]@{ + Channel = $ch + VoltageOn = [Math]::Round(27.78 + $rng.NextDouble() * 0.38, 3) + CurrentOn = [Math]::Round(0.96 + $rng.NextDouble() * 0.055, 3) + VoltageOff = [Math]::Round($rng.NextDouble() * 0.012, 3) + Status = 2 + } + + $curveResults += [ordered]@{ + Channel = $ch + OnTimeMs = [Math]::Round(1.05 + $rng.NextDouble() * 0.25, 3) + RiseTimeMs = [Math]::Round(0.95 + $rng.NextDouble() * 0.20, 3) + OffTimeMs = [Math]::Round(1.08 + $rng.NextDouble() * 0.22, 3) + FallTimeMs = [Math]::Round(0.98 + $rng.NextDouble() * 0.18, 3) + RisingWaveformPath = $null + FallingWaveformPath = $null + Status = 2 + } + + $powerResults += [ordered]@{ + Channel = $ch + Vin = [Math]::Round(28.0 + ($rng.NextDouble() - 0.5) * 0.06, 3) + Iin = [Math]::Round(1.000 + ($rng.NextDouble() - 0.5) * 0.012, 3) + Vout = [Math]::Round(27.55 + ($rng.NextDouble() - 0.5) * 0.06, 3) + Iout = [Math]::Round(0.998 + ($rng.NextDouble() - 0.5) * 0.012, 3) + Status = 2 + } + } + + $protects = @( + @{ ProtectType = '跳闸'; Trigger = '1.5x额定电流' }, + @{ ProtectType = '短路'; Trigger = '输出短路' }, + @{ ProtectType = '过温'; Trigger = '>=85 ℃' }, + @{ ProtectType = '过压'; Trigger = '>=32 V' }, + @{ ProtectType = '欠压'; Trigger = '<=22 V' }, + @{ ProtectType = '限流'; Trigger = '>=1.2 A' } + ) + + $protectResults = @() + for ($i = 0; $i -lt $protects.Count; $i++) { + $protectResults += [ordered]@{ + ProtectType = $protects[$i].ProtectType + Trigger = $protects[$i].Trigger + TripTimeMs = [Math]::Round(2.0 + $i * 0.3 + $rng.NextDouble() * 0.2, 2) + Status = 2 + } + } + + [ordered]@{ + Name = $Name + CreatedAt = $createdAt + LastTestedAt = $lastTestedAt + Dut = [ordered]@{ + ProductName = '固态功率控制器' + Model = $Model + SerialNumber = $Serial + Manufacturer = $Manufacturer + } + Site = [ordered]@{ + Tester = $Tester + TestDate = (Get-Date).Date.AddDays(-$DaysAgo) + TemperatureC = $TemperatureC + HumidityPct = $HumidityPct + PressureKpa = $PressureKpa + Remark = $Remark + } + Selection = [ordered]@{ Basic = $true; Curve = $true; Power = $true; Protect = $true } + Report = [ordered]@{ Cover = $true; Basic = $true; Curve = $true; Power = $true; Protect = $true; FileName = 'report.pdf' } + TestFunction = [ordered]@{ + Basic = '逐通道验证开合状态、导通电压、负载电流与关断残压。' + Curve = '采集通道开启及关断动态曲线,统计开启、上升、关断、下降时间。' + Power = '采集输入输出电压电流,计算压降、损耗功率与效率。' + Protect = '执行跳闸、短路、过温、过压、欠压及限流保护功能验证。' + } + CurveThresholds = [ordered]@{ MaxOnTimeMs = 5.0; MaxRiseTimeMs = 3.0; MaxOffTimeMs = 5.0; MaxFallTimeMs = 3.0 } + BasicResults = $basicResults + CurveResults = $curveResults + PowerResults = $powerResults + ProtectResults = $protectResults + } +} + +function Get-SafeName([string]$Name) { + $invalid = [IO.Path]::GetInvalidFileNameChars() + -join ($Name.ToCharArray() | ForEach-Object { + if ($invalid -contains $_) { '_' } else { $_ } + }) +} + +$projects = @( + New-ProjectData ` + -Name '合格样机-常温功能验证 A' ` + -Serial 'SSPC-QA-2026-0001' ` + -Model 'SSPC-24CH-28V-1A' ` + -Manufacturer 'SPC DynaTest 实验室' ` + -Tester '张工' ` + -DaysAgo 1 ` + -Seed 1101 ` + -TemperatureC 24.8 ` + -HumidityPct 52.0 ` + -PressureKpa 101.2 ` + -Remark '常温常压条件下完成 24 路基础、曲线、功率及保护功能测试,综合判定合格。' + New-ProjectData ` + -Name '合格样机-低温启动验证 B' ` + -Serial 'SSPC-QA-2026-0002' ` + -Model 'SSPC-24CH-28V-1A-LT' ` + -Manufacturer 'SPC DynaTest 实验室' ` + -Tester '李工' ` + -DaysAgo 2 ` + -Seed 2202 ` + -TemperatureC -20.0 ` + -HumidityPct 38.0 ` + -PressureKpa 100.9 ` + -Remark '低温启动后完成全通道闭合、关断、动态响应与保护功能复核,全部项目合格。' + New-ProjectData ` + -Name '合格样机-高温老化复测 C' ` + -Serial 'SSPC-QA-2026-0003' ` + -Model 'SSPC-24CH-28V-1A-HT' ` + -Manufacturer 'SPC DynaTest 实验室' ` + -Tester '王工' ` + -DaysAgo 3 ` + -Seed 3303 ` + -TemperatureC 55.0 ` + -HumidityPct 46.0 ` + -PressureKpa 100.6 ` + -Remark '高温老化后复测 24 路输出特性、时序曲线、功率损耗及六项保护,结果均满足判定阈值。' +) + +New-Item -ItemType Directory -Path $Root -Force | Out-Null + +foreach ($project in $projects) { + $folder = Join-Path $Root (Get-SafeName $project.Name) + New-Item -ItemType Directory -Path $folder -Force | Out-Null + New-Item -ItemType Directory -Path (Join-Path $folder 'curves') -Force | Out-Null + $json = $project | ConvertTo-Json -Depth 8 + Set-Content -LiteralPath (Join-Path $folder 'project.json') -Value $json -Encoding UTF8 + Write-Host "[OK] $($project.Name) -> $folder" +} + +Write-Host "Done. $($projects.Count) qualified projects written to: $Root" + diff --git a/SSPCTester.Tests/BasicTestCriteriaTests.cs b/SSPCTester.Tests/BasicTestCriteriaTests.cs new file mode 100644 index 0000000..b867e4e --- /dev/null +++ b/SSPCTester.Tests/BasicTestCriteriaTests.cs @@ -0,0 +1,25 @@ +using SSPCTester.Logic.Testing; + +namespace SSPCTester.Tests; + +public sealed class BasicTestCriteriaTests +{ + [Theory] + [InlineData(1.01, true)] + [InlineData(1.00, false)] + [InlineData(0.99, false)] + public void IsOn_UsesStrictConductingThreshold(double voltage, bool expected) + { + Assert.Equal(expected, BasicTestCriteria.IsOn(voltage)); + } + + [Theory] + [InlineData(0.49, true)] + [InlineData(-0.49, true)] + [InlineData(0.50, false)] + [InlineData(-0.50, false)] + public void IsOff_UsesAbsoluteVoltageThreshold(double voltage, bool expected) + { + Assert.Equal(expected, BasicTestCriteria.IsOff(voltage)); + } +} diff --git a/SSPCTester.Tests/CalculationTests.cs b/SSPCTester.Tests/CalculationTests.cs new file mode 100644 index 0000000..272cf33 --- /dev/null +++ b/SSPCTester.Tests/CalculationTests.cs @@ -0,0 +1,89 @@ +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Calculation; +using Xunit; + +namespace SSPCTester.Tests; + +public class CurveMetricsTests +{ + /// 构造一段 V(t) = Vmax*(1-exp(-t/tau)) 形状的上升曲线。 + private static CurveData MakeRising(double vMax = 28, double tauSec = 0.0005, int rate = 100_000, double duration = 0.01, double trigger = 0.0025) + { + int n = (int)(rate * duration); + var v = new double[n]; + for (int i = 0; i < n; i++) + { + double t = (double)i / rate - trigger; + v[i] = t <= 0 ? 0 : vMax * (1 - System.Math.Exp(-t / tauSec)); + } + return new CurveData { SampleRateHz = rate, TriggerTimeSec = trigger, Voltage = v }; + } + + private static CurveData MakeFalling(double vMax = 28, double tauSec = 0.0005, int rate = 100_000, double duration = 0.01, double trigger = 0.0025) + { + int n = (int)(rate * duration); + var v = new double[n]; + for (int i = 0; i < n; i++) + { + double t = (double)i / rate - trigger; + v[i] = t <= 0 ? vMax : vMax * System.Math.Exp(-t / tauSec); + } + return new CurveData { SampleRateHz = rate, TriggerTimeSec = trigger, Voltage = v }; + } + + [Fact] + public void OnTimeMs_ReachesNinetyPercent_AtAboutMinusLogPointOneTau() + { + var c = MakeRising(); + double onMs = CurveMetrics.OnTimeMs(c, 28, 0.9); + // 90% 时刻 t = -tau * ln(0.1) ≈ 1.151 ms + Assert.InRange(onMs, 1.1, 1.2); + } + + [Fact] + public void RiseTimeMs_TenToNinety_AboutTwoPointTwo() + { + var c = MakeRising(); + double rt = CurveMetrics.RiseTimeMs(c, 28); + // ln(0.9/0.1) = ln 9 ≈ 2.197;rt = tau * 2.197 ≈ 1.099 ms + Assert.InRange(rt, 1.05, 1.15); + } + + [Fact] + public void OffTimeMs_FallingToTenPercent() + { + var c = MakeFalling(); + double off = CurveMetrics.OffTimeMs(c, 28, 0.1); + Assert.InRange(off, 1.1, 1.2); + } + + [Fact] + public void EstimateVMax_NearActualMax() + { + var c = MakeRising(); + double v = CurveMetrics.EstimateVMax(c.Voltage); + Assert.InRange(v, 27, 28.001); + } +} + +public class PowerLossTests +{ + [Fact] + public void VoltageDrop_Subtracts() + => Assert.Equal(1.5, PowerLoss.VoltageDrop(28, 26.5), 3); + + [Fact] + public void Loss_PinMinusPout() + => Assert.Equal(28 * 1.0 - 26.5 * 1.0, PowerLoss.LossWatts(28, 1, 26.5, 1), 3); + + [Fact] + public void Efficiency_Percentage() + { + double e = PowerLoss.EfficiencyPct(28, 1, 26.5, 1); + Assert.InRange(e, 94, 95); + } + + [Fact] + public void Efficiency_ZeroInputReturnsZero() + => Assert.Equal(0.0, PowerLoss.EfficiencyPct(0, 0, 0, 0)); +} diff --git a/SSPCTester.Tests/ChannelNumberingTests.cs b/SSPCTester.Tests/ChannelNumberingTests.cs new file mode 100644 index 0000000..de23b14 --- /dev/null +++ b/SSPCTester.Tests/ChannelNumberingTests.cs @@ -0,0 +1,55 @@ +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Drivers.Mock; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Storage; + +namespace SSPCTester.Tests; + +public sealed class ChannelNumberingTests +{ + [Fact] + public async Task MockSspc_Accepts1To24AndRejectsZero() + { + var sspc = new MockSspc(Options.Create(new DeviceOptions()), NullLogger.Instance); + + await sspc.TurnOnAsync(1); + await sspc.TurnOnAsync(24); + + Assert.True(await sspc.GetChannelStateAsync(1)); + Assert.True(await sspc.GetChannelStateAsync(24)); + await Assert.ThrowsAsync(() => sspc.TurnOnAsync(0)); + } + + [Fact] + public async Task LoadingLegacyZeroBasedProject_ClearsChannelResults() + { + string folder = Path.Combine(Path.GetTempPath(), "SSPCTester.Tests", Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(folder); + try + { + await File.WriteAllTextAsync(Path.Combine(folder, "project.json"), + """ + { + "Name": "legacy", + "BasicResults": [ { "Channel": 0 } ], + "CurveResults": [ { "Channel": 0 } ], + "PowerResults": [ { "Channel": 0 } ] + } + """); + var store = new ProjectStore(); + + Project? project = await store.LoadAsync(folder); + + Assert.NotNull(project); + Assert.Empty(project.BasicResults); + Assert.Empty(project.CurveResults); + Assert.Empty(project.PowerResults); + } + finally + { + if (Directory.Exists(folder)) Directory.Delete(folder, true); + } + } +} diff --git a/SSPCTester.Tests/DaqChannelOptionsNormalizerTests.cs b/SSPCTester.Tests/DaqChannelOptionsNormalizerTests.cs new file mode 100644 index 0000000..d7e302b --- /dev/null +++ b/SSPCTester.Tests/DaqChannelOptionsNormalizerTests.cs @@ -0,0 +1,77 @@ +using System.Text.Json; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.Tests; + +public sealed class DaqChannelOptionsNormalizerTests +{ + [Fact] + public void Normalize_ReturnsExactlyEightOrderedChannels() + { + var channels = new[] + { + new DaqChannelOptions { PhysicalChannel = 3, Role = nameof(DaqChannelRole.InputCurrent), Name = "Iin" }, + new DaqChannelOptions { PhysicalChannel = 0, Role = nameof(DaqChannelRole.OutputVoltage), Name = "Vout" }, + new DaqChannelOptions { PhysicalChannel = 12, Role = nameof(DaqChannelRole.OutputCurrent), Name = "Ignored" } + }; + + var normalized = DaqChannelOptionsNormalizer.Normalize(channels); + + Assert.Equal(8, normalized.Count); + Assert.Equal(Enumerable.Range(0, 8), normalized.Select(x => x.PhysicalChannel)); + Assert.Equal(nameof(DaqChannelRole.OutputVoltage), normalized[0].Role); + Assert.Equal(nameof(DaqChannelRole.Unconfigured), normalized[1].Role); + Assert.Equal(nameof(DaqChannelRole.InputCurrent), normalized[3].Role); + Assert.Equal("CH1", normalized[1].Name); + } + + [Fact] + public void Normalize_ReplacesInvalidRoleAndPreservesCalibrationFields() + { + var channels = new[] + { + new DaqChannelOptions + { + PhysicalChannel = 0, + Role = "bad-role", + Name = "Vout", + Scale = 2.5, + Offset = -0.1, + IsCalibrated = true + } + }; + + var normalized = DaqChannelOptionsNormalizer.Normalize(channels); + + Assert.Equal(nameof(DaqChannelRole.Unconfigured), normalized[0].Role); + Assert.Equal("Vout", normalized[0].Name); + Assert.Equal(2.5, normalized[0].Scale); + Assert.Equal(-0.1, normalized[0].Offset); + Assert.True(normalized[0].IsCalibrated); + } + + [Fact] + public void NormalizedChannels_SerializeRoleAndCalibrationValues() + { + var options = new DeviceOptions(); + options.Daq.Channels = DaqChannelOptionsNormalizer.Normalize(new[] + { + new DaqChannelOptions + { + PhysicalChannel = 0, + Role = nameof(DaqChannelRole.OutputVoltage), + Name = "输出电压", + Scale = 1, + IsCalibrated = true + } + }); + + string json = JsonSerializer.Serialize(new { Devices = options }); + + Assert.Contains("\"PhysicalChannel\":0", json); + Assert.Contains("\"Role\":\"OutputVoltage\"", json); + Assert.Contains("\"IsCalibrated\":true", json); + Assert.Contains("\"PhysicalChannel\":7", json); + } +} diff --git a/SSPCTester.Tests/DaqIntegrationTests.cs b/SSPCTester.Tests/DaqIntegrationTests.cs new file mode 100644 index 0000000..c19f447 --- /dev/null +++ b/SSPCTester.Tests/DaqIntegrationTests.cs @@ -0,0 +1,195 @@ +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; +using Pcie8586Probe.Hardware; +using Pcie8586Probe.Models; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Drivers.Mock; +using SSPCTester.Devices.Interfaces; +using RealPcie8586Daq = SSPCTester.Devices.Drivers.Real.Pcie8586Daq; + +namespace SSPCTester.Tests; + +public sealed class DaqIntegrationTests +{ + [Fact] + public async Task MockCaptureAroundAction_InvokesActionAndPlacesSoftwareMarker() + { + var options = new DeviceOptions(); + options.Daq.ClockDivider = 1_000; + var daq = new MockDaq(Options.Create(options), NullLogger.Instance); + await daq.ConnectAsync(); + bool invoked = false; + + var curve = await daq.CaptureAroundActionAsync( + new DaqActionCaptureRequest(10, 40, true), + _ => + { + invoked = true; + return Task.CompletedTask; + }); + + Assert.True(invoked); + Assert.Equal(1_000, curve.TriggerSampleIndex); + Assert.Equal(0.010, curve.TriggerTimeSec, 6); + Assert.Contains(curve.EngineeringChannels, x => x.Role == DaqChannelRole.OutputVoltage); + Assert.True(curve.Voltage[^1] > curve.Voltage[0]); + } + + [Fact] + public async Task MockCaptureAroundAction_ExecutesSspcOnAndOffActions() + { + var options = new DeviceOptions(); + var optionWrapper = Options.Create(options); + var daq = new MockDaq(optionWrapper, NullLogger.Instance); + var sspc = new MockSspc(optionWrapper, NullLogger.Instance); + await daq.ConnectAsync(); + await sspc.ConnectAsync(); + + await daq.CaptureAroundActionAsync( + new DaqActionCaptureRequest(10, 40, true), + token => sspc.TurnOnAsync(3, token)); + Assert.True(await sspc.GetChannelStateAsync(3)); + + await daq.CaptureAroundActionAsync( + new DaqActionCaptureRequest(10, 40, false), + token => sspc.TurnOffAsync(3, token)); + Assert.False(await sspc.GetChannelStateAsync(3)); + } + + [Theory] + [InlineData(1000, 100_000)] + [InlineData(100, 1_000_000)] + public void DaqOptions_ComputesActualSampleRate(int divider, double expected) + { + var options = new DaqOptions { ClockDivider = divider }; + Assert.Equal(expected, options.ActualSampleRateHz); + } + + [Fact(Skip = "Requires an x64 testhost because Pcie8586.Driver is built x64-only.")] + public async Task RealCaptureAroundAction_InvokesActionAfterPreSamples() + { + var options = CreateRealDaqOptions(); + var digitizer = FakeDigitizer.WithBlocks( + new SampleBlock(new[] { new[] { 0.1 } }, 100, 0, DateTimeOffset.Now), + new SampleBlock(new[] { new[] { 1.0 } }, 100, 1, DateTimeOffset.Now)); + var daq = new RealPcie8586Daq(options.Daq, NullLogger.Instance, digitizer); + bool invoked = false; + + var curve = await daq.CaptureAroundActionAsync( + new DaqActionCaptureRequest(10, 10, true), + _ => + { + invoked = true; + return Task.CompletedTask; + }); + + Assert.True(invoked); + Assert.True(digitizer.Stopped); + Assert.Equal(1, curve.TriggerSampleIndex); + Assert.Equal(new[] { 0.1, 1.0 }, curve.Voltage); + } + + [Fact(Skip = "Requires an x64 testhost because Pcie8586.Driver is built x64-only.")] + public async Task RealCaptureAroundAction_TimesOutWhenPreSamplesNeverArrive() + { + var options = CreateRealDaqOptions(); + var digitizer = FakeDigitizer.WithoutBlocks(); + var daq = new RealPcie8586Daq(options.Daq, NullLogger.Instance, digitizer); + bool invoked = false; + + var ex = await Assert.ThrowsAsync(() => + daq.CaptureAroundActionAsync( + new DaqActionCaptureRequest(10, 10, true), + _ => + { + invoked = true; + return Task.CompletedTask; + })); + + Assert.False(invoked); + Assert.True(digitizer.Stopped); + Assert.Contains("pre-trigger samples", ex.Message); + Assert.Contains("samples=0/1", ex.Message); + } + + private static DeviceOptions CreateRealDaqOptions() + { + var options = new DeviceOptions(); + options.Daq.UseMock = false; + options.Daq.ClockDivider = 1_000_000; + options.Daq.ChannelCount = 1; + options.Daq.PreTriggerMs = 10; + options.Daq.PostTriggerMs = 10; + options.Daq.Channels[0].Role = nameof(DaqChannelRole.OutputVoltage); + options.Daq.Channels[0].Name = "Vout"; + options.Daq.Channels[0].Scale = 1; + options.Daq.Channels[0].IsCalibrated = true; + return options; + } + + private sealed class FakeDigitizer : IDigitizer + { + private readonly IReadOnlyList? _blocks; + private bool _open; + + private FakeDigitizer(IReadOnlyList? blocks) + { + _blocks = blocks; + } + + public bool IsOpen => _open; + public bool Stopped { get; private set; } + + public static FakeDigitizer WithBlocks(params SampleBlock[] blocks) => new(blocks); + public static FakeDigitizer WithoutBlocks() => new(null); + + public ValueTask> EnumerateDevicesAsync(CancellationToken cancellationToken) => + ValueTask.FromResult>(new[] + { + new DeviceInfo(0, 0, "fake", true) + }); + + public ValueTask OpenAsync(DeviceInfo device, CancellationToken cancellationToken) + { + _open = true; + return ValueTask.CompletedTask; + } + + public ValueTask ConfigureAsync(AcquisitionConfig config, CancellationToken cancellationToken) => + ValueTask.CompletedTask; + + public async IAsyncEnumerable StartAcquisitionAsync( + [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken) + { + if (_blocks == null) + { + while (!cancellationToken.IsCancellationRequested) + await Task.Delay(25, cancellationToken); + yield break; + } + + foreach (var block in _blocks) + { + cancellationToken.ThrowIfCancellationRequested(); + yield return block; + await Task.Yield(); + } + } + + public ValueTask StopAsync() + { + Stopped = true; + return ValueTask.CompletedTask; + } + + public ValueTask CloseAsync() + { + _open = false; + return ValueTask.CompletedTask; + } + + public void Dispose() + { + } + } +} diff --git a/SSPCTester.Tests/InterfacePowerTests.cs b/SSPCTester.Tests/InterfacePowerTests.cs new file mode 100644 index 0000000..385a59d --- /dev/null +++ b/SSPCTester.Tests/InterfacePowerTests.cs @@ -0,0 +1,190 @@ +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Testing; + +namespace SSPCTester.Tests; + +#pragma warning disable CS0067 + +public sealed class InterfacePowerTests +{ + [Fact] + public async Task PowerTest_UsesUdpInputAndIt8702pOutputPower() + { + var project = new Project(); + var sspc = new MeasuringSspc(); + var forbiddenPower = new ForbiddenPowerSupply(); + var load = new MeasuringLoad(); + var daq = new MeasuringDaq(); + var options = Options.Create(new DeviceOptions + { + Daq = new DaqOptions + { + ChannelCount = 1, + Channels = new List + { + new() { PhysicalChannel = 0, Role = nameof(DaqChannelRole.OutputVoltage), IsCalibrated = true }, + } + } + }); + var test = new PowerTest(new FixedPowerSupply()) { SamplesPerChannel = 1, IntervalMs = 0 }; + var context = new TestContext(project, sspc, forbiddenPower, load, daq); + + await test.RunAsync(context, new Progress(), CancellationToken.None); + + Assert.Equal(24, project.PowerResults.Count); + Assert.All(project.PowerResults, row => + { + Assert.Equal(TestStatus.Measured, row.Status); + Assert.Equal(30.0, row.Vin, 6); // 输入端电压来自高速采集卡 + Assert.Equal(1.0, row.Iin, 6); // 通流电流来自 Modbus(Iin = Iout) + Assert.Equal(28.0, row.Vout, 6); // 输出端电压来自 Modbus + Assert.Equal(1.0, row.Iout, 6); + Assert.Equal(27.5, row.MeasuredPowerOut.GetValueOrDefault(), 6); + Assert.Equal(2.5, row.PowerLossW, 6); + Assert.Equal(91.666667, row.EfficiencyPct, 5); + }); + Assert.Equal(24, sspc.TurnOffCount); + Assert.Equal(0, sspc.ReadMeasurementCount); + Assert.Equal(24, load.ReadPowerCount); + Assert.Equal(0, daq.ReadInstantCount); + } + + [Fact] + public void PowerLossRow_FallsBackToCalculatedOutputPower() + { + var row = new PowerLossRow { Vin = 30, Iin = 1, Vout = 28, Iout = 1 }; + + Assert.Equal(28, row.PowerOut, 6); + Assert.Equal(2, row.PowerLossW, 6); + } + + private sealed class MeasuringSspc : ISspc + { + public int TurnOffCount { get; private set; } + public int ReadMeasurementCount { get; private set; } + public int ChannelCount => 24; + public bool IsConnected => true; + public string DisplayName => "test"; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => Task.FromResult(true); + public Task DisconnectAsync() => Task.CompletedTask; + public Task TurnOnAsync(int physicalSlot, CancellationToken ct = default) => Task.CompletedTask; + public Task TurnOffAsync(int physicalSlot, CancellationToken ct = default) { TurnOffCount++; return Task.CompletedTask; } + public Task FlashAsync(int physicalSlot, int milliseconds, CancellationToken ct = default) => Task.CompletedTask; + public Task GetChannelStateAsync(int physicalSlot, CancellationToken ct = default) => Task.FromResult(true); + public Task ReadMeasurementAsync(int physicalSlot, CancellationToken ct = default) + { + ReadMeasurementCount++; + return Task.FromResult(new ChannelMeasurement { PhysicalSlot = physicalSlot, Voltage = 28.0, Current = 1.0 }); + } + public Task> ReadMeasurementsAsync(CancellationToken ct = default) => + Task.FromResult>(Array.Empty()); + } + + private sealed class MeasuringDaq : IDaq + { + public int ReadInstantCount { get; private set; } + public bool IsConnected { get; private set; } + public string DisplayName => "daq"; + public event EventHandler? ConnectionChanged; + public event EventHandler? SampleReceived; + + public Task ConnectAsync(CancellationToken ct = default) + { + IsConnected = true; + ConnectionChanged?.Invoke(this, true); + return Task.FromResult(true); + } + + public Task DisconnectAsync() + { + IsConnected = false; + ConnectionChanged?.Invoke(this, false); + return Task.CompletedTask; + } + + public Task> EnumerateDevicesAsync(CancellationToken ct = default) => + Task.FromResult>(Array.Empty()); + + public Task CaptureAsync(int[] channels, int sampleRateHz, double durationSec, CancellationToken ct = default) => + throw new InvalidOperationException(); + + public Task ReadInstantAsync(int[] channels, CancellationToken ct = default) + { + ReadInstantCount++; + // 采集卡输入端电压固定返回 30V。 + var values = channels.Select(ch => ch == 0 ? 30.0 : double.NaN).ToArray(); + return Task.FromResult(values); + } + + public Task CaptureAroundActionAsync(DaqActionCaptureRequest request, Func action, CancellationToken ct = default) => + throw new InvalidOperationException(); + } + + private sealed class MeasuringLoad : ILoad + { + public int ReadPowerCount { get; private set; } + public bool IsConnected => true; + public string DisplayName => "it8702p"; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => Task.FromResult(true); + public Task DisconnectAsync() => Task.CompletedTask; + public Task SetModeAsync(LoadMode mode, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task SetValueAsync(double value, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task InputAsync(bool on, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) => Task.FromResult((28.0, 1.0)); + public Task ReadPowerAsync(CancellationToken ct = default) + { + ReadPowerCount++; + return Task.FromResult(new PowerReading(28.0, 1.0, 27.5)); + } + public Task QueryIdentityAsync(CancellationToken ct = default) => Task.FromResult("it8702p"); + } + + private sealed class FixedPowerSupply : IPowerSupply + { + public bool IsConnected => true; + public string DisplayName => "fixed power"; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => Task.FromResult(true); + public Task DisconnectAsync() => Task.CompletedTask; + public Task SetVoltageAsync(double volts, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task SetCurrentLimitAsync(double amps, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task OutputAsync(bool on, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) => Task.FromResult((30.0, 1.0)); + public Task QueryIdentityAsync(CancellationToken ct = default) => Task.FromResult("fixed"); + } + + private sealed class ForbiddenPowerSupply : IPowerSupply + { + public bool IsConnected => false; + public string DisplayName => "forbidden"; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => throw new InvalidOperationException(); + public Task DisconnectAsync() => Task.CompletedTask; + public Task SetVoltageAsync(double volts, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task SetCurrentLimitAsync(double amps, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task OutputAsync(bool on, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) => throw new InvalidOperationException(); + public Task QueryIdentityAsync(CancellationToken ct = default) => throw new InvalidOperationException(); + } + + private sealed class ForbiddenLoad : ILoad + { + public bool IsConnected => false; + public string DisplayName => "forbidden"; + public event EventHandler? ConnectionChanged; + public Task ConnectAsync(CancellationToken ct = default) => throw new InvalidOperationException(); + public Task DisconnectAsync() => Task.CompletedTask; + public Task SetModeAsync(LoadMode mode, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task SetValueAsync(double value, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task InputAsync(bool on, CancellationToken ct = default) => throw new InvalidOperationException(); + public Task<(double volts, double amps)> ReadAsync(CancellationToken ct = default) => throw new InvalidOperationException(); + public Task ReadPowerAsync(CancellationToken ct = default) => throw new InvalidOperationException(); + public Task QueryIdentityAsync(CancellationToken ct = default) => throw new InvalidOperationException(); + } +} +#pragma warning restore CS0067 diff --git a/SSPCTester.Tests/It87xxLoadTests.cs b/SSPCTester.Tests/It87xxLoadTests.cs new file mode 100644 index 0000000..6d62b9f --- /dev/null +++ b/SSPCTester.Tests/It87xxLoadTests.cs @@ -0,0 +1,161 @@ +using System.Net; +using System.Net.Sockets; +using System.Text; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Drivers.Real; + +namespace SSPCTester.Tests; + +public sealed class It87xxLoadTests +{ + [Fact] + public async Task CombinedQuery_ReadsVoltageCurrentAndPower() + { + var commands = new List(); + await using var server = await FakeScpiServer.StartAsync(command => + { + commands.Add(command); + return command switch + { + "*IDN?" => "ITECH,IT8702P,SN,1.0", + "SYST:REM" => FakeScpiServer.NoResponse, + "CHAN 1" => FakeScpiServer.NoResponse, + "FETC:VOLT?;:FETC:CURR?;:FETC:POW?" => "2.971700E+00;1.040000E+00;3.090000E+00", + "SYST:LOC" => FakeScpiServer.NoResponse, + _ => "0" + }; + }); + var driver = CreateDriver(server.Port, LoadQueryMode.Combined); + + Assert.True(await driver.ConnectAsync()); + var reading = await driver.ReadPowerAsync(); + await driver.DisconnectAsync(); + + Assert.Equal(2.9717, reading.Volts, 6); + Assert.Equal(1.04, reading.Amps, 6); + Assert.Equal(3.09, reading.Watts, 6); + Assert.Contains("*IDN?", commands); + Assert.Contains("SYST:REM", commands); + Assert.Contains("CHAN 1", commands); + } + + [Fact] + public async Task SeparateQuery_ReadsVoltageCurrentAndPower() + { + await using var server = await FakeScpiServer.StartAsync(command => command switch + { + "*IDN?" => "ITECH,IT8702P,SN,1.0", + "SYST:REM" => FakeScpiServer.NoResponse, + "CHAN 1" => FakeScpiServer.NoResponse, + "FETC:VOLT?" => "2.5", + "FETC:CURR?" => "1.2", + "FETC:POW?" => "3.0", + "SYST:LOC" => FakeScpiServer.NoResponse, + _ => "0" + }); + var driver = CreateDriver(server.Port, LoadQueryMode.Separate); + + Assert.True(await driver.ConnectAsync()); + var reading = await driver.ReadPowerAsync(); + + Assert.Equal(2.5, reading.Volts, 6); + Assert.Equal(1.2, reading.Amps, 6); + Assert.Equal(3.0, reading.Watts, 6); + } + + [Fact] + public async Task QueryFailure_MarksDisconnected() + { + await using var server = await FakeScpiServer.StartAsync(command => command switch + { + "*IDN?" => "ITECH,IT8702P,SN,1.0", + "SYST:REM" => FakeScpiServer.NoResponse, + "CHAN 1" => FakeScpiServer.NoResponse, + "FETC:VOLT?;:FETC:CURR?;:FETC:POW?" => FakeScpiServer.CloseConnection, + _ => "0" + }); + var driver = CreateDriver(server.Port, LoadQueryMode.Combined); + + Assert.True(await driver.ConnectAsync()); + await Assert.ThrowsAsync(() => driver.ReadPowerAsync()); + Assert.False(driver.IsConnected); + } + + private static It87xxLoad CreateDriver(int port, LoadQueryMode queryMode) + { + var options = Options.Create(new DeviceOptions + { + Load = new LoadOptions + { + Host = IPAddress.Loopback.ToString(), + Port = port, + TimeoutSeconds = 1, + Channel = 1, + UseFetch = true, + QueryMode = queryMode + } + }); + return new It87xxLoad(options, NullLogger.Instance); + } + + private sealed class FakeScpiServer : IAsyncDisposable + { + public const string NoResponse = "__NO_RESPONSE__"; + public const string CloseConnection = "__CLOSE_CONNECTION__"; + private readonly TcpListener _listener; + private readonly Func _handler; + private readonly CancellationTokenSource _cts = new(); + private readonly Task _loop; + + private FakeScpiServer(TcpListener listener, Func handler) + { + _listener = listener; + _handler = handler; + Port = ((IPEndPoint)listener.LocalEndpoint).Port; + _loop = Task.Run(AcceptLoopAsync); + } + + public int Port { get; } + + public static Task StartAsync(Func handler) + { + var listener = new TcpListener(IPAddress.Loopback, 0); + listener.Start(); + return Task.FromResult(new FakeScpiServer(listener, handler)); + } + + public async ValueTask DisposeAsync() + { + _cts.Cancel(); + _listener.Stop(); + try { await _loop; } catch { } + _cts.Dispose(); + } + + private async Task AcceptLoopAsync() + { + while (!_cts.IsCancellationRequested) + { + using var client = await _listener.AcceptTcpClientAsync(_cts.Token); + await using var stream = client.GetStream(); + var buffer = new byte[1024]; + while (!_cts.IsCancellationRequested) + { + int read = await stream.ReadAsync(buffer, _cts.Token); + if (read <= 0) break; + + string command = Encoding.ASCII.GetString(buffer, 0, read).Trim(); + string response = _handler(command); + if (response == CloseConnection) break; + if (response == NoResponse) continue; + + byte[] payload = Encoding.ASCII.GetBytes(response + "\n"); + await stream.WriteAsync(payload, _cts.Token); + await stream.FlushAsync(_cts.Token); + } + } + } + } +} diff --git a/SSPCTester.Tests/ModbusProfileTests.cs b/SSPCTester.Tests/ModbusProfileTests.cs new file mode 100644 index 0000000..6cb3011 --- /dev/null +++ b/SSPCTester.Tests/ModbusProfileTests.cs @@ -0,0 +1,73 @@ +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Protocol; + +namespace SSPCTester.Tests; + +public sealed class ModbusProfileTests +{ + [Fact] + public void FieldProfile_IsValidAndCoversPhysicalSlots1To24() + { + string path = FindRepoFile("Docs", "Modbus接口规范", "device-profile.json"); + + var profile = ModbusDeviceProfileLoader.Load(path); + + Assert.Equal(Enumerable.Range(1, 24), profile.Channels.OrderBy(x => x.PhysicalSlot).Select(x => x.PhysicalSlot)); + Assert.Equal((byte)1, profile.Channels.Single(x => x.PhysicalSlot == 1).Relay.Slave); + Assert.Equal((ushort)7, profile.Channels.Single(x => x.PhysicalSlot == 1).Relay.Coil); + Assert.Equal(12, profile.Channels.Single(x => x.PhysicalSlot == 24).Current.RegisterOffset); + } + + [Fact] + public void Crc16_UsesModbusLowByteFirst() + { + byte[] request = ModbusRtuProtocol.BuildRequest(4, 3, 0, 24); + + Assert.Equal(new byte[] { 0x04, 0x03, 0x00, 0x00, 0x00, 0x18 }, request[..6]); + Assert.Equal((byte)(ModbusRtuProtocol.ComputeCrc(request.AsSpan(0, 6)) & 0xFF), request[6]); + ModbusRtuProtocol.ValidateCrc(request); + } + + [Fact] + public void SignedCurrent_UsesInt16TwosComplementAndFormulaA() + { + ushort rawBits = unchecked((ushort)(short)-1000); + + double amps = ModbusValueConverter.ConvertRaw(rawBits, true, "A", 60.0); + + Assert.Equal(-6.0, amps, 6); + } + + [Fact] + public void InvalidDuplicateRegisterMapping_IsRejected() + { + var profile = ModbusDeviceProfileLoader.Load(ProfilePath()); + profile.Current.ChannelsForTestDuplicate(profile.Channels); + + var error = Assert.Throws(() => ModbusDeviceProfileLoader.Validate(profile)); + Assert.Contains("current.registerOffset 存在重复", error.Message); + } + + private static string ProfilePath() => FindRepoFile("Docs", "Modbus接口规范", "device-profile.json"); + + private static string FindRepoFile(params string[] parts) + { + var directory = new DirectoryInfo(AppContext.BaseDirectory); + while (directory != null) + { + string candidate = Path.Combine(new[] { directory.FullName }.Concat(parts).ToArray()); + if (File.Exists(candidate)) return candidate; + directory = directory.Parent; + } + throw new FileNotFoundException($"找不到仓库文件:{Path.Combine(parts)}"); + } +} + +internal static class ProfileTestExtensions +{ + public static void ChannelsForTestDuplicate( + this MeasurementProtocol _, IReadOnlyList channels) + { + channels[1].Current.RegisterOffset = channels[0].Current.RegisterOffset; + } +} diff --git a/SSPCTester.Tests/ReportFileHelperTests.cs b/SSPCTester.Tests/ReportFileHelperTests.cs new file mode 100644 index 0000000..8273497 --- /dev/null +++ b/SSPCTester.Tests/ReportFileHelperTests.cs @@ -0,0 +1,160 @@ +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Report; + +namespace SSPCTester.Tests; + +public sealed class ReportFileHelperTests +{ + [Fact] + public void ResolveFileName_ExpandsVariablesAndKeepsPdfExtension() + { + var project = new Project + { + Name = "ProjectA", + Dut = + { + ProductName = "SSPC", + Model = "M24", + SerialNumber = "SN001" + }, + Report = { FileName = "{ProjectName}_{SerialNumber}_{yyyyMMdd_HHmmss}.pdf" } + }; + + string fileName = ReportFileHelper.ResolveFileName(project, new DateTime(2026, 6, 28, 9, 8, 7)); + + Assert.Equal("ProjectA_SN001_20260628_090807.pdf", fileName); + } + + [Fact] + public void ResolveFileName_CanUseWordExtensionFromSameTemplate() + { + var project = new Project + { + Name = "ProjectA", + Dut = { SerialNumber = "SN001" }, + Report = { FileName = "{ProjectName}_{SerialNumber}_{yyyyMMdd_HHmmss}.pdf" } + }; + + string fileName = ReportFileHelper.ResolveFileName(project, new DateTime(2026, 6, 28, 9, 8, 7), ".docx"); + + Assert.Equal("ProjectA_SN001_20260628_090807.docx", fileName); + } + + [Fact] + public void ResolveFileName_CleansInvalidCharactersAndAddsPdfExtension() + { + var project = new Project + { + Name = "A:B/C", + Report = { FileName = "{ProjectName}_{Date}" } + }; + + string fileName = ReportFileHelper.ResolveFileName(project, new DateTime(2026, 6, 28, 0, 0, 0)); + + Assert.Equal("A_B_C_20260628.pdf", fileName); + } + + [Fact] + public void ResolveFileName_UsesFallbackForBlankTemplate() + { + var project = new Project { Report = { FileName = " " } }; + + string fileName = ReportFileHelper.ResolveFileName(project, new DateTime(2026, 6, 28, 1, 2, 3)); + + Assert.Equal("report_20260628_010203.pdf", fileName); + } + + [Theory] + [InlineData("Pdf", ReportOutputFormat.Pdf)] + [InlineData("word", ReportOutputFormat.Word)] + [InlineData("BOTH", ReportOutputFormat.Both)] + [InlineData("invalid", ReportOutputFormat.Pdf)] + [InlineData(null, ReportOutputFormat.Pdf)] + public void ParseFormat_HandlesKnownValuesAndFallsBackToPdf(string? value, ReportOutputFormat expected) + { + Assert.Equal(expected, ReportFileHelper.ParseFormat(value)); + } + + [Fact] + public void EnumeratePdfFiles_SortsByLastWriteTimeDescending() + { + string folder = Path.Combine(Path.GetTempPath(), "SSPCTester-reports-" + Guid.NewGuid().ToString("N")); + try + { + Directory.CreateDirectory(folder); + string older = Path.Combine(folder, "older.pdf"); + string newer = Path.Combine(folder, "newer.pdf"); + string ignored = Path.Combine(folder, "ignored.txt"); + File.WriteAllText(older, "old"); + File.WriteAllText(newer, "new"); + File.WriteAllText(ignored, "txt"); + File.SetLastWriteTime(older, new DateTime(2026, 6, 27, 8, 0, 0)); + File.SetLastWriteTime(newer, new DateTime(2026, 6, 28, 8, 0, 0)); + + var files = ReportFileHelper.EnumeratePdfFiles(folder); + + Assert.Equal(2, files.Count); + Assert.Equal("newer.pdf", files[0].DisplayName); + Assert.Equal("older.pdf", files[1].DisplayName); + } + finally + { + if (Directory.Exists(folder)) Directory.Delete(folder, true); + } + } + + [Fact] + public void EnumerateReportFiles_BothIncludesPdfAndWord() + { + string folder = Path.Combine(Path.GetTempPath(), "SSPCTester-reports-" + Guid.NewGuid().ToString("N")); + try + { + Directory.CreateDirectory(folder); + string pdf = Path.Combine(folder, "a.pdf"); + string docx = Path.Combine(folder, "b.docx"); + File.WriteAllText(pdf, "pdf"); + File.WriteAllText(docx, "docx"); + + var files = ReportFileHelper.EnumerateReportFiles(folder, ReportOutputFormat.Both); + + Assert.Contains(files, x => x.DisplayName == "a.pdf" && x.Kind == ReportFileKind.Pdf); + Assert.Contains(files, x => x.DisplayName == "b.docx" && x.Kind == ReportFileKind.Word); + } + finally + { + if (Directory.Exists(folder)) Directory.Delete(folder, true); + } + } + + [Fact] + public void ReportInfo_RoundTripsBesideReport() + { + string folder = Path.Combine(Path.GetTempPath(), "SSPCTester-reports-" + Guid.NewGuid().ToString("N")); + try + { + Directory.CreateDirectory(folder); + string report = Path.Combine(folder, "report.docx"); + File.WriteAllText(report, ""); + var info = new ReportInfo + { + ProjectName = "ProjectA", + ProductName = "SSPC", + GeneratedAt = new DateTime(2026, 6, 28, 12, 0, 0), + Format = ReportOutputFormat.Word.ToString(), + WordPath = report, + OverallStatus = TestStatus.Pass.ToString() + }; + + ReportFileHelper.SaveInfo(info, ReportFileHelper.BuildInfoPath(report)); + var loaded = ReportFileHelper.LoadInfoForReport(report); + + Assert.NotNull(loaded); + Assert.Equal("ProjectA", loaded.ProjectName); + Assert.Equal(report, loaded.WordPath); + } + finally + { + if (Directory.Exists(folder)) Directory.Delete(folder, true); + } + } +} diff --git a/SSPCTester.Tests/ReportLayoutTests.cs b/SSPCTester.Tests/ReportLayoutTests.cs new file mode 100644 index 0000000..88ede8a --- /dev/null +++ b/SSPCTester.Tests/ReportLayoutTests.cs @@ -0,0 +1,104 @@ +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Report; + +namespace SSPCTester.Tests; + +public sealed class ReportLayoutTests +{ + [Fact] + public void ProfessionalReport_RendersFull24ChannelDocument() + { + string output = Path.Combine(Path.GetTempPath(), $"SSPCTester-report-{Guid.NewGuid():N}.pdf"); + try + { + var project = BuildProject(); + + new ReportGenerator().Generate(project, output); + + Assert.True(File.Exists(output)); + Assert.True(new FileInfo(output).Length > 20_000); + byte[] header = File.ReadAllBytes(output)[..4]; + Assert.Equal("%PDF"u8.ToArray(), header); + } + finally + { + if (File.Exists(output)) File.Delete(output); + } + } + + private static Project BuildProject() + { + var project = new Project + { + Name = "24路固态功率控制器出厂检验", + CreatedAt = new DateTime(2026, 6, 23, 8, 30, 0), + LastTestedAt = new DateTime(2026, 6, 23, 10, 20, 0), + Dut = new DutInfo + { + ProductName = "固态功率控制器", + Model = "SSPC-24CH-28V-1A", + SerialNumber = "SSPC-20260623-001", + Manufacturer = "示例制造单位" + }, + Site = new TestSiteInfo + { + Tester = "测试员", + TestDate = new DateTime(2026, 6, 23), + TemperatureC = 24.8, + HumidityPct = 52.3, + PressureKpa = 101.2, + Remark = "常温常压条件下进行全项目测试。" + } + }; + + for (int channel = 1; channel <= 24; channel++) + { + bool failed = channel == 8; + project.BasicResults.Add(new ChannelResult + { + Channel = channel, + VoltageOn = failed ? 0.12 : 28.01, + CurrentOn = failed ? 0 : 1.002, + VoltageOff = 0.01, + Status = failed ? TestStatus.Fail : TestStatus.Pass + }); + project.CurveResults.Add(new CurveResultRow + { + Channel = channel, + OnTimeMs = failed ? 6.2 : 1.22, + RiseTimeMs = failed ? 3.4 : 0.98, + OffTimeMs = 1.18, + FallTimeMs = 0.91, + Status = failed ? TestStatus.Fail : TestStatus.Pass + }); + project.PowerResults.Add(new PowerLossRow + { + Channel = channel, + Vin = 28.01, + Iin = 1.01, + Vout = failed ? 25.7 : 27.62, + Iout = 1.0, + Status = failed ? TestStatus.Fail : TestStatus.Pass + }); + } + + foreach (var item in new[] + { + ("跳闸", "1.5×额定电流"), ("短路", "输出短路"), ("过温", "≥85℃"), + ("过压", "≥32V"), ("欠压", "≤22V"), ("限流", "≥1.2A") + }) + { + project.ProtectResults.Add(new ProtectRow + { + ProtectType = item.Item1, + Trigger = item.Item2, + TripTimeMs = 2.15, + Status = TestStatus.Pass + }); + } + + project.TestFunction.Basic = "各通道依次执行导通、采集及关断操作。"; + project.TestFunction.Curve = "曲线指标按照项目阈值进行判定。"; + return project; + } +} diff --git a/SSPCTester.Tests/SSPCTester.Tests.csproj b/SSPCTester.Tests/SSPCTester.Tests.csproj new file mode 100644 index 0000000..21080cc --- /dev/null +++ b/SSPCTester.Tests/SSPCTester.Tests.csproj @@ -0,0 +1,39 @@ + + + + net8.0 + x64 + x64 + enable + enable + + false + true + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/SSPCTester.Tests/Udp5080Tests.cs b/SSPCTester.Tests/Udp5080Tests.cs new file mode 100644 index 0000000..a9e708b --- /dev/null +++ b/SSPCTester.Tests/Udp5080Tests.cs @@ -0,0 +1,148 @@ +using System.Net; +using System.Net.Sockets; +using System.Text; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Drivers.Real; + +namespace SSPCTester.Tests; + +public sealed class Udp5080Tests +{ + [Theory] + [InlineData("48.125", 48.125)] + [InlineData("+1.25E+01 V", 12.5)] + [InlineData("VOLT: 48.000 V", 48.0)] + public void ParseNumber_ExtractsFirstFiniteNumber(string response, double expected) + { + Assert.Equal(expected, Udp5080.ParseNumber(response), 6); + } + + [Fact] + public void ParseNumber_RejectsInvalidResponse() + { + Assert.Throws(() => Udp5080.ParseNumber("NO DATA")); + } + + [Fact] + public async Task TcpDriver_QueriesIdentityAndMeasurements() + { + await using var server = await FakeScpiServer.StartAsync(command => command switch + { + "*IDN?" => "UNI-T,UDP5080-100,AWPK225300032,1.03.0513", + "MEASure:VOLTage?" => "48.125 V", + "MEASure:CURRent?" => "+1.25E+00 A", + _ => "0" + }); + var driver = CreateDriver(server.Port); + + Assert.True(await driver.ConnectAsync()); + Assert.Equal("UNI-T,UDP5080-100,AWPK225300032,1.03.0513", await driver.QueryIdentityAsync()); + var reading = await driver.ReadAsync(); + + Assert.Equal(48.125, reading.volts, 6); + Assert.Equal(1.25, reading.amps, 6); + Assert.True(driver.IsConnected); + } + + [Fact] + public async Task TcpDriver_MarksDisconnectedWhenRemoteCloses() + { + await using var server = await FakeScpiServer.StartAsync(_ => null); + var driver = CreateDriver(server.Port); + + await Assert.ThrowsAsync(() => driver.ConnectAsync()); + + Assert.False(driver.IsConnected); + } + + [Fact] + public async Task TcpDriver_RejectsUnexpectedIdentity() + { + await using var server = await FakeScpiServer.StartAsync(command => command switch + { + "*IDN?" => "SOME,OTHER-DEVICE,SN,1.0", + _ => "0" + }); + var driver = CreateDriver(server.Port); + + var ex = await Assert.ThrowsAsync(() => driver.ConnectAsync()); + + Assert.Contains("Unexpected UDP5080 identity", ex.Message); + Assert.False(driver.IsConnected); + } + + private static Udp5080 CreateDriver(int port) + { + var options = Options.Create(new DeviceOptions + { + PowerSupply = new PowerSupplyOptions + { + Host = IPAddress.Loopback.ToString(), + Port = port, + TimeoutSeconds = 1, + IdnCommand = "*IDN?", + VoltageCommand = "MEASure:VOLTage?", + CurrentCommand = "MEASure:CURRent?" + } + }); + return new Udp5080(options, NullLogger.Instance); + } + + private sealed class FakeScpiServer : IAsyncDisposable + { + private readonly TcpListener _listener; + private readonly Func _handler; + private readonly CancellationTokenSource _cts = new(); + private readonly Task _loop; + + private FakeScpiServer(TcpListener listener, Func handler) + { + _listener = listener; + _handler = handler; + Port = ((IPEndPoint)listener.LocalEndpoint).Port; + _loop = Task.Run(AcceptLoopAsync); + } + + public int Port { get; } + + public static Task StartAsync(Func handler) + { + var listener = new TcpListener(IPAddress.Loopback, 0); + listener.Start(); + return Task.FromResult(new FakeScpiServer(listener, handler)); + } + + public async ValueTask DisposeAsync() + { + _cts.Cancel(); + _listener.Stop(); + try { await _loop; } catch { } + _cts.Dispose(); + } + + private async Task AcceptLoopAsync() + { + while (!_cts.IsCancellationRequested) + { + using var client = await _listener.AcceptTcpClientAsync(_cts.Token); + await using var stream = client.GetStream(); + var buffer = new byte[1024]; + while (!_cts.IsCancellationRequested) + { + int read = await stream.ReadAsync(buffer, _cts.Token); + if (read <= 0) break; + + string command = Encoding.ASCII.GetString(buffer, 0, read).Trim(); + string? response = _handler(command); + if (response is null) break; + + byte[] payload = Encoding.ASCII.GetBytes(response + "\n"); + await stream.WriteAsync(payload, _cts.Token); + await stream.FlushAsync(_cts.Token); + } + } + } + } +} diff --git a/SSPCTester.Tests/WaveformStoreTests.cs b/SSPCTester.Tests/WaveformStoreTests.cs new file mode 100644 index 0000000..4bdc3a9 --- /dev/null +++ b/SSPCTester.Tests/WaveformStoreTests.cs @@ -0,0 +1,101 @@ +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Report; +using SSPCTester.Logic.Storage; + +namespace SSPCTester.Tests; + +public sealed class WaveformStoreTests +{ + [Fact] + public async Task SaveThenLoad_RestoresCurveDataAndChannels() + { + string folder = Path.Combine(Path.GetTempPath(), "SSPCTester-waveform-" + Guid.NewGuid().ToString("N")); + try + { + var project = new Project { FolderPath = folder }; + var curve = new CurveData + { + SampleRateHz = 100_000, + TriggerSampleIndex = 2, + TriggerTimeSec = 0.00002, + Voltage = new[] { 0.0, 3.5, 10.0, 22.0 }, + Current = new[] { 0.0, 0.1, 0.4, 0.8 }, + EngineeringChannels = new[] + { + new CurveChannelData(0, DaqChannelRole.OutputVoltage, "Vout", "V", 2, 0, new[] { 0.0, 3.5, 10.0, 22.0 }), + new CurveChannelData(1, DaqChannelRole.OutputCurrent, "Iout", "A", 1, 0, new[] { 0.0, 0.1, 0.4, 0.8 }) + } + }; + + string? path = await WaveformStore.SaveAsync(project, 1, "on", curve); + var loaded = await WaveformStore.LoadAsync(project, path); + + Assert.NotNull(path); + Assert.NotNull(loaded); + Assert.Equal(curve.SampleRateHz, loaded.SampleRateHz); + Assert.Equal(curve.TriggerSampleIndex, loaded.TriggerSampleIndex); + Assert.Equal(curve.TriggerTimeSec, loaded.TriggerTimeSec, 8); + Assert.Equal(curve.Voltage, loaded.Voltage, new ApproximateDoubleComparer()); + Assert.Equal(curve.Current!, loaded.Current!, new ApproximateDoubleComparer()); + Assert.Contains(loaded.EngineeringChannels, x => x.Role == DaqChannelRole.OutputVoltage); + Assert.Contains(loaded.EngineeringChannels, x => x.Role == DaqChannelRole.OutputCurrent); + } + finally + { + if (Directory.Exists(folder)) Directory.Delete(folder, true); + } + } + + [Fact] + public async Task Load_ReturnsNull_WhenPathIsMissing() + { + var project = new Project { FolderPath = Path.GetTempPath() }; + + var loaded = await WaveformStore.LoadAsync(project, "curves/missing.json"); + + Assert.Null(loaded); + } + + [Fact] + public void CurveImageRenderer_RendersPngFromLoadedCurves() + { + var rising = MakeCurve(true); + var falling = MakeCurve(false); + + byte[] png = CurveImageRenderer.RenderChannel(3, rising, falling); + + Assert.True(png.Length > 1_000); + Assert.Equal(new byte[] { 0x89, 0x50, 0x4E, 0x47 }, png[..4]); + } + + private static CurveData MakeCurve(bool rising) + { + const int sampleRate = 100_000; + const int count = 200; + var voltage = new double[count]; + for (int i = 0; i < count; i++) + { + double ratio = i / (double)(count - 1); + voltage[i] = rising ? 28 * ratio : 28 * (1 - ratio); + } + + return new CurveData + { + SampleRateHz = sampleRate, + TriggerSampleIndex = 50, + TriggerTimeSec = 50.0 / sampleRate, + Voltage = voltage, + EngineeringChannels = new[] + { + new CurveChannelData(0, DaqChannelRole.OutputVoltage, "Vout", "V", 1, 0, voltage) + } + }; + } + + private sealed class ApproximateDoubleComparer : IEqualityComparer + { + public bool Equals(double x, double y) => Math.Abs(x - y) < 1e-6; + public int GetHashCode(double obj) => 0; + } +} diff --git a/SSPCTester.Tests/WordReportGeneratorTests.cs b/SSPCTester.Tests/WordReportGeneratorTests.cs new file mode 100644 index 0000000..a279310 --- /dev/null +++ b/SSPCTester.Tests/WordReportGeneratorTests.cs @@ -0,0 +1,134 @@ +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Report; + +namespace SSPCTester.Tests; + +public sealed class WordReportGeneratorTests +{ + [Fact] + public void WordReport_GeneratesOpenXmlDocumentWithSimSunTextAndImage() + { + string output = Path.Combine(Path.GetTempPath(), $"SSPCTester-report-{Guid.NewGuid():N}.docx"); + try + { + var project = BuildProject(); + var generator = new WordReportGenerator + { + CurveImages = { [1] = MinimalPng } + }; + + generator.Generate(project, output); + + Assert.True(File.Exists(output)); + Assert.True(new FileInfo(output).Length > 4_000); + + using var document = WordprocessingDocument.Open(output, false); + string text = document.MainDocumentPart!.Document.Body!.InnerText; + Assert.Contains("动态参数测试报告", text); + Assert.Contains("ProjectA", text); + Assert.Contains("基础测试", text); + Assert.Contains("功率损耗", text); + + var fontNames = document.MainDocumentPart.Document.Descendants() + .SelectMany(x => new[] { x.Ascii?.Value, x.HighAnsi?.Value, x.EastAsia?.Value }) + .Where(x => !string.IsNullOrWhiteSpace(x)) + .ToArray(); + Assert.Contains("SimSun", fontNames); + Assert.NotEmpty(document.MainDocumentPart.ImageParts); + } + finally + { + if (File.Exists(output)) File.Delete(output); + } + } + + [Fact] + public void WordReport_GeneratesWithoutCurveImages() + { + string output = Path.Combine(Path.GetTempPath(), $"SSPCTester-report-{Guid.NewGuid():N}.docx"); + try + { + new WordReportGenerator().Generate(BuildProject(), output); + + Assert.True(File.Exists(output)); + using var document = WordprocessingDocument.Open(output, false); + Assert.Contains("开启与关断曲线", document.MainDocumentPart!.Document.Body!.InnerText); + } + finally + { + if (File.Exists(output)) File.Delete(output); + } + } + + private static Project BuildProject() + { + var project = new Project + { + Name = "ProjectA", + CreatedAt = new DateTime(2026, 6, 28, 9, 0, 0), + Dut = new DutInfo + { + ProductName = "SSPC", + Model = "M24", + SerialNumber = "SN001", + Manufacturer = "Factory" + }, + Site = new TestSiteInfo + { + Tester = "Tester", + TestDate = new DateTime(2026, 6, 28), + Remark = "OK" + } + }; + project.BasicResults.Add(new ChannelResult + { + Channel = 1, + VoltageOn = 28.0, + CurrentOn = 1.0, + VoltageOff = 0.01, + Status = TestStatus.Pass + }); + project.CurveResults.Add(new CurveResultRow + { + Channel = 1, + OnTimeMs = 1.2, + RiseTimeMs = 0.9, + OffTimeMs = 1.1, + FallTimeMs = 0.8, + Status = TestStatus.Pass + }); + project.PowerResults.Add(new PowerLossRow + { + Channel = 1, + Vin = 28.0, + Iin = 1.0, + Vout = 27.5, + Iout = 1.0, + MeasuredPowerOut = 27.5, + Status = TestStatus.Pass + }); + project.ProtectResults.Add(new ProtectRow + { + ProtectType = "短路", + Trigger = "输出短路", + TripTimeMs = 2.1, + Status = TestStatus.Pass + }); + return project; + } + + private static readonly byte[] MinimalPng = + { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, + 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, + 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, + 0xDE, 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, + 0x54, 0x08, 0xD7, 0x63, 0xF8, 0xFF, 0xFF, 0x3F, + 0x00, 0x05, 0xFE, 0x02, 0xFE, 0xDC, 0xCC, 0x59, + 0xE7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, + 0x44, 0xAE, 0x42, 0x60, 0x82 + }; +} diff --git a/SSPCTester.UI/App.xaml b/SSPCTester.UI/App.xaml new file mode 100644 index 0000000..65d8a63 --- /dev/null +++ b/SSPCTester.UI/App.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/SSPCTester.UI/App.xaml.cs b/SSPCTester.UI/App.xaml.cs new file mode 100644 index 0000000..75ec561 --- /dev/null +++ b/SSPCTester.UI/App.xaml.cs @@ -0,0 +1,315 @@ +using System.IO; +using System.Windows; +using System.Windows.Threading; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Serilog; +using Serilog.Extensions.Logging; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Drivers.Mock; +using SSPCTester.Devices.Drivers.Real; +using SSPCTester.Devices.Drivers; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Report; +using SSPCTester.Logic.Storage; +using SSPCTester.Logic.Testing; +using SSPCTester.UI.Services; +using SSPCTester.UI.ViewModels; +using SSPCTester.UI.Views; + +namespace SSPCTester.UI; + +public partial class App : Application +{ + private ServiceProvider? _services; + public static IServiceProvider Services => ((App)Current)._services!; + + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + DispatcherUnhandledException += OnDispatcherUnhandledException; + AppDomain.CurrentDomain.UnhandledException += OnDomainUnhandledException; + + try + { + var builder = new ConfigurationBuilder() + .SetBasePath(AppContext.BaseDirectory) + .AddInMemoryCollection(DefaultSettings()) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile(UserSettingsStore.SettingsPath, optional: true, reloadOnChange: false); + var configuration = builder.Build(); + + ExpandEnvPaths(configuration); + + // Serilog fail-safe:配置加载失败时退回到代码直接配置。 + try + { + Log.Logger = new LoggerConfiguration() + .ReadFrom.Configuration(configuration) + .CreateLogger(); + } + catch + { + var logFile = Environment.ExpandEnvironmentVariables( + "%LOCALAPPDATA%\\SSPCTester\\Logs\\app-.log"); + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .WriteTo.Debug() + .WriteTo.File(logFile, rollingInterval: Serilog.RollingInterval.Day, retainedFileCountLimit: 7) + .CreateLogger(); + } + + var services = new ServiceCollection(); + services.AddSingleton(configuration); + services.AddLogging(b => + { + b.ClearProviders(); + b.AddProvider(new SerilogLoggerProvider(Log.Logger, dispose: false)); + }); + ConfigureServices(configuration, services); + _services = services.BuildServiceProvider(); + + Log.Information("UI 启动:DI 构建完成。"); + var main = _services.GetRequiredService(); + main.Show(); + Log.Information("UI 启动:MainWindow.Show 已调用。"); + } + catch (Exception ex) + { + FatalCrash(ex); + } + } + + internal static void DiagTrace(string tag) + { + try + { + var path = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "SSPCTester", "Logs", "diag.log"); + Directory.CreateDirectory(Path.GetDirectoryName(path)!); + File.AppendAllText(path, $"{DateTime.Now:HH:mm:ss.fff} {tag}{Environment.NewLine}"); + } + catch { /* ignore */ } + } + + protected override void OnExit(ExitEventArgs e) + { + if (_services != null) + { + try + { + var store = _services.GetRequiredService(); + store.SaveAsync().GetAwaiter().GetResult(); + _services.GetRequiredService().DisconnectAsync().GetAwaiter().GetResult(); + _services.GetRequiredService().DisconnectAsync().GetAwaiter().GetResult(); + _services.GetRequiredService().DisconnectAsync().GetAwaiter().GetResult(); + _services.GetRequiredService().DisconnectAsync().GetAwaiter().GetResult(); + } + catch (Exception ex) { Log.Warning(ex, "退出时保存配置或断开设备失败。"); } + } + try { _services?.Dispose(); } catch { /* swallow */ } + Log.CloseAndFlush(); + base.OnExit(e); + } + + private static void ConfigureServices(IConfiguration cfg, IServiceCollection services) + { + var devOpts = cfg.GetSection(DeviceOptions.SectionName).Get() ?? new DeviceOptions(); + NormalizeDaqOptions(devOpts.Daq); + if (cfg["Devices:Sspc:UseMock"] == null) + { + devOpts.Sspc.UseMock = devOpts.MockMode; + devOpts.PowerSupply.UseMock = devOpts.MockMode; + devOpts.Load.UseMock = devOpts.MockMode; + devOpts.Daq.UseMock = devOpts.MockMode; + } + var storageOpts = cfg.GetSection(StorageOptions.SectionName).Get() ?? new StorageOptions(); + var reportOpts = cfg.GetSection(ReportOptions.SectionName).Get() ?? new ReportOptions(); + services.AddSingleton>(Options.Create(devOpts)); + services.AddSingleton>(Options.Create(storageOpts)); + services.AddSingleton>(Options.Create(reportOpts)); + + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + + services.AddSingleton(sp => + { + var opt = sp.GetRequiredService>().Value; + if (!string.IsNullOrEmpty(opt.ProjectsRoot)) Directory.CreateDirectory(opt.ProjectsRoot); + return new ProjectStore { ProjectsRoot = opt.ProjectsRoot }; + }); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddTransient(); + services.AddTransient(sp => new CurveTest(sp.GetRequiredService>())); + services.AddTransient(); + services.AddTransient(); + + services.AddSingleton(); + + services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddSingleton(); + } + + private static void ExpandEnvPaths(IConfiguration cfg) + { + string[] keys = + { + "Storage:ProjectsRoot", + "Report:SavePath", + "Serilog:WriteTo:1:Args:path", + }; + foreach (var k in keys) + { + var v = cfg[k]; + if (!string.IsNullOrEmpty(v)) + cfg[k] = Environment.ExpandEnvironmentVariables(v); + } + } + + /// 当 appsettings.json 缺失时使用的内置默认配置(与该文件等价)。 + private static IEnumerable> DefaultSettings() + { + return new Dictionary + { + ["Devices:MockMode"] = "false", + ["Devices:Sspc:UseMock"] = "false", + ["Devices:Sspc:AutoConnect"] = "true", + ["Devices:Sspc:PortName"] = "COM1", + ["Devices:Sspc:BaudRate"] = "9600", + ["Devices:Sspc:DataBits"] = "8", + ["Devices:Sspc:Parity"] = "None", + ["Devices:Sspc:StopBits"] = "One", + ["Devices:Sspc:ReadTimeoutMs"] = "500", + ["Devices:Sspc:Retry"] = "2", + ["Devices:Sspc:DeviceProfilePath"] = "Config/device-profile.json", + ["Devices:Sspc:CloseAllRelaysOnDisconnect"] = "false", + ["Devices:Sspc:LogRawFrames"] = "true", + ["Devices:Sspc:ModuleAddresses:0"] = "1", + ["Devices:Sspc:ModuleAddresses:1"] = "2", + ["Devices:Sspc:ModuleAddresses:2"] = "3", + ["Devices:Sspc:ChannelsPerModule"] = "8", + ["Devices:PowerSupply:PortName"] = "COM2", + ["Devices:PowerSupply:UseMock"] = "false", + ["Devices:PowerSupply:AutoConnect"] = "true", + ["Devices:PowerSupply:BaudRate"] = "9600", + ["Devices:PowerSupply:Host"] = "192.168.6.5", + ["Devices:PowerSupply:Port"] = "5025", + ["Devices:PowerSupply:TimeoutSeconds"] = "2", + ["Devices:PowerSupply:RequirePingBeforeConnect"] = "true", + ["Devices:PowerSupply:Terminator"] = "\n", + ["Devices:PowerSupply:IdnCommand"] = "*IDN?", + ["Devices:PowerSupply:VoltageCommand"] = "MEASure:VOLTage?", + ["Devices:PowerSupply:CurrentCommand"] = "MEASure:CURRent?", + ["Devices:Load:PortName"] = "COM3", + ["Devices:Load:UseMock"] = "false", + ["Devices:Load:AutoConnect"] = "true", + ["Devices:Load:BaudRate"] = "9600", + ["Devices:Load:Host"] = "192.168.200.100", + ["Devices:Load:Port"] = "30000", + ["Devices:Load:TimeoutSeconds"] = "3", + ["Devices:Load:Terminator"] = "\n", + ["Devices:Load:Channel"] = "1", + ["Devices:Load:UseFetch"] = "true", + ["Devices:Load:QueryMode"] = "Combined", + ["Devices:Daq:LogicalDeviceId"] = "0", + ["Devices:Daq:UseMock"] = "false", + ["Devices:Daq:AutoConnect"] = "true", + ["Devices:Daq:ChannelCount"] = "4", + ["Devices:Daq:InputRange"] = "PlusMinus5V", + ["Devices:Daq:ClockDivider"] = "1000", + ["Devices:Daq:PreTriggerMs"] = "10", + ["Devices:Daq:PostTriggerMs"] = "40", + ["Devices:Daq:Channels:0:PhysicalChannel"] = "0", + ["Devices:Daq:Channels:0:Role"] = "OutputVoltage", + ["Devices:Daq:Channels:0:Name"] = "输出电压", + ["Devices:Daq:Channels:0:Scale"] = "1", + ["Devices:Daq:Channels:0:Offset"] = "0", + ["Devices:Daq:Channels:0:IsCalibrated"] = "true", + ["Devices:Daq:Channels:1:PhysicalChannel"] = "1", + ["Devices:Daq:Channels:1:Role"] = "OutputCurrent", + ["Devices:Daq:Channels:1:Name"] = "输出电流", + ["Devices:Daq:Channels:1:Scale"] = "1", + ["Devices:Daq:Channels:1:Offset"] = "0", + ["Devices:Daq:Channels:1:IsCalibrated"] = "true", + ["Devices:Daq:Channels:2:PhysicalChannel"] = "2", + ["Devices:Daq:Channels:2:Role"] = "InputVoltage", + ["Devices:Daq:Channels:2:Name"] = "输入电压", + ["Devices:Daq:Channels:2:Scale"] = "1", + ["Devices:Daq:Channels:2:Offset"] = "0", + ["Devices:Daq:Channels:2:IsCalibrated"] = "true", + ["Devices:Daq:Channels:3:PhysicalChannel"] = "3", + ["Devices:Daq:Channels:3:Role"] = "InputCurrent", + ["Devices:Daq:Channels:3:Name"] = "输入电流", + ["Devices:Daq:Channels:3:Scale"] = "1", + ["Devices:Daq:Channels:3:Offset"] = "0", + ["Devices:Daq:Channels:3:IsCalibrated"] = "true", + ["Storage:ProjectsRoot"] = "%LOCALAPPDATA%\\SSPCTester\\Projects", + ["Report:SavePath"] = "%LOCALAPPDATA%\\SSPCTester\\Reports", + ["Report:Format"] = "Pdf", + ["Serilog:MinimumLevel:Default"] = "Information", + ["Serilog:WriteTo:0:Name"] = "Debug", + ["Serilog:WriteTo:1:Name"] = "File", + ["Serilog:WriteTo:1:Args:path"] = "%LOCALAPPDATA%\\SSPCTester\\Logs\\app-.log", + ["Serilog:WriteTo:1:Args:rollingInterval"] = "Day", + ["Serilog:WriteTo:1:Args:retainedFileCountLimit"] = "7", + }; + } + + private static void NormalizeDaqOptions(DaqOptions options) + { + options.Channels = DaqChannelOptionsNormalizer.Normalize(options.Channels); + } + + private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) + { + FatalCrash(e.Exception); + e.Handled = true; + } + + private static void OnDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) + { + if (e.ExceptionObject is Exception ex) FatalCrash(ex); + } + + private static void FatalCrash(Exception ex) + { + try + { + Log.Error(ex, "Fatal"); + var path = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "SSPCTester", "Logs", $"crash-{DateTime.Now:yyyyMMdd_HHmmss}.txt"); + Directory.CreateDirectory(Path.GetDirectoryName(path)!); + File.WriteAllText(path, ex.ToString()); + } + catch { /* swallow */ } + MessageBox.Show(ex.ToString(), "SSPCTester 启动失败", MessageBoxButton.OK, MessageBoxImage.Error); + } +} diff --git a/SSPCTester.UI/AssemblyInfo.cs b/SSPCTester.UI/AssemblyInfo.cs new file mode 100644 index 0000000..cc29e7f --- /dev/null +++ b/SSPCTester.UI/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/SSPCTester.UI/Controls/CurvePlotControl.xaml b/SSPCTester.UI/Controls/CurvePlotControl.xaml new file mode 100644 index 0000000..fa61701 --- /dev/null +++ b/SSPCTester.UI/Controls/CurvePlotControl.xaml @@ -0,0 +1,10 @@ + + + + + diff --git a/SSPCTester.UI/Controls/CurvePlotControl.xaml.cs b/SSPCTester.UI/Controls/CurvePlotControl.xaml.cs new file mode 100644 index 0000000..aa75fd9 --- /dev/null +++ b/SSPCTester.UI/Controls/CurvePlotControl.xaml.cs @@ -0,0 +1,136 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using ScottPlot; +using SSPCTester.Devices.Interfaces; + +namespace SSPCTester.UI.Controls; + +public partial class CurvePlotControl : UserControl +{ + public CurvePlotControl() + { + InitializeComponent(); + Loaded += (_, _) => InitPlot(); + } + + public static readonly DependencyProperty CurveProperty = DependencyProperty.Register( + nameof(Curve), typeof(CurveData), typeof(CurvePlotControl), + new PropertyMetadata(null, (d, e) => ((CurvePlotControl)d).Render())); + + public static readonly DependencyProperty IsRisingProperty = DependencyProperty.Register( + nameof(IsRising), typeof(bool), typeof(CurvePlotControl), + new PropertyMetadata(true, (d, e) => ((CurvePlotControl)d).Render())); + + public static readonly DependencyProperty VMaxProperty = DependencyProperty.Register( + nameof(VMax), typeof(double), typeof(CurvePlotControl), + new PropertyMetadata(28.0, (d, e) => ((CurvePlotControl)d).Render())); + + public static readonly DependencyProperty ViewStartMsProperty = DependencyProperty.Register( + nameof(ViewStartMs), typeof(double?), typeof(CurvePlotControl), + new PropertyMetadata(null, (d, e) => ((CurvePlotControl)d).Render())); + + public static readonly DependencyProperty ViewEndMsProperty = DependencyProperty.Register( + nameof(ViewEndMs), typeof(double?), typeof(CurvePlotControl), + new PropertyMetadata(null, (d, e) => ((CurvePlotControl)d).Render())); + + public CurveData? Curve { get => (CurveData?)GetValue(CurveProperty); set => SetValue(CurveProperty, value); } + public bool IsRising { get => (bool)GetValue(IsRisingProperty); set => SetValue(IsRisingProperty, value); } + public double VMax { get => (double)GetValue(VMaxProperty); set => SetValue(VMaxProperty, value); } + public double? ViewStartMs { get => (double?)GetValue(ViewStartMsProperty); set => SetValue(ViewStartMsProperty, value); } + public double? ViewEndMs { get => (double?)GetValue(ViewEndMsProperty); set => SetValue(ViewEndMsProperty, value); } + + private void InitPlot() + { + Plot.Plot.Title(""); + Plot.Plot.XLabel("t (ms)"); + Plot.Plot.YLabel("V"); + Plot.Plot.Axes.AntiAlias(true); + Plot.Plot.FigureBackground.Color = ScottPlot.Color.FromHex("#FBFCFD"); + Plot.Plot.DataBackground.Color = ScottPlot.Color.FromHex("#FBFCFD"); + Plot.Plot.Grid.MajorLineColor = ScottPlot.Color.FromHex("#DFE4EA"); + Render(); + } + + private void Render() + { + if (!IsLoaded || Plot == null) return; + Plot.Plot.Clear(); + var c = Curve; + if (c == null || c.Voltage.Length == 0) + { + Plot.Refresh(); + return; + } + var points = BuildViewPoints(c); + if (points.Count == 0) + { + Plot.Refresh(); + return; + } + + var xs = new double[points.Count]; + var ys = new double[points.Count]; + // 以触发时刻为 0;x 单位 ms + for (int i = 0; i < points.Count; i++) + { + xs[i] = points[i].TimeMs; + ys[i] = points[i].Voltage; + } + var color = IsRising ? "#1A73C4" : "#D23B3B"; + var sig = Plot.Plot.Add.ScatterLine(xs, ys, ScottPlot.Color.FromHex(color)); + sig.LineWidth = 2; + sig.MarkerSize = 0; + + // 阈值线 + double threshold = IsRising ? VMax * 0.9 : VMax * 0.1; + var hLine = Plot.Plot.Add.HorizontalLine(threshold); + hLine.Color = ScottPlot.Color.FromHex("#98A1AD"); + hLine.LinePattern = ScottPlot.LinePattern.Dashed; + hLine.LineWidth = 1; + var label = Plot.Plot.Add.Text($"{(IsRising ? 90 : 10)}%", xs[0], threshold); + label.LabelFontColor = ScottPlot.Color.FromHex("#98A1AD"); + label.LabelFontSize = 10; + + // 触发线 t=0 + if (!HasViewWindow(out double start, out double end) || (start <= 0 && end >= 0)) + { + var vLine = Plot.Plot.Add.VerticalLine(0); + vLine.Color = ScottPlot.Color.FromHex("#98A1AD"); + vLine.LinePattern = ScottPlot.LinePattern.Dotted; + vLine.LineWidth = 1; + } + + Plot.Plot.Axes.AutoScale(); + Plot.Refresh(); + } + + private List<(double TimeMs, double Voltage)> BuildViewPoints(CurveData curve) + { + var points = new List<(double TimeMs, double Voltage)>(curve.Voltage.Length); + bool hasWindow = HasViewWindow(out double start, out double end); + + for (int i = 0; i < curve.Voltage.Length; i++) + { + double timeMs = (curve.TimeAt(i) - curve.TriggerTimeSec) * 1000.0; + if (!hasWindow || (timeMs >= start && timeMs <= end)) + points.Add((timeMs, curve.Voltage[i])); + } + + return points; + } + + private bool HasViewWindow(out double start, out double end) + { + start = ViewStartMs ?? 0; + end = ViewEndMs ?? 0; + return ViewStartMs.HasValue && ViewEndMs.HasValue + && double.IsFinite(start) && double.IsFinite(end) && end > start; + } + + /// 导出为 PNG 字节。 + public byte[] ExportPng(int width = 800, int height = 300) + { + return Plot.Plot.GetImageBytes(width, height, ImageFormat.Png); + } +} diff --git a/SSPCTester.UI/Converters/Converters.cs b/SSPCTester.UI/Converters/Converters.cs new file mode 100644 index 0000000..83a832d --- /dev/null +++ b/SSPCTester.UI/Converters/Converters.cs @@ -0,0 +1,120 @@ +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Media; +using SSPCTester.Logic.Models; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.Converters; + +/// TestStatus → 实色徽标背景。 +public sealed class StatusToBrushConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object? parameter, CultureInfo culture) + { + var key = value switch + { + true => "SuccessBrush", + false => "DangerBrush", + TestStatus.Pass => "SuccessBrush", + TestStatus.Fail => "DangerBrush", + TestStatus.Running => "RunningBrush", + TestStatus.Measured => "PrimaryBrush", + _ => "NeutralBrush" + }; + return Application.Current.TryFindResource(key) as Brush ?? Brushes.Gray; + } + public object ConvertBack(object value, Type targetType, object? parameter, CultureInfo culture) => Binding.DoNothing; +} + +/// TestStatus → 浅色徽标背景。 +public sealed class StatusToSoftBrushConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object? parameter, CultureInfo culture) + { + var key = value switch + { + true => "SuccessSoftBrush", + false => "DangerSoftBrush", + TestStatus.Pass => "SuccessSoftBrush", + TestStatus.Fail => "DangerSoftBrush", + TestStatus.Running => "RunningSoftBrush", + TestStatus.Measured => "PrimarySoftBrush", + _ => "NeutralSoftBrush" + }; + return Application.Current.TryFindResource(key) as Brush ?? Brushes.LightGray; + } + public object ConvertBack(object value, Type targetType, object? parameter, CultureInfo culture) => Binding.DoNothing; +} + +/// TestStatus → 中文文本。 +public sealed class StatusToTextConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object? parameter, CultureInfo culture) + => value is TestStatus s ? s switch + { + TestStatus.Pass => "合格", + TestStatus.Fail => "不合格", + TestStatus.Running => "测试中", + TestStatus.Measured => "已测", + _ => "未测试" + } : "—"; + public object ConvertBack(object value, Type targetType, object? parameter, CultureInfo culture) => Binding.DoNothing; +} + +/// bool → Visibility(参数 "Invert" 取反)。 +public sealed class BoolToVisConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object? parameter, CultureInfo culture) + { + bool b = value is bool x && x; + if (parameter is string s && s.Equals("Invert", StringComparison.OrdinalIgnoreCase)) b = !b; + return b ? Visibility.Visible : Visibility.Collapsed; + } + public object ConvertBack(object value, Type targetType, object? parameter, CultureInfo culture) + => value is Visibility v && v == Visibility.Visible; +} + +/// null → Collapsed,非 null → Visible(参数 "Invert" 取反)。 +public sealed class NullToVisConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object? parameter, CultureInfo culture) + { + bool isNull = value == null; + if (parameter is string s && s.Equals("Invert", StringComparison.OrdinalIgnoreCase)) isNull = !isNull; + return isNull ? Visibility.Collapsed : Visibility.Visible; + } + public object ConvertBack(object value, Type targetType, object? parameter, CultureInfo culture) => Binding.DoNothing; +} + +/// UiLogLevel → 颜色。 +public sealed class LogLevelToBrushConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object? parameter, CultureInfo culture) + { + var key = value is UiLogLevel l ? l switch + { + UiLogLevel.Success => "SuccessBrush", + UiLogLevel.Warning => "WarningBrush", + UiLogLevel.Error => "DangerBrush", + _ => "TextPrimaryBrush" + } : "TextPrimaryBrush"; + return Application.Current.TryFindResource(key) as Brush ?? Brushes.Black; + } + public object ConvertBack(object value, Type targetType, object? parameter, CultureInfo culture) => Binding.DoNothing; +} + +/// 数值 → "—"(NaN/0 时)或格式化字符串。参数为 .NET 格式串(如 "F2")。 +public sealed class NumberOrDashConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is double d) + { + if (double.IsNaN(d)) return "—"; + return d.ToString(parameter as string ?? "F2", CultureInfo.InvariantCulture); + } + return "—"; + } + public object ConvertBack(object value, Type targetType, object? parameter, CultureInfo culture) => Binding.DoNothing; +} diff --git a/SSPCTester.UI/Resources/Controls.xaml b/SSPCTester.UI/Resources/Controls.xaml new file mode 100644 index 0000000..5cca872 --- /dev/null +++ b/SSPCTester.UI/Resources/Controls.xaml @@ -0,0 +1,356 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SSPCTester.UI/Resources/DataTemplates.xaml b/SSPCTester.UI/Resources/DataTemplates.xaml new file mode 100644 index 0000000..e86fb74 --- /dev/null +++ b/SSPCTester.UI/Resources/DataTemplates.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SSPCTester.UI/Resources/Icons.xaml b/SSPCTester.UI/Resources/Icons.xaml new file mode 100644 index 0000000..3ae591f --- /dev/null +++ b/SSPCTester.UI/Resources/Icons.xaml @@ -0,0 +1,25 @@ + + + + + M13 3L4 14H11L10 21L19 10H12L13 3Z + + + M19.14,12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24,0-.43.17-.47.41l-.36,2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47,0-.59.22L2.74,8.87c-.12.21-.08.47.12.61l2.03,1.58c-.05.3-.09.63-.09.94 0,.31.02.64.07.94l-2.03,1.58c-.18.14-.23.41-.12.61l1.92,3.32c.12.22.37.29.59.22l2.39-.96c.5.38,1.03.7,1.62.94l.36,2.54c.05.24.24.41.48.41h3.84c.24,0,.44-.17.47-.41l.36-2.54c.59-.24,1.13-.56,1.62-.94l2.39.96c.22.08.47,0,.59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12,15.6c-1.98,0-3.6-1.62-3.6-3.6s1.62-3.6,3.6-3.6 3.6,1.62,3.6,3.6-1.62,3.6-3.6,3.6z + + + M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z + + + M10 4H4C2.89 4 2 4.89 2 6V18A2 2 0 0 0 4 20H20A2 2 0 0 0 22 18V8C22 6.89 21.1 6 20 6H12L10 4Z + + + M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z + + + M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z + + + M12,12m-4,0a4,4 0 1,0 8,0a4,4 0 1,0 -8,0 + diff --git a/SSPCTester.UI/Resources/Tokens.xaml b/SSPCTester.UI/Resources/Tokens.xaml new file mode 100644 index 0000000..282f05b --- /dev/null +++ b/SSPCTester.UI/Resources/Tokens.xaml @@ -0,0 +1,86 @@ + + + + + #EEF1F5 + + + + + + + + + + + + + + + + + + + + + + #1A73C4 + + + + + + + + + + + + + + + + + + + + + + + + #1A73C4 + #D23B3B + + + + + + + + Microsoft YaHei, PingFang SC, Segoe UI + Consolas, Cascadia Mono + + + 18 + 16 + 14 + 13 + 12 + 11 + 14 + + + 3 + 5 + 8 + + + 30 + 24 + 48 + 232 + 38 + 34 + diff --git a/SSPCTester.UI/SSPCTester.UI.csproj b/SSPCTester.UI/SSPCTester.UI.csproj new file mode 100644 index 0000000..49e8d68 --- /dev/null +++ b/SSPCTester.UI/SSPCTester.UI.csproj @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + WinExe + net8.0-windows + x64 + x64 + enable + enable + true + SSPCTester.UI + true + $(DefaultItemExcludes);bin-codex\**;obj-codex\** + + + + + PreserveNewest + + + PreserveNewest + PreserveNewest + + + + + + PreserveNewest + PreserveNewest + + + + diff --git a/SSPCTester.UI/Services/AppLog.cs b/SSPCTester.UI/Services/AppLog.cs new file mode 100644 index 0000000..ec9b171 --- /dev/null +++ b/SSPCTester.UI/Services/AppLog.cs @@ -0,0 +1,10 @@ +namespace SSPCTester.UI.Services; + +/// +/// 全局日志接收器静态访问点(仅供 XAML 绑定使用,应用其余地方一律 DI 注入 UiLogSink)。 +/// +public static class AppLog +{ + private static UiLogSink? _sink; + public static UiLogSink Sink => _sink ??= (UiLogSink)App.Services.GetService(typeof(UiLogSink))!; +} diff --git a/SSPCTester.UI/Services/AppOptions.cs b/SSPCTester.UI/Services/AppOptions.cs new file mode 100644 index 0000000..edce9b6 --- /dev/null +++ b/SSPCTester.UI/Services/AppOptions.cs @@ -0,0 +1,15 @@ +namespace SSPCTester.UI.Services; + +/// UI 层配置:项目存储、报告路径等。 +public sealed class StorageOptions +{ + public const string SectionName = "Storage"; + public string ProjectsRoot { get; set; } = ""; +} + +public sealed class ReportOptions +{ + public const string SectionName = "Report"; + public string SavePath { get; set; } = ""; + public string Format { get; set; } = "Pdf"; +} diff --git a/SSPCTester.UI/Services/UiLogSink.cs b/SSPCTester.UI/Services/UiLogSink.cs new file mode 100644 index 0000000..b8929ca --- /dev/null +++ b/SSPCTester.UI/Services/UiLogSink.cs @@ -0,0 +1,35 @@ +using System.Collections.ObjectModel; +using System.Windows.Threading; + +namespace SSPCTester.UI.Services; + +/// +/// UI 日志接收器:把日志事件投递到 UI 线程的 ObservableCollection,供日志面板绑定。 +/// +public sealed class UiLogSink +{ + private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher; + public ObservableCollection Entries { get; } = new(); + + public int MaxEntries { get; set; } = 500; + + public void Add(UiLogLevel level, string message) + { + var entry = new LogEntry(DateTime.Now, level, message); + if (_dispatcher.CheckAccess()) Append(entry); + else _dispatcher.BeginInvoke(() => Append(entry)); + } + + private void Append(LogEntry entry) + { + Entries.Add(entry); + while (Entries.Count > MaxEntries) Entries.RemoveAt(0); + } +} + +public enum UiLogLevel { Info, Success, Warning, Error } + +public sealed record LogEntry(DateTime Time, UiLogLevel Level, string Message) +{ + public string TimeText => Time.ToString("HH:mm:ss.fff"); +} diff --git a/SSPCTester.UI/Services/UserSettingsStore.cs b/SSPCTester.UI/Services/UserSettingsStore.cs new file mode 100644 index 0000000..844f017 --- /dev/null +++ b/SSPCTester.UI/Services/UserSettingsStore.cs @@ -0,0 +1,96 @@ +using System.IO; +using System.Text.Json; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; + +namespace SSPCTester.UI.Services; + +/// 将机器本地硬件配置保存到 LocalAppData,不修改发布目录。 +public sealed class UserSettingsStore : IDisposable +{ + private static readonly JsonSerializerOptions JsonOptions = new() + { + WriteIndented = true, + Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; + + private readonly DeviceOptions _devices; + private readonly StorageOptions _storage; + private readonly ReportOptions _report; + private readonly SemaphoreSlim _writeLock = new(1, 1); + private readonly object _timerLock = new(); + private Timer? _timer; + + public UserSettingsStore( + IOptions devices, + IOptions storage, + IOptions report) + { + _devices = devices.Value; + _storage = storage.Value; + _report = report.Value; + } + + public static string SettingsPath => Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "SSPCTester", "settings.json"); + + public void ScheduleSave() + { + lock (_timerLock) + { + _timer?.Dispose(); + _timer = new Timer(async _ => + { + try { await SaveAsync().ConfigureAwait(false); } + catch { /* 后续显式保存或退出时会再次尝试 */ } + }, null, 600, Timeout.Infinite); + } + } + + public async Task SaveAsync() + { + await _writeLock.WaitAsync().ConfigureAwait(false); + try + { + string path = SettingsPath; + Directory.CreateDirectory(Path.GetDirectoryName(path)!); + string temp = path + ".tmp"; + _devices.Daq.Channels = DaqChannelOptionsNormalizer.Normalize(_devices.Daq.Channels); + var model = new + { + Devices = _devices, + Storage = _storage, + Report = _report + }; + await File.WriteAllTextAsync(temp, JsonSerializer.Serialize(model, JsonOptions)).ConfigureAwait(false); + File.Move(temp, path, true); + WriteDaqSaveTrace(path); + } + finally { _writeLock.Release(); } + } + + private void WriteDaqSaveTrace(string settingsPath) + { + try + { + string logDir = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "SSPCTester", "Logs"); + Directory.CreateDirectory(logDir); + string channels = string.Join(", ", _devices.Daq.Channels + .OrderBy(x => x.PhysicalChannel) + .Select(x => $"CH{x.PhysicalChannel}:{x.Role}/{x.IsCalibrated}")); + File.AppendAllText( + Path.Combine(logDir, "settings-save.log"), + $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} {settingsPath} Pre={_devices.Daq.PreTriggerMs:R} Post={_devices.Daq.PostTriggerMs:R} Channels=[{channels}]{Environment.NewLine}"); + } + catch { } + } + + public void Dispose() + { + lock (_timerLock) { _timer?.Dispose(); } + _writeLock.Dispose(); + } +} diff --git a/SSPCTester.UI/ViewModels/BasicTestViewModel.cs b/SSPCTester.UI/ViewModels/BasicTestViewModel.cs new file mode 100644 index 0000000..f74cd6b --- /dev/null +++ b/SSPCTester.UI/ViewModels/BasicTestViewModel.cs @@ -0,0 +1,308 @@ +using System.Collections.ObjectModel; +using System.Windows; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Testing; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.ViewModels; + +/// 基础测试页 VM:24 通道 + 行内开/关按钮 + 统计条 + 一键测试全部。 +public partial class BasicTestViewModel : ObservableObject +{ + private const int SwitchSettleDelayMs = BasicTestCriteria.SwitchSettleDelayMs; + private readonly ISspc _sspc; + private readonly UiLogSink _log; + private readonly object _pollLock = new(); + private readonly HashSet _pollingChannels = new(); + private CancellationTokenSource? _pollCts; + private Task? _pollTask; + private CancellationTokenSource? _runAllCts; + + [ObservableProperty] private bool _busy; + [ObservableProperty] private bool _isBatchRunning; + [ObservableProperty] private Project? _project; + [ObservableProperty] private int _selectedRefreshRateHz = 5; + + public ObservableCollection Rows { get; } = new(); + public IReadOnlyList RefreshRatesHz { get; } = new[] { 2, 5 }; + + public BasicTestViewModel(ISspc sspc, UiLogSink log) + { + _sspc = sspc; _log = log; + } + + public int Total => Rows.Count; + public int PassCount => Rows.Count(r => r.Status == TestStatus.Pass); + public int FailCount => Rows.Count(r => r.Status == TestStatus.Fail); + public int UntestedCount => Rows.Count(r => r.Status == TestStatus.Untested); + public bool CanRunAll => !Busy && !IsBatchRunning; + + partial void OnBusyChanged(bool value) => OnPropertyChanged(nameof(CanRunAll)); + + partial void OnIsBatchRunningChanged(bool value) => OnPropertyChanged(nameof(CanRunAll)); + + public void SetProject(Project p) + { + StopAllPolling(); + Project = p; + Rows.Clear(); + if (p.BasicResults.Count == 0) + { + for (int i = 1; i <= _sspc.ChannelCount; i++) + p.BasicResults.Add(new ChannelResult { Channel = i }); + } + foreach (var r in p.BasicResults) + { + r.PropertyChanged += (_, _) => RaiseStats(); + Rows.Add(r); + } + RaiseStats(); + } + + private void RaiseStats() + { + Application.Current?.Dispatcher.Invoke(() => + { + OnPropertyChanged(nameof(PassCount)); + OnPropertyChanged(nameof(FailCount)); + OnPropertyChanged(nameof(UntestedCount)); + OnPropertyChanged(nameof(Total)); + }); + } + + [RelayCommand] + private async Task TurnOn(ChannelResult? row) + { + if (row == null) return; + Busy = true; + try + { + if (!_sspc.IsConnected) await _sspc.ConnectAsync(); + row.Status = TestStatus.Running; + await _sspc.TurnOnAsync(row.Channel); + await Task.Delay(SwitchSettleDelayMs); + var measurement = await _sspc.ReadMeasurementAsync(row.Channel); + row.VoltageOn = measurement.Voltage; + row.CurrentOn = Math.Abs(measurement.Current); + StartPolling(row.Channel); + _log.Add(UiLogLevel.Info, $"CH{row.Channel} 开 -> V={row.VoltageOn:F2}V I={row.CurrentOn:F3}A"); + } + catch (Exception ex) + { + await StopPollingAsync(row.Channel); + row.Status = TestStatus.Fail; + _log.Add(UiLogLevel.Error, $"CH{row.Channel} 开启或读取失败:{ex.Message}"); + try { await _sspc.TurnOffAsync(row.Channel); } catch { } + } + finally { Busy = false; } + } + + [RelayCommand] + private async Task TurnOff(ChannelResult? row) + { + if (row == null) return; + Busy = true; + try + { + await StopPollingAsync(row.Channel); + await _sspc.TurnOffAsync(row.Channel); + await Task.Delay(SwitchSettleDelayMs); + var offResult = await BasicTestCriteria.WaitForStableOffAsync(_sspc, row.Channel); + row.VoltageOff = offResult.Measurement.Voltage; + bool onOk = BasicTestCriteria.IsOn(row.VoltageOn); + row.Status = (onOk && offResult.IsStableOff) ? TestStatus.Pass : TestStatus.Fail; + string verdict = row.Status == TestStatus.Pass ? "合格" : "不合格"; + string offState = offResult.IsStableOff ? "已稳定关断" : "关断超时"; + _log.Add(row.Status == TestStatus.Pass ? UiLogLevel.Success : UiLogLevel.Error, + $"CH{row.Channel} 关 -> V={row.VoltageOff:F2}V {offState} {verdict}"); + } + catch (Exception ex) + { + await StopPollingAsync(row.Channel); + row.Status = TestStatus.Fail; + _log.Add(UiLogLevel.Error, $"CH{row.Channel} 关断或读取失败:{ex.Message}"); + try { await _sspc.TurnOffAsync(row.Channel); } catch { } + } + finally { Busy = false; } + } + + [RelayCommand] + private async Task RunAll() + { + if (IsBatchRunning) return; + + _runAllCts?.Dispose(); + _runAllCts = new CancellationTokenSource(); + var ct = _runAllCts.Token; + + Busy = true; + IsBatchRunning = true; + try + { + foreach (var row in Rows) + { + ct.ThrowIfCancellationRequested(); + await RunChannelAsync(row, ct); + } + _log.Add(UiLogLevel.Success, "基础测试全部完成。"); + } + catch (OperationCanceledException) + { + foreach (var row in Rows) + { + if (row.Status == TestStatus.Running) + row.Status = TestStatus.Untested; + } + _log.Add(UiLogLevel.Warning, "基础测试批量测试已中断。"); + } + finally + { + _runAllCts?.Dispose(); + _runAllCts = null; + IsBatchRunning = false; + Busy = false; + } + } + + [RelayCommand] + private async Task CancelRunAll() + { + if (!IsBatchRunning) return; + + _runAllCts?.Cancel(); + foreach (var row in Rows) + { + if (row.Status != TestStatus.Running) continue; + + try + { + await StopPollingAsync(row.Channel); + await _sspc.TurnOffAsync(row.Channel); + } + catch { } + } + } + + private async Task RunChannelAsync(ChannelResult row, CancellationToken ct) + { + if (!_sspc.IsConnected) await _sspc.ConnectAsync(ct); + + row.Status = TestStatus.Running; + await _sspc.TurnOnAsync(row.Channel, ct); + await Task.Delay(SwitchSettleDelayMs, ct); + + var measurement = await _sspc.ReadMeasurementAsync(row.Channel, ct); + row.VoltageOn = measurement.Voltage; + row.CurrentOn = Math.Abs(measurement.Current); + StartPolling(row.Channel); + + ct.ThrowIfCancellationRequested(); + + await StopPollingAsync(row.Channel); + await _sspc.TurnOffAsync(row.Channel, ct); + await Task.Delay(SwitchSettleDelayMs, ct); + + var offResult = await BasicTestCriteria.WaitForStableOffAsync(_sspc, row.Channel, ct); + row.VoltageOff = offResult.Measurement.Voltage; + bool onOk = BasicTestCriteria.IsOn(row.VoltageOn); + row.Status = (onOk && offResult.IsStableOff) ? TestStatus.Pass : TestStatus.Fail; + } + + [RelayCommand] + private void Clear() + { + foreach (var r in Rows) + { + r.VoltageOn = 0; r.CurrentOn = 0; r.VoltageOff = 0; + r.Status = TestStatus.Untested; + } + } + + private void StartPolling(int channel) + { + lock (_pollLock) + { + _pollingChannels.Add(channel); + if (_pollTask is { IsCompleted: false }) return; + + _pollCts = new CancellationTokenSource(); + _pollTask = PollMeasurementsAsync(_pollCts.Token); + } + } + + private async Task StopPollingAsync(int channel) + { + Task? taskToWait = null; + CancellationTokenSource? ctsToDispose = null; + lock (_pollLock) + { + _pollingChannels.Remove(channel); + if (_pollingChannels.Count != 0 || _pollCts == null) return; + + _pollCts.Cancel(); + taskToWait = _pollTask; + ctsToDispose = _pollCts; + _pollTask = null; + _pollCts = null; + } + + if (taskToWait != null) + { + try { await taskToWait; } + catch (OperationCanceledException) { } + } + ctsToDispose?.Dispose(); + } + + private void StopAllPolling() + { + lock (_pollLock) + { + _pollingChannels.Clear(); + _pollCts?.Cancel(); + _pollCts = null; + _pollTask = null; + } + } + + private async Task PollMeasurementsAsync(CancellationToken ct) + { + while (!ct.IsCancellationRequested) + { + int refreshRate = Math.Max(1, SelectedRefreshRateHz); + await Task.Delay(TimeSpan.FromSeconds(1.0 / refreshRate), ct); + + IReadOnlyList measurements; + try + { + measurements = await _sspc.ReadMeasurementsAsync(ct); + } + catch (OperationCanceledException) when (ct.IsCancellationRequested) + { + break; + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Error, $"基础测试刷新失败:{ex.Message}"); + continue; + } + + HashSet activeChannels; + lock (_pollLock) + activeChannels = _pollingChannels.ToHashSet(); + + foreach (var measurement in measurements) + { + if (!activeChannels.Contains(measurement.PhysicalSlot)) continue; + var row = Rows.FirstOrDefault(x => x.Channel == measurement.PhysicalSlot); + if (row == null) continue; + + row.VoltageOn = measurement.Voltage; + row.CurrentOn = Math.Abs(measurement.Current); + } + } + } +} diff --git a/SSPCTester.UI/ViewModels/CurveTestViewModel.cs b/SSPCTester.UI/ViewModels/CurveTestViewModel.cs new file mode 100644 index 0000000..d95a876 --- /dev/null +++ b/SSPCTester.UI/ViewModels/CurveTestViewModel.cs @@ -0,0 +1,456 @@ +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Calculation; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Storage; +using SSPCTester.Logic.Testing; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.ViewModels; + +/// 曲线测试页 VM。 +public partial class CurveTestViewModel : ObservableObject +{ + private readonly ISspc _sspc; + private readonly IDaq _daq; + private readonly DaqOptions _daqOpts; + private readonly UiLogSink _log; + private readonly ProjectStore _store; + private int _loadVersion; + private int _viewWindowSaveVersion; + private bool _syncingViewWindow; + + public ObservableCollection Rows { get; } = new(); + public ObservableCollection Channels { get; } = new(); + + [ObservableProperty] private Project? _project; + [ObservableProperty] private int _selectedChannel; + [ObservableProperty] private CurveData? _risingCurve; + [ObservableProperty] private CurveData? _fallingCurve; + [ObservableProperty] private double _vMax = 28.0; + [ObservableProperty] private bool _busy; + [ObservableProperty] private CurveResultRow? _selectedRow; + [ObservableProperty] private double? _risingViewStartMs; + [ObservableProperty] private double? _risingViewEndMs; + [ObservableProperty] private double? _fallingViewStartMs; + [ObservableProperty] private double? _fallingViewEndMs; + + public CurveTestViewModel(ISspc sspc, IDaq daq, IOptions opt, UiLogSink log, ProjectStore store) + { + _sspc = sspc; _daq = daq; _daqOpts = opt.Value.Daq; _log = log; + _store = store; + for (int i = 1; i <= _sspc.ChannelCount; i++) Channels.Add(i); + SelectedChannel = 1; + } + + public CurveThresholds Thresholds => Project?.CurveThresholds ?? new CurveThresholds(); + + public void SetProject(Project p) + { + Project = p; + Rows.Clear(); + if (p.CurveResults.Count == 0) + { + for (int i = 1; i <= _sspc.ChannelCount; i++) + p.CurveResults.Add(new CurveResultRow { Channel = i }); + } + foreach (var r in p.CurveResults) Rows.Add(r); + SyncSelectedRow(); + OnPropertyChanged(nameof(Thresholds)); + _ = LoadSelectedChannelCurvesAsync(); + } + + public void AttachSession(TestSessionViewModel s) + { + s.CurveReady += (ch, rising, falling) => + { + if (ch == SelectedChannel) + { + RisingCurve = rising; + FallingCurve = falling; + } + }; + } + + partial void OnSelectedChannelChanged(int value) + { + SyncSelectedRow(); + _ = LoadSelectedChannelCurvesAsync(); + } + + partial void OnRisingViewStartMsChanged(double? value) + { + if (_syncingViewWindow || SelectedRow == null) return; + SelectedRow.RisingViewStartMs = value; + SaveProjectQuietly(); + } + + partial void OnRisingViewEndMsChanged(double? value) + { + if (_syncingViewWindow || SelectedRow == null) return; + SelectedRow.RisingViewEndMs = value; + SaveProjectQuietly(); + } + + partial void OnFallingViewStartMsChanged(double? value) + { + if (_syncingViewWindow || SelectedRow == null) return; + SelectedRow.FallingViewStartMs = value; + SaveProjectQuietly(); + } + + partial void OnFallingViewEndMsChanged(double? value) + { + if (_syncingViewWindow || SelectedRow == null) return; + SelectedRow.FallingViewEndMs = value; + SaveProjectQuietly(); + } + + private void SyncSelectedRow() + { + _syncingViewWindow = true; + try + { + SelectedRow = Rows.FirstOrDefault(x => x.Channel == SelectedChannel) + ?? Project?.CurveResults.FirstOrDefault(x => x.Channel == SelectedChannel); + RisingViewStartMs = SelectedRow?.RisingViewStartMs ?? SelectedRow?.ViewStartMs; + RisingViewEndMs = SelectedRow?.RisingViewEndMs ?? SelectedRow?.ViewEndMs; + FallingViewStartMs = SelectedRow?.FallingViewStartMs ?? SelectedRow?.ViewStartMs; + FallingViewEndMs = SelectedRow?.FallingViewEndMs ?? SelectedRow?.ViewEndMs; + } + finally + { + _syncingViewWindow = false; + } + } + + [RelayCommand] + private void ResetRisingView() + { + if (SelectedRow == null) return; + RisingViewStartMs = null; + RisingViewEndMs = null; + SelectedRow.RisingViewStartMs = null; + SelectedRow.RisingViewEndMs = null; + SaveProjectQuietly(); + } + + [RelayCommand] + private void ResetFallingView() + { + if (SelectedRow == null) return; + FallingViewStartMs = null; + FallingViewEndMs = null; + SelectedRow.FallingViewStartMs = null; + SelectedRow.FallingViewEndMs = null; + SaveProjectQuietly(); + } + + private void SaveProjectQuietly() + { + var project = Project; + if (project == null) return; + int version = Interlocked.Increment(ref _viewWindowSaveVersion); + _ = SaveProjectQuietlyAsync(project, version); + } + + private async Task SaveProjectQuietlyAsync(Project project, int version) + { + try + { + await Task.Delay(300); + if (version != _viewWindowSaveVersion) return; + await _store.SaveAsync(project); + } + catch (Exception ex) { _log.Add(UiLogLevel.Warning, $"曲线视图窗口保存失败:{ex.Message}"); } + } + + private async Task LoadSelectedChannelCurvesAsync() + { + int version = ++_loadVersion; + var project = Project; + if (project == null) + { + RisingCurve = null; + FallingCurve = null; + return; + } + + var row = Rows.FirstOrDefault(x => x.Channel == SelectedChannel) + ?? project.CurveResults.FirstOrDefault(x => x.Channel == SelectedChannel); + if (row == null) + { + RisingCurve = null; + FallingCurve = null; + return; + } + + try + { + var rising = await WaveformStore.LoadAsync(project, row.RisingWaveformPath); + var falling = await WaveformStore.LoadAsync(project, row.FallingWaveformPath); + if (version != _loadVersion) return; + + RisingCurve = rising; + FallingCurve = falling; + if (rising != null) + VMax = CurveMetrics.EstimateVMax(rising.Voltage); + } + catch (Exception ex) + { + if (version != _loadVersion) return; + RisingCurve = null; + FallingCurve = null; + _log.Add(UiLogLevel.Warning, $"CH{SelectedChannel} 历史曲线加载失败:{ex.Message}"); + } + } + + /// 仅用于"浏览历史项目"时的可视化预览:调用 MockDaq 合成一段波形,不操作 SSPC。 + private async Task PreviewSelectedAsync() + { + if (Busy) return; + try + { + Busy = true; + var request = new DaqActionCaptureRequest(_daqOpts.PreTriggerMs, _daqOpts.PostTriggerMs, true); + var rising = await _daq.CaptureAroundActionAsync(request, _ => Task.CompletedTask); + var falling = await _daq.CaptureAroundActionAsync(request with { IsRising = false }, _ => Task.CompletedTask); + VMax = CurveMetrics.EstimateVMax(rising.Voltage); + RisingCurve = rising; + FallingCurve = falling; + } + catch { /* 预览失败不影响主流程 */ } + finally { Busy = false; } + } + + [RelayCommand] + private void OpenPopup() + { + var win = new Views.CurvePopupWindow(this) { Owner = System.Windows.Application.Current?.MainWindow }; + win.Show(); + } + + [RelayCommand] + private async Task CaptureRising() + { + if (Project == null) return; + Busy = true; + try + { + int ch = SelectedChannel; + await EnsureCurveCaptureReadyAsync(ch); + await _sspc.TurnOffAsync(ch); + await BasicTestCriteria.WaitForStableOffAsync(_sspc, ch); + + _log.Add(UiLogLevel.Info, $"CH{ch} 开始预采集,待触发后发送开启动作。"); + var rising = await _daq.CaptureAroundActionAsync( + new DaqActionCaptureRequest(_daqOpts.PreTriggerMs, _daqOpts.PostTriggerMs, true), + async token => + { + _log.Add(UiLogLevel.Info, $"CH{ch} 触发开启动作命令。"); + await _sspc.TurnOnAsync(ch, token); + }); + + await ApplyRisingCaptureAsync(Project, ch, rising); + _log.Add(UiLogLevel.Success, $"CH{ch} 开启曲线采集完成。"); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Error, + $"开启曲线采集失败:{ex.GetType().Name} - {ex.Message}(CH{SelectedChannel},SSPC连接={_sspc.IsConnected},DAQ连接={_daq.IsConnected})"); + try { await _sspc.TurnOffAsync(SelectedChannel); } catch { } + } + finally { Busy = false; } + } + + [RelayCommand] + private async Task CaptureFalling() + { + if (Project == null) return; + Busy = true; + try + { + int ch = SelectedChannel; + await EnsureCurveCaptureReadyAsync(ch); + _log.Add(UiLogLevel.Info, $"CH{ch} 准备采集关断曲线:先确保通道已开启并稳定。"); + await _sspc.TurnOnAsync(ch); + await WaitForStableOnAsync(ch); + + _log.Add(UiLogLevel.Info, $"CH{ch} 开始预采集,待触发后发送关断动作。"); + var falling = await _daq.CaptureAroundActionAsync( + new DaqActionCaptureRequest(_daqOpts.PreTriggerMs, _daqOpts.PostTriggerMs, false), + async token => + { + _log.Add(UiLogLevel.Info, $"CH{ch} 触发关断动作命令。"); + await _sspc.TurnOffAsync(ch, token); + }); + + await ApplyFallingCaptureAsync(Project, ch, falling); + _log.Add(UiLogLevel.Success, $"CH{ch} 关断曲线采集完成。"); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Error, + $"关断曲线采集失败:{ex.GetType().Name} - {ex.Message}(CH{SelectedChannel},SSPC连接={_sspc.IsConnected},DAQ连接={_daq.IsConnected})"); + try { await _sspc.TurnOffAsync(SelectedChannel); } catch { } + } + finally { Busy = false; } + } + + private async Task EnsureCurveCaptureReadyAsync(int ch) + { + if (!ValidateCurveCaptureConfig(out var configMessage)) + { + _log.Add(UiLogLevel.Error, $"CH{ch} 曲线采集被阻止:{configMessage}"); + throw new InvalidOperationException(configMessage); + } + + try + { + if (!_sspc.IsConnected) await _sspc.ConnectAsync(); + } + catch (Exception ex) + { + throw new InvalidOperationException($"Modbus(继电器端)连接失败:{ex.Message}。请在设置中检查串口与连接,否则继电器无法动作。", ex); + } + + try + { + if (!_daq.IsConnected) await _daq.ConnectAsync(); + } + catch (Exception ex) + { + throw new InvalidOperationException($"高速采集卡连接失败:{ex.Message}。请在设置中检查采集卡。", ex); + } + } + + private async Task ApplyRisingCaptureAsync(Project project, int ch, CurveData rising) + { + double vMax = CurveMetrics.EstimateVMax(rising.Voltage); + var row = Rows.First(r => r.Channel == ch); + row.OnTimeMs = CurveMetrics.OnTimeMs(rising, vMax); + row.RiseTimeMs = CurveMetrics.RiseTimeMs(rising, vMax); + row.RisingWaveformPath = await WaveformStore.SaveAsync(project, ch, "on", rising); + RisingCurve = rising; + UpdateVMax(rising, FallingCurve); + RefreshCurveRowStatus(row); + await _store.SaveAsync(project); + } + + private async Task ApplyFallingCaptureAsync(Project project, int ch, CurveData falling) + { + double vMax = CurveMetrics.EstimateVMax(falling.Voltage); + var row = Rows.First(r => r.Channel == ch); + row.OffTimeMs = CurveMetrics.OffTimeMs(falling, vMax); + row.FallTimeMs = CurveMetrics.FallTimeMs(falling, vMax); + row.FallingWaveformPath = await WaveformStore.SaveAsync(project, ch, "off", falling); + + FallingCurve = falling; + UpdateVMax(RisingCurve, falling); + RefreshCurveRowStatus(row); + await _store.SaveAsync(project); + } + + private void RefreshCurveRowStatus(CurveResultRow row) + { + bool hasRising = !string.IsNullOrWhiteSpace(row.RisingWaveformPath); + bool hasFalling = !string.IsNullOrWhiteSpace(row.FallingWaveformPath); + if (!hasRising && !hasFalling) + { + row.Status = TestStatus.Untested; + return; + } + + if (!(hasRising && hasFalling)) + { + row.Status = TestStatus.Measured; + return; + } + + var th = Thresholds; + bool ok = double.IsFinite(row.OnTimeMs) + && double.IsFinite(row.RiseTimeMs) + && double.IsFinite(row.OffTimeMs) + && double.IsFinite(row.FallTimeMs) + && !double.IsNaN(row.OnTimeMs) + && !double.IsNaN(row.RiseTimeMs) + && !double.IsNaN(row.OffTimeMs) + && !double.IsNaN(row.FallTimeMs) + && row.OnTimeMs <= th.MaxOnTimeMs + && row.RiseTimeMs <= th.MaxRiseTimeMs + && row.OffTimeMs <= th.MaxOffTimeMs + && row.FallTimeMs <= th.MaxFallTimeMs; + row.Status = ok ? TestStatus.Pass : TestStatus.Fail; + } + + private void UpdateVMax(params CurveData?[] curves) + { + var candidates = curves.Where(x => x != null) + .Select(x => CurveMetrics.EstimateVMax(x!.Voltage)) + .Where(x => double.IsFinite(x) && !double.IsNaN(x)) + .ToArray(); + if (candidates.Length > 0) + VMax = candidates.Max(); + } + + private async Task WaitForStableOnAsync(int channel, CancellationToken ct = default) + { + await Task.Delay(BasicTestCriteria.SwitchSettleDelayMs, ct); + var measurement = await _sspc.ReadMeasurementAsync(channel, ct); + if (!BasicTestCriteria.IsOn(measurement.Voltage)) + throw new InvalidOperationException($"CH{channel} 未能稳定开启,当前电压 {measurement.Voltage:F3} V。"); + } + + private bool ValidateCurveCaptureConfig(out string message) + { + if (_daqOpts.UseMock) + { + message = "Mock 模式,曲线采集配置有效。"; + return true; + } + + if (_daqOpts.ChannelCount is not (1 or 2 or 4 or 8)) + { + message = "DAQ 启用通道数只能为 1、2、4 或 8。"; + return false; + } + + var enabled = _daqOpts.Channels.Where(x => x.PhysicalChannel < _daqOpts.ChannelCount).ToArray(); + if (enabled.Length == 0) + { + message = "DAQ 没有可用的启用通道。"; + return false; + } + + var outputVoltage = enabled.Where(x => string.Equals(x.Role, nameof(DaqChannelRole.OutputVoltage), StringComparison.OrdinalIgnoreCase)).ToArray(); + if (outputVoltage.Length != 1) + { + message = $"曲线测试必须配置且只能配置一个 OutputVoltage 角色,当前配置了 {outputVoltage.Length} 个。"; + return false; + } + + var voltageChannel = outputVoltage[0]; + if (!voltageChannel.IsCalibrated) + { + message = $"CH{voltageChannel.PhysicalChannel} OutputVoltage 尚未勾选已标定。"; + return false; + } + if (!double.IsFinite(voltageChannel.Scale) || voltageChannel.Scale == 0) + { + message = $"CH{voltageChannel.PhysicalChannel} 输出电压通道 Scale 无效。"; + return false; + } + if (!double.IsFinite(voltageChannel.Offset)) + { + message = $"CH{voltageChannel.PhysicalChannel} 输出电压通道 Offset 无效。"; + return false; + } + + message = "曲线采集配置有效。"; + return true; + } +} diff --git a/SSPCTester.UI/ViewModels/HomeViewModel.cs b/SSPCTester.UI/ViewModels/HomeViewModel.cs new file mode 100644 index 0000000..c3a5ae9 --- /dev/null +++ b/SSPCTester.UI/ViewModels/HomeViewModel.cs @@ -0,0 +1,32 @@ +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SSPCTester.Logic.Models; + +namespace SSPCTester.UI.ViewModels; + +/// 首页 / 概览。 +public partial class HomeViewModel : ObservableObject +{ + private readonly MainViewModel _main; + public HomeViewModel(MainViewModel main) + { + _main = main; + Projects = _main.AllProjects; + } + + public ObservableCollection Projects { get; } + + [RelayCommand] + private void OpenProject(Project? p) + { + if (p == null) return; + _main.OpenProjectInfo(p); + } + + [RelayCommand] + private async Task NewProject() + { + await _main.NewProjectCommand.ExecuteAsync(null); + } +} diff --git a/SSPCTester.UI/ViewModels/MainViewModel.cs b/SSPCTester.UI/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..49443df --- /dev/null +++ b/SSPCTester.UI/ViewModels/MainViewModel.cs @@ -0,0 +1,409 @@ +using System.Collections.ObjectModel; +using System.IO; +using System.Windows; +using System.Windows.Threading; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Devices.Config; +using Microsoft.Extensions.Options; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Storage; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.ViewModels; + +/// 主窗口 VM:持有项目集合、当前页面、应用状态。 +public partial class MainViewModel : ObservableObject +{ + private readonly IServiceProvider _sp; + private readonly ProjectStore _store; + private readonly ILogger _logger; + private readonly ISspc _sspc; + private readonly IPowerSupply _power; + private readonly ILoad _load; + private readonly IDaq _daq; + private readonly UiLogSink _logSink; + private readonly DeviceOptions _deviceOptions; + private readonly DispatcherTimer _deviceMonitorTimer; + private object? _viewBeforeSettings; + + public MainViewModel( + IServiceProvider sp, ProjectStore store, ILogger logger, + ISspc sspc, IPowerSupply power, ILoad load, IDaq daq, UiLogSink logSink, + IOptions deviceOptions) + { + _sp = sp; _store = store; _logger = logger; + _sspc = sspc; _power = power; _load = load; _daq = daq; + _logSink = logSink; + _deviceOptions = deviceOptions.Value; + _sspc.ConnectionChanged += (_, _) => RefreshDeviceStatus(); + _power.ConnectionChanged += (_, _) => RefreshDeviceStatus(); + _load.ConnectionChanged += (_, _) => RefreshDeviceStatus(); + _daq.ConnectionChanged += (_, _) => RefreshDeviceStatus(); + _deviceMonitorTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; + _deviceMonitorTimer.Tick += (_, _) => RefreshDeviceStatus(); + _deviceMonitorTimer.Start(); + + AllProjects = new ObservableCollection(); + TreeRoots = new ObservableCollection(); + } + + /// 由 MainWindow.Loaded 调用,启动背景加载(避免在 DI 构造器中触发重入)。 + public void Initialize() + { + if (_initialized) return; + _initialized = true; + _ = LoadProjectsAsync(); + _ = ConnectConfiguredDevicesAsync(); + } + private bool _initialized; + + public ObservableCollection AllProjects { get; } + public ObservableCollection TreeRoots { get; } + + [ObservableProperty] private AppState _state = AppState.Browsing; + [ObservableProperty] private Project? _currentProject; + [ObservableProperty] private object? _currentView; + [ObservableProperty] private bool _devicesConnected; + [ObservableProperty] private bool _devicePanelOpen; + [ObservableProperty] private bool _deviceOperationBusy; + [ObservableProperty] private string _deviceSummary = "设备状态检查中"; + [ObservableProperty] private string _sspcConnectionStatus = "检查中"; + [ObservableProperty] private string _powerConnectionStatus = "检查中"; + [ObservableProperty] private string _loadConnectionStatus = "检查中"; + [ObservableProperty] private string _daqConnectionStatus = "检查中"; + [ObservableProperty] private string _testingMessage = ""; + [ObservableProperty] private TestSessionViewModel? _currentSession; + + partial void OnStateChanged(AppState value) => RebuildTree(); + partial void OnCurrentProjectChanged(Project? value) => RebuildTree(); + + private async Task ConnectConfiguredDevicesAsync() + { + var jobs = new[] + { + ConnectOneAsync("SSPC", _sspc, _deviceOptions.Sspc.AutoConnect), + ConnectOneAsync("电源", _power, _deviceOptions.PowerSupply.AutoConnect), + ConnectOneAsync("负载", _load, _deviceOptions.Load.AutoConnect), + ConnectOneAsync("PCIe8586", _daq, _deviceOptions.Daq.AutoConnect) + }; + await Task.WhenAll(jobs); + DevicesConnected = + (!_deviceOptions.Sspc.AutoConnect || _sspc.IsConnected) && + (!_deviceOptions.PowerSupply.AutoConnect || _power.IsConnected) && + (!_deviceOptions.Load.AutoConnect || _load.IsConnected) && + (!_deviceOptions.Daq.AutoConnect || _daq.IsConnected); + RefreshDeviceStatus(); + } + + private async Task ConnectOneAsync(string name, IDeviceConnection device, bool autoConnect) + { + if (!autoConnect) return; + try + { + bool connected = await device.ConnectAsync(); + if (connected && device.IsConnected) + { + _logSink.Add(UiLogLevel.Success, $"{name} 已自动连接。"); + } + else + { + _logSink.Add(UiLogLevel.Warning, $"{name} 自动连接未成功,设备保持未连接。"); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "{Device} auto connect failed.", name); + _logSink.Add(UiLogLevel.Error, $"{name} 自动连接失败:{ex.Message}"); + } + } + + private void RefreshDeviceStatus() + { + Application.Current?.Dispatcher.Invoke(() => + { + SspcConnectionStatus = DeviceStatusText(_sspc); + PowerConnectionStatus = DeviceStatusText(_power); + LoadConnectionStatus = DeviceStatusText(_load); + DaqConnectionStatus = DeviceStatusText(_daq); + DevicesConnected = + (!_deviceOptions.Sspc.AutoConnect || _sspc.IsConnected) && + (!_deviceOptions.PowerSupply.AutoConnect || _power.IsConnected) && + (!_deviceOptions.Load.AutoConnect || _load.IsConnected) && + (!_deviceOptions.Daq.AutoConnect || _daq.IsConnected); + int connected = new[] { _sspc.IsConnected, _power.IsConnected, _load.IsConnected, _daq.IsConnected }.Count(x => x); + DeviceSummary = connected == 4 ? "设备已连接" : $"设备 {connected}/4 已连接"; + }); + } + + private static string DeviceStatusText(IDeviceConnection device) => + device.IsConnected ? "已连接" : "未连接"; + + [RelayCommand] + private void ToggleDevicePanel() + { + RefreshDeviceStatus(); + DevicePanelOpen = !DevicePanelOpen; + } + + [RelayCommand] + private async Task ConnectAllDevices() + { + if (DeviceOperationBusy) return; + DeviceOperationBusy = true; + try + { + await Task.WhenAll( + ConnectOneAsync("SSPC", _sspc, true), + ConnectOneAsync("电源", _power, true), + ConnectOneAsync("负载", _load, true), + ConnectOneAsync("PCIe8586", _daq, true)); + } + finally + { + DeviceOperationBusy = false; + RefreshDeviceStatus(); + } + } + + [RelayCommand] + private async Task DisconnectAllDevices() + { + if (DeviceOperationBusy) return; + DeviceOperationBusy = true; + try + { + await Task.WhenAll( + SafeDisconnectAsync("SSPC", _sspc), + SafeDisconnectAsync("电源", _power), + SafeDisconnectAsync("负载", _load), + SafeDisconnectAsync("PCIe8586", _daq)); + } + finally + { + DeviceOperationBusy = false; + RefreshDeviceStatus(); + } + } + + [RelayCommand] + private void RefreshDevices() => RefreshDeviceStatus(); + + private async Task SafeDisconnectAsync(string name, IDeviceConnection device) + { + try + { + await device.DisconnectAsync(); + _logSink.Add(UiLogLevel.Info, $"{name} 已断开。"); + } + catch (Exception ex) + { + _logger.LogWarning(ex, "{Device} disconnect failed.", name); + _logSink.Add(UiLogLevel.Error, $"{name} 断开失败:{ex.Message}"); + } + } + + public async Task LoadProjectsAsync() + { + AllProjects.Clear(); + var list = await _store.LoadAllAsync(); + foreach (var p in list) AllProjects.Add(p); + RebuildTree(); + if (CurrentView == null) NavigateHome(); + } + + public void RebuildTree() + { + TreeRoots.Clear(); + var src = State == AppState.Testing && CurrentProject != null + ? new[] { CurrentProject } + : AllProjects.ToArray(); + foreach (var p in src) + { + var node = new ProjectNode(p); + node.Children.Add(new ProjectNode(p, NodeKind.Info)); + node.Children.Add(new ProjectNode(p, NodeKind.Test)); + node.Children.Add(new ProjectNode(p, NodeKind.Report)); + TreeRoots.Add(node); + } + } + + [RelayCommand] + private void NavigateHome() + { + CurrentView = _sp.GetRequiredService(); + } + + [RelayCommand] + private async Task NewProject() + { + var dlg = new Views.NewProjectDialog { Owner = Application.Current?.MainWindow }; + if (dlg.ShowDialog() != true) return; + + var p = new Project + { + Name = dlg.ProjectName, + Dut = new DutInfo + { + ProductName = dlg.DeviceName, + SerialNumber = dlg.SerialNumber, + Model = dlg.Model, + }, + Site = new TestSiteInfo + { + Tester = dlg.Tester, + TestDate = DateTime.Today, + } + }; + await _store.SaveAsync(p); + AllProjects.Insert(0, p); + CurrentProject = p; + OpenProjectInfo(p); + } + + public void OpenProjectInfo(Project p) + { + CurrentProject = p; + var vm = _sp.GetRequiredService(); + vm.SetProject(p, StartTesting); + CurrentView = vm; + } + + public void OpenTestHost(Project p) + { + CurrentProject = p; + var vm = _sp.GetRequiredService(); + vm.SetProject(p); + CurrentView = vm; + } + + public void OpenReport(Project p) + { + CurrentProject = p; + var vm = _sp.GetRequiredService(); + vm.SetProject(p); + CurrentView = vm; + } + + [RelayCommand] + private void OpenSettings() + { + if (CurrentView is SettingsViewModel) + { + CloseSettings(); + return; + } + _viewBeforeSettings = CurrentView; + var vm = _sp.GetRequiredService(); + vm.SetCloseAction(CloseSettings); + CurrentView = vm; + DevicePanelOpen = false; + } + + [RelayCommand] + private void OpenSettingsFromDevicePanel() + { + DevicePanelOpen = false; + OpenSettings(); + } + + private void CloseSettings() + { + CurrentView = _viewBeforeSettings ?? _sp.GetRequiredService(); + _viewBeforeSettings = null; + } + + /// 从项目信息页点击"开始测试"调用。 + public async void StartTesting(Project p) + { + CurrentProject = p; + State = AppState.Testing; + TestingMessage = $"测试进行中:{p.Name}"; + + var session = new TestSessionViewModel(_sp, p, _sspc, _power, _load, _daq, _logSink); + CurrentSession = session; + + var host = _sp.GetRequiredService(); + host.SetProject(p); + host.AttachSession(session); + CurrentView = host; + + try + { + await session.RunAllAsync(); + _logSink.Add(UiLogLevel.Success, "全部测试完成。"); + } + catch (OperationCanceledException) + { + _logSink.Add(UiLogLevel.Warning, "测试已中止。"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Test failed."); + _logSink.Add(UiLogLevel.Error, "测试出错:" + ex.Message); + } + finally + { + await _store.SaveAsync(p); + State = AppState.Browsing; + CurrentSession = null; + } + } + + [RelayCommand] + private void AbortTest() + { + CurrentSession?.Cancel(); + } + + [RelayCommand] + private void OpenProjectsFolder() + { + if (Directory.Exists(_store.ProjectsRoot)) + System.Diagnostics.Process.Start("explorer.exe", _store.ProjectsRoot); + } + + /// 由 View 双击树节点时调用。 + public void HandleNodeActivated(ProjectNode? node) + { + if (node == null) return; + switch (node.Kind) + { + case NodeKind.Root: + case NodeKind.Info: + OpenProjectInfo(node.Project); break; + case NodeKind.Test: + OpenTestHost(node.Project); break; + case NodeKind.Report: + OpenReport(node.Project); break; + } + } +} + +/// 侧栏 TreeView 用的节点。 +public sealed class ProjectNode +{ + public Project Project { get; } + public NodeKind Kind { get; } + public string Title { get; } + public ObservableCollection Children { get; } = new(); + + public ProjectNode(Project p, NodeKind kind = NodeKind.Root) + { + Project = p; + Kind = kind; + Title = kind switch + { + NodeKind.Root => p.Name, + NodeKind.Info => "项目信息", + NodeKind.Test => "测试", + NodeKind.Report => "报告", + _ => p.Name + }; + } +} + +public enum NodeKind { Root, Info, Test, Report } diff --git a/SSPCTester.UI/ViewModels/PowerTestViewModel.cs b/SSPCTester.UI/ViewModels/PowerTestViewModel.cs new file mode 100644 index 0000000..bd57e47 --- /dev/null +++ b/SSPCTester.UI/ViewModels/PowerTestViewModel.cs @@ -0,0 +1,203 @@ +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.ViewModels; + +/// 功率损耗页 VM。 +public partial class PowerTestViewModel : ObservableObject +{ + private readonly ISspc _sspc; + private readonly IPowerSupply _power; + private readonly ILoad _load; + private readonly UiLogSink _log; + + public ObservableCollection Rows { get; } = new(); + public ObservableCollection Channels { get; } = new(); + [ObservableProperty] private Project? _project; + [ObservableProperty] private int _selectedChannel; + [ObservableProperty] private int _samplesPerChannel = 5; + [ObservableProperty] private int _intervalMs = 100; + [ObservableProperty] private PowerLossRow? _current; + [ObservableProperty] private bool _busy; + + public bool CanOperate => !Busy; + + public PowerTestViewModel(ISspc sspc, IPowerSupply power, ILoad load, UiLogSink log) + { + _sspc = sspc; + _power = power; + _load = load; + _log = log; + for (int i = 1; i <= sspc.ChannelCount; i++) Channels.Add(i); + SelectedChannel = 1; + } + + partial void OnBusyChanged(bool value) => OnPropertyChanged(nameof(CanOperate)); + + public void SetProject(Project p) + { + Project = p; + Rows.Clear(); + if (p.PowerResults.Count == 0) + { + for (int i = 1; i <= Channels.Count; i++) + p.PowerResults.Add(new PowerLossRow { Channel = i }); + } + foreach (var r in p.PowerResults) Rows.Add(r); + Current = Rows.FirstOrDefault(); + } + + [RelayCommand] + private async Task TurnOnCurrentChannel() + { + Busy = true; + int ch = SelectedChannel; + try + { + if (!_sspc.IsConnected) await _sspc.ConnectAsync(); + await _sspc.TurnOnAsync(ch); + _log.Add(UiLogLevel.Info, $"CH{ch} 已开启。"); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Error, $"CH{ch} 开启失败:{ex.Message}"); + } + finally + { + Busy = false; + } + } + + [RelayCommand] + private async Task TurnOffCurrentChannel() + { + Busy = true; + int ch = SelectedChannel; + try + { + if (!_sspc.IsConnected) await _sspc.ConnectAsync(); + await _sspc.TurnOffAsync(ch); + _log.Add(UiLogLevel.Info, $"CH{ch} 已关断。"); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Error, $"CH{ch} 关断失败:{ex.Message}"); + } + finally + { + Busy = false; + } + } + + [RelayCommand] + private async Task MeasureCurrent() + { + if (Project == null) return; + Busy = true; + int ch = SelectedChannel; + var row = Rows.First(r => r.Channel == ch); + try + { + // 功率损耗输入端来自 UDP5080-100 电源实时测量。 + + try + { + await Task.CompletedTask; + } + catch (Exception ex) + { + throw new InvalidOperationException($"Modbus(继电器端)连接失败:{ex.Message}。请在设置中检查串口与连接。", ex); + } + try + { + if (!_power.IsConnected) await _power.ConnectAsync(); + } + catch (Exception ex) + { + throw new InvalidOperationException($"高速采集卡连接失败:{ex.Message}。请在设置中检查采集卡。", ex); + } + + try + { + if (!_load.IsConnected) await _load.ConnectAsync(); + } + catch (Exception ex) + { + throw new InvalidOperationException($"IT8702P connection failed: {ex.Message}", ex); + } + + double sVin = 0, sIin = 0, sVout = 0, sIout = 0, sPout = 0; + for (int s = 0; s < SamplesPerChannel; s++) + { + /* + // 输出端:Modbus 继电器端电压 + 通流电流(SSPC 为串联开关,Iin = Iout)。 + var measurement = await _load.ReadPowerAsync(); + // 输入端:高速采集卡电压。 + var daqValues = await _daq.ReadInstantAsync(new[] { daqVoltageChannel }); + */ + var input = await _power.ReadAsync(); + var measurement = await _load.ReadPowerAsync(); + double vin = input.volts; + double iin = Math.Abs(input.amps); + double vout = measurement.Volts; + double iout = Math.Abs(measurement.Amps); + double pout = measurement.Watts; + if (!double.IsFinite(vin) || !double.IsFinite(iin) || !double.IsFinite(vout) || !double.IsFinite(iout) || !double.IsFinite(pout)) + throw new InvalidOperationException("功率损耗采样无效,请检查采集卡电压通道标定与 Modbus 连接。"); + + sVin += vin; + sIin += iin; + sVout += vout; + sIout += iout; + sPout += pout; + await Task.Delay(IntervalMs); + } + + row.Vin = sVin / SamplesPerChannel; + row.Iin = sIin / SamplesPerChannel; + row.Vout = sVout / SamplesPerChannel; + row.Iout = sIout / SamplesPerChannel; + row.MeasuredPowerOut = sPout / SamplesPerChannel; + row.Status = TestStatus.Measured; + Current = row; + _log.Add(UiLogLevel.Success, $"CH{ch} 功率损耗 {row.PowerLossPct:F1}%,效率 {row.EfficiencyRatio:F3}"); + } + catch (Exception ex) + { + row.Status = TestStatus.Fail; + _log.Add(UiLogLevel.Error, $"CH{ch} 功率损耗读取失败:{ex.Message}"); + } + finally + { + Busy = false; + } + } + + /// 解析用于输入端电压的高速采集卡通道(取已标定的电压通道,优先 OutputVoltage)。 + private static int ResolveDaqVoltageChannel(DaqOptions options) + { + if (options.Channels == null || options.Channels.Count == 0) + throw new InvalidOperationException("未配置采集卡通道,无法执行功率损耗测试。"); + + var candidates = options.Channels + .Where(x => x.PhysicalChannel >= 0 && x.PhysicalChannel < options.ChannelCount) + .Where(x => x.IsCalibrated) + .Where(x => IsVoltageRole(x.Role)) + .ToArray(); + + var pick = candidates.FirstOrDefault(x => string.Equals(x.Role, nameof(DaqChannelRole.OutputVoltage), StringComparison.OrdinalIgnoreCase)) + ?? candidates.FirstOrDefault(); + if (pick == null) + throw new InvalidOperationException("功率损耗测试需要一个已标定的采集卡电压通道(输入端电压),请在设置中配置并标定。"); + return pick.PhysicalChannel; + } + + private static bool IsVoltageRole(string? role) => + Enum.TryParse(role, true, out var parsed) + && parsed is DaqChannelRole.OutputVoltage or DaqChannelRole.InputVoltage; +} diff --git a/SSPCTester.UI/ViewModels/ProjectInfoViewModel.cs b/SSPCTester.UI/ViewModels/ProjectInfoViewModel.cs new file mode 100644 index 0000000..0444bcf --- /dev/null +++ b/SSPCTester.UI/ViewModels/ProjectInfoViewModel.cs @@ -0,0 +1,25 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SSPCTester.Logic.Models; + +namespace SSPCTester.UI.ViewModels; + +/// 项目信息页:被测件 + 测试信息 + 测试项选择 + 开始测试。 +public partial class ProjectInfoViewModel : ObservableObject +{ + [ObservableProperty] private Project? _project; + private Action? _onStart; + + public void SetProject(Project p, Action onStart) + { + Project = p; + _onStart = onStart; + } + + [RelayCommand] + private void StartTest() + { + if (Project == null) return; + _onStart?.Invoke(Project); + } +} diff --git a/SSPCTester.UI/ViewModels/ProtectViewModel.cs b/SSPCTester.UI/ViewModels/ProtectViewModel.cs new file mode 100644 index 0000000..77aa453 --- /dev/null +++ b/SSPCTester.UI/ViewModels/ProtectViewModel.cs @@ -0,0 +1,60 @@ +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using SSPCTester.Logic.Models; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.ViewModels; + +/// 保护功能页 VM(框架占位)。 +public partial class ProtectViewModel : ObservableObject +{ + private readonly UiLogSink _log; + public ObservableCollection Rows { get; } = new(); + + [ObservableProperty] private Project? _project; + [ObservableProperty] private bool _enableTrip = true; + [ObservableProperty] private bool _enableShort = true; + [ObservableProperty] private bool _enableOverTemp = true; + [ObservableProperty] private bool _enableOverVolt = true; + [ObservableProperty] private bool _enableUnderVolt = true; + [ObservableProperty] private bool _enableLimit = true; + + [ObservableProperty] private double _overVoltThreshold = 32; + [ObservableProperty] private double _underVoltThreshold = 22; + [ObservableProperty] private double _overCurrentThreshold = 1.2; + [ObservableProperty] private double _overTempThreshold = 85; + + public ProtectViewModel(UiLogSink log) { _log = log; } + + public void SetProject(Project p) + { + Project = p; + Rows.Clear(); + foreach (var r in p.ProtectResults) Rows.Add(r); + } + + [RelayCommand] + private void RunDemo() + { + if (Project == null) return; + Project.ProtectResults.Clear(); + Rows.Clear(); + var items = new (string, string)[] + { + ("跳闸", "1.5x额定电流"), + ("短路", "输出短路"), + ("过温", $">={OverTempThreshold} ℃"), + ("过压", $">={OverVoltThreshold} V"), + ("欠压", $"<={UnderVoltThreshold} V"), + ("限流", $">={OverCurrentThreshold} A"), + }; + for (int i = 0; i < items.Length; i++) + { + var r = new ProtectRow { ProtectType = items[i].Item1, Trigger = items[i].Item2, TripTimeMs = 2 + i * 0.3, Status = TestStatus.Pass }; + Project.ProtectResults.Add(r); + Rows.Add(r); + } + _log.Add(UiLogLevel.Warning, "保护功能模块仅生成框架演示数据。"); + } +} diff --git a/SSPCTester.UI/ViewModels/ReportViewModel.cs b/SSPCTester.UI/ViewModels/ReportViewModel.cs new file mode 100644 index 0000000..a8a4fdb --- /dev/null +++ b/SSPCTester.UI/ViewModels/ReportViewModel.cs @@ -0,0 +1,333 @@ +using System.IO; +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.Options; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Report; +using SSPCTester.Logic.Storage; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.ViewModels; + +/// 测试报告页。 +public partial class ReportViewModel : ObservableObject +{ + private readonly ReportGenerator _gen; + private readonly WordReportGenerator _wordGen; + private readonly ReportOptions _opts; + private readonly ProjectStore _store; + private readonly UiLogSink _log; + private readonly UserSettingsStore _settingsStore; + + public ObservableCollection ReportFiles { get; } = new(); + public IReadOnlyList FormatChoices { get; } = new[] + { + new ReportFormatChoice(ReportOutputFormat.Pdf, "PDF"), + new ReportFormatChoice(ReportOutputFormat.Word, "Word"), + new ReportFormatChoice(ReportOutputFormat.Both, "PDF + Word") + }; + + [ObservableProperty] private Project? _project; + [ObservableProperty] private string _lastOutputPath = ""; + [ObservableProperty] private ReportFileDescriptor? _selectedReportFile; + [ObservableProperty] private ReportFormatChoice? _selectedFormatChoice; + [ObservableProperty] private Uri? _previewSource; + [ObservableProperty] private string _previewMessage = "暂无可预览的报告。"; + [ObservableProperty] private bool _hasPreview; + [ObservableProperty] private bool _hasWordInfo; + [ObservableProperty] private string _wordInfoText = ""; + [ObservableProperty] private string _selectedFilePath = ""; + + public ReportViewModel( + ReportGenerator gen, + WordReportGenerator wordGen, + IOptions opts, + ProjectStore store, + UiLogSink log, + UserSettingsStore settingsStore) + { + _gen = gen; + _wordGen = wordGen; + _opts = opts.Value; + _store = store; + _log = log; + _settingsStore = settingsStore; + SelectedFormatChoice = FormatChoices.First(x => x.Format == ReportFileHelper.ParseFormat(_opts.Format)); + } + + public void SetProject(Project p) + { + Project = p; + if (string.IsNullOrWhiteSpace(p.Report.FileName) || + string.Equals(p.Report.FileName, "report.pdf", StringComparison.OrdinalIgnoreCase)) + { + p.Report.FileName = ReportFileHelper.DefaultTemplate; + } + + RefreshReportFiles(selectLatest: true); + } + + [RelayCommand] + private async Task Generate() + { + if (Project == null) return; + try + { + await _store.SaveAsync(Project); + string dir = ReportDirectory(Project); + Directory.CreateDirectory(dir); + DateTime now = DateTime.Now; + var format = CurrentFormat; + string? pdfPath = null; + string? wordPath = null; + var curveImages = await BuildCurveImagesAsync(Project); + + if (format is ReportOutputFormat.Pdf or ReportOutputFormat.Both) + { + pdfPath = Path.Combine(dir, ReportFileHelper.ResolveFileName(Project, now, ".pdf")); + _gen.CurveImages = curveImages; + _gen.Generate(Project, pdfPath); + } + + if (format is ReportOutputFormat.Word or ReportOutputFormat.Both) + { + wordPath = Path.Combine(dir, ReportFileHelper.ResolveFileName(Project, now, ".docx")); + _wordGen.CurveImages = curveImages; + _wordGen.Generate(Project, wordPath); + } + + string primaryPath = pdfPath ?? wordPath!; + ReportFileHelper.SaveInfo(BuildInfo(Project, format, now, pdfPath, wordPath), ReportFileHelper.BuildInfoPath(primaryPath)); + if (wordPath != null && !string.Equals(ReportFileHelper.BuildInfoPath(wordPath), ReportFileHelper.BuildInfoPath(primaryPath), StringComparison.OrdinalIgnoreCase)) + ReportFileHelper.SaveInfo(BuildInfo(Project, format, now, pdfPath, wordPath), ReportFileHelper.BuildInfoPath(wordPath)); + + LastOutputPath = primaryPath; + RefreshReportFiles(primaryPath); + _log.Add(UiLogLevel.Success, "报告已生成:" + primaryPath); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Error, "生成报告失败:" + ex.Message); + } + } + + [RelayCommand] + private void OpenFolder() + { + if (Project == null) return; + var dir = ReportDirectory(Project); + if (Directory.Exists(dir)) + System.Diagnostics.Process.Start("explorer.exe", dir); + } + + [RelayCommand] + private void RefreshReports() => RefreshReportFiles(selectLatest: true); + + [RelayCommand] + private void OpenSelectedFile() + { + if (SelectedReportFile == null || !File.Exists(SelectedReportFile.FullPath)) return; + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(SelectedReportFile.FullPath) + { + UseShellExecute = true + }); + } + + partial void OnSelectedFormatChoiceChanged(ReportFormatChoice? value) + { + if (value == null) return; + _opts.Format = value.Format.ToString(); + _settingsStore.ScheduleSave(); + RefreshReportFiles(selectLatest: true); + } + + partial void OnSelectedReportFileChanged(ReportFileDescriptor? value) + { + if (value == null) + { + ClearPreview("暂无可预览的报告。"); + return; + } + + SelectedFilePath = value.FullPath; + if (value.IsPdf) + LoadPreview(value.FullPath); + else + LoadWordInfo(value.FullPath); + } + + public void PreviewUnavailable(string message) => ClearPreview(message); + + private void RefreshReportFiles(string? selectPath = null, bool selectLatest = false) + { + ReportFiles.Clear(); + var project = Project; + if (project == null) + { + ClearPreview("暂无项目,无法预览报告。"); + return; + } + + foreach (var file in ReportFileHelper.EnumerateReportFiles(ReportDirectory(project), CurrentFormat)) + ReportFiles.Add(file); + + SelectedReportFile = selectPath == null + ? selectLatest ? DefaultSelectedReportFile() : SelectedReportFile + : ReportFiles.FirstOrDefault(x => string.Equals(x.FullPath, selectPath, StringComparison.OrdinalIgnoreCase)); + + if (SelectedReportFile == null) + ClearPreview(CurrentFormat == ReportOutputFormat.Word + ? "当前报告目录下暂无 Word 报告。生成报告后将在这里显示文件信息。" + : "当前报告目录下暂无报告。生成报告后将在这里预览或显示文件信息。"); + } + + private void LoadPreview(string path) + { + if (!File.Exists(path)) + { + ClearPreview("选中的报告文件不存在。"); + return; + } + + LastOutputPath = path; + PreviewSource = new Uri(path); + PreviewMessage = ""; + HasPreview = true; + var info = ReportFileHelper.LoadInfoForReport(path); + if (!string.IsNullOrWhiteSpace(info?.WordPath)) + SetWordInfo(info, path); + else + HasWordInfo = false; + } + + private void LoadWordInfo(string path) + { + if (!File.Exists(path)) + { + ClearPreview("选中的 Word 报告文件不存在。"); + return; + } + + LastOutputPath = path; + HasPreview = false; + PreviewSource = null; + PreviewMessage = ""; + SetWordInfo(ReportFileHelper.LoadInfoForReport(path), path); + } + + private void ClearPreview(string message) + { + HasPreview = false; + PreviewSource = null; + PreviewMessage = message; + HasWordInfo = false; + WordInfoText = ""; + SelectedFilePath = ""; + } + + private string ReportDirectory(Project project) => + string.IsNullOrWhiteSpace(project.FolderPath) ? _opts.SavePath : project.FolderPath; + + private ReportOutputFormat CurrentFormat => SelectedFormatChoice?.Format ?? ReportFileHelper.ParseFormat(_opts.Format); + + private ReportFileDescriptor? DefaultSelectedReportFile() + { + if (CurrentFormat == ReportOutputFormat.Both) + return ReportFiles.FirstOrDefault(x => x.IsPdf) ?? ReportFiles.FirstOrDefault(); + return ReportFiles.FirstOrDefault(); + } + + private static ReportInfo BuildInfo(Project project, ReportOutputFormat format, DateTime generatedAt, string? pdfPath, string? wordPath) => + new() + { + ProjectName = project.Name, + ProductName = project.Dut.ProductName, + Model = project.Dut.Model, + SerialNumber = project.Dut.SerialNumber, + GeneratedAt = generatedAt, + Format = format.ToString(), + PdfPath = pdfPath, + WordPath = wordPath, + OverallStatus = project.OverallStatus.ToString(), + Sections = new ReportSectionInfo + { + Cover = project.Report.Cover, + Basic = project.Report.Basic, + Curve = project.Report.Curve, + Power = project.Report.Power, + Protect = project.Report.Protect + } + }; + + private void SetWordInfo(ReportInfo? info, string selectedPath) + { + var file = new FileInfo(selectedPath); + string? wordPath = info?.WordPath; + string? pdfPath = info?.PdfPath; + var lines = new List + { + $"文件名:{file.Name}", + $"完整路径:{file.FullName}", + $"文件大小:{FormatBytes(file.Length)}", + $"修改时间:{file.LastWriteTime:yyyy-MM-dd HH:mm:ss}", + $"格式:{(file.Extension.Equals(".docx", StringComparison.OrdinalIgnoreCase) ? "Word" : "PDF")}" + }; + + if (info != null) + { + lines.Add($"项目名称:{info.ProjectName}"); + lines.Add($"设备编号:{info.SerialNumber}"); + lines.Add($"设备名称:{info.ProductName}"); + lines.Add($"设备型号:{info.Model}"); + lines.Add($"生成时间:{info.GeneratedAt:yyyy-MM-dd HH:mm:ss}"); + lines.Add($"输出格式:{info.Format}"); + lines.Add($"综合判定:{info.OverallStatus}"); + lines.Add($"关联 PDF:{(string.IsNullOrWhiteSpace(pdfPath) ? "无" : File.Exists(pdfPath) ? pdfPath : "文件缺失")}"); + lines.Add($"关联 Word:{(string.IsNullOrWhiteSpace(wordPath) ? "无" : File.Exists(wordPath) ? wordPath : "文件缺失")}"); + } + else + { + lines.Add("报告信息文件:未找到,已显示文件系统信息。"); + } + + WordInfoText = string.Join(Environment.NewLine, lines); + HasWordInfo = true; + } + + private static string FormatBytes(long bytes) + { + if (bytes >= 1024 * 1024) return $"{bytes / 1024d / 1024d:F2} MB"; + if (bytes >= 1024) return $"{bytes / 1024d:F1} KB"; + return $"{bytes} B"; + } + + private async Task> BuildCurveImagesAsync(Project project) + { + var images = new Dictionary(); + foreach (var row in project.CurveResults.OrderBy(x => x.Channel)) + { + try + { + var rising = await WaveformStore.LoadAsync(project, row.RisingWaveformPath); + var falling = await WaveformStore.LoadAsync(project, row.FallingWaveformPath); + if (rising == null || falling == null) continue; + + images[row.Channel] = CurveImageRenderer.RenderChannel( + row.Channel, + rising, + falling, + row.ViewStartMs, + row.ViewEndMs); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Warning, $"CH{row.Channel} 曲线插图生成失败:{ex.Message}"); + } + } + + return images; + } +} + +public sealed record ReportFormatChoice(ReportOutputFormat Format, string DisplayName); diff --git a/SSPCTester.UI/ViewModels/SettingsViewModel.cs b/SSPCTester.UI/ViewModels/SettingsViewModel.cs new file mode 100644 index 0000000..c0dc637 --- /dev/null +++ b/SSPCTester.UI/ViewModels/SettingsViewModel.cs @@ -0,0 +1,459 @@ +using System.IO; +using System.Collections.ObjectModel; +using System.IO.Ports; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; +using Microsoft.Extensions.Options; +using Microsoft.Win32; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.ViewModels; + +/// 系统设置页。 +public partial class SettingsViewModel : ObservableObject +{ + private readonly UiLogSink _log; + private readonly ISspc _sspc; + private readonly IPowerSupply _power; + private readonly ILoad _load; + private readonly IDaq _daq; + private readonly DeviceOptions _devOpts; + private readonly StorageOptions _storeOpts; + private readonly ReportOptions _reportOpts; + private readonly UserSettingsStore _settingsStore; + private Action? _closeAction; + + public SettingsViewModel( + IOptions devOpts, + IOptions storeOpts, + IOptions reportOpts, + ISspc sspc, IPowerSupply power, ILoad load, IDaq daq, UiLogSink log, + UserSettingsStore settingsStore) + { + _devOpts = devOpts.Value; + _storeOpts = storeOpts.Value; + _reportOpts = reportOpts.Value; + _sspc = sspc; _power = power; _load = load; _daq = daq; _log = log; + _settingsStore = settingsStore; + NormalizeDaqChannels(); + LoadDaqChannelEditors(); + RefreshPorts(); + _sspc.ConnectionChanged += (_, _) => OnPropertyChanged(nameof(SspcStatus)); + _power.ConnectionChanged += (_, _) => OnPropertyChanged(nameof(PowerStatus)); + _load.ConnectionChanged += (_, _) => OnPropertyChanged(nameof(LoadStatus)); + _daq.ConnectionChanged += (_, _) => OnPropertyChanged(nameof(DaqStatus)); + _ = RefreshDaqDevices(); + } + + public DeviceOptions Devices => _devOpts; + public StorageOptions Storage => _storeOpts; + public ReportOptions Report => _reportOpts; + public ObservableCollection PortNames { get; } = new(); + public ObservableCollection DaqDevices { get; } = new(); + public ObservableCollection DaqChannelEditors { get; } = new(); + public IReadOnlyList DaqChannelCounts { get; } = new[] { 1, 2, 4, 8 }; + public IReadOnlyList DaqInputRanges { get; } = new[] { "PlusMinus5V", "PlusMinus1V" }; + public IReadOnlyList DaqRoles { get; } = Enum.GetNames(); + public IReadOnlyList LoadQueryModes { get; } = Enum.GetValues(); + public IReadOnlyList TerminatorOptions { get; } = new[] + { + new TerminatorOption("LF (\\n)", "\n"), + new TerminatorOption("CRLF (\\r\\n)", "\r\n"), + new TerminatorOption("CR (\\r)", "\r") + }; + public int SelectedDaqLogicalId + { + get => _devOpts.Daq.LogicalDeviceId; + set + { + if (_devOpts.Daq.LogicalDeviceId == value) return; + _devOpts.Daq.LogicalDeviceId = value; + OnPropertyChanged(); + ApplyDaqChannelEditorsToOptions(); + _settingsStore.ScheduleSave(); + } + } + + public string SspcStatus => _sspc.IsConnected ? "已连接" : "未连接"; + public string PowerStatus => _power.IsConnected ? "已连接" : "未连接"; + public string LoadStatus => _load.IsConnected ? "已连接" : "未连接"; + public string DaqStatus => _daq.IsConnected ? "已连接" : "未连接"; + + public void SetCloseAction(Action closeAction) => _closeAction = closeAction; + public void ScheduleSave() + { + ApplyDaqChannelEditorsToOptions(); + _settingsStore.ScheduleSave(); + } + + public async Task SaveSettingsAsync() + { + ApplyDaqChannelEditorsToOptions(); + await _settingsStore.SaveAsync(); + } + + [RelayCommand] + private async Task Close() + { + ApplyDaqChannelEditorsToOptions(); + await _settingsStore.SaveAsync(); + _closeAction?.Invoke(); + } + + [RelayCommand] + private void RefreshPorts() + { + string? selected = _devOpts.Sspc.PortName; + PortNames.Clear(); + foreach (string port in SerialPort.GetPortNames().OrderBy(x => x)) + PortNames.Add(port); + if (!string.IsNullOrWhiteSpace(selected) && !PortNames.Contains(selected)) + PortNames.Add(selected); + } + + [RelayCommand] + private async Task SaveAndReconnect() + { + ApplyDaqChannelEditorsToOptions(); + await _settingsStore.SaveAsync(); + await Reconnect("SSPC", _sspc); + await Reconnect("电源", _power); + await Reconnect("负载", _load); + await TestDaq(); + RaiseStatuses(); + _log.Add(UiLogLevel.Success, "硬件配置已保存并重新连接。"); + } + + [RelayCommand] + private async Task TestSspc() { await Reconnect("SSPC", _sspc); OnPropertyChanged(nameof(SspcStatus)); } + [RelayCommand] + private async Task TestPower() + { + await Reconnect("电源", _power); + if (_power.IsConnected) + { + try + { + var id = await _power.QueryIdentityAsync(); + _log.Add(UiLogLevel.Success, $"UDP5080 设备标识:{id}"); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Warning, $"UDP5080 已连接,但读取设备标识失败:{ex.Message}"); + } + } + OnPropertyChanged(nameof(PowerStatus)); + } + [RelayCommand] + private async Task TestLoad() + { + await Reconnect("负载", _load); + if (_load.IsConnected) + { + try + { + var id = await _load.QueryIdentityAsync(); + var reading = await _load.ReadPowerAsync(); + _log.Add(UiLogLevel.Success, $"IT8702P 设备标识:{id};V={reading.Volts:F3}V I={reading.Amps:F3}A P={reading.Watts:F3}W"); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Warning, $"IT8702P 已连接,但读取标识或测量值失败:{ex.Message}"); + } + } + OnPropertyChanged(nameof(LoadStatus)); + } + [RelayCommand] + private async Task TestDaq() + { + ApplyDaqChannelEditorsToOptions(); + try { await _daq.DisconnectAsync(); } catch { } + await RefreshDaqDevices(); + try + { + await _daq.ConnectAsync(); + await _settingsStore.SaveAsync(); + _log.Add(UiLogLevel.Success, "PCIe8586 连接成功。"); + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Error, $"PCIe8586 连接失败:{ex.Message}"); + } + OnPropertyChanged(nameof(DaqStatus)); + } + + [RelayCommand] + private async Task RefreshDaqDevices() + { + try + { + var devices = await _daq.EnumerateDevicesAsync(); + if (devices.Count > 0) + { + int selectedId = _devOpts.Daq.LogicalDeviceId; + DaqDevices.Clear(); + foreach (var device in devices) DaqDevices.Add(device); + if (devices.Any(x => x.LogicalId == selectedId)) + _devOpts.Daq.LogicalDeviceId = selectedId; + else + SelectedDaqLogicalId = devices[0].LogicalId; + OnPropertyChanged(nameof(SelectedDaqLogicalId)); + } + else if (!DaqDevices.Any(x => x.LogicalId == _devOpts.Daq.LogicalDeviceId)) + { + DaqDevices.Add(new DaqDeviceDescriptor( + _devOpts.Daq.LogicalDeviceId, null, "当前配置的 PCIe8586", _devOpts.Daq.UseMock)); + } + _log.Add(devices.Count > 0 ? UiLogLevel.Success : UiLogLevel.Error, + devices.Count > 0 ? $"发现 {devices.Count} 台 PCIe8586。" : "未发现 PCIe8586。"); + } + catch (Exception ex) + { + if (!DaqDevices.Any(x => x.LogicalId == _devOpts.Daq.LogicalDeviceId)) + DaqDevices.Add(new DaqDeviceDescriptor( + _devOpts.Daq.LogicalDeviceId, null, "当前配置的 PCIe8586", _devOpts.Daq.UseMock)); + _log.Add(UiLogLevel.Error, $"枚举 PCIe8586 失败:{ex.Message}"); + } + } + + public double DaqActualSampleRateHz => _devOpts.Daq.ActualSampleRateHz; + public string DaqValidationMessage + { + get + { + if (_devOpts.Daq.UseMock) + return "当前为 Mock 模式,可直接验证继电器动作和曲线流程。"; + ApplyDaqChannelEditorsToOptions(); + if (_devOpts.Daq.ChannelCount is not (1 or 2 or 4 or 8)) + return "启用通道数只能为 1、2、4 或 8。"; + var enabled = _devOpts.Daq.Channels.Where(x => x.PhysicalChannel < _devOpts.Daq.ChannelCount).ToArray(); + if (enabled.Length == 0) + return "没有可用的启用通道。"; + var outputVoltage = enabled.Where(x => + string.Equals(x.Role, nameof(DaqChannelRole.OutputVoltage), StringComparison.OrdinalIgnoreCase)).ToArray(); + if (outputVoltage.Length != 1) + return $"必须配置且只能配置一个 OutputVoltage 角色,当前配置了 {outputVoltage.Length} 个。"; + var voltageChannel = outputVoltage[0]; + if (!voltageChannel.IsCalibrated) + return $"CH{voltageChannel.PhysicalChannel} OutputVoltage 尚未勾选已标定。"; + if (!double.IsFinite(voltageChannel.Scale) || voltageChannel.Scale == 0) + return $"CH{voltageChannel.PhysicalChannel} Scale 无效。"; + if (!double.IsFinite(voltageChannel.Offset)) + return $"CH{voltageChannel.PhysicalChannel} Offset 无效。"; + return "采集配置可用于曲线测试。"; + } + } + public void NotifyDaqSettingsChanged() + { + ApplyDaqChannelEditorsToOptions(); + RefreshDaqEditorEnabledStates(); + OnPropertyChanged(nameof(DaqActualSampleRateHz)); + OnPropertyChanged(nameof(DaqValidationMessage)); + } + + [RelayCommand] + private async Task DisconnectSspc() + { + await _sspc.DisconnectAsync(); + ApplyDaqChannelEditorsToOptions(); + await _settingsStore.SaveAsync(); + OnPropertyChanged(nameof(SspcStatus)); + } + + private async Task Reconnect(string name, IDeviceConnection device) + { + try + { + await device.DisconnectAsync(); + bool connected = await device.ConnectAsync(); + ApplyDaqChannelEditorsToOptions(); + await _settingsStore.SaveAsync(); + if (connected && device.IsConnected) + { + _log.Add(UiLogLevel.Success, $"{name} 连接成功。"); + } + else + { + _log.Add(UiLogLevel.Warning, $"{name} 连接未成功,设备保持未连接。"); + } + } + catch (Exception ex) + { + _log.Add(UiLogLevel.Error, $"{name} 连接失败:{ex.Message}"); + } + } + + private void RaiseStatuses() + { + OnPropertyChanged(nameof(SspcStatus)); + OnPropertyChanged(nameof(PowerStatus)); + OnPropertyChanged(nameof(LoadStatus)); + OnPropertyChanged(nameof(DaqStatus)); + } + + [RelayCommand] + private void BrowseProjects() + { + string? selected = SelectFolder("选择项目数据目录", _storeOpts.ProjectsRoot); + if (string.IsNullOrWhiteSpace(selected)) return; + _storeOpts.ProjectsRoot = selected; + OnPropertyChanged(nameof(Storage)); + ApplyDaqChannelEditorsToOptions(); + _settingsStore.ScheduleSave(); + } + + [RelayCommand] + private void BrowseReports() + { + string? selected = SelectFolder("选择报告保存目录", _reportOpts.SavePath); + if (string.IsNullOrWhiteSpace(selected)) return; + _reportOpts.SavePath = selected; + OnPropertyChanged(nameof(Report)); + ApplyDaqChannelEditorsToOptions(); + _settingsStore.ScheduleSave(); + } + + [RelayCommand] + private void OpenProjectsDirectory() => OpenDirectory(_storeOpts.ProjectsRoot); + + [RelayCommand] + private void OpenReportsDirectory() => OpenDirectory(_reportOpts.SavePath); + + private static string? SelectFolder(string description, string currentPath) + { + var dialog = new OpenFolderDialog + { + Title = description, + InitialDirectory = Directory.Exists(currentPath) ? currentPath : null + }; + return dialog.ShowDialog() == true ? dialog.FolderName : null; + } + + private static void OpenDirectory(string path) + { + if (string.IsNullOrWhiteSpace(path)) return; + Directory.CreateDirectory(path); + System.Diagnostics.Process.Start("explorer.exe", path); + } + + private void NormalizeDaqChannels() + { + _devOpts.Daq.Channels = DaqChannelOptionsNormalizer.Normalize(_devOpts.Daq.Channels); + } + + private void LoadDaqChannelEditors() + { + DaqChannelEditors.Clear(); + NormalizeDaqChannels(); + foreach (var channel in _devOpts.Daq.Channels) + { + var editor = new DaqChannelEditor + { + PhysicalChannel = channel.PhysicalChannel, + Role = channel.Role, + Name = channel.Name, + Scale = channel.Scale, + Offset = channel.Offset, + IsCalibrated = channel.IsCalibrated, + IsEnabled = channel.PhysicalChannel < _devOpts.Daq.ChannelCount + }; + editor.Bind(channel, OnDaqChannelEditorChanged); + DaqChannelEditors.Add(editor); + } + ApplyDaqChannelEditorsToOptions(); + } + + private void OnDaqChannelEditorChanged() + { + ApplyDaqChannelEditorsToOptions(); + _settingsStore.ScheduleSave(); + OnPropertyChanged(nameof(DaqValidationMessage)); + } + + private void RefreshDaqEditorEnabledStates() + { + foreach (var editor in DaqChannelEditors) + editor.IsEnabled = editor.PhysicalChannel < _devOpts.Daq.ChannelCount; + } + + private void ApplyDaqChannelEditorsToOptions() + { + if (DaqChannelEditors.Count == 0) + { + NormalizeDaqChannels(); + return; + } + + _devOpts.Daq.Channels = DaqChannelOptionsNormalizer.Normalize( + DaqChannelEditors.Select(x => new DaqChannelOptions + { + PhysicalChannel = x.PhysicalChannel, + Role = x.Role, + Name = x.Name, + Scale = x.Scale, + Offset = x.Offset, + IsCalibrated = x.IsCalibrated + })); + } +} + +public sealed record TerminatorOption(string Name, string Value); + +public sealed partial class DaqChannelEditor : ObservableObject +{ + private DaqChannelOptions? _source; + private Action? _changed; + + public int PhysicalChannel { get; init; } + public string ChannelName => $"CH{PhysicalChannel}"; + + [ObservableProperty] private string _role = nameof(DaqChannelRole.Unconfigured); + [ObservableProperty] private string _name = ""; + [ObservableProperty] private double _scale = 1; + [ObservableProperty] private double _offset; + [ObservableProperty] private bool _isCalibrated; + [ObservableProperty] private bool _isEnabled; + + public void Bind(DaqChannelOptions source, Action changed) + { + _source = source; + _changed = changed; + } + + partial void OnRoleChanged(string value) + { + if (_source == null) return; + _source.Role = value; + _changed?.Invoke(); + } + + partial void OnNameChanged(string value) + { + if (_source == null) return; + _source.Name = value; + _changed?.Invoke(); + } + + partial void OnScaleChanged(double value) + { + if (_source == null) return; + _source.Scale = value; + _changed?.Invoke(); + } + + partial void OnOffsetChanged(double value) + { + if (_source == null) return; + _source.Offset = value; + _changed?.Invoke(); + } + + partial void OnIsCalibratedChanged(bool value) + { + if (_source == null) return; + _source.IsCalibrated = value; + _changed?.Invoke(); + } +} diff --git a/SSPCTester.UI/ViewModels/TestHostViewModel.cs b/SSPCTester.UI/ViewModels/TestHostViewModel.cs new file mode 100644 index 0000000..d63c424 --- /dev/null +++ b/SSPCTester.UI/ViewModels/TestHostViewModel.cs @@ -0,0 +1,36 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using SSPCTester.Logic.Models; + +namespace SSPCTester.UI.ViewModels; + +/// 测试主界面(TabControl 容器)。 +public partial class TestHostViewModel : ObservableObject +{ + [ObservableProperty] private Project? _project; + [ObservableProperty] private TestSessionViewModel? _session; + + public BasicTestViewModel Basic { get; } + public CurveTestViewModel Curve { get; } + public PowerTestViewModel Power { get; } + public ProtectViewModel Protect { get; } + + public TestHostViewModel(BasicTestViewModel basic, CurveTestViewModel curve, PowerTestViewModel power, ProtectViewModel protect) + { + Basic = basic; Curve = curve; Power = power; Protect = protect; + } + + public void SetProject(Project p) + { + Project = p; + Basic.SetProject(p); + Curve.SetProject(p); + Power.SetProject(p); + Protect.SetProject(p); + } + + public void AttachSession(TestSessionViewModel s) + { + Session = s; + Curve.AttachSession(s); + } +} diff --git a/SSPCTester.UI/ViewModels/TestSessionViewModel.cs b/SSPCTester.UI/ViewModels/TestSessionViewModel.cs new file mode 100644 index 0000000..777235b --- /dev/null +++ b/SSPCTester.UI/ViewModels/TestSessionViewModel.cs @@ -0,0 +1,68 @@ +using System.Windows; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using SSPCTester.Devices.Config; +using SSPCTester.Devices.Interfaces; +using SSPCTester.Logic.Models; +using SSPCTester.Logic.Testing; +using SSPCTester.UI.Services; + +namespace SSPCTester.UI.ViewModels; + +/// +/// 一次测试会话:包装 TestRunner + CancellationToken + 进度上报。 +/// +public sealed class TestSessionViewModel +{ + private readonly IServiceProvider _sp; + private readonly Project _project; + private readonly ISspc _sspc; + private readonly IPowerSupply _power; + private readonly ILoad _load; + private readonly IDaq _daq; + private readonly UiLogSink _logSink; + private readonly CancellationTokenSource _cts = new(); + + public event Action? CurveReady; + + public TestSessionViewModel(IServiceProvider sp, Project project, + ISspc sspc, IPowerSupply power, ILoad load, IDaq daq, UiLogSink logSink) + { + _sp = sp; _project = project; + _sspc = sspc; _power = power; _load = load; _daq = daq; + _logSink = logSink; + } + + public CancellationToken Token => _cts.Token; + public void Cancel() => _cts.Cancel(); + + public async Task RunAllAsync() + { + var ctx = new TestContext(_project, _sspc, _power, _load, _daq); + var runner = _sp.GetRequiredService(); + var modules = new List + { + _sp.GetRequiredService(), + new CurveTest(_sp.GetRequiredService>(), (ch, r, f) => CurveReady?.Invoke(ch, r, f)), + _sp.GetRequiredService(), + _sp.GetRequiredService(), + }; + + IProgress progress = new Progress(p => + { + if (!string.IsNullOrEmpty(p.Message)) + { + var lvl = p.StepStatus switch + { + TestStatus.Fail => UiLogLevel.Error, + TestStatus.Pass => UiLogLevel.Success, + TestStatus.Measured => UiLogLevel.Success, + _ => UiLogLevel.Info + }; + _logSink.Add(lvl, $"[{p.ModuleName}] {p.Message}"); + } + }); + + await runner.RunAllAsync(ctx, modules, progress, _cts.Token); + } +} diff --git a/SSPCTester.UI/Views/BasicTestView.xaml b/SSPCTester.UI/Views/BasicTestView.xaml new file mode 100644 index 0000000..9882b6d --- /dev/null +++ b/SSPCTester.UI/Views/BasicTestView.xaml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +