Просмотр исходного кода

feat(d2-02-t3): 删调试页旧抓图按钮/流程(SavePic/ShuiPingZhuaPai/AutoFocusPic,用户确认不要;画面改用MJPEG预览)

- VM: 删 SavePic/ShuiPingZhuaPai/AutoFocusPic/GetPicData + AddPic 方法 + AddPicEvent 事件(删后全工程无引用)
- View.xaml.cs: 删 GetPic_Click/ShuiPingPic_Click/EndPic_Click/AutoFocus_Click + AddPic handler + AddPicEvent 订阅 + 两个 TextChanged 高亮 handler
- View.xaml: 删单张抓拍/水平抓图/结束抓图三按钮 + 拍摄/循环次数两输入框 + 清晰图层抓图按钮(_auto_Button)
- 保留: MJPEG预览/标定协作/手动命令/存范围(SaveAutoFocus_Click)/Serial+Cam属性/IsStop属性(卸载End_Click仍用)/_warpPanelPictures面板(Clear_Click仍清)
- Release -o 编译 0 错

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
huangjie 1 день назад
Родитель
Сommit
93b2081c98

+ 1 - 7
ivf_tl_operate_2.0/ivf_tl_Operate/View/HouseDebugPageView.xaml

@@ -399,13 +399,7 @@
             <StackPanel Grid.Row="8" x:Name="_stackPanel4" Orientation="Horizontal" HorizontalAlignment="Center" IsEnabled="False">
             <StackPanel Grid.Row="8" x:Name="_stackPanel4" Orientation="Horizontal" HorizontalAlignment="Center" IsEnabled="False">
                 <customControl:ButtonCornerRadius  Content="{DynamicResource C0091}" Click="Clear_Click" FontSize="24"  Margin="20" Width="150" Height="100" CornerRadius="20" Background="#BFD87D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
                 <customControl:ButtonCornerRadius  Content="{DynamicResource C0091}" Click="Clear_Click" FontSize="24"  Margin="20" Width="150" Height="100" CornerRadius="20" Background="#BFD87D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
                 <customControl:ButtonCornerRadius  Content="{DynamicResource C0092}" Click="Motor_Click" FontSize="24"  Margin="20" Width="150" Height="100" CornerRadius="20" Background="#BFD87D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
                 <customControl:ButtonCornerRadius  Content="{DynamicResource C0092}" Click="Motor_Click" FontSize="24"  Margin="20" Width="150" Height="100" CornerRadius="20" Background="#BFD87D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
-                <customControl:ButtonCornerRadius  Content="{DynamicResource C0093}" Click="GetPic_Click" FontSize="24"  Margin="20" Width="150" Height="100" CornerRadius="20" Background="#BFD87D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
-                <customControl:ButtonCornerRadius  Content="{DynamicResource C0094}" Click="ShuiPingPic_Click" FontSize="24"  Margin="20" Width="200" Height="100" CornerRadius="20" Background="#BFD87D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
-                <customControl:ButtonCornerRadius  Content="{DynamicResource C0095}" Click="EndPic_Click" FontSize="24"  Margin="20" Width="150" Height="100" CornerRadius="20" Background="#BFD87D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
-
-                <TextBox x:Name="_autoFocusNum_TextBox" TextChanged="_autoFocusNum_TextBox_TextChanged" Background="{StaticResource HelpBrush2}" Text="" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="24" Width="200" Height="80" Margin="30 0 0 0"/>
-                <TextBox x:Name="_autoFocus_TextBox" TextChanged="_autoFocus_TextBox_TextChanged"  Background="{StaticResource HelpBrush3}" Text="" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="24" Width="200" Height="80" Margin="30 0 0 0"/>
-                <customControl:ButtonCornerRadius x:Name="_auto_Button" Click="AutoFocus_Click" Content="{DynamicResource C0107}" FontSize="24"  Margin="20" Width="250" Height="100" CornerRadius="20" Background="#BFD87D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
+                <!-- 旧抓图按钮(单张抓拍/水平抓图/结束抓图/清晰图层抓图)已移除,调试页画面改用 MJPEG 实时预览。 -->
                 <!-- M2-05 场景A 一键全自动标定(沙盒):选中 well 逐个跑四步标定,合格绿/伪峰红,结果存档 scene=0 + calibration.json。 -->
                 <!-- M2-05 场景A 一键全自动标定(沙盒):选中 well 逐个跑四步标定,合格绿/伪峰红,结果存档 scene=0 + calibration.json。 -->
                 <customControl:ButtonCornerRadius x:Name="_oneClickCalib_Button" Click="OneClickCalibrate_Click" Content="一键标定" FontSize="24"  Margin="20" Width="200" Height="100" CornerRadius="20" Background="#7DB5D8" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
                 <customControl:ButtonCornerRadius x:Name="_oneClickCalib_Button" Click="OneClickCalibrate_Click" Content="一键标定" FontSize="24"  Margin="20" Width="200" Height="100" CornerRadius="20" Background="#7DB5D8" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
                 <customControl:ButtonCornerRadius x:Name="_stopCalib_Button" Click="StopCalibrate_Click" Content="中止标定" FontSize="24"  Margin="20" Width="200" Height="100" CornerRadius="20" Background="#D8907D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>
                 <customControl:ButtonCornerRadius x:Name="_stopCalib_Button" Click="StopCalibrate_Click" Content="中止标定" FontSize="24"  Margin="20" Width="200" Height="100" CornerRadius="20" Background="#D8907D" EnabledBackground="#bdbdbd"  BorderThickness="0"/>

+ 5 - 180
ivf_tl_operate_2.0/ivf_tl_Operate/View/HouseDebugPageView.xaml.cs

@@ -69,7 +69,6 @@ namespace ivf_tl_Operate.View
         {
         {
             vm.MessageEvent += AddMessageInfo;
             vm.MessageEvent += AddMessageInfo;
             vm.OpenVideoEvent += OpenVideo;
             vm.OpenVideoEvent += OpenVideo;
-            vm.AddPicEvent += AddPic;
             foreach (var item in vm.HouseList)
             foreach (var item in vm.HouseList)
             {
             {
                 switch (item.houseSn)
                 switch (item.houseSn)
@@ -153,54 +152,8 @@ namespace ivf_tl_Operate.View
             }
             }
         }
         }
 
 
-        private void AddPic(string fileName, int well, int focal)
-        {
-            Dispatcher.Invoke(() =>
-            {
-                if (!File.Exists(fileName))
-                {
-                    AddMessageInfo($"图片不存在:{fileName}");
-                    return;
-                }
-                string imageUrl = $"file:\\{fileName}";
-                var imageSource = AppData.Instance.ConvertHelper.StringToBitmapImage(imageUrl);
-                if (imageSource == null)
-                {
-                    AddMessageInfo($"图片加载失败:{fileName}");
-                    return;
-                }
-
-                Canvas canvas = new Canvas();
-                _warpPanelPictures.Children.Add(canvas);
-                TextBlock text = new TextBlock();
-                Image image = new Image();
-                canvas.Children.Add(image);
-                canvas.Children.Add(text);
-
-                canvas.Margin = new Thickness(20, 5, 20, 0);
-                canvas.Width = 300;
-                canvas.Height = 330;
-
-                text.Text = $"well{well} - {focal}";
-                text.FontSize = 22;
-                text.Foreground = new SolidColorBrush(Color.FromRgb(181, 184, 189));
-                Canvas.SetLeft(text, 80);
-                Canvas.SetTop(text, 302);
-
-                image.Width = 300;
-                image.Height = 300;
-                image.Source = imageSource;
-                image.Tag = imageUrl;
-
-
-                //image.MouseUp += (s, arg) =>
-                //{
-                //    text.Foreground = new SolidColorBrush(Colors.Red);
-                //    PhotoListWindow win2 = new PhotoListWindow(_warpPanelPictures.Children, image, text);
-                //    win2.ShowDialog();
-                //};
-            });
-        }
+        // 旧抓图把图片铺到 _warpPanelPictures 的 AddPic 处理已移除(画面改用 MJPEG 预览);
+        // 面板与"清空"按钮保留(Clear_Click 仍可清空消息/残留图)。
 
 
 
 
         /// <summary>
         /// <summary>
@@ -923,108 +876,8 @@ namespace ivf_tl_Operate.View
 
 
         }
         }
 
 
-        /// <summary>
-        /// 单张抓拍
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void GetPic_Click(object sender, RoutedEventArgs e)
-        {
-            try
-            {
-                if (!isOpen)
-                {
-                    AddMessageInfo("开启实时图像以后才可以拍照");
-                    return;
-                }
-                if (vm.CurrentHouse == null)
-                {
-                    AddMessageInfo("获取舱室信息失败");
-                    return;
-                }
-
-                string path = AppData.Instance.LogHelper.GetDeBugDanZhangDirectory(vm.CurrentHouse.houseSn, vm.CurrentWell);
-                if (!Directory.Exists(path))
-                {
-                    Directory.CreateDirectory(path);
-                }
-                string fullName = $"{path}house{vm.CurrentHouse.houseSn}_{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff")}_{vm.CurrentHor}-{vm.CurrentVer}.jpg";
-                if (!vm.SavePic(fullName)) return;
-                AddPic(fullName, vm.CurrentWell, vm.CurrentFocal);
-            }
-            catch (Exception ex)
-            {
-                ExLog(ex, "GetPic_Click");
-                AddMessageInfo($"单张抓拍异常:{ex.Message}");
-            }
-
-        }
-
-        /// <summary>
-        /// 水平抓拍
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ShuiPingPic_Click(object sender, RoutedEventArgs e)
-        {
-            if (vm.CurrentHouse == null)
-            {
-                AddMessageInfo("获取舱室信息失败");
-                return;
-            }
-            if (!isOpen)
-            {
-                AddMessageInfo("开启实时图像以后才可以拍照");
-                return;
-            }
-            Task.Run(() =>
-            {
-                vm.ShuiPingZhuaPai();
-            });
-        }
-
-        /// <summary>
-        /// 结束抓图
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void EndPic_Click(object sender, RoutedEventArgs e)
-        {
-            vm.IsStop = true;
-        }
-
-        /// <summary>
-        /// 清晰图层抓图
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private async void AutoFocus_Click(object sender, RoutedEventArgs e)
-        {
-            try
-            {
-                if (vm.CurrentHouse == null)
-                {
-                    ShowMessageDefeat("获取舱室信息失败");
-                    return;
-                }
-
-                if (int.TryParse(this._autoFocusNum_TextBox.Text.Trim(), out int autoFocusNum) && autoFocusNum > 0 && int.TryParse(this._autoFocus_TextBox.Text.Trim(), out int xun) && xun > 0)
-                {
-                    this._auto_Button.IsEnabled = false;
-                    await vm.AutoFocusPic(autoFocusNum, xun);
-                    this._auto_Button.IsEnabled = true;
-                }
-                else
-                {
-                    ShowMessageDefeat($"请输入正确的拍摄次数以及循环次数");
-                }
-            }
-            catch (Exception ex)
-            {
-                ExLog(ex, "AutoFocus_Click");
-                AddMessageInfo($"清晰图层抓图异常:{ex.Message}");
-            }
-        }
+        // 旧抓图按钮的事件处理(单张抓拍 GetPic_Click / 水平抓图 ShuiPingPic_Click /
+        // 结束抓图 EndPic_Click / 清晰图层抓图 AutoFocus_Click)已移除——调试页画面改用 MJPEG 实时预览。
 
 
         private void CloseVideo_Click(object sender, RoutedEventArgs e)
         private void CloseVideo_Click(object sender, RoutedEventArgs e)
         {
         {
@@ -1268,35 +1121,7 @@ namespace ivf_tl_Operate.View
             }
             }
         }
         }
 
 
-        private void _autoFocusNum_TextBox_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            TextBox passwordBox = sender as TextBox;
-            if (passwordBox == null) return;
-            string ss = passwordBox.Text.Trim();
-            if (string.IsNullOrEmpty(ss))
-            {
-                passwordBox.Background = (VisualBrush)this.FindResource("HelpBrush2");
-            }
-            else
-            {
-                passwordBox.Background = new SolidColorBrush(Colors.White);
-            }
-        }
-
-        private void _autoFocus_TextBox_TextChanged(object sender, TextChangedEventArgs e)
-        {
-            TextBox passwordBox = sender as TextBox;
-            if (passwordBox == null) return;
-            string ss = passwordBox.Text.Trim();
-            if (string.IsNullOrEmpty(ss))
-            {
-                passwordBox.Background = (VisualBrush)this.FindResource("HelpBrush3");
-            }
-            else
-            {
-                passwordBox.Background = new SolidColorBrush(Colors.White);
-            }
-        }
+        // 旧"清晰图层抓图"那两个输入框(拍摄次数/循环次数)的 TextChanged 高亮处理已随抓图按钮一并移除。
 
 
         private void Paiqi_Click(object sender, RoutedEventArgs e)
         private void Paiqi_Click(object sender, RoutedEventArgs e)
         {
         {

+ 2 - 194
ivf_tl_operate_2.0/ivf_tl_Operate/ViewModel/HouseDebugPageViewModel.cs

@@ -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 重构)