|
@@ -25,7 +25,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
#region 字段
|
|
#region 字段
|
|
|
private Thread m_hReceiveThread;
|
|
private Thread m_hReceiveThread;
|
|
|
// 用于序列化对同一相机实例的操作,防止同一实例被并发操作
|
|
// 用于序列化对同一相机实例的操作,防止同一实例被并发操作
|
|
|
- private readonly SemaphoreSlim _operationSemaphore = new SemaphoreSlim(1, 1);
|
|
|
|
|
|
|
+ //private readonly SemaphoreSlim _operationSemaphore = new SemaphoreSlim(1, 1);
|
|
|
// 用于保护状态变量(例如 IsGrabbing)的并发访问
|
|
// 用于保护状态变量(例如 IsGrabbing)的并发访问
|
|
|
private readonly object _stateLock = new object();
|
|
private readonly object _stateLock = new object();
|
|
|
#endregion
|
|
#endregion
|
|
@@ -275,7 +275,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
/// <exception cref="Exception"></exception>
|
|
/// <exception cref="Exception"></exception>
|
|
|
public bool OpenDevice()
|
|
public bool OpenDevice()
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Wait();
|
|
|
|
|
|
|
+ //_operationSemaphore.Wait();
|
|
|
uint nReVal = SciCam.SCI_CAMERA_OK;
|
|
uint nReVal = SciCam.SCI_CAMERA_OK;
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
@@ -357,7 +357,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -379,14 +379,14 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
public void CloseDevice()
|
|
public void CloseDevice()
|
|
|
{
|
|
{
|
|
|
// ch:关闭设备 | en:Close Device
|
|
// ch:关闭设备 | en:Close Device
|
|
|
- _operationSemaphore.Wait();
|
|
|
|
|
|
|
+ //_operationSemaphore.Wait();
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
mvCameraAcq.CloseDevice();
|
|
mvCameraAcq.CloseDevice();
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -396,7 +396,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
public ICogImage Grab()
|
|
public ICogImage Grab()
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Wait();
|
|
|
|
|
|
|
+ //_operationSemaphore.Wait();
|
|
|
uint nReVal = SciCam.SCI_CAMERA_OK;
|
|
uint nReVal = SciCam.SCI_CAMERA_OK;
|
|
|
IntPtr payload = IntPtr.Zero;
|
|
IntPtr payload = IntPtr.Zero;
|
|
|
try
|
|
try
|
|
@@ -424,7 +424,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
{
|
|
{
|
|
|
nReVal = mvCameraAcq.FreePayload(payload);
|
|
nReVal = mvCameraAcq.FreePayload(payload);
|
|
|
nReVal = mvCameraAcq.StopGrabbing();
|
|
nReVal = mvCameraAcq.StopGrabbing();
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
CloseDevice();
|
|
CloseDevice();
|
|
|
OpenDevice();
|
|
OpenDevice();
|
|
|
ErrorMessage = "图像采集失败!";
|
|
ErrorMessage = "图像采集失败!";
|
|
@@ -432,7 +432,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
CloseDevice();
|
|
CloseDevice();
|
|
|
OpenDevice();
|
|
OpenDevice();
|
|
|
ErrorMessage = ex.Message;
|
|
ErrorMessage = ex.Message;
|
|
@@ -447,7 +447,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -497,7 +497,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
public bool SetExposureTime(float ExposureTime)
|
|
public bool SetExposureTime(float ExposureTime)
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Wait();
|
|
|
|
|
|
|
+ //_operationSemaphore.Wait();
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
if (!mvCameraAcq.IsDeviceOpen())
|
|
if (!mvCameraAcq.IsDeviceOpen())
|
|
@@ -512,7 +512,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -522,7 +522,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
public float GetExposureTime()
|
|
public float GetExposureTime()
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Wait();
|
|
|
|
|
|
|
+ //_operationSemaphore.Wait();
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
if (!mvCameraAcq.IsDeviceOpen())
|
|
if (!mvCameraAcq.IsDeviceOpen())
|
|
@@ -551,7 +551,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -562,7 +562,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
public bool SetGain(float Gain)
|
|
public bool SetGain(float Gain)
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Wait();
|
|
|
|
|
|
|
+ //_operationSemaphore.Wait();
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
if (!mvCameraAcq.IsDeviceOpen())
|
|
if (!mvCameraAcq.IsDeviceOpen())
|
|
@@ -577,7 +577,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -587,7 +587,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
public float GetGain()
|
|
public float GetGain()
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Wait();
|
|
|
|
|
|
|
+ //_operationSemaphore.Wait();
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
if (!mvCameraAcq.IsDeviceOpen())
|
|
if (!mvCameraAcq.IsDeviceOpen())
|
|
@@ -615,7 +615,7 @@ namespace TeamAAS_VP.Core.Cameras
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
|
- _operationSemaphore.Release();
|
|
|
|
|
|
|
+ //_operationSemaphore.Release();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|