Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
CarerayImage
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit f2dde140
由
刘韬
编写于
2023-06-05 17:16:37 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化昊博报错信息
1 个父辈
9bdb6abc
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
3033 行增加
和
84 行删除
CarerayImage/CarerayImage.cs
CarerayImage/CarerayImage.csproj
CarerayImage/HaoboSDK/HBI_FPD_DLL.cs → CarerayImage/HaoboSDK/HBI_FPD_DLL_v1.cs
CarerayImage/HaoboSDK/HBI_FPD_DLL_v2.cs
CarerayImage/HaoboSDK/HbiError.cs
CarerayImage/XrayImage.cs
CarerayImage/XrayImageInterface.cs
CarerayImage/haobo.cs → CarerayImage/haobo_v1.cs
CarerayImage/haobo_v2.cs
CarerayImage_Test/App.config
CarerayImage_Test/CarerayImage_Test.csproj
CarerayImage_Test/Properties/Resources.Designer.cs
CarerayImage_Test/Properties/Settings.Designer.cs
CarerayImage/CarerayImage.cs
查看文件 @
f2dde14
...
@@ -347,6 +347,12 @@ namespace Asa
...
@@ -347,6 +347,12 @@ namespace Asa
{
{
throw
new
NotImplementedException
();
throw
new
NotImplementedException
();
}
}
public
bool
SetExposureTime
(
int
time
)
{
//throw new NotImplementedException();
return
false
;
}
}
}
...
...
CarerayImage/CarerayImage.csproj
查看文件 @
f2dde14
...
@@ -9,9 +9,10 @@
...
@@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa</RootNamespace>
<RootNamespace>Asa</RootNamespace>
<AssemblyName>Asa.CarerayImage</AssemblyName>
<AssemblyName>Asa.CarerayImage</AssemblyName>
<TargetFrameworkVersion>v4.
6.1
</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.
7.2
</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
...
@@ -50,10 +51,13 @@
...
@@ -50,10 +51,13 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="HaoboSDK\HbiError.cs" />
<Compile Include="haobo_v1.cs" />
<Compile Include="HaoboSDK\HBI_FPD_DLL_v2.cs" />
<Compile Include="HaoboSDK\HBI_FPD_DLL_v1.cs" />
<Compile Include="ONNXAlgoMatch.cs" />
<Compile Include="ONNXAlgoMatch.cs" />
<Compile Include="eyemLib.cs" />
<Compile Include="eyemLib.cs" />
<Compile Include="haobo.cs" />
<Compile Include="haobo_v2.cs" />
<Compile Include="HaoboSDK\HBI_FPD_DLL.cs" />
<Compile Include="MatchLib.cs" />
<Compile Include="MatchLib.cs" />
<Compile Include="XrayImage.cs" />
<Compile Include="XrayImage.cs" />
<Compile Include="CarerayImage.cs" />
<Compile Include="CarerayImage.cs" />
...
...
CarerayImage/HaoboSDK/HBI_FPD_DLL.cs
→
CarerayImage/HaoboSDK/HBI_FPD_DLL
_v1
.cs
查看文件 @
f2dde14
...
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
...
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
Asa.HaoboSDK
namespace
Asa.HaoboSDK
_v1
{
{
public
class
HBI_FPD_DLL
public
class
HBI_FPD_DLL
{
{
...
@@ -307,6 +307,24 @@ namespace Asa.HaoboSDK
...
@@ -307,6 +307,24 @@ namespace Asa.HaoboSDK
[
DllImport
(
"HBI_FPD.dll"
,
EntryPoint
=
"HBI_SetPreAcqTm"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
[
DllImport
(
"HBI_FPD.dll"
,
EntryPoint
=
"HBI_SetPreAcqTm"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SetPreAcqTm
(
IntPtr
handle
,
int
intime
);
public
static
extern
int
HBI_SetPreAcqTm
(
IntPtr
handle
,
int
intime
);
/*********************************************************
* 编 号: No095
* 函 数 名: HBI_SetLiveAcquisitionTime
* 功能描述: 设置采集时间间隔(动态平板,即可设置帧率)
* 参数说明:
In: void *handle - 句柄(无符号指针)
int time - 间隔时间,单位是毫秒ms
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBI_FPD.dll"
,
EntryPoint
=
"HBI_SetLiveAcquisitionTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SetLiveAcquisitionTime
(
IntPtr
handle
,
int
intime
);
/*********************************************************
/*********************************************************
* 函 数 名: HBI_GetPreAcqTm
* 函 数 名: HBI_GetPreAcqTm
* 功能描述: 获取软触发单帧采集清空和采集之间的时间间隔
* 功能描述: 获取软触发单帧采集清空和采集之间的时间间隔
...
...
CarerayImage/HaoboSDK/HBI_FPD_DLL_v2.cs
0 → 100644
查看文件 @
f2dde14
/*---------------------------------------------------------------------------
* Copyright (c) 2022 上海昊博影像科技有限公司
* All rights reserved.
*
* 文件名称: HBI_FPD_DLL.cs
* 文件标识: Pro-SDK C# Demo Project
* 摘 要:
*
* 当前版本: 4.0.1.4
* 作 者: mhyang
* 创建日期: 2022/03/28
* 修改日期:
----------------------------------------------------------------------------*/
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Text
;
namespace
Asa.HaoboSDK_v2
{
public
class
HBI_FPD_DLL
{
/// <summary>
/// 记录与Detector连接后的句柄
/// </summary>
public
static
IntPtr
_handel
;
#
region
functions
/*********************************************************
* 函 数 名: HBI_Init
* 功能描述: 初始化动态库
* 参数说明:
* In: int fpdid - 平板id,默认为0
* 返 回 值:IntPtr
失败:NULL,成功:非空
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_Init"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
IntPtr
HBI_Init
(
int
fpdid
=
0
);
/*********************************************************
* 函 数 名: HBI_Destroy
* 功能描述: 释放动态库资源
* 参数说明:
In: IntPtr handle - 句柄
Out: 无
* 返 回 值:void
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_Destroy"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
void
HBI_Destroy
(
IntPtr
handle
);
/*********************************************************
* 函 数 名: HBI_RegEventCallBackFun
* 功能描述: 注册回调函数
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
USER_CALLBACK_HANDLE_ENVENT handleEventfun - 注册回调函数
IntPtr pContext - 对象指针,一般上位机软件将对象指针传入SDK,回调函数反馈给上位机,以便静态或全局函数访问其他对象,亦可为空指针。
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_RegEventCallBackFun"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_RegEventCallBackFun
(
IntPtr
handle
,
USER_CALLBACK_HANDLE_ENVENT
handleEventfun
,
IntPtr
pContext
);
/*********************************************************
* 函 数 名: HBI_ConnectDetector
* 功能描述: 建立连接
* 参数说明:
In: void *handle - 句柄(无符号指针)
COMM_CFG commCfg - 连接配置参数,详细见《HbiType.h》
int doOffsetTemp - 非1:连接成功后固件不重新做offset模板
1:连接成功后固件重新做offset模板
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_ConnectDetector"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_ConnectDetector
(
IntPtr
handle
,
COMM_CFG
commCfg
,
int
doOffsetTemp
=
0
);
/*********************************************************
* 函 数 名: HBI_DisConnectDetector
* 功能描述: 断开连接
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_DisConnectDetector"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_DisConnectDetector
(
IntPtr
handle
);
/*********************************************************
* 函 数 名: HBI_GetFpdCfgInfo
* 功能描述: 获取固件ROM参数
* 参数说明:
In: void *handle - 句柄(无符号指针)
Out:RegCfgInfo* pRegCfg,见HbDllType.h。
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetFpdCfgInfo"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetFpdCfgInfo
(
IntPtr
handle
,
ref
RegCfgInfo
pRegCfg
);
/*********************************************************
* 函 数 名: HBI_SinglePrepare
* 功能描述: 软触发,清空准备指令,单帧采集准备指令
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
0 成功
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_SinglePrepare"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SinglePrepare
(
IntPtr
handle
);
/*********************************************************
* 函 数 名: HBI_SingleAcquisition
* 功能描述: 单帧采集
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
FPD_AQC_MODE _mode - 采集模式以及参数
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_SingleAcquisition"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SingleAcquisition
(
IntPtr
handle
,
FPD_AQC_MODE
_mode
);
/*********************************************************
* 函 数 名: HBI_LiveAcquisition
* 功能描述: 连续采集
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
FPD_AQC_MODE _mode - 采集模式以及参数
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_LiveAcquisition"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_LiveAcquisition
(
IntPtr
handle
,
FPD_AQC_MODE
_mode
);
/*********************************************************
* 函 数 名: HBI_StopAcquisition
* 功能描述: 停止连续采集
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_StopAcquisition"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_StopAcquisition
(
IntPtr
handle
);
/*********************************************************
* 函 数 名: HBI_GetImageProperty
* 功能描述: 获取图像属性
* 参数说明:
In: void *handle - 句柄(无符号指针)
Out: IMAGE_PROPERTY *img_pro,见HbDllType.h。
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetImageProperty"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetImageProperty
(
IntPtr
handle
,
ref
IMAGE_PROPERTY
img_pro
);
/*********************************************************
* 函 数 名: HBI_UpdateTriggerMode
* 功能描述: 设置触发模式
* 参数说明:
In: void *handle - 句柄(无符号指针)
int _triggerMode,1-软触发,3-高压触发,4-FreeAED。
Out:无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_UpdateTriggerMode"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_UpdateTriggerMode
(
IntPtr
handle
,
int
_triggerMode
);
/*********************************************************
* 函 数 名: HBI_TriggerAndCorrectApplay
* 功能描述: 设置触发模式和图像校正使能(工作站)新版本
* 参数说明:
In: void *handle - 句柄(无符号指针)
int _triggerMode,1-软触发,3-高压触发,4-FreeAED。
IMAGE_CORRECT_ENABLE* pCorrect,见HbDllType.h。
Out:无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_TriggerAndCorrectApplay"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_TriggerAndCorrectApplay
(
IntPtr
handle
,
int
_triggerMode
,
ref
IMAGE_CORRECT_ENABLE
pCorrect
);
/*********************************************************
* 函 数 名: HBI_UpdateCorrectEnable
* 功能描述: 更新图像固件校正使能
* 参数说明:
In: void *handle - 句柄(无符号指针)
IMAGE_CORRECT_ENABLE* pCorrect,见HbDllType.h。
Out:无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_UpdateCorrectEnable"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_UpdateCorrectEnable
(
IntPtr
handle
,
ref
IMAGE_CORRECT_ENABLE
pCorrect
);
/*********************************************************
* 函 数 名: HBI_GetCorrectEnable
* 功能描述: 获取图像固件校正使能
* 参数说明:
In: void *handle - 句柄(无符号指针)
IMAGE_CORRECT_ENABLE* pCorrect,见HbDllType.h。
Out:无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetCorrectEnable"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetCorrectEnable
(
IntPtr
handle
,
ref
IMAGE_CORRECT_ENABLE
pCorrect
);
/*********************************************************
* 函 数 名: HBI_GetFirmareVerion
* 功能描述: 获取固件版本号
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
Out: StringBuilder szFirmwareVer
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetFirmareVerion"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetFirmareVerion
(
IntPtr
handle
,
StringBuilder
szFirmwareVer
);
/*********************************************************
* 函 数 名: HBI_GetSDKVerion
* 功能描述: 获取SDK版本号
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
Out: char *szVer
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetSDKVerion"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetSDKVerion
(
IntPtr
handle
,
StringBuilder
szSDKVer
);
/*********************************************************
* 函 数 名: HBI_GetFPDSerialNumber
* 功能描述: 获取产品序列号
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
In/Out: char *szSn,长度14位
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetFPDSerialNumber"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetFPDSerialNumber
(
IntPtr
handle
,
StringBuilder
szSn
);
/*********************************************************
* 函 数 名: HBI_ReadPcieVersion
* 功能描述: 获取PCIe卡版本号
* 参数说明:
In: void *handle - 句柄(无符号指针)
In/Out: char *szVersion,至少为16个字节
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_ReadPcieVersion"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_ReadPcieVersion
(
IntPtr
handle
,
StringBuilder
szVersion
);
/*********************************************************
* 函 数 名: HBI_SetSelfDumpingTime
* 功能描述: 设置采集时间间隔(网口动态UDP Jumbo或光口PCIe)
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
int time - 间隔时间,单位是毫秒ms,>= 1000ms
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_SetSelfDumpingTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SetSelfDumpingTime
(
IntPtr
handle
,
int
time
);
/*********************************************************
* 函 数 名: HBI_GetSelfDumpingTime
* 功能描述: 获取采集时间间隔(网口动态UDP Jumbo或光口PCIe)
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
out:int *out_time - 时间,单位是毫秒ms
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetSelfDumpingTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetSelfDumpingTime
(
IntPtr
handle
,
ref
int
time
);
/*********************************************************
* 函 数 名: HBI_SetLiveAcquisitionTime
* 功能描述: 设置采集时间间隔(网口静态态UDP或无线UDP)
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
int time - 间隔时间,单位是毫秒ms,>= 1000ms
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_SetLiveAcquisitionTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SetLiveAcquisitionTime
(
IntPtr
handle
,
int
time
);
/*********************************************************
* 函 数 名: HBI_SetPGALevel
* 功能描述: 设置增益挡位,即设置可编程积分电容档位,提高灵敏度
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
int mode - 模式
[n]-Invalid
[1]-0.6pC
[2]-1.2pC
[3]-2.4pC
[4]-3.6pC
[5]-4.8pC
[6]-7.2pC,默认7.2pC
[7]-9.6pC
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_SetPGALevel"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SetPGALevel
(
IntPtr
handle
,
int
nGainLevel
);
/*********************************************************
* 编 号: No040
* 函 数 名: HBI_SetBinning
* 功能描述: 设置图像binning方式
* 参数说明:
In:
IntPtr handle - 句柄(无符号指针)
unsigned int bintype - 1:1x1,2:2x2,3:3x3(暂不支持),4:4x4
Out:无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_SetBinning"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SetBinning
(
IntPtr
handle
,
int
bintype
);
/*********************************************************
* 函 数 名: HBI_GetLiveAcquisitionTime
* 功能描述: 获取采集时间间隔(网口静态态UDP或无线UDP)
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
out:int *out_time - 时间,单位是毫秒ms
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetLiveAcquisitionTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetLiveAcquisitionTime
(
IntPtr
handle
,
ref
int
time
);
/*********************************************************
* 函 数 名: HBI_SetSinglePrepareTime
* 功能描述: 设置软触发单帧采集清空和采集之间的时间间隔
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
int *in_itime - 时间,>=0,单位:mm
0-表示软触发单帧采集先HBI_Prepare后HBI_SingleAcquisition完成单帧采集
非0-表示软触发单帧采集,只需HBI_Prepare即可按照预定时间完成单帧采集
* 返 回 值:int
0 - 成功(
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_SetSinglePrepareTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_SetSinglePrepareTime
(
IntPtr
handle
,
int
intime
);
/*********************************************************
* 函 数 名: HBI_GetPreAcqTm
* 功能描述: 获取软触发单帧采集清空和采集之间的时间间隔
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
out:int *out_itime - 时间 >=0 单位:mm
0-表示软触发单帧采集先HBI_Prepare后HBI_SingleAcquisition完成单帧采集
非0-表示软触发单帧采集,只需HBI_Prepare即可按照预定时间完成单帧采集
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GetSinglePrepareTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GetSinglePrepareTime
(
IntPtr
handle
,
ref
int
outtime
);
/*********************************************************
* 函 数 名: HBI_AutoWindowWidthWindowLevel(新增)
* 功能描述: 自动窗宽窗位算法将16位数据进行窗宽窗位处理转换为8位无符号数据,用户可以直接显示8位数据。
* 8位数据保存在imgbuff缓冲区内,数据长度减半保存在*nbufflen指针地址
* 参数说明:
In: void *handle - 句柄(无符号指针)
In/Out: unsigned char *imgbuff,源数据(16位无符号小端数据),目的数据(8位无符号数据)
In/Out: int *nbufflen,缓冲区数据长度(转换后数据大小减半)
In: int nwidth - 图像数据宽
In: int nheight - 图像数据高
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_AutoWindowWidthWindowLevel"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_AutoWindowWidthWindowLevel
(
IntPtr
handle
,
IntPtr
imgbuff
,
ref
int
nbufflen
,
int
nwindth
,
int
nheight
);
/*********************************************************
* 函 数 名: HBI_GenerateTemplate
* 功能描述: 快速生成模板(集成开发)
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
EnumIMAGE_ACQ_CMD _mode - 生成模板类型,见HbDllType.h。
OFFSET_TEMPLATE_TYPE 连续采集一组暗场图 - Firmware PreOffset Template
GAIN_TEMPLATE_TYPE 连续采集一组亮场图 - gain Template
DEFECT_TEMPLATE_GROUP1, 连续采集一组亮场图 - defect group1
DEFECT_TEMPLATE_GROUP2, 连续采集一组亮场图 - defect group2
DEFECT_ACQ_AND_TEMPLATE, 连续采集一组亮场图 - defect group3 and generate template
SOFTWARE_OFFSET_TEMPLATE 连续采集一组暗场图 - Software PreOffset Template
int bprevew - 是否生成preview模板,1-生成,0-不生成
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
* 1、OFFSET_TEMPLATE:生成暗场模板,注意球管关闭,固件采集一组暗场图并生成Offset模板
* 2、GAIN_TEMPLATE:生成增益矫正模板,需要打开球管,调节好剂量开,始平板采集亮场图像并生成gain模板
* 3、DEFECT_TEMPLATE_GROUP1:生成坏点矫正模板,需要打开球管,调节好剂量,开始平板采集第1组亮场图像
* 4、DEFECT_TEMPLATE_GROUP2:生成坏点矫正模板,需要打开球管,调节好剂量,开始平板采集第2组亮场图像
* 5、DEFECT_TEMPLATE_GROUP3:生成坏点矫正模板,需要打开球管,调节好剂量,开始平板采集第3组亮场图像并生成defect模板
* 6、SOFTWARE_OFFSET_TEMPLATE:生成暗场模板,注意球管关闭,SDK采集一组暗场图并生成Offset模板
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_GenerateTemplate"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_GenerateTemplate
(
IntPtr
handle
,
EnumIMAGE_ACQ_CMD
_mode
,
int
bprevew
=
0
);
/*********************************************************
* 函 数 名: HBI_RegProgressCallBack
* 功能描述: 注册回调函数
* 参数说明: 处理模板下载固件或者固件升级反馈信息
In: void *handle - 句柄(无符号指针)
USER_CALLBACK_HANDLE_ENVENT handleStatusfun - 注册回调函数
void* _Object - 上位机某个模块对象指针,也可为空值(例如C/C++为NULL)
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_RegProgressCallBack"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_RegProgressCallBack
(
IntPtr
handle
,
USER_CALLBACK_HANDLE_PROCESS
handleStatusfun
,
IntPtr
pContext
);
/*********************************************************
* 函 数 名: HBI_DownloadTemplate
* 功能描述: 下载矫正模板
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
ref DOWNLOAD_FILE downloadfile - 下载模板文件对象指针
emUPLOAD_FILE_TYPE emfiletype-模板类型(OFFSET_TMP-offset模板.GAIN_TMP-gain模板,DEFECT_TMP-defect模板)
int nBinningtype-模板binning类型(1-binning1*1,2-binning2*2,3-binning3*3,4-binning4*4)默认为1
char filepath-模板绝对路径
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_DownloadTemplate"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_DownloadTemplate
(
IntPtr
handle
,
ref
DOWNLOAD_FILE
downloadfile
);
/*********************************************************
* 函 数 名: HBI_DownloadTemplateByType
* 功能描述: 按照类型默认下载固定矫正模板文件
* 参数说明: Binning类型为平板当前binning类型
In: void *handle - 句柄(无符号指针)
int infiletype - 下载文件类型0-gain模板,1-defect模板,2-offset模板,其他-不支持
Out: 无
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_DownloadTemplateByType"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_DownloadTemplateByType
(
IntPtr
handle
,
int
infiletype
);
/*********************************************************
* 函 数 名: HBI_TriggerBinningAcqTime
* 功能描述: 设置触发模式、binning方式以及帧率(采集图像时间间隔)
* 参数说明:
In: void *handle - 句柄(无符号指针)
int triggerMode - 触发模式
静态平板(每秒1帧):1-软触发,2-Clear,3-高压触发,4-FreeAED
动态平板(每秒2帧以上):05-Dynamic:Hvg Sync Mode,06-Dynamic:Fpd Sync Mode,7-Continue Mode
unsigned char binning - 1:1x1,2:2x2,3:3x3,4:4x4,其他不支持
int time - 间隔时间,单位是毫秒ms,大于0
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:void *handle, int triggerMode, unsigned char binning, int time
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_TriggerBinningAcqTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_TriggerBinningAcqTime
(
IntPtr
handle
,
int
triggerMode
,
byte
binning
,
int
time
);
/*********************************************************
* 函 数 名: HBI_PgaBinningAcqTime
* 功能描述: 设置PGA档位、binning方式以及帧率(采集图像时间间隔)
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
int nPgaLevel - PGA 档位,[n]-Invalid,[1]-0.6pC,[2]-1.2pC,[3]-2.4pC,[4]-3.6pC,[5]-4.8pC,[6]-7.2pC,默认7.2pC,[7]-9.6pC
unsigned char binning - 1:1x1,2:2x2,3:3x3,4:4x4,其他不支持
int acqtime - 间隔时间,单位是毫秒ms,大于0
int nfeedback - 1:设置成功后自动反馈固件参数,非1:反馈设置成功信号(见参数和信号见回调函数)
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_PgaBinningAcqTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_PgaBinningAcqTime
(
IntPtr
handle
,
int
nPgaLevel
,
byte
binning
,
int
acqtime
,
int
nfeedback
=
0
);
/*********************************************************
* 函 数 名: HBI_TriggerPgaBinningAcqTime
* 功能描述: 设置触发模式、PGA档位、binning方式以及帧率(采集图像时间间隔)
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
int triggerMode - 触发模式
静态平板(每秒1帧):1-软触发,2-Clear,3-高压触发,4-FreeAED
动态平板(每秒2帧以上):05-Dynamic:Hvg Sync Mode,06-Dynamic:Fpd Sync Mode,7-Continue Mode
int nPgaLevel - PGA 档位,[n]-Invalid,[1]-0.6pC,[2]-1.2pC,[3]-2.4pC,[4]-3.6pC,[5]-4.8pC,[6]-7.2pC,默认7.2pC,[7]-9.6pC
unsigned char binning - 1:1x1,2:2x2,3:3x3,4:4x4,其他不支持
int acqtime - 间隔时间,单位是毫秒ms,大于0
int nfeedback - 1:设置成功后自动反馈固件参数,非1:反馈设置成功信号(见参数和信号见回调函数)
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_TriggerPgaBinningAcqTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_TriggerPgaBinningAcqTime
(
IntPtr
handle
,
int
triggerMode
,
int
nPgaLevel
,
byte
binning
,
int
acqtime
,
int
nfeedback
=
0
);
/*********************************************************
* 函 数 名: HBI_PgaAcqTime
* 功能描述: 设置PGA档位、及帧率(采集图像时间间隔)
* 参数说明:
In: IntPtr handle - 句柄(无符号指针)
int nPgaLevel - PGA 档位,[n]-Invalid,[1]-0.6pC,[2]-1.2pC,[3]-2.4pC,[4]-3.6pC,[5]-4.8pC,[6]-7.2pC,默认7.2pC,[7]-9.6pC
int acqtime - 间隔时间,单位是毫秒ms,大于0
int nfeedback - 1:设置成功后自动反馈固件参数,非1:反馈设置成功信号(见参数和信号见回调函数)
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_PgaAcqTime"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_PgaAcqTime
(
IntPtr
handle
,
int
nPgaLevel
,
int
acqtime
,
int
nfeedback
=
0
);
/*********************************************************
* 函 数 名: HBI_OpenTemplateWizard
* 功能描述: 打开模板向导窗口(生成模板、设置主要参数)
* 参数说明:
In: void *handle - 句柄(无符号指针)
* 返 回 值:int
0 - 成功
非0 - 失败
* 备 注:
*********************************************************/
[
DllImport
(
"HBISDKApi.dll"
,
EntryPoint
=
"HBI_OpenTemplateWizard"
,
CharSet
=
CharSet
.
Ansi
,
CallingConvention
=
CallingConvention
.
StdCall
)]
public
static
extern
int
HBI_OpenTemplateWizard
(
IntPtr
handle
);
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//// 其他接口类似,用户根据需求添加
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#
endregion
}
#
region
delegate
// Notice: call back function
// @USER_CALLBACK_HANDLE_ENVENT
// @byteEventid:enum eEventCallbackCommType
// @ufpdId:平板设备ID
// @PVEventParam1:fpd config or image data buffer addr
// @nEventParam2:参数2,例如data size或状态
// @nEventParam3:参数3,例如帧率 frame rate或状态等
// @nEventParam4:参数4,例如pcie事件id或预留扩展
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
delegate
int
USER_CALLBACK_HANDLE_ENVENT
(
IntPtr
pContext
,
int
ufpdId
,
byte
byteEventId
,
IntPtr
PVEventParam1
,
int
nEventParam2
,
int
nEventParam3
,
int
nEventParam4
);
// Notice: call back function
// @USER_CALLBACK_HANDLE_PROCESS
// @cmd:enum eAnswerCallbackCommType
// @buff
// @len
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
delegate
int
USER_CALLBACK_HANDLE_PROCESS
(
byte
cmd
,
int
retcode
,
IntPtr
pContext
);
#
endregion
#
region
enum
//Note:fpd communication Type
public
enum
FPD_COMM_TYPE
{
UDP_COMM_TYPE
=
0x00
,
UDP_JUMBO_COMM_TYPE
=
0x01
,
PCIE_COMM_TYPE
=
0x02
,
WALN_COMM_TYPE
=
0x03
};
//Note:fpd Status Type
public
enum
EFpdStatusType
{
FPD_DISCONN_STATUS
=
0
,
// fpd disconnect status
FPD_PREPARE_STATUS
=
1
,
// fpd prepare status
FPD_READY_STATUS
=
2
,
// fpd ready status
FPD_DOOFFSET_TEMPLATE
=
3
,
// firmware do offset template
FPD_EXPOSE_STATUS
=
4
,
// fpd busy/expose status
FPD_CONTINUE_READY
=
5
,
// continue ready
FPD_DWONLOAD_GAIN
=
6
,
// download gain template success ack respond
FPD_DWONLOAD_DEFECT
=
7
,
// download defect template success ack respond
FPD_DWONLOAD_OFFSET
=
8
,
// download offset template success ack respond
FPD_UPDATE_FIRMARE
=
9
,
// update firmware
FPD_RETRANS_MISS
=
10
,
// Retransmission
FPD_STATUS_AED
=
11
,
// AED mode,avild image data
FPD_STATUS_SLEEP
=
12
,
// Energy saving status
FPD_STATUS_WAKEUP
=
13
,
// Wake up
FPD_DOWNLOAD_NO_IMAGE
=
14
,
// Retransmission
FPD_DOWNLOAD_TAIL_IMAGE
=
15
,
// AED mode,avild image data
FPD_EMMC_MAX_NUMBER
=
16
,
// emmc save image:Maximum number of stored images
FPD_ENDTIME_WARNNING
=
17
,
// AED mode,avild image data
FPD_WLAN_BATTERY_STATUS
=
18
,
// WLAN Battery Status Message
FPD_CONN_SUCCESS
=
100
// fpd connect status
};
// Notice:Fpd Trigger Work Mode
public
enum
EnumTRIGGER_MODE
{
INVALID_TRIGGER_MODE
=
0x00
,
// 无效模式
STATIC_SOFTWARE_TRIGGER_MODE
=
0x01
,
// 静态采集-软触发模式
STATIC_PREP_TRIGGER_MODE
=
0x02
,
// 静态采集-Clear触发模式
STATIC_HVG_TRIGGER_MODE
=
0x03
,
// 静态采集-高压触发模式
STATIC_AED_TRIGGER_MODE
=
0x04
,
// 静态采集-FreeAED触发模式
DYNAMIC_HVG_TRIGGER_MODE
=
0x05
,
// 动态采集-高压同步模式
DYNAMIC_FPD_TRIGGER_MODE
=
0x06
,
// 动态采集-FPD同步模式
DYNAMIC_FPD_CONTINUE_MODE
=
0x07
,
// 动态采集-FPD Conitnue模式
DYNAMIC_FPD_SAEC_MODE
=
0x08
// 08-Static:SAECMode;
};
// Notice: acq mode:static and dynamic
public
enum
EnumIMAGE_ACQ_CMD
{
SINGLE_ACQ_DEFAULT_TYPE
=
0x00
,
// 默认单帧采集
LIVE_ACQ_DEFAULT_TYPE
,
// 默认连续采集
// 分布生成矫正模板,用于验证模板
LIVE_ACQ_OFFSET_IMAGE
,
// 创建Offset模板-连续采集暗场图
SINGLE_ACQ_GAIN_IMAGE
,
// 创建Gain模板-单帧采集亮场图
LIVE_ACQ_GAIN_IMAGE
,
// 创建Gain模板-连续采集亮场图
SINGLE_ACQ_DEFECT_IMAGE
,
// 创建Defect模板-单帧采集亮场图
LIVE_ACQ_DEFECT_IMAGE
,
// 创建Defect模板-连续采集亮场图
// 快速生成矫正模板,用于系统集成
OFFSET_TEMPLATE_TYPE
,
// 快速生成模板采集类型,连续采集一组暗场图并生成offset模板,固件生成模板
GAIN_TEMPLATE_TYPE
,
// 快速生成模板采集类型,连续采集一组亮场图并生成gain模板
DEFECT_TEMPLATE_GROUP1
,
// 快速生成模板采集类型,连续采集一组亮场图 - defect group1
DEFECT_TEMPLATE_GROUP2
,
// 快速生成模板采集类型,连续采集一组亮场图 - defect group2
DEFECT_TEMPLATE_GROUP3
,
// 快速生成模板采集类型,连续采集一组亮场图 - defect group3 and generate template
SOFTWARE_OFFSET_TEMPLATE
// 快速生成模板采集类型,连续采集一组暗场图 - SDK生成offset模板
};
// Notice: Live Acquisition'properties
public
enum
EnumLIVE_ACQUISITION
{
PREOFFSET_IMAGE
=
0x01
,
// preoffset template and image
ONLY_IMAGE
=
0x02
,
// only image
ONLY_PREOFFSET
=
0x03
,
// only preoffset template
OVERLAY_16BIT_IMG
=
0x04
,
// overlap result is 16bit'image
OVERLAY_32BIT_IMG
=
0x05
// overlap result is 32bit'image
};
// Notice: Live Acquisition'properties
public
enum
emHBI_DATA_TYPE
{
EHBI_8UC1
=
0X01
,
// 1 - 8bits
EHBI_16UC1
=
0X02
,
// 2 - 16bits
EHBI_32FC1
=
0X04
// 4 - 32bits
};
// Notice: upload template file
// template file type
public
enum
emUPLOAD_FILE_TYPE
{
OFFSET_TMP
=
0x00
,
GAIN_TMP
=
0x01
,
DEFECT_TMP
=
0x02
};
// upload process status
public
enum
emUPLOAD_FILE_STATUS
{
UPLOAD_FILE_START
=
0x00
,
UPLOAD_FILE_DURING
=
0x01
,
UPLOAD_FILE_STOP
=
0x02
};
// Notice: After Each Member Variables, show Variables enum ,
// before '-' is variables' value, after '-' is the meaning of the value;
// each value departed by ';' symbol
public
enum
eRequestCommType
{
EDL_COMMON_TYPE_INVALVE
=
0x00
,
EDL_COMMON_TYPE_GLOBAL_RESET
=
0x01
,
EDL_COMMON_TYPE_PREPARE
=
0x02
,
EDL_COMMON_TYPE_SINGLE_SHORT
=
0x03
,
EDL_COMMON_TYPE_LIVE_ACQ
=
0x04
,
EDL_COMMON_TYPE_STOP_ACQ
=
0x05
,
EDL_COMMON_TYPE_PACKET_MISS
=
0x06
,
EDL_COMMON_TYPE_FRAME_MISS
=
0x07
,
EDL_COMMON_TYPE_DUMMPING
=
0x08
,
EDL_COMMON_TYPE_FPD_STATUS
=
0x09
,
EDL_COMMON_TYPE_END_RESPONSE
=
0x0A
,
// End response packet
EDL_COMMON_TYPE_CONNECT_FPD
=
0x0B
,
// connect fpd
EDL_COMMON_TYPE_DOWNLOAD_IMAGE
=
0x0C
,
// wireless download image
EDL_COMMON_TYPE_SLEEP_STATE
=
0x0D
,
// wireless set sleep state
EDL_COMMON_TYPE_WAKE_UP
=
0x0E
,
// wireless wake up
EDL_COMMON_TYPE_DISCONNECT_FPD
=
0x0F
,
// disconnect fpd
EDL_COMMON_TYPE_SET_RAM_PARAM_CFG
=
0x10
,
EDL_COMMON_TYPE_GET_RAM_PARAM_CFG
=
0x11
,
EDL_COMMON_TYPE_SET_ROM_PARAM_CFG
=
0x12
,
EDL_COMMON_TYPE_GET_ROM_PARAM_CFG
=
0x13
,
EDL_COMMON_TYPE_SET_FACTORY_PARAM_CFG
=
0x14
,
EDL_COMMON_TYPE_GET_FACTORY_PARAM_CFG
=
0x15
,
EDL_COMMON_TYPE_RESET_FIRM_PARAM_CFG
=
0x16
,
EDL_COMMON_UPLOAD_OFFSET_TEMPLATE
=
0x2E
,
//add by MH.YANG 30/12
EDL_COMMON_UPLOAD_GAIN_TEMPLATE
=
0x2F
,
// Upload gain template
EDL_COMMON_UPLOAD_DEFECT_TEMPLATE
=
0x30
,
// Upload defect template
EDL_COMMON_PRIMARY_AUTHOR
=
0x31
,
//
EDL_COMMON_SECONDARY_AUTHOR
=
0x32
,
//
EDL_COMMON_UPDATE_PCIE_INIT
=
0x4A
,
// Update PCIe software Init
EDL_COMMON_UPDATE_PCIE_VERSION
=
0x4B
,
// Update PCIe software File
EDL_COMMON_ERASE_FIRMWARE
=
0x4F
,
// Erase old firmware package request
EDL_COMMON_UPDATE_FIRMWARE
=
0x50
,
// Update new firmware package request
EDL_COMMON_UPDATE_EMBEDDED_INIT
=
0xFC
,
// Update embedded software Init
EDL_COMMON_UPDATE_EMBEDDED_SOFTWARE
=
0xFD
,
// Update embedded software File
EDL_COMMON_TYPE_SWITCH_WALN_MODE
=
0xFE
,
// Switch wlan ap/client Mode and 2.4G/5G net Type
EDL_COMMON_TYPE_SET_AQC_MODE
=
0xFF
};
// Notice: After Each Member Variables, show Variables enum ,
// before '-' is variables' value, after '-' is the meaning of the value;
// each value departed by ';' symbol
public
enum
eCallbackEventCommType
{
ECALLBACK_TYPE_INVALVE
=
0X00
,
ECALLBACK_TYPE_COMM_RIGHT
=
0X01
,
ECALLBACK_TYPE_COMM_WRONG
=
0X02
,
ECALLBACK_TYPE_DUMMPLING
=
0X03
,
ECALLBACK_TYPE_ACQ_END
=
0X04
,
ECALLBACK_TYPE_UPDATE_FIRMWARE
=
0X06
,
// Update old firmware package answer
ECALLBACK_TYPE_ERASE_FIRMWARE
=
0X07
,
// Update new firmware package answer
ECALLBACK_TYPE_FPD_STATUS
=
0X09
,
// Status package
ECALLBACK_TYPE_ROM_UPLOAD
=
0X10
,
ECALLBACK_TYPE_RAM_UPLOAD
=
0X11
,
ECALLBACK_TYPE_FACTORY_UPLOAD
=
0X12
,
ECALLBACK_TYPE_WLAN_BATTERY
=
0X13
,
ECALLBACK_TYPE_SINGLE_IMAGE
=
0X51
,
ECALLBACK_TYPE_MULTIPLE_IMAGE
=
0X52
,
ECALLBACK_TYPE_PREVIEW_IMAGE
=
0X53
,
ECALLBACK_TYPE_PACKET_MISS
=
0X5B
,
ECALLBACK_TYPE_OFFSET_TMP
=
0X5C
,
ECALLBACK_OVERLAY_NUMBER
=
0X5D
,
ECALLBACK_OVERLAY_16BIT_IMAGE
=
0X5E
,
ECALLBACK_OVERLAY_32BIT_IMAGE
=
0X5F
,
ECALLBACK_TYPE_SENDTO_WIZARD
=
0XA0
,
ECALLBACK_TYPE_PACKET_MISS_MSG
=
0XA4
,
ECALLBACK_TYPE_THREAD_EVENT
=
0XA5
,
ECALLBACK_TYPE_ACQ_DISCARDDED
=
0XA6
,
ECALLBACK_TYPE_OFFSET_ERR_MSG
=
0XA7
,
ECALLBACK_TYPE_GAIN_ERR_MSG
=
0XA8
,
ECALLBACK_TYPE_DEFECT_ERR_MSG
=
0XA9
,
ECALLBACK_TYPE_NET_ERR_MSG
=
0XAA
,
ECALLBACK_TYPE_SET_CFG_OK
=
0XAB
,
// 设置参数成功
ECALLBACK_TYPE_SAVE_SUCCESS
=
0XAC
,
// 保存图像成功
ECALLBACK_TYPE_GENERATE_TEMPLATE
=
0XAD
,
// 生成模板
ECALLBACK_TYPE_FILE_NOTEXIST
=
0XAE
,
// 文件不存在
ECALLBACK_TYPE_WORK_STATUS
=
0XAF
// 工作状态(生产模式或测试模式)
};
public
enum
eCallbackUpdateFirmwareStatus
{
ECALLBACK_UPDATE_STATUS_START
=
0XB0
,
// Start status or Erase Firmaware
ECALLBACK_UPDATE_STATUS_PROGRESS
=
0XB1
,
// progress
ECALLBACK_UPDATE_STATUS_RESULT
=
0XB2
// the Processing Result
};
enum
eCallbackDownloadTemplateFileStatus
{
ECALLBACK_TEMPLATE_BEGIN
=
0X00
,
ECALLBACK_TEMPLATE_INVALVE_PARAM
=
0X01
,
ECALLBACK_TEMPLATE_MALLOC_FAILED
=
0X02
,
ECALLBACK_TEMPLATE_SEND_FAILED
=
0X03
,
ECALLBACK_TEMPLATE_STATUS_ABORMAL
=
0X04
,
ECALLBACK_TEMPLATE_FRAME_NUM
=
0X05
,
ECALLBACK_TEMPLATE_TIMEOUT
=
0X06
,
ECALLBACK_TEMPLATE_MEAN
=
0X07
,
ECALLBACK_TEMPLATE_GENERATE
=
0X08
,
ECALLBACK_TEMPLATE_RESULT
=
0X09
};
public
enum
HBIRETCODE
{
HBI_SUCCSS
=
0
,
HBI_ERR_OPEN_DETECTOR_FAILED
=
8001
,
HBI_ERR_INVALID_PARAMS
=
8002
,
HBI_ERR_CONNECT_FAILED
=
8003
,
HBI_ERR_MALLOC_FAILED
=
8004
,
HBI_ERR_RELIMGMEM_FAILED
=
8005
,
HBI_ERR_RETIMGMEM_FAILED
=
8006
,
HBI_ERR_NODEVICE
=
8007
,
HBI_ERR_NODEVICE_TRY_CONNECT
=
8008
,
HBI_ERR_DEVICE_BUSY
=
8009
,
HBI_ERR_SENDDATA_FAILED
=
8010
,
HBI_ERR_RECEIVE_DATA_FAILED
=
8011
,
HBI_ERR_COMMAND_DISMATCH
=
8012
,
HBI_ERR_NO_IMAGE_RAW
=
8013
,
HBI_ERR_PTHREAD_ACTIVE_FAILED
=
8014
,
HBI_ERR_STOP_ACQUISITION
=
8015
,
HBI_ERR_INSERT_FAILED
=
8016
,
HBI_ERR_GET_CFG_FAILED
=
8017
,
HBI_NOT_SUPPORT
=
8018
,
HBI_REGISTER_CALLBACK_FAILED
=
8019
,
HBI_SEND_MESSAGE_FAILD
=
8020
,
HBI_ERR_WORKMODE
=
8021
,
HBI_END
};
public
enum
eCallbackTemplateStatus
{
ECALLBACK_TEMPLATE_BEGIN
=
0X00
,
ECALLBACK_TEMPLATE_INVALVE_PARAM
=
0X01
,
ECALLBACK_TEMPLATE_MALLOC_FAILED
=
0X02
,
ECALLBACK_TEMPLATE_SEND_FAILED
=
0X03
,
ECALLBACK_TEMPLATE_STATUS_ABORMAL
=
0X04
,
ECALLBACK_TEMPLATE_FRAME_NUM
=
0X05
,
ECALLBACK_TEMPLATE_TIMEOUT
=
0X06
,
ECALLBACK_TEMPLATE_MEAN
=
0X07
,
ECALLBACK_TEMPLATE_GENERATE
=
0X08
,
ECALLBACK_TEMPLATE_RESULT
=
0X09
};
public
enum
EnumTempType
{
OFFSETFILE
=
0x00
,
GAINFILE
,
BADPIXFILE
,
GAINA
,
GAINB
};
//public static const CodeStringTable CrErrStrList[] = {
//{ 0, HBI_SUCCSS, "Success" },
//{ 1, HBI_ERR_OPEN_DETECTOR_FAILED, "Open device driver failed" },
//{ 2, HBI_ERR_INVALID_PARAMS, "Parameter error" },
//{ 3, HBI_ERR_CONNECT_FAILED, "Connect failed" },
//{ 4, HBI_ERR_MALLOC_FAILED, "Malloc memory failed" },
//{ 5, HBI_ERR_RELIMGMEM_FAILED, "Releaseimagemem fail" },
//{ 6, HBI_ERR_RETIMGMEM_FAILED, "ReturnImageMem fail" },
//{ 7, HBI_ERR_NODEVICE, "No Init DLL Instance" },
//{ 8, HBI_ERR_NODEVICE_TRY_CONNECT, "Disconnect status" },
//{ 9, HBI_ERR_DEVICE_BUSY, "Fpd is busy" },
//{ 10, HBI_ERR_SENDDATA_FAILED, "SendData failed" },
//{ 11, HBI_ERR_RECEIVE_DATA_FAILED, "Receive Data failed" },
//{ 12, HBI_ERR_COMMAND_DISMATCH, "Command dismatch" },
//{ 13, HBI_ERR_NO_IMAGE_RAW, "No Image raw" },
//{ 14, HBI_ERR_PTHREAD_ACTIVE_FAILED, "Pthread active failed" },
//{ 15, HBI_ERR_STOP_ACQUISITION, "Pthread stop data acquisition failed" },
//{ 16, HBI_ERR_INSERT_FAILED, "insert calibrate mode failed" },
//{ 17, HBI_ERR_GET_CFG_FAILED, "get Fpd config failed" },
//{ 18, HBI_NOT_SUPPORT, "not surport yet" },
//{ 19, HBI_REGISTER_CALLBACK_FAILED, "failed to register callback function" },
//{ 20, HBI_SEND_MESSAGE_FAILD, "send message failed" },
//{ 21, HBI_ERR_WORKMODE, "switch work mode failed" },
//{ 22, HBI_FAILED, "operation failed" },
//{ 23, HBI_FILE_NOT_EXIST, "file does not exist" },
//{ 24, HBI_TYPE_IS_NOT_EXISTS, "this type is not exists"},
//{ 25, HBI_SAVE_FILE_FAILED, "save file failed"},
//{ 26, HBI_INIT_PARAM_FAILED, "Init dll param failed"},
//{ 27, HBI_END, "Exit monitoring"}
//};
#
endregion
#
region
struct
#
region
//Note:fpd connect config param
public
struct
COMM_CFG
{
public
FPD_COMM_TYPE
_type
;
// 网口通讯需要设置,PCIe只要设置类型即可
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
16
)]
public
byte
[]
_remoteip
;
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
16
)]
public
byte
[]
_localip
;
public
ushort
_loacalPort
;
public
ushort
_remotePort
;
};
// Notice:generate calibrate template input param
public
struct
CALIBRATE_INPUT_PARAM
{
public
int
image_w
;
// image width
public
int
image_h
;
// image height
public
int
binning
;
// binning
public
int
roi_x
;
// ROI left
public
int
roi_y
;
// ROI top
public
int
roi_w
;
// ROI width
public
int
roi_h
;
// ROI height
public
int
group_sum
;
// group sum
public
int
per_group_num
;
// num per group
};
// Notice:fpd aqc mode
public
struct
FPD_AQC_MODE
{
public
EnumIMAGE_ACQ_CMD
eAqccmd
;
// 采集命令
public
EnumLIVE_ACQUISITION
eLivetype
;
// 只限于连续采集(LIVE_ACQ_DEFAULT_TYPE)详细任务, 1-固件做offset模板并上图;2-只上图;3-固件做只做offset模板;
// 4 - 叠加:上传16位均图;5 - 叠加:上传32位均图;
public
int
ngroupno
;
// 组号
public
int
nAcqnumber
;
// 实际采集帧数
public
int
ndiscard
;
// 忽略的帧数
public
int
nframeid
;
// 计数器
};
// Notice: Image Property
public
struct
IMAGE_PROPERTY
{
public
int
nFpdNum
;
//fpd Number
public
int
nwidth
;
//image width
public
int
nheight
;
//image height
public
int
datatype
;
//data type:0-unsigned char,1-char,2-unsigned short,3-float,4-double
public
int
ndatabit
;
//data bit:0-16bit,1-14bit,2-12bit,3-8bit
public
int
nendian
;
//endian:0-little endian,1-biger endian
public
int
packet_size
;
//fpd send the number of packet per frame
public
int
frame_size
;
//data size per frame
public
int
tailPacketSize
;
//Tail packet size
public
int
frame_number
;
//The number of buffer capacity,Integer,[2~32],buff_szie=frame_size * ncapacity
};
// Notice:Image data object
// image buff size(8bits) datalen = uwidth * uheight;
// image buff size(16bits) datalen = uwidth * uheight * 2;
// image buff size(32bits) datalen = uwidth * uheight * 4;
public
struct
ImageData
{
public
int
uwidth
;
// image width
public
int
uheight
;
// image height
public
emHBI_DATA_TYPE
ndatabits
;
// data bit:1-8bit,2-16bit,4-32bit,其他默认-16bit
public
int
uframeid
;
// frame id
// public byte[] databuff; // buffer address
public
IntPtr
databuff
;
public
int
datalen
;
// buffer size
};
// StructLayout使设计者可以控制类或结构的数据字段的物理布局
// Explicit与FieldOffset一起可以控制每个数据成员的精确位置
[
StructLayout
(
LayoutKind
.
Explicit
)]
public
struct
ImageBuff
{
// FieldOffset控制字段所在的物理位置偏移为0
[
FieldOffset
(
0
)]
public
byte
[]
imagebytetemp
;
// 同样偏移为0,开始位置与a重叠了。
[
FieldOffset
(
0
)]
public
ushort
[]
imageushorttemp
;
};
[
StructLayout
(
LayoutKind
.
Sequential
)]
public
struct
CodeStringTable
{
int
num
;
int
HBIRETCODE
;
String
errString
;
// const char *errString;
};
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
)]
public
struct
SOFTWARE_CALIBRATE_ENABLE
{
[
MarshalAs
(
UnmanagedType
.
U1
)]
public
bool
enableOffsetCalib
;
[
MarshalAs
(
UnmanagedType
.
U1
)]
public
bool
enableGainCalib
;
[
MarshalAs
(
UnmanagedType
.
U1
)]
public
bool
enableDefectCalib
;
[
MarshalAs
(
UnmanagedType
.
U1
)]
public
bool
enableDummyCalib
;
};
// Notice:fpd software calibrate enable info.
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
)]
public
struct
IMAGE_CORRECT_ENABLE
{
[
MarshalAs
(
UnmanagedType
.
U1
)]
public
bool
bFeedbackCfg
;
//true-ECALLBACK_TYPE_ROM_UPLOAD Event,false-ECALLBACK_TYPE_SET_CFG_OK Event
public
char
ucOffsetCorrection
;
//00-"Do nothing";01-"prepare Offset Correction"; 02-"post Offset Correction";
public
char
ucGainCorrection
;
//00-"Do nothing";01-"Software Gain Correction"; 02-"Hardware Gain Correction"
public
char
ucDefectCorrection
;
//00-"Do nothing";01-"Software Defect Correction"; 02-"Software Defect Correction"
public
char
ucDummyCorrection
;
//00-"Do nothing";01-"Software Dummy Correction"; 02-"Software Dummy Correction"
};
// Notice: calibrate template raw file call back info
[
StructLayout
(
LayoutKind
.
Sequential
)]
public
struct
ECALLBACK_RAW_INFO
{
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
260
)]
public
char
[]
szRawName
;
// 返回数据文件名称
public
double
dMean
;
// 灰度均值
};
// Notice:template file attributes
[
StructLayout
(
LayoutKind
.
Sequential
)]
public
struct
DOWNLOAD_FILE
{
public
emUPLOAD_FILE_TYPE
emfiletype
;
public
int
nBinningtype
;
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
260
)]
public
char
[]
filepath
;
};
#
endregion
// Notice:wireless battery info
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
BATTERY_STATUS_INFO
{
public
ushort
usTemperature
;
// Detector Temperature
public
ushort
usHumidity
;
// Detector Humidity
public
char
uzStatusCmd
;
// Battery Status command,default:0x12
public
char
uzPercentage
;
// Battery Percentage,0~100
public
char
uzBatteryStatus
;
// Battery Status,01-Battery charging,02-Battery powered,03-Power supply,04-Charging complete.
public
ushort
usRemainingTime
;
// Remaining Charging Time,unit:minute
public
char
uzIsWlan24G5G
;
// WLAN:1-2.4G,2-5G,others-Invalid
public
char
uzIsApClientMode
;
// WLAN:AP Mode or Client Mode,1-AP Mode,2-Client Mode,others-Invalid
};
// Notice:Region of interest in images:9
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
CuttingImageRect
{
public
char
m_byCuttingEnable
;
//01 ROI enbale or disable,1-enbale,非1-disable
public
ushort
m_sCutRectLeft
;
//02 ROI rect left
public
ushort
m_sCutRectTop
;
//02 ROI rect top
public
ushort
m_sCutRectWidth
;
//02 ROI rect Width
public
ushort
m_sCutRectHeight
;
//02 ROI rect Height
};
// Notice:save image:4
public
struct
SAVE_IMAGE
{
public
char
m_bySaveType
;
//0-show image only,1-save image only,2-show and save image;
public
char
m_bySaveFileType
;
//0-image,1-video;
public
ushort
m_bySaveNumber
;
//Number of images included in the video,》0
};
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
SysBaseInfo
{
// Register_1
public
char
m_byProductType
;
//01 //01-Flat Panel Detector; 02-Linear Array Detector
// Register_2
public
char
m_byXRaySensorType
;
//01 //01-Amorphous Silicon; 02-CMOS; 03-IGZO; 04-LTPS; 05-Amorphous Selenium
// Register_3
public
char
m_byPanelSize
;
//01 //01-1717 inch Panel Size; 02-1417; 03-1414; 04-1212;
//05-1012; 06-0912; 07-0910; 08-0909; 09-0506; 10-0505; 11-0503
// Register_4
public
char
m_byPixelPitch
;
//01 //01-27 um; 02-50; 03-75; 04-85; 05-100; 06-127; 07-140; 08-150; 09-180; 10-200 11-205; 12-400; 13-1000
// Register_5
public
char
m_byPixelMatrix
;
//01 //01-"3072 x 3072"; 02-"2536 x 3528"; 03-"2800 x 2304"; 04-"2304 x 2304"; 05-"2048 x 2048"; 06-"1536 x 1536";
//07-"1024 x 1536"; 08-"1024 x 1024"; 09-"1024 x 0768"; 10-"1024 x 0512"; 11-"0768 x 0768";
//12-"0512 x 0512"; 13-"0512 x 0256"; 14-"0256 x 0256"
// Register_6
public
char
m_byScintillatorType
;
//01 //01-DRZ Standard; 02-DRZ High; 03-DRZ Plus; 04-PI-200; 05-Structured GOS; 06-CSI Evaporation; 07-CSI Attach;
// Register_7
public
char
m_byScanLineFanoutMode
;
//01 //01-Single Side Single Gate; 02-Dual Side Single Gate; 03-Single Side Dual Gate; 04-Dual Side Dual Gate;
// Register_8
public
char
m_byReadoutLineFanoutMode
;
//01 //01-Single Side Single Read; 02-Dual Side Single Read; 03-Single Side Dual Read; 04-Dual Side Dual Read;
// Register_9
public
char
m_byFPDMode
;
//01 //01-Static; 02-Dynamic;
// Register_10
public
char
m_byFPDStyle
;
//01 //01-Fixed; 02-Wireless; 03-Portable;
// Register_11
public
char
m_byApplicationMode
;
//01 //01-Medical; 02-Industry;
// Register_12
public
char
m_byGateChannel
;
//01 //01-"600 Channel"; 02-"512 Channel"; 03-"384 Channel"; 04-"256 Channel"; 05-"128 Channel"; 06-"064 Channel"
// Register_13
public
char
m_byGateType
;
//01 //01-"HX8677"; 02-"HX8698D"; 03-"NT39565D"
// Register_14
public
char
m_byAFEChannel
;
//01 //01-"64 Channel"; 02-"128 Channel"; 03-"256 Channel"; 04-"512 Channel";
// Register_15
public
char
m_byAFEType
;
//01 //01-"AFE0064"; 02-"TI COF 2256"; 03-"AD8488"; 04-"ADI COF 2256";
// Register_16~Register_17
public
ushort
m_sGateNumber
;
//02 //Gate Number
// Register_18~Register_19
public
ushort
m_sAFENumber
;
//02 //AFE Number
// Register_20~Register_21
public
ushort
m_sImageWidth
;
//02 //Image Width // modified by mhyang 20191220
// Register_22~Register_23
public
ushort
m_sImageHeight
;
//02 //Image Height
// Register_24~Register_37
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
14
)]
public
char
[]
m_cSnNumber
;
//14 //sn number // modified by mhyang 20200401
// Register_38~Register_46.
public
CuttingImageRect
m_stCuttingRect
;
//9 Region Of Interest;
// Register_47~Register_53
public
char
m_byAuthorizationEndTime1
;
//01 //Authorization End Time1 // modified by mhyang 20211118
public
char
m_byAuthorizationEndTime2
;
//01 //Authorization End Time2
public
char
m_byAuthorizationEndTime3
;
//01 //Authorization End Time3
public
char
m_byAuthorizationEndTime4
;
//01 //Authorization End Time4
public
char
m_byAuthorizationEndTime5
;
//01 //Authorization End Time5
public
char
m_byAuthorizationEndTime6
;
//01 //Authorization End Time6
public
char
m_byAuthorizationStatus
;
//01 //Authorization Status
// Register_54~Register_59
public
char
m_byRtcTime1
;
//01 //RTC Time1 // modified by mhyang 20211119
public
char
m_byRtcTime2
;
//01 //RTC Time2
public
char
m_byRtcTime3
;
//01 //RTC Time3
public
char
m_byRtcTime4
;
//01 //RTC Time4
public
char
m_byRtcTime5
;
//01 //RTC Time5
public
char
m_byRtcTime6
;
//01 //RTC Time6
// Register_60~Register_66
public
char
m_bySecondaryAuthorEndTime1
;
//01 //Secondary Authorization End Time1 // modified by mhyang 20220209
public
char
m_bySecondaryAuthorEndTime2
;
//01 //Secondary Authorization End Time2
public
char
m_bySecondaryAuthorEndTime3
;
//01 //Secondary Authorization End Time3
public
char
m_bySecondaryAuthorEndTime4
;
//01 //Secondary Authorization End Time4
public
char
m_bySecondaryAuthorEndTime5
;
//01 //Secondary Authorization End Time5
public
char
m_bySecondaryAuthorEndTime6
;
//01 //Secondary Authorization End Time6
public
char
m_bySecondaryAuthorStatus
;
//01 //Secondary Authorization Status
// Register_67~Register_72
public
char
m_bySecondaryRtcTime1
;
//01 //Secondary RTC Time1 // modified by mhyang 20220209
public
char
m_bySecondaryRtcTime2
;
//01 //Secondary RTC Time2
public
char
m_bySecondaryRtcTime3
;
//01 //Secondary RTC Time3
public
char
m_bySecondaryRtcTime4
;
//01 //Secondary RTC Time4
public
char
m_bySecondaryRtcTime5
;
//01 //Secondary RTC Time5
public
char
m_bySecondaryRtcTime6
;
//01 //Secondary RTC Time6
// Register_73
public
char
m_cMaxFps
;
//01 //max fps // modified by mhyang 20220308
// Register_74~75
public
char
m_byRotate90
;
//01 //00-"Do nothing";01-"Right Rotate 90°Enable";02-"Left Rotate 90°Enable";
public
char
m_byToFlip
;
//01 //00-"Do nothing";01-"Vertically mirror Enable";02-"Horizontal mirror Enable";
// Register76
public
char
m_byBit8Image
;
//01 //00-"bit16 image";01-"bit8 image"
// Register77~Register80
public
int
m_unWindowWidth
;
//04 //window width
// Register81~Register84
public
int
m_unWindowLeveling
;
//04 //window leveling
// Register85~Register88
SAVE_IMAGE
m_stSaveOption
;
//04 //save image; // add by mhyang 20220830
// Register_89~Register_100.
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
12
)]
public
char
[]
m_abySysBaseInfoReserved
;
//16//////Registers 85To100(include) Are Reserved;
};
// System Manufacture Information:50
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
SysManuInfo
{
// Register_1~Register_4
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
// Register_5~Register_16
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
12
)]
public
char
[]
m_abyFPDSerialNumber
;
//12 //FPD SN Byte 01-12;
// Register_17~Register_18
public
short
m_sYear
;
//02 //Year
// Register_19~Register_20
public
short
m_sMouth
;
//02 //Month
// Register_21~Register_22
public
char
m_byEmbeddedSoftwareVersion1
;
//01 //Embedded Software Version
public
char
m_byEmbeddedSoftwareVersion2
;
//01 //Embedded Software Version
// Register_23~Register_26
public
char
m_byEmbeddedSoftwareBuildingTime1
;
//01 //Embedded Software Building Time
public
char
m_byEmbeddedSoftwareBuildingTime2
;
//01 //Embedded Software Building Time
public
char
m_byEmbeddedSoftwareBuildingTime3
;
//01 //Embedded Software Building Time
public
char
m_byEmbeddedSoftwareStatus
;
//01 //Embedded Software Status 0-release,1-rc,2-beta
// Register_27~Register_28
public
short
m_sMasterFPGAFirmwareVersion
;
//02 //Master FPGA Firmware Version
// Register_29~Register_31
public
char
m_byMasterFPGAFirmwareBuildingTime1
;
//01 //Master FPGA Firmware Building Time1
public
char
m_byMasterFPGAFirmwareBuildingTime2
;
//01 //Master FPGA Firmware Building Time2
public
char
m_byMasterFPGAFirmwareBuildingTime3
;
//01 //Master FPGA Firmware Building Time3
// Register_32~Register_34
public
char
m_byMasterFPGAFirmwareStatus1
;
//01 //Master FPGA Firmware Status1
public
char
m_byMasterFPGAFirmwareStatus2
;
//01 //Master FPGA Firmware Status2
public
char
m_byMasterFPGAFirmwareStatus3
;
//01 //Master FPGA Firmware Status3
// Register_35~Register_36
public
char
m_byMCUFirmwareVersion1
;
//01 //MCU Firmware Version1
public
char
m_byMCUFirmwareVersion2
;
//01 //MCU Firmware Version2
// Register_37~Register_40
public
char
m_byMCUFirmwareBuildingTime1
;
//01 //MCU Firmware Building Time1
public
char
m_byMCUFirmwareBuildingTime2
;
//01 //MCU Firmware Building Time2
public
char
m_byMCUFirmwareBuildingTime3
;
//01 //MCU Firmware Building Time3
public
char
m_byMCUFirmwareStatus
;
//01 //MCU Firmware Status
// Register_41~Register_44
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_szBatterySN
;
//04 //Battery Serial number
// Register_45~Register_50
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
6
)]
public
char
[]
m_abySysManuInfoReserved
;
//6 //Reserved Size
};
// System Status Information:28
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
SysStatusInfo
{
// Register_1~Register_4
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
// Register_5~Register_8
public
int
m_unTemperature
;
//04 //Temperature
// Register_9~Register_12
public
int
m_unHumidity
;
//04 //Humidity
// Register_13~Register_16
public
int
m_unDose
;
//04 //Dose
// Register_17~Register_28
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
12
)]
public
char
[]
m_abySysStatusInfoReserved
;
};
// Gigabit Ethernet Information:40
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
EtherInfo
{
// Register_1~Register_4
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
// Register_9~Register_14
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
6
)]
public
byte
[]
m_bySourceMAC
;
//06 //Source MAC
// Register_15~Register_18
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
byte
[]
m_bySourceIP
;
//04 //Source IP
// Register_5~Register_6
public
ushort
m_sSourceUDPPort
;
//02 //Source UDP Port
// Register_19~Register_24
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
6
)]
public
byte
[]
m_byDestMAC
;
//06 //Dest MAC
// Register_25~Register_28
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
byte
[]
m_byDestIP
;
//04 //Dest IP
// Register_7~Register_8
public
ushort
m_sDestUDPPort
;
//02 //Dest UDP Port
// Register_29
public
char
m_byIs5GMode
;
//01 //1-2.4G模式,2-5G模式
// Register_30
public
char
m_byIsAPMode
;
//01 //1-AP模式,2-Client模式
// Register_31~Register_40
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
10
)]
public
char
[]
m_abyEtherInfoReserved
;
//10 //Reserved Size
};
// High Voltage Generator Interface Trigger Mode Information:21
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
HiVolTriggerModeInfo
{
// Register_1~Register_4
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
// Register_5 HVG_Trig Mode(03)
public
char
m_byPolarityParam
;
//01 bit4:NON,bit3:i_HVG_Request,bit2:i_HVG_Sync_In,bit1:o_FPD_Ready,bit0:o_FPD_Sync_Out
public
char
m_byHVGRequestParam03
;
//01 bit4:NON,bit3:i_HVG_Request,bit2:i_HVG_Sync_In,bit1:0,bit0:0
public
char
m_byFPDReadyParam03
;
//01 bit4:NON,bit3:0,bit2:0,bit1:o_FPD_Ready,bit0:o_FPD_Sync_Out
// Register_8 HVG_SYNC Mode(05)
public
char
m_byHVGRequestParam05
;
//01 bit4:NON,bit3:i_HVG_Request,bit2:i_HVG_Sync_In,bit1:0,bit0:0
public
char
m_byFPDReadyParam05
;
//01 bit4:NON,bit3:0,bit2:0,bit1:o_FPD_Ready,bit0:o_FPD_Sync_Out
// Register_10 FPD_SYNC Mode(06)
public
char
m_byHVGRequestParam06
;
//01 bit4:NON,bit3:i_HVG_Request,bit2:i_HVG_Sync_In,bit1:0,bit0:0
public
char
m_byFPDReadyParam06
;
//01 bit4:NON,bit3:0,bit2:0,bit1:o_FPD_Ready,bit0:o_FPD_Sync_Out
// Register_12 FPD_SYNC Mode(08)
public
char
m_byHVGRequestParam08
;
//01 bit4:NON,bit3:i_HVG_Request,bit2:i_HVG_Sync_In,bit1:0,bit0:0
public
char
m_byFPDReadyParam08
;
//01 bit4:NON,bit3:0,bit2:0,bit1:o_FPD_Ready,bit0:o_FPD_Sync_Out
public
char
m_byHVGExplore08
;
//01 bit4:NON,bit3:i_HVG_Request,bit2:i_HVG_Sync_In,bit1:0,bit0:0
// Register_15~Register_21
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
7
)]
//wss
public
char
[]
m_byHiVolTriggerReserved
;
};
// System Configuration Information:127
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
SysCfgInfo
{
// Register_1~Register_4
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
// Register_5
public
char
m_byTriggerMode
;
//01 // 01-"Static: Software Mode" 02-"Static: Prep Mode"; 03-"Static Hvg Trigger Mode";
// 04-Static AED Trigger Mode, 05-Dynamic Hvg In Mode,06-Dynamic Fpd Out Mode.
// Register_6
public
char
m_byPreviewModeTransmission
;
//01 //00-"Just transmmit full resolution image matrix"; 01-"Just transmmit the preview image";
//02-"Transmmit the preview image and full resolution image"
// Register_7
public
char
m_byPositiveVsNegativeIntegrate
;
//01 //01-"Electron"; 02-"Hole" //04-"Static: Inner Trigger Mode"; 05-"Dynamic: Sync In Mode"; 06-"Dynamic: Sync Out Mode"
// Register_8
public
char
m_byBinning
;
//01 //01-"1x1"; 02-"2x2 Binning"; 03-"3x3 Binning"; 04-"4x4 Binning";
// Register_9
public
char
m_byIntegratorCapacitorSelection
;
//01 //01-"Integrator Capacitor PGA0"; 02-"Integrator Capacitor PGA1"; 03-"PGA2";......;08-"Integrator Capacitor PGA7"
// Register_10
public
char
m_byAmplifierGainSelection
;
//01 //01-"Amplifier Gain AMP0"; 02-"Amplifier Gain AMP1"; 03-"Amplifier Gain AMP2"; 04-"Amplifier Gain AMP3";
//05-"Amplifier Gain AMP4"; 06-"Amplifier Gain AMP5"; 07-"Amplifier Gain AMP6"; 08-"Amplifier Gain AMP7";
// Register_11
public
char
m_bySelfDumpingEnable
;
//01 //01-"Enable Dumping Process"; 02-"Disable Dumping Process";
// Register12
public
char
m_bySelfDumpingProcessing
;
//01 //01-"Clear Process for Dumping"; 02-"Acquisition Process for Dumping";
// add 20190705
public
char
m_byClearFrameNumber
;
//01 //01-"Clear Frame"; 02-"Clear Frame";03-"Clear Frame";04-"Clear Frame";
// Register_13
public
char
m_byPDZ
;
//01 //01-"Disable PDZ"; 02-"Enable PDZ"
// Register_14
public
char
m_byNAPZ
;
//01 //01-"Disable NAPZ"; 02-"Enable NAPZ"
// Register15
public
char
m_byInnerTriggerSensorSelection
;
//01 //00-"No Selection"; 01-"I Sensor Selection"; 02-"II Sensor Selection";
//03-"III Sensor Selection"; 04-"IV Sensor Selection"; 05-"V Sensor Selection"
// Register_16~Register_17
public
short
m_sZoomBeginRowNumber
;
//02 //Zoom Begin Row Number
// Register_18~Register_19
public
short
m_sZoomEndRowNumber
;
//02 //Zoom End Row Number
// Register_20~Register_21
public
short
m_sZoomBeginColumnNumber
;
//02 //Zoom Begin Column Number
// Register_22~Register_23
public
short
m_sZoomEndColumnNumber
;
//02 //Zoom End Column Number
// Register24~Register27
public
int
m_unSelfDumpingSpanTime
;
//04 //unit: ms
// Register28~Register31
public
int
m_unContinuousAcquisitionSpanTime
;
//04 //unit: ms
// Register32~Register35
public
int
m_unPreDumpingDelayTime
;
//04 //unit: ms
// Register36~Register39
public
int
m_unPreAcquisitionDelayTime
;
//04 //unit: ms
// Register40~Register43
public
int
m_unPostDumpingDelayTime
;
//04 //unit: ms
// Register44~Register47
public
int
m_unPostAcquisitionDelayTime
;
//04 //unit: ms
// Register48~Register51
public
int
m_unSyncInExposureWindowTime
;
//04 //unit: ms
// Register52~Register55
public
int
m_unSyncOutExposureWindowTime
;
//04 //unit: ms
// Register56~Register59
public
int
m_unTFTOffToIntegrateOffTimeSpan
;
//04 //unit: ms
// Register_60~Register_63
public
int
m_unIntegrateTime
;
//04 //unit: ms
// Register_64~Register_67
public
int
m_unPreFrameDelay
;
//04 //unit: ms
// Register_68~Register_71
public
int
m_unPostFrameDelay
;
//04 //unit: ms
// Register_72~Register_75
public
int
m_unSaturation
;
//04 //unit: ms
// Register_76~Register_79
public
int
m_unClipping
;
//04 //unit: ms
// Register_80~Register_81
public
short
m_sHvgRdyMode
;
//02 //0-"Edge Trigger"; 非0-"[1~255]:Config Delay,unit:n*128 ms"
// Register_82~Register_83
public
short
m_sSaecPreRdyTm
;
//02 //SAEC pre ready time
// Register_84~Register_85
public
short
m_sSaecPostRdyTm
;
//02 //SAEC post ready time
// Register_86
public
char
m_byDefectThreshold
;
//01 //Defect correction:Calculating the threshold of bad points
// Register_87~Register_90
public
int
m_unSleepTime
;
//04 //energy conservation settings: 睡眠(Sleep,unit:minute)
// Register_91~Register_94
public
int
m_unMaxBadPointtNumber
;
//04 //defect template:Support the maximum threshold of bad points
// Register_95~Register_96
public
short
m_sPacketIntervalTm
;
//02 //UDP packet Interval time,unit,um(微秒)
// Register_97~Register_120
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
24
)]
public
char
[]
m_abySysCfgInfoReserved
;
//24
// Register_121~Register_122
public
short
m_sGainb
;
//02 //offset
// Register_123~Register_126
public
int
m_unVoltage
;
//04 //unit: kv
// Register_127
public
char
m_byExTriggerAcqType
;
//01 //Reference EnumIMAGE_ACQ_CMD type
};
// Image Calibration Configuration:20
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
ImgCaliCfg
{
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
public
byte
m_byOffsetCorrection
;
//[FieldOffset(1)]
public
byte
m_byGainCorrection
;
//[FieldOffset(2)]
public
byte
m_byDefectCorrection
;
// Register_8
//[FieldOffset(3)]
public
byte
m_byDummyCorrection
;
// Register_9~Register_10
public
short
m_sDummyStartCol
;
//02 //Dummy Area Start Column
// Register_11~Register_12
public
short
m_sDummyEndCol
;
//02 //Dummy Area End Column
// Register_13~Register_14
public
short
m_sDummyConstant
;
//02 //Dummy Constant
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
6
)]
public
char
[]
m_abyImgCaliCfgReserved
;
};
// Voltage Adjust Configuration:48
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
VolAdjustCfg
{
// Register_1~Register_4
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
// Register_5~Register_8
public
int
m_unVCOM
;
//04 //VCOM
// Register_9~Register_12
public
int
m_unVGG
;
//04 //VGG
// Register_13~Register_16
public
int
m_unVEE
;
//04 //VEE
// Register_17~Register_20
public
int
m_unVbias
;
//04 //Vbias
// Register_21~Register_36
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
int
[]
m_unComp
;
//04 //Comp1 // Register114
// Register_37~Register_48
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
12
)]
public
char
[]
m_abyVolAdjustCfgReserved
;
//12//////Registers 114(include) Are Reserved;
};
// TI COF Parameter Configuration:84
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
TICOFCfg
{
// Register_1~Register_4
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
// Register_5~Register_64
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
30
)]
public
short
[]
m_sTICOFRegister
;
// Register_65~Register_84
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
20
)]
public
char
[]
m_abyTICOFCfgReserved
;
};
//CMOS Parameter Configuration:116
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
CMOSCfg
{
// Register_1~Register_4
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
public
char
[]
m_byHead
;
// Register_5~Register_68
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
32
)]
public
short
[]
m_sCMOSRegister
;
// Register_69~Register_116
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
48
)]
public
char
[]
m_abyCMOSCfgReserved
;
};
// ADI COF Parameter Configuration:390
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
ADICOFCfg
{
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
4
)]
// Register_1~Register_4
public
char
[]
m_byHead
;
// Register_5~Register_19
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
15
)]
public
short
[]
m_sADICOFRegister
;
// Register_20~Register_375 355
[
MarshalAs
(
UnmanagedType
.
ByValArray
,
SizeConst
=
355
)]
public
char
[]
m_abyADICOFCfgReserved
;
};
// 1024 byte regedit
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
,
CharSet
=
CharSet
.
Ansi
)]
public
struct
RegCfgInfo
{
// System base Information:100,Register_1~Register_100
public
SysBaseInfo
m_SysBaseInfo
;
// System Manufacture Information:50,Register_101~Register_150
public
SysManuInfo
m_SysManuInfo
;
// System Status Information:28,Register_151~Register_178
public
SysStatusInfo
m_SysStatusInfo
;
// Gigabit Ethernet Information:40,Register_179~Register_218
public
EtherInfo
m_EtherInfo
;
// High Voltage Generator Interface Trigger Mode Information:21,Register_219~Register_239
public
HiVolTriggerModeInfo
m_HiVolTriggerModeInfo
;
// System Configuration Information:127,Register_240~Register_366
public
SysCfgInfo
m_SysCfgInfo
;
// Image Calibration Configuration:20,Register_367~Register_386
public
ImgCaliCfg
m_ImgCaliCfg
;
// Voltage Adjust Configuration:48,Register_387~Register_434
public
VolAdjustCfg
m_VolAdjustCfg
;
// TI COF Parameter Configuration:84,Register_435~Register_518
public
TICOFCfg
m_TICOFCfg
;
// CMOS Parameter Configuration:116,Register_519~Register_634
public
CMOSCfg
m_CMOSCfg
;
// ADI COF Parameter Configuration:390,Register_635~Register_1024
public
ADICOFCfg
m_ADICOFCfg
;
};
#
endregion
}
\ No newline at end of file
\ No newline at end of file
CarerayImage/HaoboSDK/HbiError.cs
0 → 100644
查看文件 @
f2dde14
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Asa
{
/// <summary>
/// 昊博错误代码
/// </summary>
public
enum
HBIRETCODE
{
HBI_SUCCSS
=
0
,
HBI_ERR_ININT_FAILED
=
8000
,
HBI_ERR_OPEN_DETECTOR_FAILED
=
8001
,
HBI_ERR_INVALID_PARAMS
=
8002
,
HBI_ERR_CONNECT_FAILED
=
8003
,
HBI_ERR_MALLOC_FAILED
=
8004
,
HBI_ERR_RELIMGMEM_FAILED
=
8005
,
HBI_ERR_RETIMGMEM_FAILED
=
8006
,
HBI_ERR_NODEVICE
=
8007
,
HBI_ERR_DISCONNECT
=
8008
,
HBI_ERR_DEVICE_BUSY
=
8009
,
HBI_ERR_SENDDATA_FAILED
=
8010
,
HBI_ERR_RECEIVE_DATA_FAILED
=
8011
,
HBI_ERR_COMMAND_DISMATCH
=
8012
,
HBI_ERR_NO_IMAGE_RAW
=
8013
,
HBI_ERR_PTHREAD_ACTIVE_FAILED
=
8014
,
HBI_ERR_STOP_ACQUISITION
=
8015
,
HBI_ERR_INSERT_FAILED
=
8016
,
HBI_ERR_GET_CFG_FAILED
=
8017
,
HBI_NOT_SUPPORT
=
8018
,
HBI_REGISTER_CALLBACK_FAILED
=
8019
,
HBI_SEND_MESSAGE_FAILD
=
8020
,
HBI_ERR_WORKMODE
=
8021
,
HBI_FAILED
=
8022
,
HBI_FILE_NOT_EXISTS
=
8023
,
HBI_COMM_TYPE_ERR
=
8024
,
HBI_TYPE_IS_NOT_EXISTS
=
8025
,
HBI_SAVE_FILE_FAILED
=
8026
,
HBI_INIT_PARAM_FAILED
=
8027
,
HBI_INIT_FILE_NOT_EXIST
=
8028
,
HBI_INVALID_FLAT_PANEL
=
8029
,
HBI_INVALID_DLL_HANDLE
=
8031
,
HBI_FPD_IS_DISCONNECT
=
8032
,
HBI_ERR_DETECTOR_NUMBER
=
8033
,
HBI_ERR_DATA_CHECK_FAILED
=
8034
,
HBI_ERR_CFG_ISEMPTY
=
8035
,
HBI_ERR_OPEN_WIZARD_FAILED
=
8036
,
HBI_ERR_WIZARD_ALREADY_EXIST
=
8037
,
// already exist
HBI_DIRECTORY_NOT_EXISTS
=
8038
,
HBI_UNREGISTER_CALLBACK
=
8039
,
HBI_ERR_IMAGE_ISEMPTY
=
8040
,
HBI_ERR_ABNORMMAL_IMAGE
=
8041
,
HBI_PREPARATION_COMPLETE
=
8042
,
HBI_ERR_FILE_EXCEPTION
=
8043
,
HBI_ERR_COMM_TYPE
=
8044
,
HBI_END
=
8045
};
public
class
HbiError
{
public
static
Dictionary
<
HBIRETCODE
,
string
>
CrErrStrList
=
new
Dictionary
<
HBIRETCODE
,
string
>
{
{
HBIRETCODE
.
HBI_SUCCSS
,
"Success"
},
{
HBIRETCODE
.
HBI_ERR_ININT_FAILED
,
"Init dll failed"
},
{
HBIRETCODE
.
HBI_ERR_OPEN_DETECTOR_FAILED
,
"Open device driver failed"
},
{
HBIRETCODE
.
HBI_ERR_INVALID_PARAMS
,
"Parameter error"
},
{
HBIRETCODE
.
HBI_ERR_CONNECT_FAILED
,
"Connect failed"
},
{
HBIRETCODE
.
HBI_ERR_MALLOC_FAILED
,
"Malloc memory failed"
},
{
HBIRETCODE
.
HBI_ERR_RELIMGMEM_FAILED
,
"Releaseimagemem fail"
},
{
HBIRETCODE
.
HBI_ERR_RETIMGMEM_FAILED
,
"ReturnImageMem fail"
},
{
HBIRETCODE
.
HBI_ERR_NODEVICE
,
"No Init DLL Instance"
},
{
HBIRETCODE
.
HBI_ERR_DISCONNECT
,
"Is Disconnect"
},
{
HBIRETCODE
.
HBI_ERR_DEVICE_BUSY
,
"Fpd is busy"
},
{
HBIRETCODE
.
HBI_ERR_SENDDATA_FAILED
,
"SendData failed"
},
{
HBIRETCODE
.
HBI_ERR_RECEIVE_DATA_FAILED
,
"Receive Data failed"
},
{
HBIRETCODE
.
HBI_ERR_COMMAND_DISMATCH
,
"Command dismatch"
},
{
HBIRETCODE
.
HBI_ERR_NO_IMAGE_RAW
,
"No Image raw"
},
{
HBIRETCODE
.
HBI_ERR_PTHREAD_ACTIVE_FAILED
,
"Pthread active failed"
},
{
HBIRETCODE
.
HBI_ERR_STOP_ACQUISITION
,
"Pthread stop data acquisition failed"
},
{
HBIRETCODE
.
HBI_ERR_INSERT_FAILED
,
"insert calibrate mode failed"
},
{
HBIRETCODE
.
HBI_ERR_GET_CFG_FAILED
,
"get Fpd config failed"
},
{
HBIRETCODE
.
HBI_NOT_SUPPORT
,
"not surport yet"
},
{
HBIRETCODE
.
HBI_REGISTER_CALLBACK_FAILED
,
"failed to register callback function"
},
{
HBIRETCODE
.
HBI_SEND_MESSAGE_FAILD
,
"send message failed"
},
{
HBIRETCODE
.
HBI_ERR_WORKMODE
,
"switch work mode failed"
},
{
HBIRETCODE
.
HBI_FAILED
,
"operation failed"
},
{
HBIRETCODE
.
HBI_FILE_NOT_EXISTS
,
"file does not exist"
},
{
HBIRETCODE
.
HBI_COMM_TYPE_ERR
,
"communication is not exist"
},
{
HBIRETCODE
.
HBI_TYPE_IS_NOT_EXISTS
,
"this type is not exists"
},
{
HBIRETCODE
.
HBI_SAVE_FILE_FAILED
,
"save file failed"
},
{
HBIRETCODE
.
HBI_INIT_PARAM_FAILED
,
"Init dll param failed"
},
{
HBIRETCODE
.
HBI_INIT_FILE_NOT_EXIST
,
"Init dll config file is not exist"
},
{
HBIRETCODE
.
HBI_INVALID_FLAT_PANEL
,
"Invalid flat panel detector"
},
{
HBIRETCODE
.
HBI_INVALID_DLL_HANDLE
,
"Invalid dll instance handle"
},
{
HBIRETCODE
.
HBI_FPD_IS_DISCONNECT
,
"Fpd is disconnect"
},
{
HBIRETCODE
.
HBI_ERR_DETECTOR_NUMBER
,
"Detector number error"
},
{
HBIRETCODE
.
HBI_ERR_DATA_CHECK_FAILED
,
"Data Check failed"
},
{
HBIRETCODE
.
HBI_ERR_CFG_ISEMPTY
,
"The configuration variable is empty"
},
{
HBIRETCODE
.
HBI_ERR_OPEN_WIZARD_FAILED
,
"Open template wizard failed"
},
{
HBIRETCODE
.
HBI_ERR_WIZARD_ALREADY_EXIST
,
"template wizard already exist"
},
{
HBIRETCODE
.
HBI_DIRECTORY_NOT_EXISTS
,
"File directory is not exists"
},
{
HBIRETCODE
.
HBI_UNREGISTER_CALLBACK
,
"Unregistered callbacke function"
},
{
HBIRETCODE
.
HBI_ERR_IMAGE_ISEMPTY
,
"Image is empty"
},
{
HBIRETCODE
.
HBI_ERR_ABNORMMAL_IMAGE
,
"Abnormal image"
},
{
HBIRETCODE
.
HBI_PREPARATION_COMPLETE
,
"Preparation complete"
},
{
HBIRETCODE
.
HBI_ERR_FILE_EXCEPTION
,
"File exception"
},
{
HBIRETCODE
.
HBI_ERR_COMM_TYPE
,
"Wrong communication type"
},
{
HBIRETCODE
.
HBI_END
,
"Exit monitoring"
}
};
}
}
CarerayImage/XrayImage.cs
查看文件 @
f2dde14
using
Asa.HaoboSDK
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Drawing
;
...
@@ -85,9 +84,12 @@ namespace Asa
...
@@ -85,9 +84,12 @@ namespace Asa
{
{
if
(
deviceType
==
DeviceType
.
CARREY
)
if
(
deviceType
==
DeviceType
.
CARREY
)
device
=
new
CarerayImage
(
logName
);
device
=
new
CarerayImage
(
logName
);
else
if
(
deviceType
==
DeviceType
.
HAOBO
)
device
=
new
haobo_v1
(
logName
);
else
if
(
deviceType
==
DeviceType
.
HAOBO_V2
)
device
=
new
haobo_v2
(
logName
);
else
else
device
=
new
haobo
(
logName
);
device
=
new
haobo_v1
(
logName
);
}
}
/// <summary>
/// <summary>
...
@@ -456,14 +458,37 @@ namespace Asa
...
@@ -456,14 +458,37 @@ namespace Asa
//eyemImageFree(ref tpModeImg);
//eyemImageFree(ref tpModeImg);
return
BmpDstImg
;
return
BmpDstImg
;
}
}
/// <summary>
/// 重新载入点料模版
/// .\CountTemplate
/// </summary>
/// <returns></returns>
public
static
int
ReloadTpl
()
public
static
int
ReloadTpl
()
{
{
eyemReleaseModel
(
ref
hModelIDs
);
int
result
=
-
1
;
return
eyemInitModel
(
"CountTemplate"
,
out
hModelIDs
);
try
{
Debug
.
WriteLine
(
"hModelIDs:"
+
hModelIDs
);
eyemReleaseModel
(
ref
hModelIDs
);
result
=
eyemInitModel
(
"CountTemplate"
,
out
hModelIDs
);
return
result
;
}
catch
(
Exception
e
)
{
Debug
.
WriteLine
(
"hModelIDs:"
+
e
);
return
result
;
}
finally
{
Debug
.
WriteLine
(
"hModelIDs:"
+
hModelIDs
);
Debug
.
WriteLine
(
"Result:"
+
result
);
}
}
}
/// <summary>
/// 终止点料
/// </summary>
/// <returns></returns>
public
static
Action
SkipCounting
()
public
static
Action
SkipCounting
()
{
{
return
()
=>
return
()
=>
...
@@ -518,10 +543,16 @@ namespace Asa
...
@@ -518,10 +543,16 @@ namespace Asa
return
device
.
GenerateTemplate
(
mode
);
return
device
.
GenerateTemplate
(
mode
);
}
}
public
bool
SetExposureTime
(
int
time
)
{
return
device
.
SetExposureTime
(
time
);
}
public
enum
DeviceType
public
enum
DeviceType
{
{
HAOBO
,
HAOBO
,
CARREY
CARREY
,
HAOBO_V2
}
}
}
}
...
...
CarerayImage/XrayImageInterface.cs
查看文件 @
f2dde14
...
@@ -31,5 +31,6 @@ namespace Asa
...
@@ -31,5 +31,6 @@ namespace Asa
int
WindowLevel
{
set
;
get
;
}
int
WindowLevel
{
set
;
get
;
}
Task
<
bool
>
GenerateTemplate
(
int
mode
);
Task
<
bool
>
GenerateTemplate
(
int
mode
);
bool
SetExposureTime
(
int
time
);
}
}
}
}
CarerayImage/haobo.cs
→
CarerayImage/haobo
_v1
.cs
查看文件 @
f2dde14
using
Asa.HaoboSDK
;
using
Asa.HaoboSDK
_v1
;
using
ConfigHelper
;
using
ConfigHelper
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
...
@@ -13,7 +13,7 @@ using static Asa.eyemLib;
...
@@ -13,7 +13,7 @@ using static Asa.eyemLib;
namespace
Asa
namespace
Asa
{
{
class
haobo
:
XrayImageInterface
class
haobo
_v1
:
XrayImageInterface
{
{
private
readonly
log4net
.
ILog
LOG
;
private
readonly
log4net
.
ILog
LOG
;
RegCfgInfo
m_pLastRegCfg
;
RegCfgInfo
m_pLastRegCfg
;
...
@@ -21,8 +21,9 @@ namespace Asa
...
@@ -21,8 +21,9 @@ namespace Asa
static
USER_CALLBACK_HANDLE_ENVENT
_dUserCallbackHandleEnvent
;
static
USER_CALLBACK_HANDLE_ENVENT
_dUserCallbackHandleEnvent
;
IMAGE_CORRECT_ENABLE
m_pCorrect
=
new
IMAGE_CORRECT_ENABLE
();
IMAGE_CORRECT_ENABLE
m_pCorrect
=
new
IMAGE_CORRECT_ENABLE
();
byte
[]
buffer
;
byte
[]
buffer
;
public
haobo
(
string
logName
=
"CarerayImage"
)
{
public
haobo
_v1
(
string
logName
=
"CarerayImage"
)
{
LOG
=
log4net
.
LogManager
.
GetLogger
(
logName
);
LOG
=
log4net
.
LogManager
.
GetLogger
(
logName
);
LOG
.
Info
(
"Load haobo_v1"
);
//1 初始化DLL
//1 初始化DLL
HBI_FPD_DLL
.
_handel
=
HBI_FPD_DLL
.
HBI_Init
();
HBI_FPD_DLL
.
_handel
=
HBI_FPD_DLL
.
HBI_Init
();
_dUserCallbackHandleEnvent
=
DataCallBack
;
_dUserCallbackHandleEnvent
=
DataCallBack
;
...
@@ -154,7 +155,7 @@ namespace Asa
...
@@ -154,7 +155,7 @@ namespace Asa
return
bmp
;
return
bmp
;
}
}
CancellationTokenSource
WaitstopToken
=
new
CancellationTokenSource
();
CancellationTokenSource
WaitstopToken
=
new
CancellationTokenSource
();
bool
buffgetted
=
false
;
volatile
bool
buffgetted
=
false
;
int
getpiccount
=
0
;
int
getpiccount
=
0
;
public
bool
GetImage
(
int
_MaxFrameCount
=
3
,
int
MaxDelay
=
5000
)
public
bool
GetImage
(
int
_MaxFrameCount
=
3
,
int
MaxDelay
=
5000
)
{
{
...
@@ -174,7 +175,7 @@ namespace Asa
...
@@ -174,7 +175,7 @@ namespace Asa
// return false;
// return false;
//}
//}
WriteLog
(
"GetImage start========================"
);
WriteLog
(
"GetImage start========================"
);
getpiccount
=
0
;
getpiccount
=
_MaxFrameCount
;
buffgetted
=
false
;
buffgetted
=
false
;
//int ret = HBI_FPD_DLL.HBI_Prepare(HBI_FPD_DLL._handel); //5
//int ret = HBI_FPD_DLL.HBI_Prepare(HBI_FPD_DLL._handel); //5
//if (ret != 0) WriteLog("HBI_Prepare" + ret.ToString());
//if (ret != 0) WriteLog("HBI_Prepare" + ret.ToString());
...
@@ -245,21 +246,24 @@ namespace Asa
...
@@ -245,21 +246,24 @@ namespace Asa
catch
{
}
catch
{
}
}
}
// 设置软触发清空时间
private
void
SetPrepareTime
()
/// <summary>
/// 设置曝光时间
/// </summary>
/// <param name="time"></param>
public
bool
SetExposureTime
(
int
time
)
{
{
WriteLog
(
string
.
Format
(
"Set
Prepare time.:[{0}]\n"
,
nPrepareTm
));
WriteLog
(
string
.
Format
(
"Set
LiveAcquisition time.:[{0}]\n"
,
time
));
int
_ret
=
HBI_FPD_DLL
.
HBI_Set
PreAcqTm
(
HBI_FPD_DLL
.
_handel
,
nPrepareTm
);
int
_ret
=
HBI_FPD_DLL
.
HBI_Set
LiveAcquisitionTime
(
HBI_FPD_DLL
.
_handel
,
time
);
if
(
0
!=
_ret
)
if
(
0
!=
_ret
)
{
{
LOG
.
Error
(
"HBI_Set
PreAcqTm
failed!"
);
LOG
.
Error
(
"HBI_Set
LiveAcquisitionTime
failed!"
);
return
;
return
false
;
}
}
else
else
{
{
WriteLog
(
"HBI_SetPreAcqTm success!\n"
);
WriteLog
(
"HBI_SetLiveAcquisitionTime success!\n"
);
if
(
nPrepareTm
==
3000
)
nPrepareTm
=
0
;
return
true
;
else
nPrepareTm
=
3000
;
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
...
@@ -345,8 +349,8 @@ namespace Asa
...
@@ -345,8 +349,8 @@ namespace Asa
//----------------图像-------------------
//----------------图像-------------------
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_SINGLE_IMAGE
):
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_SINGLE_IMAGE
):
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_MULTIPLE_IMAGE
):
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_MULTIPLE_IMAGE
):
getpiccount
++
;
getpiccount
--
;
if
(
getpiccount
==
1
)
if
(
getpiccount
>
0
)
return
1
;
return
1
;
#if savebmp8
#if savebmp8
...
...
CarerayImage/haobo_v2.cs
0 → 100644
查看文件 @
f2dde14
using
Asa.HaoboSDK_v2
;
using
ConfigHelper
;
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
static
Asa
.
eyemLib
;
namespace
Asa
{
public
class
haobo_v2
:
XrayImageInterface
{
private
readonly
log4net
.
ILog
LOG
;
COMM_CFG
commCfg
;
IMAGE_CORRECT_ENABLE
m_pCorrect
=
new
IMAGE_CORRECT_ENABLE
();
RegCfgInfo
m_pLastRegCfg
;
// 记录固件所有配置数据 1024字节的结构体
public
static
USER_CALLBACK_HANDLE_ENVENT
_dUserCallbackHandleEnvent
;
ImageData
imagedata
;
//ImageBuff imgbuff = new ImageBuff();// 共用体 // ushort[] imagetemp;
byte
[]
buffer
;
public
haobo_v2
(
string
logName
=
"CarerayImage"
)
{
LOG
=
log4net
.
LogManager
.
GetLogger
(
logName
);
LOG
.
Info
(
"Load haobo_v2"
);
//1 初始化DLL
HBI_FPD_DLL
.
_handel
=
HBI_FPD_DLL
.
HBI_Init
();
_dUserCallbackHandleEnvent
=
hbiMainCallBackFun
;
//2 注册回调函数
int
_ret
=
HBI_FPD_DLL
.
HBI_RegEventCallBackFun
(
HBI_FPD_DLL
.
_handel
,
_dUserCallbackHandleEnvent
,
IntPtr
.
Zero
);
if
(
_ret
!=
0
)
WriteLog
(
"HBI_RegEventCallBackFun:"
+
GetHbiError
(
_ret
));
}
public
bool
Open
()
{
var
HB_Remote_IP
=
Config
.
Get
(
"HB_Remote_IP"
);
var
HB_Remote_PORT
=
Config
.
Get
<
ushort
>(
"HB_Remote_PORT"
);
var
HB_Local_IP
=
Config
.
Get
(
"HB_Local_IP"
);
var
HB_Local_PORT
=
Config
.
Get
<
ushort
>(
"HB_Local_PORT"
);
commCfg
.
_type
=
FPD_COMM_TYPE
.
UDP_JUMBO_COMM_TYPE
;
//commCfg._type = FPD_COMM_TYPE.UDP_COMM_TYPE;
// IP地址
commCfg
.
_localip
=
new
byte
[
16
];
byte
[]
buf
=
Encoding
.
UTF8
.
GetBytes
(
HB_Local_IP
);
Buffer
.
BlockCopy
(
buf
,
0
,
commCfg
.
_localip
,
0
,
buf
.
Length
);
//
commCfg
.
_remoteip
=
new
byte
[
16
];
buf
=
Encoding
.
UTF8
.
GetBytes
(
HB_Remote_IP
);
Buffer
.
BlockCopy
(
buf
,
0
,
commCfg
.
_remoteip
,
0
,
buf
.
Length
);
// port
commCfg
.
_loacalPort
=
HB_Local_PORT
;
commCfg
.
_remotePort
=
HB_Remote_PORT
;
var
offsettemplate
=
1
;
var
_ret
=
HBI_FPD_DLL
.
HBI_ConnectDetector
(
HBI_FPD_DLL
.
_handel
,
commCfg
,
offsettemplate
);
if
(
_ret
!=
0
)
{
LOG
.
Error
(
"HBI_ConnectDetector:"
+
GetHbiError
(
_ret
));
}
else
{
GetFirmwareCfg
();
btnSetCorrectEnable
(
true
);
/*
0-Invalid Trigger Mode;无效触发模式
1-Software Trigger Mode;静态软触发模式
2-Static:Clear Mode;暂不支持
3-Static:Hvg Trigger Mode;静态高压触发模式
4-Static:AED Trigger Mode;静态 AED 触发模式
5-Dynamic:Hvg Sync Mode;动态高压同步模式
6-Dynamic:Fpd Sync Mode;动态平板同步模式
7-Dynamic:Continue Mode;动态 Conitnue 模
*/
_ret
=
HBI_FPD_DLL
.
HBI_UpdateTriggerMode
(
HBI_FPD_DLL
.
_handel
,
7
);
if
(
_ret
!=
0
)
WriteLog
(
"HBI_UpdateTriggerMode:"
+
GetHbiError
(
_ret
));
else
WriteLog
(
"success HBI_UpdateTriggerMode:"
+
GetHbiError
(
_ret
));
_ret
=
HBI_FPD_DLL
.
HBI_SetSinglePrepareTime
(
HBI_FPD_DLL
.
_handel
,
1000
);
if
(
0
!=
_ret
)
{
WriteLog
(
"HBI_SetSinglePrepareTime failed!:"
+
GetHbiError
(
_ret
));
return
false
;
}
}
return
_ret
==
0
;
}
string
GetHbiError
(
int
errcode
)
{
try
{
HBIRETCODE
hBIRETCODE
=
(
HBIRETCODE
)
errcode
;
HbiError
.
CrErrStrList
.
TryGetValue
(
hBIRETCODE
,
out
string
errmsg
);
return
hBIRETCODE
+
","
+
errmsg
;
}
catch
(
Exception
e
)
{
return
errcode
+
","
+
e
;
}
}
public
bool
Close
()
{
int
ret
=
HBI_FPD_DLL
.
HBI_DisConnectDetector
(
HBI_FPD_DLL
.
_handel
);
if
(
ret
!=
0
)
{
LOG
.
Error
(
"HBI_DisConnectDetector:"
+
GetHbiError
(
ret
));
}
return
ret
==
0
;
}
/// <summary>
/// 图像宽度
/// </summary>
public
int
ImageWidth
{
private
set
;
get
;
}
=
3072
;
/// <summary>
/// 图像高度
/// </summary>
public
int
ImageHeight
{
private
set
;
get
;
}
=
3072
;
/// <summary>
/// 窗宽
/// </summary>
public
int
WindowWidth
{
set
;
get
;
}
=
65535
;
/// <summary>
/// 窗位
/// </summary>
public
int
WindowLevel
{
set
;
get
;
}
=
32768
;
public
Bitmap
Get48bImage
()
{
if
(
buffer
==
null
)
return
null
;
if
(
ImageWidth
<=
0
||
ImageHeight
<=
0
)
{
LOG
.
Info
(
"宽高不正确,ImageWidth="
+
ImageWidth
+
", ImageHeight="
+
ImageHeight
);
return
null
;
}
int
count
=
ImageWidth
*
ImageHeight
;
byte
[]
gray
=
new
byte
[
count
*
2
];
Array
.
Copy
(
buffer
,
0
,
gray
,
0
,
gray
.
Length
);
int
idx1
=
0
;
int
idx2
=
0
;
int
half
=
WindowWidth
/
2
;
byte
[]
buff
=
new
byte
[
gray
.
Length
*
3
];
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
short
point
=
BitConverter
.
ToInt16
(
gray
,
idx1
);
//point += 20000;
if
(
point
<
WindowLevel
-
half
)
{
buff
[
idx2
++]
=
0
;
buff
[
idx2
++]
=
0
;
buff
[
idx2
++]
=
0
;
buff
[
idx2
++]
=
0
;
buff
[
idx2
++]
=
0
;
buff
[
idx2
++]
=
0
;
}
else
if
(
point
>
WindowLevel
+
half
)
{
buff
[
idx2
++]
=
255
;
buff
[
idx2
++]
=
255
;
buff
[
idx2
++]
=
255
;
buff
[
idx2
++]
=
255
;
buff
[
idx2
++]
=
255
;
buff
[
idx2
++]
=
255
;
}
else
{
byte
[]
bb
=
BitConverter
.
GetBytes
(
point
);
buff
[
idx2
++]
=
bb
[
0
];
buff
[
idx2
++]
=
bb
[
1
];
buff
[
idx2
++]
=
bb
[
0
];
buff
[
idx2
++]
=
bb
[
1
];
buff
[
idx2
++]
=
bb
[
0
];
buff
[
idx2
++]
=
bb
[
1
];
}
idx1
+=
2
;
}
/*
//var bufferGCHandle = GCHandle.Alloc(buffer);
IntPtr intPtr = Marshal.UnsafeAddrOfPinnedArrayElement<byte>(buff, 0);
Bitmap bmp = new Bitmap(ImageWidth, ImageHeight, ImageWidth * 6, System.Drawing.Imaging.PixelFormat.Format48bppRgb, intPtr);
//bufferGCHandle.Free();
*/
Bitmap
bmp
=
new
Bitmap
(
ImageWidth
,
ImageHeight
,
System
.
Drawing
.
Imaging
.
PixelFormat
.
Format48bppRgb
);
System
.
Drawing
.
Imaging
.
BitmapData
bmpData
=
bmp
.
LockBits
(
new
Rectangle
(
0
,
0
,
ImageWidth
,
ImageHeight
),
System
.
Drawing
.
Imaging
.
ImageLockMode
.
ReadWrite
,
bmp
.
PixelFormat
);
Marshal
.
Copy
(
buff
,
0
,
bmpData
.
Scan0
,
bmpData
.
Stride
*
ImageHeight
);
bmp
.
UnlockBits
(
bmpData
);
return
bmp
;
}
CancellationTokenSource
WaitstopToken
=
new
CancellationTokenSource
();
volatile
bool
buffgetted
=
false
;
int
getpiccount
=
0
;
public
bool
GetImage
(
int
_MaxFrameCount
=
3
,
int
MaxDelay
=
5000
)
{
WaitstopToken
=
new
CancellationTokenSource
();
buffer
=
null
;
//FPD_AQC_MODE stMode = new FPD_AQC_MODE();
//stMode.aqc_mode = EnumIMAGE_ACQ_MODE.STATIC_ACQ_DEFAULT_MODE;
//stMode.ndiscard = 0;
//stMode.nframeid = stMode.nframesum = stMode.ngroupno = 0;
//int ret = HBI_FPD_DLL.HBI_SingleAcquisition(HBI_FPD_DLL._handel, stMode); //6
//if (ret != 0) WriteLog("HBI_SingleAcquisition" + ret.ToString());
//else WriteLog("0x03 SingleAcquisition成功");
//if (m_pLastRegCfg.m_SysCfgInfo.m_byWorkMode != 0x01)
//{
// LOG.Error("需要将触发模式改成software mode才能上图");
// return false;
//}
WriteLog
(
"GetImage start========================"
);
getpiccount
=
_MaxFrameCount
;
buffgetted
=
false
;
int
ret
=
HBI_FPD_DLL
.
HBI_SinglePrepare
(
HBI_FPD_DLL
.
_handel
);
//5
if
(
ret
!=
0
)
WriteLog
(
"HBI_SinglePrepare:"
+
GetHbiError
(
ret
));
else
WriteLog
(
"0x02 prepare成功"
);
Task
a
=
Task
.
Delay
(
MaxDelay
);
Task
b
=
Task
.
Run
(()=>
{
while
(
true
)
{
Thread
.
Sleep
(
100
);
if
(
buffgetted
)
break
;
}
});
Task
.
WaitAny
(
a
,
b
);
Thread
.
Sleep
(
500
);
/*
if (buffer != null)
{
using (FileStream fileStream = File.OpenWrite("logs\\raw.raw"))
{
fileStream.Write(buffer, 0, buffer.Length);
fileStream.Close();
fileStream.Dispose();
}
}*/
return
buffer
!=
null
;
}
IntPtr
BufferPtr
;
public
EyemImage
GetRawBufferHandle
()
{
EyemImage
eyemImage
=
new
EyemImage
();
if
(
buffer
==
null
)
throw
new
Exception
(
"图像buffer为空"
);
if
(
ImageWidth
<=
0
||
ImageHeight
<=
0
)
{
LOG
.
Info
(
"宽高不正确,ImageWidth="
+
ImageWidth
+
", ImageHeight="
+
ImageHeight
);
throw
new
Exception
(
"图像宽高不正确"
);
}
BufferPtr
=
Marshal
.
AllocHGlobal
(
buffer
.
Length
);
Marshal
.
Copy
(
buffer
,
0
,
BufferPtr
,
buffer
.
Length
);
eyemImage
.
ucpImage
=
BufferPtr
;
eyemImage
.
iWidth
=
ImageWidth
;
eyemImage
.
iHeight
=
ImageHeight
;
eyemImage
.
iChannels
=
1
;
eyemImage
.
iDepth
=
2
;
return
eyemImage
;
}
public
void
FreeRawBufferHandle
()
{
try
{
Marshal
.
FreeHGlobal
(
BufferPtr
);
}
catch
{
}
}
/// <summary>
/// 设置曝光时间
/// </summary>
/// <param name="time"></param>
public
bool
SetExposureTime
(
int
time
)
{
WriteLog
(
string
.
Format
(
"Set Prepare time.:[{0}]\n"
,
time
));
int
_ret
=
HBI_FPD_DLL
.
HBI_SetSinglePrepareTime
(
HBI_FPD_DLL
.
_handel
,
time
);
if
(
0
!=
_ret
)
{
WriteLog
(
"HBI_SetSinglePrepareTime failed!:"
+
GetHbiError
(
_ret
));
return
false
;
}
else
{
WriteLog
(
"HBI_SetSinglePrepareTime success!\n"
);
return
true
;
}
WriteLog
(
string
.
Format
(
"Set LiveAcquisition time.:[{0}]\n"
,
time
));
_ret
=
HBI_FPD_DLL
.
HBI_SetLiveAcquisitionTime
(
HBI_FPD_DLL
.
_handel
,
time
);
if
(
0
!=
_ret
)
{
LOG
.
Error
(
"HBI_SetLiveAcquisitionTime failed!"
);
return
false
;
}
else
{
WriteLog
(
"HBI_SetLiveAcquisitionTime success!\n"
);
return
true
;
}
}
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// 回调函数 //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
private
int
hbiMainCallBackFun
(
IntPtr
pContext
,
int
ufpdId
,
byte
eventId
,
IntPtr
ptrParam1
,
int
nParam2
,
int
nParam3
,
int
nParam4
)
{
int
status
=
0
;
switch
(
eventId
)
{
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_FPD_STATUS
):
WriteLog
(
string
.
Format
(
"ECALLBACK_TYPE_FPD_STATUS,fpdid={0},recode={1}\n"
,
ufpdId
,
nParam2
));
if
(
nParam2
<=
0
&&
nParam2
>=
-
11
)
{
if
(
nParam2
==
0
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,Err:网络未连接!\n"
);
else
if
(
nParam2
==
-
1
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,Err:参数异常!\n"
);
else
if
(
nParam2
==
-
2
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,Err:准备就绪的描述符数返回失败!\n"
);
else
if
(
nParam2
==
-
3
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,Err:接收超时!\n"
);
else
if
(
nParam2
==
-
4
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,Err:接收失败!\n"
);
else
if
(
nParam2
==
-
5
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,Err:端口不可读!\n"
);
else
if
(
nParam2
==
-
6
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,network card unusual!\n"
);
else
if
(
nParam2
==
-
7
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,network card ok!\n"
);
else
if
(
nParam2
==
-
8
)
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG:update Firmware end!\n"
);
else
if
(
nParam2
==
-
9
)
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:光纤已断开!\n"
);
else
if
(
nParam2
==
-
10
)
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:read ddr failed,try restarting the PCIe driver!\n"
);
else
/*if (nParam2 == -11)*/
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:is not jumb!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_DISCONN_STATUS
;
}
else
if
(
nParam2
==
100
)
{
// connect
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,开始监听!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_CONN_SUCCESS
;
}
else
if
(
nParam2
==
1
)
{
// connect
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,prepare!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_PREPARE_STATUS
;
}
else
if
(
nParam2
==
2
)
{
// ready
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,ready!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_READY_STATUS
;
}
else
if
(
nParam2
==
3
)
{
// busy
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Firmware generates offset template!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_DOOFFSET_TEMPLATE
;
}
else
if
(
nParam2
==
4
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_NET_ERR_MSG,busy!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_EXPOSE_STATUS
;
}
else
if
(
nParam2
==
5
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Continue ready!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_CONTINUE_READY
;
}
else
if
(
nParam2
==
6
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Download gain template ack!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_DWONLOAD_GAIN
;
}
else
if
(
nParam2
==
7
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Download defect template ack!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_DWONLOAD_DEFECT
;
}
else
if
(
nParam2
==
8
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Download offset template ack!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_DWONLOAD_OFFSET
;
}
else
if
(
nParam2
==
9
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Update firmware!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_UPDATE_FIRMARE
;
}
else
if
(
nParam2
==
10
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Retransmission!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_RETRANS_MISS
;
}
// wireless fpd
else
if
(
nParam2
==
12
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Sleep State!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_STATUS_SLEEP
;
}
else
if
(
nParam2
==
13
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:The Last Image!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_DOWNLOAD_TAIL_IMAGE
;
}
else
if
(
nParam2
==
14
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Download offset template ack!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_STATUS_SLEEP
;
}
else
if
(
nParam2
==
16
)
{
// Last Image
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Maximum number of stored images!"
);
status
=
(
int
)
EFpdStatusType
.
FPD_EMMC_MAX_NUMBER
;
}
else
if
(
nParam2
==
17
)
{
// prepare
WriteLog
(
"ECALLBACK_TYPE_FPD_STATUS:Download offset template ack!\n"
);
status
=
(
int
)
EFpdStatusType
.
FPD_ENDTIME_WARNNING
;
}
else
WriteLog
(
string
.
Format
(
"ECALLBACK_TYPE_NET_ERR_MSG,Err:other error={0}\n"
,
nParam2
));
// 异常并断开连接
if
(
status
!=
-
1
)
{
// 更新状态信息
if
(
nParam2
<=
0
&&
nParam2
>=
-
10
)
{
//触发断开消息
HBI_FPD_DLL
.
HBI_DisConnectDetector
(
HBI_FPD_DLL
.
_handel
);
// 更新平板断开信息
//btnDisconnect_Click(null, null);
}
}
break
;
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_ROM_UPLOAD
):
WriteLog
(
string
.
Format
(
"ECALLBACK_TYPE_ROM_UPLOAD\n"
));
if
(
ptrParam1
!=
null
)
{
////int size1 = Marshal.SizeOf(typeof(SysBaseInfo)); //100
////int size2 = Marshal.SizeOf(typeof(SysManuInfo)); //50
////int size3 = Marshal.SizeOf(typeof(SysStatusInfo)); //28
////int size4 = Marshal.SizeOf(typeof(EtherInfo)); //40
////int size5 = Marshal.SizeOf(typeof(HiVolTriggerModeInfo));//21
////int size6 = Marshal.SizeOf(typeof(SysCfgInfo)); //128
////int size7 = Marshal.SizeOf(typeof(ImgCaliCfg)); //20
////int size8 = Marshal.SizeOf(typeof(VolAdjustCfg)); //48
////int size9 = Marshal.SizeOf(typeof(TICOFCfg)); //84
////int size10 = Marshal.SizeOf(typeof(CMOSCfg)); //116
////int size11 = Marshal.SizeOf(typeof(ADICOFCfg)); //389
////int size = Marshal.SizeOf(typeof(RegCfgInfo)); //1024
// 当前反馈固件参数,转化为结构体
m_pLastRegCfg
=
(
RegCfgInfo
)
Marshal
.
PtrToStructure
(
ptrParam1
,
typeof
(
RegCfgInfo
));
// 平板类型
var
nFpdSize
=
(
byte
)
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
;
// 平板分辨率
var
nImageWidth
=
m_pLastRegCfg
.
m_SysBaseInfo
.
m_sImageWidth
;
var
nImageHeight
=
m_pLastRegCfg
.
m_SysBaseInfo
.
m_sImageHeight
;
WriteLog
(
string
.
Format
(
"\tnFpdSize={0},Image width={0},hight={1}\n"
,
nFpdSize
,
nImageWidth
,
nImageHeight
));
// 打印参数,同步参数比较慢 ???
//#if 1
// PrintFirmwrae(); // 打印结构体信息
//#endif
}
break
;
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_SET_CFG_OK
):
WriteLog
(
"ECALLBACK_TYPE_SET_CFG_OK!\n"
);
break
;
//----------------图像-------------------
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_SINGLE_IMAGE
):
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_MULTIPLE_IMAGE
):
WriteLog
(
"success,ECALLBACK_TYPE_MULTIPLE_IMAGE or ECALLBACK_TYPE_SINGLE_IMAGE!\n"
);
if
(
ptrParam1
==
null
)
{
WriteLog
(
"err:ptrParam1 is null!\n"
);
return
1
;
}
// 当前反馈固件参数,转化为结构体 add by mhyang 20220402
imagedata
=
(
ImageData
)
Marshal
.
PtrToStructure
(
ptrParam1
,
typeof
(
ImageData
));
#if !savebmp8 // 正常按照16bit图像显示,add by mhyang 20220615
SaveImage
();
// 保存
buffgetted
=
true
;
WaitstopToken
.
Cancel
(
false
);
#else // 按照8bit图像显示,add by mhyang 20221104
//int length = imagedata.datalen;
if
(
0
==
HBI_FPD_DLL
.
HBI_AutoWindowWidthWindowLevel
(
HBI_FPD_DLL
.
_handel
,
imagedata
.
databuff
,
ref
imagedata
.
datalen
,
imagedata
.
uwidth
,
imagedata
.
uheight
))
{
if
(
bSaveImage
)
{
if
(
imagedata
.
ndatabits
!=
emHBI_DATA_TYPE
.
EHBI_8UC1
)
imagedata
.
ndatabits
=
emHBI_DATA_TYPE
.
EHBI_8UC1
;
if
(
nImageWidth
!=
imagedata
.
uwidth
)
nImageWidth
=
imagedata
.
uwidth
;
if
(
nImageHeight
!=
imagedata
.
uheight
)
nImageHeight
=
imagedata
.
uheight
;
if
(
nframeId
!=
imagedata
.
uframeid
)
nframeId
=
imagedata
.
uframeid
;
//
WriteLog
(
"success,ECALLBACK_TYPE_MULTIPLE_IMAGE or ECALLBACK_TYPE_SINGLE_IMAGE!\n"
);
if
(!
Directory
.
Exists
(
Directory
.
GetCurrentDirectory
()
+
"\\raw_dir"
))
Directory
.
CreateDirectory
(
Directory
.
GetCurrentDirectory
()
+
"\\raw_dir"
);
string
fileName
=
Directory
.
GetCurrentDirectory
()
+
"\\raw_dir\\"
+
/*DateTime.Now.ToString("yyyyMMddHHmmss")*/
nframeId
.
ToString
()
+
"_8bit.bmp"
;
int
ww
=
m_pLastRegCfg
.
m_SysBaseInfo
.
m_sImageWidth
;
int
hh
=
m_pLastRegCfg
.
m_SysBaseInfo
.
m_sImageHeight
;
SaveBmp8
(
ww
,
hh
,
imagedata
.
databuff
,
fileName
);
// 保存
}
else
{
Show8bitImage
();
// 显示
}
}
#endif
break
;
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_GENERATE_TEMPLATE
):
{
if
(
nParam2
==
0
)
{
WriteLog
(
"success,ECALLBACK_TYPE_MULTIPLE_IMAGE or ECALLBACK_TYPE_SINGLE_IMAGE!\n"
);
}
else
if
(
nParam2
==
1
)
{
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_INVALVE_PARAM,fpdid={0},recode={1}\n"
,
ufpdId
,
nParam3
));
}
else
if
(
nParam2
==
2
)
{
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_MALLOC_FAILED,fpdid={0},recode={1}\n"
,
ufpdId
,
nParam3
));
}
else
if
(
nParam2
==
3
)
{
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_SEND_FAILED,fpdid={0},recode={1}\n"
,
ufpdId
,
nParam3
));
}
else
if
(
nParam2
==
4
)
{
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_STATUS_ABORMAL,fpdid={0},recode={1}\n"
,
ufpdId
,
nParam3
));
}
else
if
(
nParam2
==
5
)
{
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_FRAME_NUM,fpdid={0},recode={1}\n"
,
ufpdId
,
nParam3
));
}
else
if
(
nParam2
==
6
)
{
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_TIMEOUT,fpdid={0},recode={1}\n"
,
ufpdId
,
nParam3
));
}
else
if
(
nParam2
==
7
)
{
var
m_rawinfo
=
(
ECALLBACK_RAW_INFO
)
Marshal
.
PtrToStructure
(
ptrParam1
,
typeof
(
ECALLBACK_RAW_INFO
));
WriteLog
(
"ECALLBACK_TEMPLATE_MEAN:dMean="
+
m_rawinfo
.
dMean
.
ToString
());
WriteLog
(
"ECALLBACK_TEMPLATE_MEAN:dMean="
+
new
string
(
m_rawinfo
.
szRawName
));
}
else
if
(
nParam2
==
8
)
{
if
(
nParam3
==
(
byte
)(
emUPLOAD_FILE_TYPE
.
OFFSET_TMP
))
WriteLog
(
"ECALLBACK_TEMPLATE_GENERATE:OFFSET_TMP!\n"
);
else
if
(
nParam3
==
(
byte
)(
emUPLOAD_FILE_TYPE
.
GAIN_TMP
))
WriteLog
(
"ECALLBACK_TEMPLATE_GENERATE:GAIN_TMP\n"
);
else
if
(
nParam3
==
(
byte
)(
emUPLOAD_FILE_TYPE
.
DEFECT_TMP
))
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_GENERATE:DEFECT_TMP,bad point={0}\n"
,
nParam4
));
else
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_GENERATE,fpdid={0},recode={1}\n"
,
ufpdId
,
nParam3
));
}
else
if
(
nParam2
==
9
)
{
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_RESULT={0}\n"
,
nParam3
));
inState
=
nParam3
;
}
else
{
// other
WriteLog
(
string
.
Format
(
"ECALLBACK_TEMPLATE_GENERATE,other:fpdid={0},recode={1}\n"
,
ufpdId
,
nParam3
));
}
break
;
}
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_OVERLAY_16BIT_IMAGE
):
break
;
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_OVERLAY_32BIT_IMAGE
):
break
;
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_FILE_NOTEXIST
):
break
;
#
region
case
(
byte
)(
eCallbackEventCommType
.
ECALLBACK_TYPE_THREAD_EVENT
):
if
(
nParam2
==
100
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,start recv data!\n"
);
else
if
(
nParam2
==
101
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,end recv data!\n"
);
else
if
(
nParam2
==
104
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,Packet Retransmission:start recv data!\n"
);
else
if
(
nParam2
==
105
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,Frame Retransmission:start recv data!\n"
);
else
if
(
nParam2
==
106
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,Frame loss retransmission over,end recv data!\n"
);
else
if
(
nParam2
==
107
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,image buff is null:end recv data!\n"
);
else
if
(
nParam2
==
108
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,Generate Offset Template:start thread!\n"
);
else
if
(
nParam2
==
109
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,Generate Offset Template:end thread!\n"
);
else
if
(
nParam2
==
110
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,Generate Gain Template:start thread!\n"
);
else
if
(
nParam2
==
111
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,Generate Gain Template:end thread!\n"
);
else
if
(
nParam2
==
112
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,offset calibrate:success!\n"
);
else
if
(
nParam2
==
113
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,offset calibrate:failed!\n"
);
else
if
(
nParam2
==
114
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,gain calibrate:success!\n"
);
else
if
(
nParam2
==
115
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,gain calibrate:failed!\n"
);
else
if
(
nParam2
==
116
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,defect calibrate:success!\n"
);
else
if
(
nParam2
==
117
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,defect calibrate:failed!\n"
);
else
if
(
nParam2
==
118
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,InitGainTemplate:failed!\n"
);
else
if
(
nParam2
==
119
)
WriteLog
(
"ECALLBACK_TYPE_THREAD_EVENT,firmare offset calibrate:success!\n"
);
else
WriteLog
(
string
.
Format
(
"ECALLBACK_TYPE_THREAD_EVENT,Err:未知错误[{0}]\n"
,
nParam2
));
break
;
#
endregion
default
:
// WriteLog(string.Format("ECALLBACK_TYPE_THREAD_EVENT,ECALLBACK_TYPE_INVALVE,command=[{0}]\n", cmd));
break
;
}
return
1
;
}
private
void
GetFirmwareCfg
()
{
var
m_pLastRegCfg
=
new
RegCfgInfo
();
//RegCfgInfo 1024
var
_ret
=
Marshal
.
SizeOf
(
m_pLastRegCfg
);
_ret
=
HBI_FPD_DLL
.
HBI_GetFpdCfgInfo
(
HBI_FPD_DLL
.
_handel
,
ref
m_pLastRegCfg
);
//获取固件参数,连接后即可获取参数
if
(
_ret
!=
0
)
{
WriteLog
(
"Error,HBI_GetFpdCfgInfo:"
+
GetHbiError
(
_ret
));
return
;
}
// WriteLog("HBI_GetDevCfgInfo:\n", img_pro.nwidth, img_pro.nheight);
// 测试,置零,检查结果
ushort
usValue
=
(
ushort
)(((
m_pLastRegCfg
.
m_EtherInfo
.
m_sDestUDPPort
&
0xff
)
<<
8
)
|
((
m_pLastRegCfg
.
m_EtherInfo
.
m_sDestUDPPort
>>
8
)
&
0xff
));
// 高低位需要转换
WriteLog
(
string
.
Format
(
"\tSourceIP:{0}.{1}.{2}.{3}:{4}\n"
,
(
int
)(
m_pLastRegCfg
.
m_EtherInfo
.
m_byDestIP
[
0
]),
(
int
)(
m_pLastRegCfg
.
m_EtherInfo
.
m_byDestIP
[
1
]),
(
int
)(
m_pLastRegCfg
.
m_EtherInfo
.
m_byDestIP
[
2
]),
(
int
)(
m_pLastRegCfg
.
m_EtherInfo
.
m_byDestIP
[
3
]),
(
ushort
)(
usValue
)));
usValue
=
(
ushort
)(((
m_pLastRegCfg
.
m_EtherInfo
.
m_sSourceUDPPort
&
0xff
)
<<
8
)
|
((
m_pLastRegCfg
.
m_EtherInfo
.
m_sSourceUDPPort
>>
8
)
&
0xff
));
WriteLog
(
string
.
Format
(
"\tDestIP:{0}.{1}.{2}.{3}:{4}\n"
,
(
int
)(
m_pLastRegCfg
.
m_EtherInfo
.
m_bySourceIP
[
0
]),
(
int
)(
m_pLastRegCfg
.
m_EtherInfo
.
m_bySourceIP
[
1
]),
(
int
)(
m_pLastRegCfg
.
m_EtherInfo
.
m_bySourceIP
[
2
]),
(
int
)(
m_pLastRegCfg
.
m_EtherInfo
.
m_bySourceIP
[
3
]),
(
ushort
)(
usValue
)));
if
(
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
>=
0x01
&&
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
<=
0x08
)
{
if
(
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
==
0x01
)
WriteLog
(
string
.
Format
(
"\tPanelSize:0x{0:X000},fpd type:4343\n"
,
(
int
)
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
));
else
if
(
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
==
0x02
)
WriteLog
(
string
.
Format
(
"\tPanelSize:0x{0:X000},fpd type:3543\n"
,
(
int
)
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
));
else
if
(
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
==
0x03
)
WriteLog
(
string
.
Format
(
"\tPanelSize:0x{0:X000},fpd type:1613\n"
,
(
int
)
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
));
else
if
(
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
==
0x04
)
WriteLog
(
string
.
Format
(
"\tPanelSize:0x{0:X000},fpd type:3030\n"
,
(
int
)
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
));
else
if
(
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
==
0x05
)
WriteLog
(
string
.
Format
(
"\tPanelSize:0x{0:X000},fpd type:2530\n"
,
(
int
)
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
));
else
WriteLog
(
string
.
Format
(
"\tPanelSize:0x{0:X000},fpd type:3025\n"
,
(
int
)
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
));
}
else
{
WriteLog
(
string
.
Format
(
"\tErr:fpd property:Do not know!fpd type:0x{0:X000}\n"
,
(
int
)
m_pLastRegCfg
.
m_SysBaseInfo
.
m_byPanelSize
));
}
WriteLog
(
string
.
Format
(
"\twidth={0},hight={1}\n"
,
m_pLastRegCfg
.
m_SysBaseInfo
.
m_sImageWidth
,
m_pLastRegCfg
.
m_SysBaseInfo
.
m_sImageHeight
));
WriteLog
(
"\tdatatype is unsigned char.\n"
);
WriteLog
(
"\tdatabit is 16bits.\n"
);
WriteLog
(
"\tdata is little endian.\n"
);
#
region
workmode
等值显示
// 图像分辨率
var
nImageWidth
=
m_pLastRegCfg
.
m_SysBaseInfo
.
m_sImageWidth
;
var
nImageHeight
=
m_pLastRegCfg
.
m_SysBaseInfo
.
m_sImageHeight
;
WriteLog
(
string
.
Format
(
"\tImage width={0},hight={1}\n"
,
nImageWidth
,
nImageHeight
));
// prepare 延时
UInt32
value
=
(
UInt32
)
m_pLastRegCfg
.
m_SysCfgInfo
.
m_unPreAcquisitionDelayTime
;
UInt32
time
=
ReverseBytes
(
value
);
WriteLog
(
string
.
Format
(
"\tPrepareTime={0}\n"
,
time
));
// 静态连续采集时间间隔
if
(
commCfg
.
_type
==
FPD_COMM_TYPE
.
UDP_COMM_TYPE
||
commCfg
.
_type
==
FPD_COMM_TYPE
.
WALN_COMM_TYPE
)
{
value
=
(
UInt32
)
m_pLastRegCfg
.
m_SysCfgInfo
.
m_unContinuousAcquisitionSpanTime
;
}
// 动态连续采集时间间隔
else
/*if (commCfg._type == FPD_COMM_TYPE.UDP_JUMBO_COMM_TYPE ||
commCfg._type == FPD_COMM_TYPE.PCIE_COMM_TYPE)*/
{
value
=
(
UInt32
)
m_pLastRegCfg
.
m_SysCfgInfo
.
m_unSelfDumpingSpanTime
;
}
time
=
ReverseBytes
(
value
);
WriteLog
(
string
.
Format
(
"\tLive acq time.time={0}\n"
,
time
));
// 触发模式
if
(
m_pLastRegCfg
.
m_SysCfgInfo
.
m_byTriggerMode
>=
0x01
&&
m_pLastRegCfg
.
m_SysCfgInfo
.
m_byTriggerMode
<=
0x08
)
{
WriteLog
(
string
.
Format
(
"\tstatic software trigger.{0:X}\n"
,
(
int
)(
m_pLastRegCfg
.
m_SysCfgInfo
.
m_byTriggerMode
)));
//cboxWorkMode.SelectedIndex = m_pLastRegCfg.m_SysCfgInfo.m_byTriggerMode;
}
else
{
//cboxWorkMode.SelectedIndex = 0;
WriteLog
(
string
.
Format
(
"\tother trigger mode.{0:X000}\n"
,
(
int
)(
m_pLastRegCfg
.
m_SysCfgInfo
.
m_byTriggerMode
)));
}
// 校正使能状态
//if (m_pLastRegCfg.m_ImgCaliCfg.m_byOffsetCorrection >= 0x00 && m_pLastRegCfg.m_ImgCaliCfg.m_byOffsetCorrection <= 0x03)
//cboxOffsetEnable.SelectedIndex = m_pLastRegCfg.m_ImgCaliCfg.m_byOffsetCorrection;
//else
//cboxOffsetEnable.SelectedIndex = 0;
WriteLog
(
string
.
Format
(
"\tOffset correction disenable.0x{0:X000}\n"
,
(
int
)(
m_pLastRegCfg
.
m_ImgCaliCfg
.
m_byOffsetCorrection
)));
//
//if (m_pLastRegCfg.m_ImgCaliCfg.m_byGainCorrection >= 0x00 && m_pLastRegCfg.m_ImgCaliCfg.m_byGainCorrection <= 0x02)
// cboxGainEnable.SelectedIndex = m_pLastRegCfg.m_ImgCaliCfg.m_byGainCorrection;
//else
// cboxGainEnable.SelectedIndex = 0;
WriteLog
(
string
.
Format
(
"\tGain correction disenable.0x{0:X000}\n"
,
(
int
)(
m_pLastRegCfg
.
m_ImgCaliCfg
.
m_byGainCorrection
)));
//
//if (m_pLastRegCfg.m_ImgCaliCfg.m_byDefectCorrection >= 0x00 && m_pLastRegCfg.m_ImgCaliCfg.m_byDefectCorrection <= 0x02)
// cboxDefectEnable.SelectedIndex = m_pLastRegCfg.m_ImgCaliCfg.m_byDefectCorrection;
//else
// cboxDefectEnable.SelectedIndex = 0;
WriteLog
(
string
.
Format
(
"\tDefect correction disenable.0x{0:X000}\n"
,
(
int
)(
m_pLastRegCfg
.
m_ImgCaliCfg
.
m_byDefectCorrection
)));
//
//if (m_pLastRegCfg.m_ImgCaliCfg.m_byDummyCorrection >= 0x00 && m_pLastRegCfg.m_ImgCaliCfg.m_byDummyCorrection <= 0x02)
// cboxDummyEnable.SelectedIndex = m_pLastRegCfg.m_ImgCaliCfg.m_byDummyCorrection;
//else
// cboxDummyEnable.SelectedIndex = 0;
WriteLog
(
string
.
Format
(
"\tDummy correction disenable.0x{0:X000}\n"
,
(
int
)(
m_pLastRegCfg
.
m_ImgCaliCfg
.
m_byDummyCorrection
)));
// 其他参数
// PGA档位 类型
UInt16
uiValue
=
(
UInt16
)
m_pLastRegCfg
.
m_TICOFCfg
.
m_sTICOFRegister
[
26
];
UInt16
uiPGA
=
ReverseBytes
(
uiValue
);
int
select
=
(
uiPGA
>>
10
)
&
0x3f
;
if
(
select
==
0x02
)
{
//cboxPgaLevel.SelectedIndex = 1;
WriteLog
(
"Binning Type.PGA-0.6pC\n"
);
}
else
if
(
select
==
0x04
)
{
//cboxPgaLevel.SelectedIndex = 2;
WriteLog
(
"Binning Type.PGA-1.2pC\n"
);
}
else
if
(
select
==
0x08
)
{
//cboxPgaLevel.SelectedIndex = 3;
WriteLog
(
"Binning Type.PGA-2.4pC\n"
);
}
else
if
(
select
==
0x0c
)
{
//cboxPgaLevel.SelectedIndex = 4;
WriteLog
(
"Binning Type.PGA-3.6pC\n"
);
}
else
if
(
select
==
0x10
)
{
//cboxPgaLevel.SelectedIndex = 5;
WriteLog
(
"Binning Type.PGA-4.8pC\n"
);
}
else
if
(
select
==
0x18
)
{
//cboxPgaLevel.SelectedIndex = 6;
WriteLog
(
"Binning Type.PGA-7.2pC\n"
);
}
else
if
(
select
==
0x3e
)
{
//cboxPgaLevel.SelectedIndex = 7;
WriteLog
(
"Binning Type.PGA-9.6pC\n"
);
}
else
{
//cboxPgaLevel.SelectedIndex = 0;
WriteLog
(
"Binning Type.PGA-Invalid\n"
);
}
// Binning 类型
if
(
1
<=
m_pLastRegCfg
.
m_SysCfgInfo
.
m_byBinning
&&
m_pLastRegCfg
.
m_SysCfgInfo
.
m_byBinning
<=
4
)
{
//cboxBinningType.SelectedIndex = m_pLastRegCfg.m_SysCfgInfo.m_byBinning;
WriteLog
(
string
.
Format
(
"\tBinning Type.{0:X}\n"
,
(
int
)(
m_pLastRegCfg
.
m_SysCfgInfo
.
m_byBinning
)));
}
else
{
//cboxBinningType.SelectedIndex = 0;
WriteLog
(
string
.
Format
(
"\tother Binning Type.{0:X}\n"
,
(
int
)(
m_pLastRegCfg
.
m_SysCfgInfo
.
m_byTriggerMode
)));
}
//// 更新显示信息
//PostMessage(WM_USER_CURR_FPD_INFO, (WPARAM)0, (LPARAM)0);
#
endregion
}
private
void
btnSetCorrectEnable
(
bool
enable
)
{
/*
Offset correct enable:
0-No Offset Correction;不做 offset 校正
1-Software PreOffset Correction;软件 pre-offset 校正
2-Firmware PostOffset Correction;固件 pre-offset 校正
3-Firmware PreOffset Correction;固件 post-offset 校正
Gain correct enable:
0-No Gain Correction;不做 Gain 校正
1-Software Gain Correction;软件 Gain 校正
2-Firmware Gain Correction;固件 Gain 校
*/
WriteLog
(
"set correct enable begin!\n"
);
//m_pCorrect.bFeedbackCfg = false; // false - ECALLBACK_TYPE_SET_CFG_OK Event
m_pCorrect
.
bFeedbackCfg
=
true
;
// true - ECALLBACK_TYPE_ROM_UPLOAD Event
m_pCorrect
.
ucOffsetCorrection
=
enable
?
(
char
)
3
:
(
char
)
3
;
;
//(char)m_pLastRegCfg.m_ImgCaliCfg.m_byOffsetCorrection;
m_pCorrect
.
ucGainCorrection
=
enable
?
(
char
)
2
:
(
char
)
0
;
;
//(char)m_pLastRegCfg.m_ImgCaliCfg.m_byGainCorrection;
m_pCorrect
.
ucDefectCorrection
=
(
char
)
m_pLastRegCfg
.
m_ImgCaliCfg
.
m_byDefectCorrection
;
m_pCorrect
.
ucDummyCorrection
=
(
char
)
0
/*cboxDummyEnable.SelectedIndex*/
;
// 暂时不支持
// 打印软触发使能参数
WriteLog
(
"HBI_UpdateCorrectEnable\n"
);
WriteLog
(
String
.
Format
(
"\tm_pCorrect.ucOffsetCorrection={0}\n"
,
(
int
)
m_pCorrect
.
ucOffsetCorrection
));
WriteLog
(
String
.
Format
(
"\tm_pCorrect.ucGainCorrection={0}\n"
,
(
int
)
m_pCorrect
.
ucGainCorrection
));
WriteLog
(
String
.
Format
(
"\tm_pCorrect.ucDefectCorrection={0}\n"
,
(
int
)
m_pCorrect
.
ucDefectCorrection
));
WriteLog
(
String
.
Format
(
"\tm_pCorrect.ucDummyCorrection={0}\n"
,
(
int
)
m_pCorrect
.
ucDummyCorrection
));
int
_ret
=
HBI_FPD_DLL
.
HBI_UpdateCorrectEnable
(
HBI_FPD_DLL
.
_handel
,
ref
m_pCorrect
);
if
(
_ret
==
0
)
{
WriteLog
(
"\tHBI_UpdateCorrectEnable success!:"
+
GetHbiError
(
_ret
));
}
else
{
WriteLog
(
"HBI_UpdateCorrectEnable failed!"
);
}
}
public
static
void
SaveBmp8
(
int
width
,
int
height
,
IntPtr
buff
,
string
savePath
)
{
int
nwidth
=
width
;
int
nheight
=
height
;
short
fiBitCount
=
8
;
int
iLineByteCnt
=
(((
width
*
fiBitCount
)
+
31
)
>>
5
)
<<
2
;
int
dataSize
=
iLineByteCnt
*
height
;
//byte[] fsbytes = new byte[14];//文件头
//byte[] fibytes = new byte[40];//信息头
byte
[]
pbytes
=
new
byte
[
256
*
4
];
//调色板
byte
[]
bfType
=
new
byte
[
2
];
bfType
[
0
]
=
(
int
)
'B'
;
bfType
[
1
]
=
(
int
)
'M'
;
byte
[]
bfSize
=
BitConverter
.
GetBytes
(
dataSize
+
14
+
40
+
1024
);
byte
[]
bfReserved
=
new
byte
[
4
]
{
0
,
0
,
0
,
0
};
byte
[]
biOffbits
=
BitConverter
.
GetBytes
(
1024
+
14
+
40
);
byte
[]
biSize
=
BitConverter
.
GetBytes
(
40
);
byte
[]
biWidth
=
BitConverter
.
GetBytes
(
width
);
byte
[]
biHeight
=
BitConverter
.
GetBytes
(-
1
*
height
);
byte
[]
biPlanes
=
new
byte
[]
{
0
,
1
};
byte
[]
biBitCount
=
BitConverter
.
GetBytes
(
fiBitCount
);
byte
[]
biCompression
=
new
byte
[]
{
0
,
0
,
0
,
0
};
byte
[]
biSizeImage
=
new
byte
[]
{
0
,
0
,
0
,
0
};
byte
[]
biXYPelsPerMeter
=
new
byte
[]
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
byte
[]
biClrUsed
=
BitConverter
.
GetBytes
(
256
);
byte
[]
biClrImportant
=
BitConverter
.
GetBytes
(
256
);
//调色版
for
(
int
i
=
0
;
i
<
256
;
i
++)
{
pbytes
[
i
*
4
]
=
(
byte
)
i
;
pbytes
[
i
*
4
+
1
]
=
(
byte
)
i
;
pbytes
[
i
*
4
+
2
]
=
(
byte
)
i
;
pbytes
[
i
*
4
+
3
]
=
255
;
}
byte
[]
data
=
new
byte
[
dataSize
];
Marshal
.
Copy
(
buff
,
data
,
0
,
width
*
height
);
using
(
FileStream
fileStream
=
File
.
OpenWrite
(
savePath
))
{
fileStream
.
Write
(
bfType
,
0
,
2
);
fileStream
.
Write
(
bfSize
,
0
,
4
);
fileStream
.
Write
(
bfReserved
,
0
,
4
);
fileStream
.
Write
(
biOffbits
,
0
,
4
);
//
fileStream
.
Write
(
biSize
,
0
,
4
);
fileStream
.
Write
(
biWidth
,
0
,
4
);
fileStream
.
Write
(
biHeight
,
0
,
4
);
fileStream
.
Write
(
biPlanes
,
0
,
2
);
fileStream
.
Write
(
biBitCount
,
0
,
2
);
fileStream
.
Write
(
biCompression
,
0
,
4
);
fileStream
.
Write
(
biSizeImage
,
0
,
4
);
fileStream
.
Write
(
biXYPelsPerMeter
,
0
,
8
);
fileStream
.
Write
(
biClrUsed
,
0
,
4
);
fileStream
.
Write
(
biClrImportant
,
0
,
4
);
//
fileStream
.
Write
(
pbytes
,
0
,
pbytes
.
Length
);
//
fileStream
.
Write
(
data
,
0
,
data
.
Length
);
//
fileStream
.
Close
();
fileStream
.
Dispose
();
}
}
public
int
SaveImage
()
{
if
(
imagedata
.
ndatabits
!=
emHBI_DATA_TYPE
.
EHBI_16UC1
)
{
WriteLog
(
string
.
Format
(
"err:imagedata.ndatabits:0x{0:X000}\n"
,
imagedata
.
ndatabits
));
return
1
;
}
//
if
(
imagedata
.
databuff
==
null
)
{
return
0
;
}
//
int
bufflen
=
imagedata
.
uwidth
*
imagedata
.
uheight
*
2
;
if
(
bufflen
<=
0
)
{
return
0
;
}
var
nframeId
=
imagedata
.
uframeid
;
int
imgagesize
=
0
;
buffer
=
new
byte
[
bufflen
];
// 存储数据
//if (imgbuff.imageushorttemp == null)
//{
// imgbuff.imagebytetemp = new byte[bufflen];
// imgagesize = bufflen;
//}
//else
//{
// if (imgagesize != bufflen)
// {
// imgbuff.imagebytetemp = new byte[bufflen];
// imgagesize = bufflen;
// }
//}
//// 拷贝到指定数组中保存
//if (imagedata.datalen != imgagesize)
//{
// return 0;
//}
Marshal
.
Copy
(
imagedata
.
databuff
,
buffer
,
0
,
bufflen
);
string
fileName
=
Directory
.
GetCurrentDirectory
()
+
"\\current.raw"
;
File
.
WriteAllBytes
(
fileName
,
buffer
);
// 图片信息
WriteLog
(
string
.
Format
(
"SaveImage success:0x{0:X000}\n"
,
nframeId
));
//
return
1
;
}
/// <summary>
/// 加载本地RAW图片,64字节头
/// </summary>
/// <param name="filePath">图片路径</param>
public
void
LoadRAW
(
string
filePath
)
{
buffer
=
System
.
IO
.
File
.
ReadAllBytes
(
filePath
);
}
/// <summary>
/// 保存本地RAW图片
/// </summary>
/// <param name="filePath">图片路径</param>
public
void
SaveRAW
(
string
filePath
)
{
if
(
buffer
==
null
)
return
;
System
.
IO
.
File
.
WriteAllBytes
(
filePath
,
buffer
);
}
int
inState
=
int
.
MinValue
;
/// <summary>
/// 校准平板
/// </summary>
/// <param name="mode">1:暗场校准,2亮场校准</param>
/// <returns></returns>
public
async
Task
<
bool
>
GenerateTemplate
(
int
mode
)
{
inState
=
int
.
MinValue
;
EnumIMAGE_ACQ_CMD
tmode
;
if
(
mode
==
1
)
{
tmode
=
EnumIMAGE_ACQ_CMD
.
OFFSET_TEMPLATE_TYPE
;
return
true
;
}
else
{
tmode
=
EnumIMAGE_ACQ_CMD
.
GAIN_TEMPLATE_TYPE
;
btnSetCorrectEnable
(
false
);
}
int
ret
=
HBI_FPD_DLL
.
HBI_GenerateTemplate
(
HBI_FPD_DLL
.
_handel
,
tmode
);
WriteLog
(
$
"ret:{ret},tmode:{tmode}"
);
if
(
ret
!=
0
)
return
false
;
if
(
mode
==
2
)
{
downloadStatus
=
0
;
//下载前置0
// 第二步:注册回调函数
ret
=
HBI_FPD_DLL
.
HBI_RegProgressCallBack
(
HBI_FPD_DLL
.
_handel
,
DownloadCallBack
,
IntPtr
.
Zero
);
if
(
ret
!=
0
)
{
WriteLog
(
"HBI_RegProgressCallBack failed!ret:[{0}]:"
+
GetHbiError
(
ret
));
return
false
;
}
else
WriteLog
(
"HBI_RegProgressCallBack success!"
);
// 第三步:将gain模板下载到固件
int
m_emfiletype
=
0
;
HBI_FPD_DLL
.
HBI_DownloadTemplateByType
(
HBI_FPD_DLL
.
_handel
,
m_emfiletype
);
if
(
ret
!=
0
)
{
WriteLog
(
"HBI_DownloadTemplateByType:gain template failed!ret:[{0}]:"
+
GetHbiError
(
ret
));
return
false
;
}
for
(
int
i
=
0
;
i
<
30
;
i
++){
if
(
downloadStatus
==
0
)
{
Task
.
Delay
(
1000
).
Wait
();
}
else
{
if
(
downloadStatus
==
1
)
{
WriteLog
(
"模版下载成功"
);
btnSetCorrectEnable
(
true
);
return
true
;
}
else
if
(
downloadStatus
==
2
)
{
WriteLog
(
"模版下载失败"
);
btnSetCorrectEnable
(
false
);
return
false
;
}
}
}
}
//Task a = Task.Delay(160*1000);
//Task b = Task.Run(() => {
// while (true)
// {
// Thread.Sleep(100);
// //WriteLog($"inState:{inState}");
// if (inState==2 || inState==1)
// break;
// }
//});
//var result = await Task.WhenAny(a, b);
//if (result == a) {
// WriteLog($"{tmode}: time out");
// return false;
//}
return
true
;
}
// dwnload template callcallback function
int
downloadStatus
=
0
;
//0: 等待下载, 1:下载完成, 2:下载失败
private
int
DownloadCallBack
(
byte
command
,
int
code
,
IntPtr
pContext
)
{
switch
(
command
)
{
case
(
byte
)(
eCallbackUpdateFirmwareStatus
.
ECALLBACK_UPDATE_STATUS_START
):
// 开始 初始化
WriteLog
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_START:start download\n"
);
break
;
case
(
byte
)(
eCallbackUpdateFirmwareStatus
.
ECALLBACK_UPDATE_STATUS_PROGRESS
):
// 进度 code:百分比(0~100)
WriteLog
(
string
.
Format
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_PROGRESS:%% {0}\n"
,
code
));
break
;
case
(
byte
)(
eCallbackUpdateFirmwareStatus
.
ECALLBACK_UPDATE_STATUS_RESULT
):
// update result and error
if
((
0
<=
code
)
&&
(
code
<=
6
))
{
if
(
code
==
0
)
{
// 下载offset模板
WriteLog
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_RESULT:download offset template!\n"
);
}
else
if
(
code
==
1
)
{
// 下载gain模板
WriteLog
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_RESULT:download gain template!\n"
);
}
else
if
(
code
==
2
)
{
// 下载defect模板
WriteLog
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_RESULT:download defect template!\n"
);
}
else
if
(
code
==
3
)
{
// offset模板上传完成
WriteLog
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_RESULT:download offset finish!\n"
);
}
else
if
(
code
==
4
)
{
// gain模板上传完成
WriteLog
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_RESULT:download gain finish!\n"
);
}
else
if
(
code
==
5
)
{
// defect模板上传完成
WriteLog
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_RESULT:download defect finish!\n"
);
}
else
/* if (code == 6)*/
{
// 模板上传完成
WriteLog
(
"DownloadCallBack:ECALLBACK_UPDATE_STATUS_RESULT:Download finish and sucess!!\n"
);
}
downloadStatus
=
1
;
}
else
// 失败
{
if
(
code
==
-
1
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:wait event other error!\n"
);
}
else
if
(
code
==
-
2
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:timeout!\n"
);
}
else
if
(
code
==
-
3
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:downlod offset failed!\n"
);
}
else
if
(
code
==
-
4
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:downlod gain failed!\n"
);
}
else
if
(
code
==
-
5
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:downlod defect failed!\n"
);
}
else
if
(
code
==
-
6
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:Download failed!\n"
);
}
else
if
(
code
==
-
7
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:read offset failed!!\n"
);
}
else
if
(
code
==
-
8
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:read gain failed!!\n"
);
}
else
if
(
code
==
-
9
)
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:read defect failed!!\n"
);
}
else
{
WriteLog
(
"err:ECALLBACK_UPDATE_STATUS_RESULT:unknow error!\n"
);
}
downloadStatus
=
2
;
}
break
;
default
:
// unusual
WriteLog
(
string
.
Format
(
"DownloadCallBack,retcode:[{0}]\n"
,
code
));
break
;
}
return
1
;
}
void
WriteLog
(
string
log
)
{
LOG
.
Info
(
log
);
}
// 翻转字节顺序 (16-bit)
public
static
UInt16
ReverseBytes
(
UInt16
value
)
{
return
(
UInt16
)((
value
&
0xFFU
)
<<
8
|
(
value
&
0xFF00U
)
>>
8
);
}
// 翻转字节顺序 (32-bit)
public
static
UInt32
ReverseBytes
(
UInt32
value
)
{
return
(
value
&
0x000000FFU
)
<<
24
|
(
value
&
0x0000FF00U
)
<<
8
|
(
value
&
0x00FF0000U
)
>>
8
|
(
value
&
0xFF000000U
)
>>
24
;
}
// 翻转字节顺序 (64-bit)
public
static
UInt64
ReverseBytes
(
UInt64
value
)
{
return
(
value
&
0x00000000000000FFU
L
)
<<
56
|
(
value
&
0x000000000000FF00U
L
)
<<
40
|
(
value
&
0x0000000000FF0000U
L
)
<<
24
|
(
value
&
0x00000000FF000000U
L
)
<<
8
|
(
value
&
0x000000FF00000000U
L
)
>>
8
|
(
value
&
0x0000FF0000000000U
L
)
>>
24
|
(
value
&
0x00FF000000000000U
L
)
>>
40
|
(
value
&
0xFF00000000000000U
L
)
>>
56
;
}
//翻转byte数组
public
static
void
ReverseBytes
(
byte
[]
bytes
)
{
byte
tmp
;
int
len
=
bytes
.
Length
;
for
(
int
i
=
0
;
i
<
len
/
2
;
i
++)
{
tmp
=
bytes
[
len
-
1
-
i
];
bytes
[
len
-
1
-
i
]
=
bytes
[
i
];
bytes
[
i
]
=
tmp
;
}
}
//规定转换起始位置和长度
public
static
void
ReverseBytes
(
byte
[]
bytes
,
int
start
,
int
len
)
{
int
end
=
start
+
len
-
1
;
byte
tmp
;
int
i
=
0
;
for
(
int
index
=
start
;
index
<
start
+
len
/
2
;
index
++,
i
++)
{
tmp
=
bytes
[
end
-
i
];
bytes
[
end
-
i
]
=
bytes
[
index
];
bytes
[
index
]
=
tmp
;
}
}
public
static
void
TemplateTool
()
{
int
ret
=
HBI_FPD_DLL
.
HBI_OpenTemplateWizard
(
HBI_FPD_DLL
.
_handel
);
if
(
ret
!=
0
)
{
//System.Windows.Forms.MessageBox.Show("HBI_OpenTemplateWizard failed!" + ret.ToString());
//MessageBox.Show("HBI_OpenTemplateWizard failed!" + ret.ToString());
return
;
}
else
{
//WriteLog("HBI_OpenTemplateWizard success!");
}
}
}
}
CarerayImage_Test/App.config
查看文件 @
f2dde14
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
configuration
>
<
configSections
>
<
configSections
>
<
section
name
=
"log4net"
type
=
"log4net.Config.Log4NetConfigurationSectionHandler,log4net"
/>
<
section
name
=
"log4net"
type
=
"log4net.Config.Log4NetConfigurationSectionHandler,log4net"
/>
</
configSections
>
</
configSections
>
<
startup
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.
6.1"
/>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.
8"
/>
</
startup
>
</
startup
>
<
log4net
>
<
log4net
>
<
appender
name
=
"CarerayImage"
type
=
"log4net.Appender.RollingFileAppender"
>
<
appender
name
=
"CarerayImage"
type
=
"log4net.Appender.RollingFileAppender"
>
...
@@ -22,4 +22,4 @@
...
@@ -22,4 +22,4 @@
<
appender
-
ref
ref
=
"CarerayImage"
/>
<
appender
-
ref
ref
=
"CarerayImage"
/>
</
root
>
</
root
>
</
log4net
>
</
log4net
>
</
configuration
>
\ No newline at end of file
\ No newline at end of file
</
configuration
>
CarerayImage_Test/CarerayImage_Test.csproj
查看文件 @
f2dde14
...
@@ -8,10 +8,11 @@
...
@@ -8,10 +8,11 @@
<OutputType>WinExe</OutputType>
<OutputType>WinExe</OutputType>
<RootNamespace>CarerayImage_Test</RootNamespace>
<RootNamespace>CarerayImage_Test</RootNamespace>
<AssemblyName>CarerayImage_Test</AssemblyName>
<AssemblyName>CarerayImage_Test</AssemblyName>
<TargetFrameworkVersion>v4.
6.1
</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.
8
</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
...
@@ -96,6 +97,7 @@
...
@@ -96,6 +97,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
</Compile>
<None Include="Properties\Settings.settings">
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<Generator>SettingsSingleFileGenerator</Generator>
...
...
CarerayImage_Test/Properties/Resources.Designer.cs
查看文件 @
f2dde14
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// <auto-generated>
// 此代码由工具生成。
// 此代码由工具生成。
// 运行时版本:
4.0.30319.42000
// 运行时版本:4.0.30319.42000
//
//
// 对此文件的更改可能
导致不正确的行为,
如果
// 对此文件的更改可能
会导致不正确的行为,并且
如果
// 重新生成代码,
则所做更改将
丢失。
// 重新生成代码,
这些更改将会
丢失。
// </auto-generated>
// </auto-generated>
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace
CarerayImage_Test.Properties
namespace
CarerayImage_Test.Properties
{
{
using
System
;
/// <summary>
/// <summary>
///
强类型资源类,用于查找本地化
字符串等。
///
一个强类型的资源类,用于查找本地化的
字符串等。
/// </summary>
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或
删
除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// 若要添加或
移
除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
// (以 /str 作为命令选项),或重新生成 VS 项目。
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"System.Resources.Tools.StronglyTypedResourceBuilder"
,
"
4
.0.0.0"
)]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"System.Resources.Tools.StronglyTypedResourceBuilder"
,
"
17
.0.0.0"
)]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
internal
class
Resources
internal
class
Resources
{
{
private
static
global
::
System
.
Resources
.
ResourceManager
resourceMan
;
private
static
global
::
System
.
Resources
.
ResourceManager
resourceMan
;
private
static
global
::
System
.
Globalization
.
CultureInfo
resourceCulture
;
private
static
global
::
System
.
Globalization
.
CultureInfo
resourceCulture
;
[
global
::
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessageAttribute
(
"Microsoft.Performance"
,
"CA1811:AvoidUncalledPrivateCode"
)]
[
global
::
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessageAttribute
(
"Microsoft.Performance"
,
"CA1811:AvoidUncalledPrivateCode"
)]
internal
Resources
()
internal
Resources
()
{
{
}
}
/// <summary>
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// 返回此类使用的缓存
的
ResourceManager 实例。
/// </summary>
/// </summary>
[
global
::
System
.
ComponentModel
.
EditorBrowsableAttribute
(
global
::
System
.
ComponentModel
.
EditorBrowsableState
.
Advanced
)]
[
global
::
System
.
ComponentModel
.
EditorBrowsableAttribute
(
global
::
System
.
ComponentModel
.
EditorBrowsableState
.
Advanced
)]
internal
static
global
::
System
.
Resources
.
ResourceManager
ResourceManager
internal
static
global
::
System
.
Resources
.
ResourceManager
ResourceManager
{
{
get
{
get
if
(
object
.
ReferenceEquals
(
resourceMan
,
null
))
{
{
if
((
resourceMan
==
null
))
{
global
::
System
.
Resources
.
ResourceManager
temp
=
new
global
::
System
.
Resources
.
ResourceManager
(
"CarerayImage_Test.Properties.Resources"
,
typeof
(
Resources
).
Assembly
);
global
::
System
.
Resources
.
ResourceManager
temp
=
new
global
::
System
.
Resources
.
ResourceManager
(
"CarerayImage_Test.Properties.Resources"
,
typeof
(
Resources
).
Assembly
);
resourceMan
=
temp
;
resourceMan
=
temp
;
}
}
return
resourceMan
;
return
resourceMan
;
}
}
}
}
/// <summary>
/// <summary>
///
覆盖当前线程的 CurrentUICulture 属性
///
重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型
的资源类的资源查找
。
/// 使用此强类型
资源类的所有资源查找执行重写
。
/// </summary>
/// </summary>
[
global
::
System
.
ComponentModel
.
EditorBrowsableAttribute
(
global
::
System
.
ComponentModel
.
EditorBrowsableState
.
Advanced
)]
[
global
::
System
.
ComponentModel
.
EditorBrowsableAttribute
(
global
::
System
.
ComponentModel
.
EditorBrowsableState
.
Advanced
)]
internal
static
global
::
System
.
Globalization
.
CultureInfo
Culture
internal
static
global
::
System
.
Globalization
.
CultureInfo
Culture
{
{
get
{
get
{
return
resourceCulture
;
return
resourceCulture
;
}
}
set
set
{
{
resourceCulture
=
value
;
resourceCulture
=
value
;
}
}
}
}
...
...
CarerayImage_Test/Properties/Settings.Designer.cs
查看文件 @
f2dde14
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// <auto-generated>
//
This code was generated by a tool.
//
此代码由工具生成。
//
Runtime Version
:4.0.30319.42000
//
运行时版本
:4.0.30319.42000
//
//
//
Changes to this file may cause incorrect behavior and will be lost if
//
对此文件的更改可能会导致不正确的行为,并且如果
//
the code is regenerated.
//
重新生成代码,这些更改将会丢失。
// </auto-generated>
// </auto-generated>
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace
CarerayImage_Test.Properties
namespace
CarerayImage_Test.Properties
{
{
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator"
,
"11.0.0.0"
)]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator"
,
"17.5.0.0"
)]
internal
sealed
partial
class
Settings
:
global
::
System
.
Configuration
.
ApplicationSettingsBase
internal
sealed
partial
class
Settings
:
global
::
System
.
Configuration
.
ApplicationSettingsBase
{
{
private
static
Settings
defaultInstance
=
((
Settings
)(
global
::
System
.
Configuration
.
ApplicationSettingsBase
.
Synchronized
(
new
Settings
())));
private
static
Settings
defaultInstance
=
((
Settings
)(
global
::
System
.
Configuration
.
ApplicationSettingsBase
.
Synchronized
(
new
Settings
())));
public
static
Settings
Default
public
static
Settings
Default
{
{
get
{
get
{
return
defaultInstance
;
return
defaultInstance
;
}
}
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论