From e33a8aa1dd7b9d0a29cc38a38f40d0308aa9dcf4 Mon Sep 17 00:00:00 2001
From: C3032 <C3032@BC3032>
Date: 星期五, 09 一月 2026 10:08:09 +0800
Subject: [PATCH] 冲突解决
---
LB_VisionProcesses/Cameras/LBCameras/LBCamera.cs | 69 +++++++++++++++++++++++++++++++---
1 files changed, 63 insertions(+), 6 deletions(-)
diff --git a/LB_VisionProcesses/Cameras/LBCameras/LBCamera.cs b/LB_VisionProcesses/Cameras/LBCameras/LBCamera.cs
index 0594010..6e27e23 100644
--- a/LB_VisionProcesses/Cameras/LBCameras/LBCamera.cs
+++ b/LB_VisionProcesses/Cameras/LBCameras/LBCamera.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
+using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
@@ -310,8 +311,8 @@
public override bool SetExpouseTime(double value) => SetParam(EnumNameId.ExposureTime, (float)value);
public override bool GetExpouseTime(out double value) { float v; bool r = GetParam(EnumNameId.ExposureTime, out v); value = v; return r; }
- public override bool SetGain(double gain) => SetParam(EnumNameId.AnalogGain, (float)gain);
- public override bool GetGain(out double gain) { float v; bool r = GetParam(EnumNameId.AnalogGain, out v); gain = v; return r; }
+ public override bool SetGain(double gain) => SetParam(EnumNameId.AnalogGain, (int)gain);
+ public override bool GetGain(out double gain) { int v; bool r = GetParam(EnumNameId.AnalogGain, out v); gain = v; return r; }
public override bool SetTriggerMode(TriggerMode mode, TriggerSource triggerEnum = TriggerSource.Line0)
{
@@ -588,13 +589,49 @@
private void SyncConfigFromCamera()
{
- foreach (EnumNameId id in Enum.GetValues(typeof(EnumNameId)))
+ try
{
- int iVal = 0; double dVal = 0; int eVal = 0;
- if (PHM6000Profiler.GetProfilerParameter(_cameraHandle, (int)id, ref iVal, ref dVal, ref eVal) == 0)
+ if (!_isConnected) return;
+
+ PropertyInfo[] props = _sensorConfig.GetType().GetProperties();
+ foreach (PropertyInfo p in props)
{
- // Update _sensorConfig values here if needed
+ // 璺宠繃鑷畾涔夊弬鏁�
+ var iscustomAttr = p.GetCustomAttribute<IsCustomAttribute>();
+ if (iscustomAttr != null) continue;
+
+ if (Enum.TryParse(typeof(EnumNameId), p.Name, out object nameIdObj))
+ {
+ EnumNameId nameId = (EnumNameId)nameIdObj;
+ int intValue = 0;
+ double doubleValue = 0;
+ int enumValue = 0;
+
+ if (PHM6000Profiler.GetProfilerParameter(_cameraHandle, (int)nameId, ref intValue, ref doubleValue, ref enumValue) == 0)
+ {
+ if (p.PropertyType == typeof(int))
+ {
+ p.SetValue(_sensorConfig, intValue);
+ }
+ else if (p.PropertyType == typeof(float))
+ {
+ p.SetValue(_sensorConfig, (float)doubleValue);
+ }
+ else if (p.PropertyType == typeof(double))
+ {
+ p.SetValue(_sensorConfig, doubleValue);
+ }
+ else // Enum or other types
+ {
+ p.SetValue(_sensorConfig, enumValue);
+ }
+ }
+ }
}
+ }
+ catch (Exception ex)
+ {
+ AsyncLogHelper.Error($"LBCamera: SyncConfigFromCamera error - {ex.Message}");
}
}
@@ -602,6 +639,13 @@
{
if (!_isConnected) return false;
return PHM6000Profiler.SetProfilerParameter(_cameraHandle, (int)id, 0, value, 0) == 0;
+ }
+
+ private bool SetParam(EnumNameId id, int value)
+ {
+ if (!_isConnected) return false;
+ // 瀵逛簬鏋氫妇绫诲瀷锛岄�氬父閫氳繃 enumValue (鏈�鍚庝竴涓弬鏁�) 浼犻��
+ return PHM6000Profiler.SetProfilerParameter(_cameraHandle, (int)id, 0, 0, value) == 0;
}
private bool GetParam(EnumNameId id, out float value)
@@ -616,6 +660,19 @@
}
return false;
}
+
+ private bool GetParam(EnumNameId id, out int value)
+ {
+ value = 0;
+ if (!_isConnected) return false;
+ int iVal = 0; double dVal = 0; int eVal = 0;
+ if (PHM6000Profiler.GetProfilerParameter(_cameraHandle, (int)id, ref iVal, ref dVal, ref eVal) == 0)
+ {
+ value = eVal; // Assuming it returns in enumValue
+ return true;
+ }
+ return false;
+ }
#endregion
}
}
\ No newline at end of file
--
Gitblit v1.9.3