Commit 79c08d62 刘韬

Neox接口添加错误信息输出

1 个父辈 25aba30b
...@@ -68,9 +68,9 @@ public static class NeoX ...@@ -68,9 +68,9 @@ public static class NeoX
} }
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
public static bool AlgoC(string filename,string templateFile, int shrinkOffset, int Corner, string type, out int count, out Bitmap bitmap) public static bool AlgoC(string filename,string templateFile, int shrinkOffset, int Corner, string type, out int count, out Bitmap bitmap, out string errormsg)
{ {
errormsg = "";
var d = new NeoXData(); var d = new NeoXData();
d.imgPath = filename; d.imgPath = filename;
d.outPath = Corner + "-Mark.png"; d.outPath = Corner + "-Mark.png";
...@@ -99,6 +99,10 @@ public static class NeoX ...@@ -99,6 +99,10 @@ public static class NeoX
} }
else else
{ {
errormsg += "input:" + s + "\r\n";
errormsg += "output:" + ss + "\r\n";
errormsg += "err:" + r?.error + "\r\n";
Console.WriteLine(ss); Console.WriteLine(ss);
Debug.WriteLine(ss); Debug.WriteLine(ss);
return false; return false;
...@@ -107,6 +111,7 @@ public static class NeoX ...@@ -107,6 +111,7 @@ public static class NeoX
catch (Exception ex) catch (Exception ex)
{ {
Debug.WriteLine(ex); Debug.WriteLine(ex);
errormsg= ex.ToString();
return false; return false;
} }
} }
......
...@@ -249,15 +249,16 @@ namespace Asa ...@@ -249,15 +249,16 @@ namespace Asa
/// <param name="tpDstImg"></param> /// <param name="tpDstImg"></param>
/// <returns></returns> /// <returns></returns>
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
public static int GetLocalCountIrregular(string path, int ShrinkOffset, string type, out int[] count, out Bitmap BmpDstImg) public static int GetLocalCountIrregular(string path, int ShrinkOffset, string type, out int[] count, out Bitmap BmpDstImg,out string errmsg)
{ {
type = NeoX.ConverterType(type,true); type = NeoX.ConverterType(type,true);
errmsg = "";
if (NeoX.HasNeox() && type.StartsWith("ID")) if (NeoX.HasNeox() && type.StartsWith("ID"))
{ {
var tf = GetTemplateFile(path); var tf = GetTemplateFile(path);
if (!string.IsNullOrEmpty(tf)) if (!string.IsNullOrEmpty(tf))
type = "ID_TYPE_T"; type = "ID_TYPE_T";
var result = NeoX.AlgoC(path, tf, ShrinkOffset,0, type, out int c, out Bitmap bitmap); var result = NeoX.AlgoC(path, tf, ShrinkOffset,0, type, out int c, out Bitmap bitmap, out errmsg);
count = new int[4] { c, 0, 0, 0 }; count = new int[4] { c, 0, 0, 0 };
BmpDstImg = bitmap; BmpDstImg = bitmap;
return result?0:-1; return result?0:-1;
...@@ -381,7 +382,7 @@ namespace Asa ...@@ -381,7 +382,7 @@ namespace Asa
var tf = GetTemplateFile(path); var tf = GetTemplateFile(path);
if (!string.IsNullOrEmpty(tf)) if (!string.IsNullOrEmpty(tf))
type1 = "ID_TYPE_T"; type1 = "ID_TYPE_T";
NeoX.AlgoC(path, tf, ShrinkOffset, Corner + 1, type1, out int c, out Bitmap bitmap); NeoX.AlgoC(path, tf, ShrinkOffset, Corner + 1, type1, out int c, out Bitmap bitmap, out _);
lock (ccresult) lock (ccresult)
{ {
ccresult.Add(Corner, (c, bitmap)); ccresult.Add(Corner, (c, bitmap));
......
...@@ -562,9 +562,11 @@ namespace Asa ...@@ -562,9 +562,11 @@ namespace Asa
// 当前反馈固件参数,转化为结构体 add by mhyang 20220402 // 当前反馈固件参数,转化为结构体 add by mhyang 20220402
imagedata = (ImageData)Marshal.PtrToStructure(ptrParam1, typeof(ImageData)); imagedata = (ImageData)Marshal.PtrToStructure(ptrParam1, typeof(ImageData));
#if !savebmp8 // 正常按照16bit图像显示,add by mhyang 20220615 #if !savebmp8 // 正常按照16bit图像显示,add by mhyang 20220615
SaveImage(); // 保存 if (SaveImage() == 0) // 保存
buffgetted = true; {
WaitstopToken.Cancel(false); buffgetted = true;
WaitstopToken.Cancel(false);
}
#else // 按照8bit图像显示,add by mhyang 20221104 #else // 按照8bit图像显示,add by mhyang 20221104
//int length = imagedata.datalen; //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 (0 == HBI_FPD_DLL.HBI_AutoWindowWidthWindowLevel(HBI_FPD_DLL._handel, imagedata.databuff, ref imagedata.datalen, imagedata.uwidth, imagedata.uheight))
...@@ -992,36 +994,25 @@ namespace Asa ...@@ -992,36 +994,25 @@ namespace Asa
{ {
return 0; return 0;
} }
var nframeId = imagedata.uframeid; try
int imgagesize = 0; {
buffer = new byte[bufflen]; var nframeId = imagedata.uframeid;
// 存储数据 int imgagesize = 0;
//if (imgbuff.imageushorttemp == null) buffer = new byte[bufflen];
//{
// 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 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"current.raw"); Marshal.Copy(imagedata.databuff, buffer, 0, bufflen);
File.WriteAllBytes(fileName, buffer);
// 图片信息 string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "current.raw");
WriteLog(string.Format("SaveImage success:0x{0:X000}\n", nframeId)); File.WriteAllBytes(fileName, buffer);
// // 图片信息
return 1; WriteLog(string.Format("SaveImage success:0x{0:X000}\n", nframeId));
//
return 1;
}
catch (Exception ex) {
WriteLog($"SaveImage fail:{ex}\n");
}
return 0;
} }
/// <summary> /// <summary>
/// 加载本地RAW图片,64字节头 /// 加载本地RAW图片,64字节头
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!