Commit f2dde140 刘韬

优化昊博报错信息

1 个父辈 9bdb6abc
......@@ -347,6 +347,12 @@ namespace Asa
{
throw new NotImplementedException();
}
public bool SetExposureTime(int time)
{
//throw new NotImplementedException();
return false;
}
}
......
......@@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Asa</RootNamespace>
<AssemblyName>Asa.CarerayImage</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -50,10 +51,13 @@
<Reference Include="System.Xml" />
</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="eyemLib.cs" />
<Compile Include="haobo.cs" />
<Compile Include="HaoboSDK\HBI_FPD_DLL.cs" />
<Compile Include="haobo_v2.cs" />
<Compile Include="MatchLib.cs" />
<Compile Include="XrayImage.cs" />
<Compile Include="CarerayImage.cs" />
......
......@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Asa.HaoboSDK
namespace Asa.HaoboSDK_v1
{
public class HBI_FPD_DLL
{
......@@ -307,6 +307,24 @@ namespace Asa.HaoboSDK
[DllImport("HBI_FPD.dll", EntryPoint = "HBI_SetPreAcqTm", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
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
* 功能描述: 获取软触发单帧采集清空和采集之间的时间间隔
......
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"}
};
}
}
using Asa.HaoboSDK;
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
......@@ -85,9 +84,12 @@ namespace Asa
{
if (deviceType == DeviceType.CARREY)
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
device = new haobo(logName);
device = new haobo_v1(logName);
}
/// <summary>
......@@ -456,14 +458,37 @@ namespace Asa
//eyemImageFree(ref tpModeImg);
return BmpDstImg;
}
/// <summary>
/// 重新载入点料模版
/// .\CountTemplate
/// </summary>
/// <returns></returns>
public static int ReloadTpl()
{
eyemReleaseModel(ref hModelIDs);
return eyemInitModel("CountTemplate", out hModelIDs);
int result = -1;
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()
{
return () =>
......@@ -518,10 +543,16 @@ namespace Asa
return device.GenerateTemplate(mode);
}
public bool SetExposureTime(int time)
{
return device.SetExposureTime(time);
}
public enum DeviceType
{
HAOBO,
CARREY
CARREY,
HAOBO_V2
}
}
......
......@@ -31,5 +31,6 @@ namespace Asa
int WindowLevel { set; get; }
Task<bool> GenerateTemplate(int mode);
bool SetExposureTime(int time);
}
}
using Asa.HaoboSDK;
using Asa.HaoboSDK_v1;
using ConfigHelper;
using System;
using System.Collections.Generic;
......@@ -13,7 +13,7 @@ using static Asa.eyemLib;
namespace Asa
{
class haobo : XrayImageInterface
class haobo_v1 : XrayImageInterface
{
private readonly log4net.ILog LOG;
RegCfgInfo m_pLastRegCfg;
......@@ -21,8 +21,9 @@ namespace Asa
static USER_CALLBACK_HANDLE_ENVENT _dUserCallbackHandleEnvent;
IMAGE_CORRECT_ENABLE m_pCorrect = new IMAGE_CORRECT_ENABLE();
byte[] buffer;
public haobo(string logName = "CarerayImage") {
public haobo_v1(string logName = "CarerayImage") {
LOG = log4net.LogManager.GetLogger(logName);
LOG.Info("Load haobo_v1");
//1 初始化DLL
HBI_FPD_DLL._handel = HBI_FPD_DLL.HBI_Init();
_dUserCallbackHandleEnvent = DataCallBack;
......@@ -154,7 +155,7 @@ namespace Asa
return bmp;
}
CancellationTokenSource WaitstopToken = new CancellationTokenSource();
bool buffgetted = false;
volatile bool buffgetted = false;
int getpiccount = 0;
public bool GetImage(int _MaxFrameCount = 3, int MaxDelay = 5000)
{
......@@ -174,7 +175,7 @@ namespace Asa
// return false;
//}
WriteLog("GetImage start========================");
getpiccount = 0;
getpiccount = _MaxFrameCount;
buffgetted = false;
//int ret = HBI_FPD_DLL.HBI_Prepare(HBI_FPD_DLL._handel); //5
//if (ret != 0) WriteLog("HBI_Prepare" + ret.ToString());
......@@ -245,21 +246,24 @@ namespace Asa
catch { }
}
// 设置软触发清空时间
private void SetPrepareTime()
/// <summary>
/// 设置曝光时间
/// </summary>
/// <param name="time"></param>
public bool SetExposureTime(int time)
{
WriteLog(string.Format("Set Prepare time.:[{0}]\n", nPrepareTm));
int _ret = HBI_FPD_DLL.HBI_SetPreAcqTm(HBI_FPD_DLL._handel, nPrepareTm);
WriteLog(string.Format("Set LiveAcquisition time.:[{0}]\n", time));
int _ret = HBI_FPD_DLL.HBI_SetLiveAcquisitionTime(HBI_FPD_DLL._handel, time);
if (0 != _ret)
{
LOG.Error("HBI_SetPreAcqTm failed!");
return;
LOG.Error("HBI_SetLiveAcquisitionTime failed!");
return false;
}
else
{
WriteLog("HBI_SetPreAcqTm success!\n");
if (nPrepareTm == 3000) nPrepareTm = 0;
else nPrepareTm = 3000;
WriteLog("HBI_SetLiveAcquisitionTime success!\n");
return true;
}
}
//////////////////////////////////////////////////////////////////////////////
......@@ -345,8 +349,8 @@ namespace Asa
//----------------图像-------------------
case (byte)(eCallbackEventCommType.ECALLBACK_TYPE_SINGLE_IMAGE):
case (byte)(eCallbackEventCommType.ECALLBACK_TYPE_MULTIPLE_IMAGE):
getpiccount++;
if (getpiccount == 1)
getpiccount--;
if (getpiccount > 0)
return 1;
#if savebmp8
......
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<log4net>
<appender name="CarerayImage" type="log4net.Appender.RollingFileAppender">
......@@ -22,4 +22,4 @@
<appender-ref ref="CarerayImage"/>
</root>
</log4net>
</configuration>
\ No newline at end of file
</configuration>
......@@ -8,10 +8,11 @@
<OutputType>WinExe</OutputType>
<RootNamespace>CarerayImage_Test</RootNamespace>
<AssemblyName>CarerayImage_Test</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -96,6 +97,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
......
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace CarerayImage_Test.Properties
{
namespace CarerayImage_Test.Properties {
using System;
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /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.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CarerayImage_Test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}
......
//------------------------------------------------------------------------------
// <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>
//------------------------------------------------------------------------------
namespace CarerayImage_Test.Properties
{
namespace CarerayImage_Test.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!