Commit 79c08d62 刘韬

Neox接口添加错误信息输出

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