Commit ac77009b 顾剑亮

debug

1 个父辈 f50be7f3
正在显示 32 个修改的文件 包含 368 行增加232 行删除
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Asa.CarerayImage.xml</DocumentationFile> <DocumentationFile>bin\Debug\Asa.CarerayImage.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
...@@ -32,6 +33,9 @@ ...@@ -32,6 +33,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
......
...@@ -10,14 +10,26 @@ namespace Asa ...@@ -10,14 +10,26 @@ namespace Asa
/// </summary> /// </summary>
public class CarerayImage public class CarerayImage
{ {
private byte[] src; private byte[] buffer;
private API.CR_EventID eventID;
private API.CallbackDelegate callback;
private const int WIDTH = 2816; private const int HEAD = 64;
private const int HEIGHT = 2816; private const int DEV_INDEX = 1;
private const int HEAD = 65536; private const int MODE_ID = 103;
private readonly log4net.ILog LOG;
/// <summary> /// <summary>
/// Careray平板图像
/// </summary>
public CarerayImage(string logName = "CarerayImage")
{
callback = new API.CallbackDelegate(Process);
LOG = log4net.LogManager.GetLogger(logName);
}
/// <summary>
/// 窗宽 /// 窗宽
/// </summary> /// </summary>
public int WindowWidth { set; get; } public int WindowWidth { set; get; }
...@@ -28,49 +40,136 @@ namespace Asa ...@@ -28,49 +40,136 @@ namespace Asa
public int WindowLevel { set; get; } public int WindowLevel { set; get; }
/// <summary> /// <summary>
/// Careray平板图像 /// 图像宽度
/// </summary>
public int ImageWidth { private set; get; }
/// <summary>
/// 图像高度
/// </summary> /// </summary>
public CarerayImage() public int ImageHeight { private set; get; }
/// <summary>
/// IP地址
/// </summary>
public string IP { private set; get; }
/// <summary>
/// 打开设备
/// </summary>
/// <returns></returns>
public bool Open()
{ {
int rtn;
//注册回调函数
callback = new API.CallbackDelegate(Process);
rtn = API.CR_RegisterEventCallbackFun(DEV_INDEX, callback);
LOG.Info("CR_RegisterEventCallbackFun Return " + rtn);
if (rtn != 0) return false;
GC.KeepAlive(callback);
//连接设备
rtn = API.CR_Connect(DEV_INDEX);
LOG.Info("CR_Connect Return " + rtn);
if (rtn != 0) return false;
//获取IP
rtn = API.CR_GetDetectorIndexAndIPAddress(out API.CR_DetrIdxAndIPAddr pDetrIdxAndIPAddr, out int pDetrNum);
LOG.Info("CR_GetDetectorIndexAndIPAddress Return " + rtn + " DetrNum=" + pDetrNum);
if (rtn != 0) return false;
int len = Array.FindIndex(pDetrIdxAndIPAddr.szIPAddr, b => b == 0);
IP = System.Text.Encoding.ASCII.GetString(pDetrIdxAndIPAddr.szIPAddr, 0, len);
//重置不重启
rtn = API.CR_ResetDetector(DEV_INDEX, false);
LOG.Info("CR_ResetDetector Return " + rtn);
if (rtn != 0) return false;
//获取应用模式
API.CR_ModeInfo[] pModeInfo = new API.CR_ModeInfo[10];
for (int i = 0; i < pModeInfo.Length; i++)
pModeInfo[i] = new API.CR_ModeInfo();
rtn = API.CR_GetApplicationMode(DEV_INDEX, pModeInfo, out int pModeNum);
LOG.Info("CR_GetApplicationMode Return " + rtn + " ModeNum=" + pModeNum);
if (rtn != 0) return false;
//获取图像宽度高度
for (int i = 0; i < pModeNum; i++)
{
if (pModeInfo[i].nModeID == MODE_ID)
{
ImageWidth = pModeInfo[i].nImageWidth;
ImageHeight = pModeInfo[i].nImageHeight;
break;
}
}
//设置参数
float pFrameRate = 1.2f; //帧率
int pExposureTime = 0; //积分时间
int nTriggType = 9; //触发类型,内触发
int nGainIndex = 6; //增益
rtn = API.CR_SetApplicationModeWithParam(DEV_INDEX, MODE_ID, ref pFrameRate, ref pExposureTime, nTriggType, nGainIndex);
LOG.Info(string.Format("CR_SetApplicationModeWithParam({0},{1},{2},{3},{4},{5}) Return {6}", DEV_INDEX, MODE_ID, pFrameRate, pExposureTime, nTriggType, nGainIndex, rtn));
if (rtn != 0) return false;
return true;
} }
/// <summary> /// <summary>
/// 加载RAW图片 /// 关闭设备
/// </summary> /// </summary>
/// <param name="filePath"></param> /// <returns></returns>
public void LoadRAW(string filePath) public bool Close()
{ {
//byte[] src = System.IO.File.ReadAllBytes(filePath); int rtn;
//byte[] gray = new byte[WIDTH * HEIGHT];
//for (int i = 0; i < gray.Length; i++) //还在采集图像
//{ if (eventID == API.CR_EventID.CR_EVT_NEW_FRAME)
// gray[i] = src[HEAD + i * 2]; {
//} rtn = API.CR_StopAcquisition(DEV_INDEX);
LOG.Info("CR_StopAcquisition Return " + rtn);
}
//int idx = 0; //关闭设备
//byte[] buff = new byte[gray.Length * 3]; rtn = API.CR_Disconnect(DEV_INDEX);
//for (int i = 0; i < gray.Length; i++) LOG.Info("CR_Disconnect Return " + rtn);
//{ if (rtn != 0) return false;
// buff[idx++] = gray[i];
// buff[idx++] = gray[i];
// buff[idx++] = gray[i];
//}
//Bitmap bmp = new Bitmap(WIDTH, HEIGHT, System.Drawing.Imaging.PixelFormat.Format24bppRgb); return true;
//System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, WIDTH, HEIGHT), System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat); }
//System.Runtime.InteropServices.Marshal.Copy(buff, 0, bmpData.Scan0, bmpData.Stride * HEIGHT);
//bmp.UnlockBits(bmpData);
//return bmp;
/// <summary>
/// 获取图像
/// </summary>
/// <returns></returns>
public bool GetImage()
{
buffer = new byte[ImageWidth * ImageHeight * 2 + HEAD];
for (int i = 0; i < buffer.Length; i++)
buffer[i] = 255;
int rtn;
rtn = API.CR_StartAcquisition(DEV_INDEX, 1, buffer);
LOG.Info("CR_StartAcquisition Return " + rtn);
if (rtn != 0) return false;
System.Threading.Thread.Sleep(5000);
rtn = API.CR_StopAcquisition(DEV_INDEX);
LOG.Info("CR_StopAcquisition Return " + rtn);
if (rtn != 0) return false;
src = System.IO.File.ReadAllBytes(filePath); return true;
WindowWidth = 65536; }
WindowLevel = 32768;
/// <summary>
/// 加载本地RAW图片,64字节头
/// </summary>
/// <param name="filePath"></param>
public void LoadRAW(string filePath)
{
buffer = System.IO.File.ReadAllBytes(filePath);
} }
...@@ -80,10 +179,10 @@ namespace Asa ...@@ -80,10 +179,10 @@ namespace Asa
/// <returns></returns> /// <returns></returns>
public Bitmap Get48bImage() public Bitmap Get48bImage()
{ {
int count = WIDTH * HEIGHT; if (buffer == null) return null;
int count = ImageWidth * ImageHeight;
byte[] gray = new byte[count * 2]; byte[] gray = new byte[count * 2];
Array.Copy(src, HEAD, gray, 0, gray.Length); Array.Copy(buffer, HEAD, gray, 0, gray.Length);
int idx1 = 0; int idx1 = 0;
int idx2 = 0; int idx2 = 0;
...@@ -92,11 +191,6 @@ namespace Asa ...@@ -92,11 +191,6 @@ namespace Asa
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
short point = BitConverter.ToInt16(gray, idx1); short point = BitConverter.ToInt16(gray, idx1);
if (point > 0)
{
}
if (point < WindowLevel - half) if (point < WindowLevel - half)
{ {
buff[idx2++] = 0; buff[idx2++] = 0;
...@@ -105,7 +199,6 @@ namespace Asa ...@@ -105,7 +199,6 @@ namespace Asa
buff[idx2++] = 0; buff[idx2++] = 0;
buff[idx2++] = 0; buff[idx2++] = 0;
buff[idx2++] = 0; buff[idx2++] = 0;
idx1 += 2;
} }
else if (point > WindowLevel + half) else if (point > WindowLevel + half)
{ {
...@@ -115,7 +208,6 @@ namespace Asa ...@@ -115,7 +208,6 @@ namespace Asa
buff[idx2++] = 255; buff[idx2++] = 255;
buff[idx2++] = 255; buff[idx2++] = 255;
buff[idx2++] = 255; buff[idx2++] = 255;
idx1 += 2;
} }
else else
{ {
...@@ -123,156 +215,37 @@ namespace Asa ...@@ -123,156 +215,37 @@ namespace Asa
buff[idx2++] = gray[idx1 + 1]; buff[idx2++] = gray[idx1 + 1];
buff[idx2++] = gray[idx1]; buff[idx2++] = gray[idx1];
buff[idx2++] = gray[idx1 + 1]; buff[idx2++] = gray[idx1 + 1];
buff[idx2++] = gray[idx1++]; buff[idx2++] = gray[idx1];
buff[idx2++] = gray[idx1++]; buff[idx2++] = gray[idx1 + 1];
} }
idx1 += 2;
} }
Bitmap bmp = new Bitmap(WIDTH, HEIGHT, System.Drawing.Imaging.PixelFormat.Format48bppRgb); Bitmap bmp = new Bitmap(ImageWidth, ImageHeight, System.Drawing.Imaging.PixelFormat.Format48bppRgb);
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, WIDTH, HEIGHT), System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat); System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, ImageWidth, ImageHeight), System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat);
System.Runtime.InteropServices.Marshal.Copy(buff, 0, bmpData.Scan0, bmpData.Stride * HEIGHT); Marshal.Copy(buff, 0, bmpData.Scan0, bmpData.Stride * ImageHeight);
bmp.UnlockBits(bmpData); bmp.UnlockBits(bmpData);
return bmp; return bmp;
} }
public Bitmap Get16bImage()
{
int count = WIDTH * HEIGHT;
byte[] gray = new byte[count * 2];
Array.Copy(src, HEAD, gray, 0, gray.Length);
internal void Process(int nEventID, ref API.CR_Event pEvent)
Bitmap bmp = new Bitmap(WIDTH, HEIGHT, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale);
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, WIDTH, HEIGHT), System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat);
Marshal.Copy(gray, 0, bmpData.Scan0, bmpData.Stride * HEIGHT);
bmp.UnlockBits(bmpData);
return bmp;
}
internal void Process(int nEventID, [In, Out] API.CR_Event pEvent)
{ {
eventID = (API.CR_EventID)nEventID;
LOG.Debug(string.Format("nEventID={0} {1}", nEventID, eventID));
Debug.Print("nEventID=" + nEventID); Debug.Print("nEventID=" + nEventID);
//pEvent = IntPtr.Zero;
}
public void GetInfo()
{
int idx = 1;
int rtn;
//CCallbackImp pCallback = new CCallbackImp();
//rtn = API.CR_RegisterEventCallback(pCallback);
//API.CallbackDelegate callback = new API.CallbackDelegate(Process);
//API.CallbackDelegate callback = Process;
//rtn = API.CR_RegisterEventCallbackFun(callback);
//API.CallbackDelegate callback = new API.CallbackDelegate(new CCallbackImp().Process);
//rtn = API.CR_RegisterEventCallback(callback);
rtn = API.CR_Connect(idx);
//rtn = API.CR_GetSystemInformation(idx, out API.CR_SystemInfo pSystemInformation);
//rtn = API.CR_GetDetectorIndexAndIPAddress(out API.CR_DetrIdxAndIPAddr pDetrIdxAndIPAddr, out int pDetrNum);
//int len = Array.FindIndex(pDetrIdxAndIPAddr.szIPAddr, b => b == 0);
//string s = Encoding.ASCII.GetString(pDetrIdxAndIPAddr.szIPAddr, 0, len);
rtn = API.CR_ResetDetector(idx, false);
API.CR_ModeInfo[] pModeInfo = new API.CR_ModeInfo[16];
for (int i = 0; i < pModeInfo.Length; i++)
pModeInfo[i] = new API.CR_ModeInfo();
rtn = API.CR_GetApplicationMode(idx, pModeInfo, out int pModeNum);
//IntPtr ptr = new IntPtr();
//rtn = API.CR_GetApplicationMode(idx, out ptr, out pModeNum);
//IntPtr infosIntptr = Marshal.AllocHGlobal(size * pModeNum);
//API.CR_ModeInfo[] infos = new API.CR_ModeInfo[pModeNum];
//for (int i = 0; i < pModeNum; i++)
//{
// IntPtr aaa = new IntPtr((ptr.ToInt64() + i * size));
// infos[i] = (API.CR_ModeInfo)Marshal.PtrToStructure(aaa, typeof(API.CR_ModeInfo));
//}
//Marshal.FreeHGlobal(ptr);
//DeviceInfoList[i] = (DeviceInfo)Marshal.PtrToStructure(pPonitor, typeof(DeviceInfo));
//API.CR_ModeInfo[] pModeInfo = new API.CR_ModeInfo[pModeNum];
//Marshal.PtrToStructure(ptr, pModeInfo[0]);
//object obj = Marshal.PtrToStructure(ptr, typeof(API.CR_ModeInfo));
//pModeInfo = (API.CR_ModeInfo[])obj;
//byte[] des = new byte[1];
//Marshal.Copy(ptr, des, 0, des.Length);
//rtn = API.CR_SetApplicationMode(idx, pModeInfo[2].nModeID);
float pFrameRate = 1.2f;
int pExposureTime = 1000;
rtn = API.CR_SetApplicationModeWithParam(idx, 103, ref pFrameRate, ref pExposureTime, 9, 6);
byte[] buff = new byte[WIDTH * HEIGHT * 2 + HEAD];
for (int i = 0; i < buff.Length; i++)
buff[i] = 255;
rtn = API.CR_StartAcquisition(idx, 1, buff);
System.Threading.Thread.Sleep(3000);
rtn = API.CR_StopAcquisition(idx);
src = buff;
//byte[] buff = new byte[WIDTH * HEIGHT * 2 + HEAD];
//IntPtr ptr = new IntPtr();
//rtn = API.CR_StartAcquisition(idx, 1, ptr);
//System.Threading.Thread.Sleep(2000);
//rtn = API.CR_StopAcquisition(idx);
//Marshal.Copy(ptr, buff, 0, buff.Length);
}
rtn = API.CR_Disconnect(idx);
} }
}
internal class CCallbackImp : API.ICallback
{
internal override void Process(int nEventID, IntPtr pEvent)
{
Debug.Print("nEventID=" + nEventID);
}
}
internal static class API internal static class API
{ {
...@@ -292,47 +265,28 @@ namespace Asa ...@@ -292,47 +265,28 @@ namespace Asa
internal static extern int CR_StartAcquisition(int nDetrIndex, int nFrameNum, [In, Out] byte[] pBuffer, int nNumFrmReqFromDetr = -1); // nNumFrmReqFromDetr == -1 means that detector sends out frames continuously until StopAcquisition() is received. internal static extern int CR_StartAcquisition(int nDetrIndex, int nFrameNum, [In, Out] byte[] pBuffer, int nNumFrmReqFromDetr = -1); // nNumFrmReqFromDetr == -1 means that detector sends out frames continuously until StopAcquisition() is received.
[DllImport("CRInterface.dll")] [DllImport("CRInterface.dll")]
internal static extern int CR_StartAcquisition(int nDetrIndex, int nFrameNum, [In,Out] IntPtr pBuffer, int nNumFrmReqFromDetr = -1); // nNumFrmReqFromDetr == -1 means that detector sends out frames continuously until StopAcquisition() is received.
[DllImport("CRInterface.dll")]
internal static extern int CR_StopAcquisition(int nDetrIndex); internal static extern int CR_StopAcquisition(int nDetrIndex);
[DllImport("CRCallback.dll")] [DllImport("CRCallback.dll")]
internal static extern int CR_RegisterEventCallbackFun(CallbackDelegate pCallback); internal static extern int CR_RegisterEventCallbackFun(int nDetrIndex, CallbackDelegate pCallback);
[DllImport("CRInterface.dll")]
internal static extern int CR_RegisterEventCallback(CallbackDelegate pCallback);
[DllImport("CRInterface.dll")] [DllImport("CRInterface.dll")]
internal static extern int CR_SetApplicationMode(int nDetrIndex, int nModeIndex); internal static extern int CR_SetApplicationMode(int nDetrIndex, int nModeIndex);
//[DllImport("CRInterface.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
[DllImport("CRInterface.dll")] [DllImport("CRInterface.dll")]
internal static extern int CR_GetApplicationMode(int nDetrIndex, [In, Out] CR_ModeInfo[] pModeInfo, out int pModeNum); internal static extern int CR_GetApplicationMode(int nDetrIndex, [In, Out] CR_ModeInfo[] pModeInfo, out int pModeNum);
[DllImport("CRInterface.dll")] [DllImport("CRInterface.dll")]
internal static extern int CR_GetDetectorIndexAndIPAddress(out CR_DetrIdxAndIPAddr pDetrIdxAndIPAddr, out int pDetrNum); internal static extern int CR_GetDetectorIndexAndIPAddress(out CR_DetrIdxAndIPAddr pDetrIdxAndIPAddr, out int pDetrNum);
[DllImport("CRInterface.dll")] [DllImport("CRInterface.dll")]
internal static extern int CR_SetApplicationModeWithParam(int nDetrIndex, int nModeIndex, ref float pFrameRate, ref int pExposureTime, int nTriggType, int nGainIndex); internal static extern int CR_SetApplicationModeWithParam(int nDetrIndex, int nModeIndex, ref float pFrameRate, ref int pExposureTime, int nTriggType, int nGainIndex);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CallbackDelegate(int nEventID, ref CR_Event pEvent);
//CARERAY_API_PORT int CR_GetDetrStatus(int nDetrIndex, CR_DetrStatus* pDetrStatus);
//CARERAY_API_PORT int CR_StartDarkCalibration(int nDetrIndex);
//CARERAY_API_PORT int CR_StartGainCalibration(int nDetrIndex);
//CARERAY_API_PORT int CR_StopCalibration(int nDetrIndex);
//CARERAY_API_PORT int CR_QueryCalibrationStatus(int nDetrIndex, CR_CalibrationInfo* pCalProgInfo);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CallbackDelegate(int nEventID, [In, Out] CR_Event pEvent);
internal abstract class ICallback
{
internal abstract void Process(int nEventID, IntPtr pEvent);
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct CR_Event internal struct CR_Event
...@@ -395,13 +349,31 @@ namespace Asa ...@@ -395,13 +349,31 @@ namespace Asa
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct CR_DetrIdxAndIPAddr internal struct CR_DetrIdxAndIPAddr
{ {
internal int nIdx; // Detector index internal int nIdx;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
internal byte[] szIPAddr; // Associated IP address internal byte[] szIPAddr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
internal byte[] szReserved; internal byte[] szReserved;
} }
}
internal enum CR_EventID
{
CR_EVT_SERVER_DISCONNECTED,
CR_EVT_DETR_DISCONNECTED,
CR_EVT_EXPOSURE_INFO,
CR_EVT_TEMPERATURE_INFO,
CR_EVT_BATTERY_INFO,
CR_EVT_WIRELESS_INFO,
CR_EVT_NEW_FRAME,
CR_EVT_CALIBRATION_IN_PROGRESS,
CR_EVT_CALIBRATION_FINISHED,
CR_EVT_ACQ_STAT_INFO
};
}
} }
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
Careray平板图像 Careray平板图像
</summary> </summary>
</member> </member>
<member name="M:Asa.CarerayImage.#ctor(System.String)">
<summary>
Careray平板图像
</summary>
</member>
<member name="P:Asa.CarerayImage.WindowWidth"> <member name="P:Asa.CarerayImage.WindowWidth">
<summary> <summary>
窗宽 窗宽
...@@ -19,14 +24,42 @@ ...@@ -19,14 +24,42 @@
窗位 窗位
</summary> </summary>
</member> </member>
<member name="M:Asa.CarerayImage.#ctor"> <member name="P:Asa.CarerayImage.ImageWidth">
<summary> <summary>
Careray平板图像 图像宽度
</summary>
</member>
<member name="P:Asa.CarerayImage.ImageHeight">
<summary>
图像高度
</summary>
</member>
<member name="P:Asa.CarerayImage.IP">
<summary>
IP地址
</summary> </summary>
</member> </member>
<member name="M:Asa.CarerayImage.Open">
<summary>
打开设备
</summary>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.Close">
<summary>
关闭设备
</summary>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.GetImage">
<summary>
获取图像
</summary>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.LoadRAW(System.String)"> <member name="M:Asa.CarerayImage.LoadRAW(System.String)">
<summary> <summary>
加载RAW图片 加载RAW图片,64字节头
</summary> </summary>
<param name="filePath"></param> <param name="filePath"></param>
</member> </member>
......
11dc75aa0263ba3fdb386f7d2a0420e585931dd4 f1f9c56bb7e07e8ee867fbe9a762cde9bc21bb47
...@@ -11,4 +11,5 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\C ...@@ -11,4 +11,5 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\C
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\obj\Debug\CarerayImage.csproj.CoreCompileInputs.cache D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\obj\Debug\CarerayImage.csproj.CoreCompileInputs.cache
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\obj\Debug\Asa.CarerayImage.dll D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\obj\Debug\Asa.CarerayImage.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\obj\Debug\Asa.CarerayImage.pdb D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\obj\Debug\Asa.CarerayImage.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\obj\Debug\CarerayImage.csprojAssemblyReference.cache D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\bin\Debug\log4net.dll
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage\obj\Debug\CarerayImage.csproj.CopyComplete
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<log4net>
<appender name="CarerayImage" type="log4net.Appender.RollingFileAppender">
<file value="logs/CarerayImage.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<root>
<level value="Debug"/>
<appender-ref ref="CarerayImage"/>
</root>
</log4net>
</configuration> </configuration>
\ No newline at end of file \ No newline at end of file
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net">
<HintPath>..\..\..\..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
...@@ -42,11 +45,11 @@ ...@@ -42,11 +45,11 @@
// //
// button1 // button1
// //
this.button1.Location = new System.Drawing.Point(12, 12); this.button1.Location = new System.Drawing.Point(12, 165);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(97, 35); this.button1.Size = new System.Drawing.Size(97, 26);
this.button1.TabIndex = 0; this.button1.TabIndex = 0;
this.button1.Text = "button1"; this.button1.Text = "打开文件";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click); this.button1.Click += new System.EventHandler(this.button1_Click);
// //
...@@ -55,9 +58,9 @@ ...@@ -55,9 +58,9 @@
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.Location = new System.Drawing.Point(135, 12); this.pictureBox1.Location = new System.Drawing.Point(115, 12);
this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(653, 426); this.pictureBox1.Size = new System.Drawing.Size(673, 426);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 1; this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
...@@ -118,19 +121,52 @@ ...@@ -118,19 +121,52 @@
// //
// button2 // button2
// //
this.button2.Location = new System.Drawing.Point(23, 230); this.button2.Location = new System.Drawing.Point(12, 197);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23); this.button2.Size = new System.Drawing.Size(97, 26);
this.button2.TabIndex = 6; this.button2.TabIndex = 6;
this.button2.Text = "button2"; this.button2.Text = "打开设备";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click); this.button2.Click += new System.EventHandler(this.button2_Click);
// //
// button3
//
this.button3.Location = new System.Drawing.Point(12, 229);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(97, 26);
this.button3.TabIndex = 7;
this.button3.Text = "关闭设备";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(12, 261);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(97, 26);
this.button4.TabIndex = 8;
this.button4.Text = "获取图像";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(12, 293);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(97, 26);
this.button5.TabIndex = 9;
this.button5.Text = "保存图像";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
...@@ -158,6 +194,9 @@ ...@@ -158,6 +194,9 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
} }
} }
...@@ -12,7 +12,8 @@ namespace CarerayImage_Test ...@@ -12,7 +12,8 @@ namespace CarerayImage_Test
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
Asa.CarerayImage careray; private Asa.CarerayImage careray;
private Bitmap bmp;
public Form1() public Form1()
{ {
...@@ -30,19 +31,10 @@ namespace CarerayImage_Test ...@@ -30,19 +31,10 @@ namespace CarerayImage_Test
if (dlg.ShowDialog() == DialogResult.Cancel) return; if (dlg.ShowDialog() == DialogResult.Cancel) return;
careray.LoadRAW(dlg.FileName); careray.LoadRAW(dlg.FileName);
//pictureBox1.Image = careray.Get48bImage(); careray.WindowWidth = Convert.ToInt32(numericUpDown1.Value);
Bitmap bmp = careray.Get48bImage(); careray.WindowLevel = Convert.ToInt32(numericUpDown2.Value);
bmp = careray.Get48bImage();
pictureBox1.Image = bmp; pictureBox1.Image = bmp;
//Bitmap bmp = careray.Get16bImage();
//bmp.Save(@"C:\Users\neotel\Desktop\20200520X-ray\11.png", System.Drawing.Imaging.ImageFormat.Png);
} }
private void numericUpDown1_ValueChanged(object sender, EventArgs e) private void numericUpDown1_ValueChanged(object sender, EventArgs e)
...@@ -59,13 +51,31 @@ namespace CarerayImage_Test ...@@ -59,13 +51,31 @@ namespace CarerayImage_Test
private void button2_Click(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e)
{ {
careray.GetInfo(); bool rtn = careray.Open();
Bitmap bmp = careray.Get48bImage(); MessageBox.Show(rtn.ToString());
pictureBox1.Image = bmp;
bmp.Save(@"C:\Users\neotel\Desktop\20200520X-ray\22.png", System.Drawing.Imaging.ImageFormat.Png);
} }
private void button3_Click(object sender, EventArgs e)
{
bool rtn = careray.Close();
MessageBox.Show(rtn.ToString());
}
private void button4_Click(object sender, EventArgs e)
{
careray.GetImage();
careray.WindowWidth = Convert.ToInt32(numericUpDown1.Value);
careray.WindowLevel = Convert.ToInt32(numericUpDown2.Value);
bmp = careray.Get48bImage();
pictureBox1.Image = bmp;
}
private void button5_Click(object sender, EventArgs e)
{
bmp.Save(Application.StartupPath + string.Format("\\{0:HHmmss}", DateTime.Now) + ".png", System.Drawing.Imaging.ImageFormat.Png);
}
} }
} }
using System; using log4net.Config;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -14,6 +15,7 @@ namespace CarerayImage_Test ...@@ -14,6 +15,7 @@ namespace CarerayImage_Test
[STAThread] [STAThread]
static void Main() static void Main()
{ {
XmlConfigurator.Configure();
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); Application.Run(new Form1());
......
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
Careray平板图像 Careray平板图像
</summary> </summary>
</member> </member>
<member name="M:Asa.CarerayImage.#ctor(System.String)">
<summary>
Careray平板图像
</summary>
</member>
<member name="P:Asa.CarerayImage.WindowWidth"> <member name="P:Asa.CarerayImage.WindowWidth">
<summary> <summary>
窗宽 窗宽
...@@ -19,14 +24,42 @@ ...@@ -19,14 +24,42 @@
窗位 窗位
</summary> </summary>
</member> </member>
<member name="M:Asa.CarerayImage.#ctor"> <member name="P:Asa.CarerayImage.ImageWidth">
<summary> <summary>
Careray平板图像 图像宽度
</summary>
</member>
<member name="P:Asa.CarerayImage.ImageHeight">
<summary>
图像高度
</summary>
</member>
<member name="P:Asa.CarerayImage.IP">
<summary>
IP地址
</summary> </summary>
</member> </member>
<member name="M:Asa.CarerayImage.Open">
<summary>
打开设备
</summary>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.Close">
<summary>
关闭设备
</summary>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.GetImage">
<summary>
获取图像
</summary>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.LoadRAW(System.String)"> <member name="M:Asa.CarerayImage.LoadRAW(System.String)">
<summary> <summary>
加载RAW图片 加载RAW图片,64字节头
</summary> </summary>
<param name="filePath"></param> <param name="filePath"></param>
</member> </member>
......
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<log4net>
<appender name="CarerayImage" type="log4net.Appender.RollingFileAppender">
<file value="logs/CarerayImage.log"/>
<param name="Encoding" value="UTF-8"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyy-MM-dd"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n"/>
</layout>
</appender>
<root>
<level value="Debug"/>
<appender-ref ref="CarerayImage"/>
</root>
</log4net>
</configuration> </configuration>
\ No newline at end of file \ No newline at end of file
# 设置root logger为DEBUG级别,使用了ca和fa两个Appender # 设置root logger为DEBUG级别,使用了ca和fa两个Appender
# log4j.rootLogger=DEBUG, ca, fa # log4j.rootLogger=DEBUG, ca, fa
log4j.rootLogger=DEBUG,fa log4j.rootLogger=WARN,fa
#test version #test version
#对Appender fa进行设置: #对Appender fa进行设置:
# 这是一个文件类型的Appender, # 这是一个文件类型的Appender,
...@@ -24,7 +24,7 @@ log4j.appender.ca=org.apache.log4j.ConsoleAppender ...@@ -24,7 +24,7 @@ log4j.appender.ca=org.apache.log4j.ConsoleAppender
log4j.appender.ca.layout=org.apache.log4j.PatternLayout log4j.appender.ca.layout=org.apache.log4j.PatternLayout
log4j.appender.ca.layout.ConversionPattern=%d | %-5p | [%t] | %m%n log4j.appender.ca.layout.ConversionPattern=%d | %-5p | [%t] | %m%n
log4j.logger.error=DEBUG, fa2 log4j.logger.error=WARN, fa2
log4j.additivity.error=true log4j.additivity.error=true
log4j.appender.fa2=org.apache.log4j.DailyRollingFileAppender log4j.appender.fa2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.fa2.DatePattern='./log/'yyyy-MM-dd'_error.log' log4j.appender.fa2.DatePattern='./log/'yyyy-MM-dd'_error.log'
......
0bdc60cf636ca9d6e9d721d157aa36b80a9e2a56 487d9744c608fc98d0fead4ea4a92cd34a5cf295
...@@ -26,3 +26,4 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\C ...@@ -26,3 +26,4 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\C
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage_Test\obj\Debug\CarerayImage_Test.csproj.CopyComplete D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage_Test\obj\Debug\CarerayImage_Test.csproj.CopyComplete
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage_Test\obj\Debug\CarerayImage_Test.exe D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage_Test\obj\Debug\CarerayImage_Test.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage_Test\obj\Debug\CarerayImage_Test.pdb D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage_Test\obj\Debug\CarerayImage_Test.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\AutoCountMachine\CarerayImage\CarerayImage_Test\bin\Debug\log4net.dll
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!