|
@@ -33,8 +33,6 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
{
|
|
{
|
|
|
public event Action<string> MessageEvent;
|
|
public event Action<string> MessageEvent;
|
|
|
|
|
|
|
|
- public event Action<string, int, int> AddPicEvent;
|
|
|
|
|
-
|
|
|
|
|
public event Action OpenVideoEvent;
|
|
public event Action OpenVideoEvent;
|
|
|
|
|
|
|
|
// M1-B2:调试页不再 new ComBin/new Camera 开第二个物理串口/相机。
|
|
// M1-B2:调试页不再 new ComBin/new Camera 开第二个物理串口/相机。
|
|
@@ -847,194 +845,8 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
CurrentFocal = 1;
|
|
CurrentFocal = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// 单张抓拍
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- public bool SavePic(string fullName)
|
|
|
|
|
- {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- if (GetPicData() == 0)
|
|
|
|
|
- {
|
|
|
|
|
- if (Cam == null) return false;
|
|
|
|
|
- // M8-G3-1:单张抓拍落盘为相机采图+保存命令入口,补操作日志埋点(module=对焦调试)。
|
|
|
|
|
- // 批量抓图(水平抓图/清晰图层抓图)经 Begin scope 调用时,本埋点自动成为其子埋点(父子链)。
|
|
|
|
|
- return Aivfo.OperationLog.OperationLogger.Run("对焦调试", "单张抓拍",
|
|
|
|
|
- () => Cam.SavePic(fullName, CurrentHouse.ccdWidth, CurrentHouse.ccdHeight),
|
|
|
|
|
- input: new { houseSn = CurrentHouseId, well = CurrentWell, focal = CurrentFocal, hor = CurrentHor, ver = CurrentVer });
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- catch (Exception ex)
|
|
|
|
|
- {
|
|
|
|
|
- AppData.Instance.LogHelper.ExceptionLog(ex, $"单张抓拍", LogEnum.RunException);
|
|
|
|
|
- AddMessageInfo($"单张抓拍异常:{ex.Message}");
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// 水平抓图
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- public void ShuiPingZhuaPai()
|
|
|
|
|
- {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- IsStop = false;
|
|
|
|
|
- if (Serial == null) return;
|
|
|
|
|
- if (IsStop) return;
|
|
|
|
|
- // M8-G3-1:水平抓图为多步循环采图流程,用 Begin scope 串联各 well 抓拍子埋点(module=对焦调试)。
|
|
|
|
|
- using var _op = Aivfo.OperationLog.OperationLogger.Begin("对焦调试", "水平抓图",
|
|
|
|
|
- houseSn: CurrentHouseId);
|
|
|
|
|
- try { _op.Input(new { houseSn = CurrentHouseId }); } catch { }
|
|
|
|
|
- Serial.HorizontalResetWait(tLSetting.motorDelay);
|
|
|
|
|
- CurrentHor = 0;
|
|
|
|
|
- CurrentWell = 0;
|
|
|
|
|
- HouseWellSetting currentHorSetting = null;
|
|
|
|
|
-
|
|
|
|
|
- string dtnow = string.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now); //24小时制
|
|
|
|
|
- string path = AppData.Instance.LogHelper.GetDeBugShuiPingDirectory(CurrentHouse.houseSn, dtnow);
|
|
|
|
|
-
|
|
|
|
|
- if (!Directory.Exists(path))
|
|
|
|
|
- {
|
|
|
|
|
- Directory.CreateDirectory(path);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 1; i <= 16; i++)
|
|
|
|
|
- {
|
|
|
|
|
- currentHorSetting = houseWellSettingList.FirstOrDefault(x => x.houseSn == CurrentHouseId && x.wellSn == i);
|
|
|
|
|
- if (currentHorSetting == null)
|
|
|
|
|
- {
|
|
|
|
|
- AddMessageInfo($"[未获取到1号well的水平电机位置]");
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- if (IsStop) return;
|
|
|
|
|
- if (Serial == null) return;
|
|
|
|
|
- Serial.HorizontalMoveToWait(currentHorSetting.horizontalMotorPosition, tLSetting.motorDelay);
|
|
|
|
|
- if (IsStop) return;
|
|
|
|
|
- CurrentHor = currentHorSetting.horizontalMotorPosition;
|
|
|
|
|
- CurrentWell = i;
|
|
|
|
|
-
|
|
|
|
|
- string filename = $"{dtnow}-house{CurrentHouse.houseSn}-well{CurrentWell}-{CurrentFocal}-{CurrentHor}-{CurrentVer}.jpg";
|
|
|
|
|
-
|
|
|
|
|
- string fullName = $"{path}{filename}";
|
|
|
|
|
- if (Cam == null) return;
|
|
|
|
|
- if (SavePic(fullName))
|
|
|
|
|
- {
|
|
|
|
|
- AddPic(fullName);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- catch (Exception ex)
|
|
|
|
|
- {
|
|
|
|
|
- AppData.Instance.LogHelper.ExceptionLog(ex, $"水平抓拍", LogEnum.RunException);
|
|
|
|
|
- AddMessageInfo($"水平抓拍异常:{ex.Message}");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// 清晰图层抓图
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- public async Task AutoFocusPic(int focalCount, int xun)
|
|
|
|
|
- {
|
|
|
|
|
- await Task.Run(async () =>
|
|
|
|
|
- {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- IsStop = false;
|
|
|
|
|
-
|
|
|
|
|
- var startAutoFocus = -1;
|
|
|
|
|
- var cc = ccdPhoto.FirstOrDefault(x => x.houseSn == CurrentHouseId && x.wellSn == CurrentWell);
|
|
|
|
|
- if (cc == null)
|
|
|
|
|
- {
|
|
|
|
|
- AddMessageInfo($"[未获取到{CurrentWell}号well的自动对焦起点]");
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- // M8-G3-1:清晰图层抓图为多步循环采图流程,用 Begin scope 串联各层抓拍子埋点(module=对焦调试)。
|
|
|
|
|
- using var _op = Aivfo.OperationLog.OperationLogger.Begin("对焦调试", "清晰图层抓图",
|
|
|
|
|
- houseSn: CurrentHouseId);
|
|
|
|
|
- try { _op.Input(new { houseSn = CurrentHouseId, well = CurrentWell, focalCount, xun }); } catch { }
|
|
|
|
|
- startAutoFocus = cc.autoFocusPosition;
|
|
|
|
|
- string dtnow = string.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now); //24小时制
|
|
|
|
|
- string path = null;
|
|
|
|
|
- string fullName = null;
|
|
|
|
|
- for (int k = 0; k < xun; k++)
|
|
|
|
|
- {
|
|
|
|
|
- if (IsStop) return;
|
|
|
|
|
- if (Serial == null) return;
|
|
|
|
|
- Serial.VerticalResetWait(tLSetting.motorDelay);
|
|
|
|
|
- CurrentVer = 0;
|
|
|
|
|
- CurrentFocal = 0;
|
|
|
|
|
- var verSpacePulse = 128;
|
|
|
|
|
- if (CurrentHouse.verticalMotorSpacePulse.HasValue) verSpacePulse = CurrentHouse.verticalMotorSpacePulse.Value;
|
|
|
|
|
- path = $"{AppData.Instance.LogHelper.GetDeBugQingXiDirectory(CurrentHouse.houseSn, CurrentWell, dtnow)}{(k + 1)}_{CurrentHor}";
|
|
|
|
|
- if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
|
|
|
- for (int i = 0; i < focalCount; i++)
|
|
|
|
|
- {
|
|
|
|
|
- CurrentFocal = i + 1;
|
|
|
|
|
- var currentVerValue = startAutoFocus + (i * verSpacePulse);
|
|
|
|
|
- if (IsStop) return;
|
|
|
|
|
- if (Serial == null) return;
|
|
|
|
|
- if(currentVerValue > tLSetting.verticalMotorPulseMax)
|
|
|
|
|
- {
|
|
|
|
|
- AddMessageInfo($"清晰图层抓图超出垂直电机上限:{tLSetting.verticalMotorPulseMax}");
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- Serial.VerticalMoveToWait(currentVerValue, tLSetting.motorDelay);
|
|
|
|
|
- CurrentVer = currentVerValue;
|
|
|
|
|
- fullName = $"{path}\\{currentVerValue}.jpg";
|
|
|
|
|
- if (IsStop) return;
|
|
|
|
|
- if (Cam == null) return;
|
|
|
|
|
- if (SavePic(fullName)) AddPic(fullName);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- catch (Exception ex)
|
|
|
|
|
- {
|
|
|
|
|
- AppData.Instance.LogHelper.ExceptionLog(ex, $"清晰图层抓图", LogEnum.RunException);
|
|
|
|
|
- AddMessageInfo($"清晰图层抓图异常:{ex.Message}");
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// 抓图
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- public int GetPicData()
|
|
|
|
|
- {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- if (Cam == null) return -1;
|
|
|
|
|
- int GetRgbData = -1;
|
|
|
|
|
- bool isWuTu = false;
|
|
|
|
|
-
|
|
|
|
|
- if (isWuTu)
|
|
|
|
|
- {
|
|
|
|
|
- GetRgbData = Cam.GrabRaw();//获取字节流
|
|
|
|
|
-
|
|
|
|
|
- AddMessageInfo($"[抓拍结果:{GetRgbData}][注:0表示成功]");
|
|
|
|
|
-
|
|
|
|
|
- if (GetRgbData == 0)
|
|
|
|
|
- {
|
|
|
|
|
- GetRgbData = Cam.RawToRgb();
|
|
|
|
|
- AddMessageInfo($"[rawToRgb结果:{GetRgbData}][注:0表示成功]");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- GetRgbData = Cam.GrabRgb();//获取字节流
|
|
|
|
|
- AddMessageInfo($"[抓拍结果:{GetRgbData}][注:0表示成功]");
|
|
|
|
|
- }
|
|
|
|
|
- return GetRgbData;
|
|
|
|
|
- }
|
|
|
|
|
- catch (Exception ex)
|
|
|
|
|
- {
|
|
|
|
|
- AppData.Instance.LogHelper.ExceptionLog(ex, $"调试模式抓拍", LogEnum.RunException);
|
|
|
|
|
- AddMessageInfo($"相机抓拍异常:{ex.Message}");
|
|
|
|
|
- return -1;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 旧抓图流程(单张抓拍 SavePic / 水平抓图 ShuiPingZhuaPai / 清晰图层抓图 AutoFocusPic /
|
|
|
|
|
+ // 取帧 helper GetPicData)已移除——调试页画面改用 control 端 MJPEG 实时预览(MjpegStreamClient)。
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
#region 相机操作
|
|
#region 相机操作
|
|
@@ -1213,10 +1025,6 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
MessageEvent?.Invoke(mess);
|
|
MessageEvent?.Invoke(mess);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void AddPic(string picFullName)
|
|
|
|
|
- {
|
|
|
|
|
- AddPicEvent?.Invoke(picFullName, CurrentWell, CurrentFocal);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
#region 场景A 一键全自动标定(经 control 协作,D2-02-T3.4 重构)
|
|
#region 场景A 一键全自动标定(经 control 协作,D2-02-T3.4 重构)
|
|
|
|
|
|