소스 검색

通过下相机自动获取P0功能支持及流程完善

新增下相机获取P0的完整流程,包括:
- CalibTechP0Mode 枚举增加 CameraFindP0 选项及多语言支持
- 新增 FixedUpCameraFindP0Info 数据模型,CalibrationInfo 增加相关属性
- 新增 FixedUpCameraFindP0 视图与 ViewModel,实现相机选择、参数设置、视觉流程运行与P0点自动计算
- 校准流程根据P0模式动态导航,支持自动与手动分支
- 优化P0模式选择控件的显示逻辑及界面布局
- 更新 csproj,注册新视图、模型和多语言资源

整体提升了校准流程的自动化和易用性。
孝锋 徐 8 달 전
부모
커밋
e2c80abe10

+ 2 - 0
TeamAAS-VM/App.xaml.cs

@@ -102,6 +102,7 @@ namespace TeamAAS_VP
             containerRegistry.RegisterForNavigation<CalibrationSelectTool>();
             containerRegistry.RegisterForNavigation<CalibrationTeachCenterPoint>();
             containerRegistry.RegisterForNavigation<CalibrationVerification>();
+            containerRegistry.RegisterForNavigation<FixedUpCameraFindP0>();
             //**************************************************************************************
 
             //------------------------注册单类------------------------------------------------
@@ -154,6 +155,7 @@ namespace TeamAAS_VP
             containerRegistry.RegisterSingleton<CalibrationSelectToolViewModel>();
             containerRegistry.RegisterSingleton<CalibrationTeachCenterPointViewModel>();
             containerRegistry.RegisterSingleton<CalibrationVerificationViewModel>();
+            containerRegistry.RegisterSingleton<FixedUpCameraFindP0ViewModel>();
             //**************************************************************************************
 
             //------------------------注册对话框------------------------------------------------

+ 7 - 0
TeamAAS-VM/Enums/CalibTechP0Mode.cs

@@ -26,5 +26,12 @@ namespace TeamAAS_VP.Enums
         [Description("手动示教P0")]
         [Localization(ResourceName = "手动示教P0", ResourceType = typeof(Lang))]
         TechP0 = 1,
+
+        /// <summary>
+        /// 通过下相机获取P0
+        /// </summary>
+        [Description("通过下相机获取P0")]
+        [Localization(ResourceName = "通过下相机获取P0", ResourceType = typeof(Lang))]
+        CameraFindP0 = 2
     }
 }

+ 10 - 0
TeamAAS-VM/Models/Calibration/CalibrationInfo.cs

@@ -350,6 +350,16 @@ namespace TeamAAS_VP.Models.Calibration
             set { SetProperty(ref _AffineTransformationMaterial, value); }
         }
 
+        private FixedUpCameraFindP0Info _FixedUpCameraFindP0Info;
+        /// <summary>
+        /// 移动相机时,下相机校准P0
+        /// </summary>
+        public FixedUpCameraFindP0Info FixedUpCameraFindP0Info
+        {
+            get { return _FixedUpCameraFindP0Info; }
+            set { SetProperty(ref _FixedUpCameraFindP0Info, value); }
+        }
+
         private CalibrationResult _CalibrationResult;
         /// <summary>
         /// 校准结果

+ 89 - 0
TeamAAS-VM/Models/Calibration/FixedUpCameraFindP0Info.cs

@@ -0,0 +1,89 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TeamAAS_VP.Models.Calibration
+{
+    public class FixedUpCameraFindP0Info : BindableBase
+    {
+        private Guid _CameraId;
+        /// <summary>
+        /// 下相机的id
+        /// </summary>
+        public Guid CameraId
+        {
+            get { return _CameraId; }
+            set { SetProperty(ref _CameraId, value); }
+        }
+
+        private string _CameraName;
+        /// <summary>
+        /// 相机名称
+        /// </summary>
+        public string CameraName
+        {
+            get { return _CameraName; }
+            set { SetProperty(ref _CameraName, value); }
+        }
+
+        private Guid _CalibrationId;
+        /// <summary>
+        /// 校准ID
+        /// </summary>
+        public Guid CalibrationId
+        {
+            get { return _CalibrationId; }
+            set { SetProperty(ref _CalibrationId, value); }
+        }
+
+        private string _CalibrationName;
+        /// <summary>
+        /// 校准名称
+        /// </summary>
+        public string CalibrationName
+        {
+            get { return _CalibrationName; }
+            set { SetProperty(ref _CalibrationName, value); }
+        }
+
+        private float _ExposureTime;
+        /// <summary>
+        /// 相机曝光时间
+        /// </summary>
+        public float ExposureTime
+        {
+            get { return _ExposureTime; }
+            set { SetProperty(ref _ExposureTime, value); }
+        }
+
+        private float _Gain;
+        /// <summary>
+        /// 相机增益
+        /// </summary>
+        public float Gain
+        {
+            get { return _Gain; }
+            set { SetProperty(ref _Gain, value); }
+        }
+
+        public FixedUpCameraFindP0Info()
+        {
+
+        }
+
+        public FixedUpCameraFindP0Info(Guid cameraId, string cameraName, Guid calibrationId, string calibrationName, float exposureTime, float gain)
+        {
+            CameraId = cameraId;
+            CameraName = cameraName;
+            CalibrationId = calibrationId;
+            CalibrationName = calibrationName;
+            ExposureTime = exposureTime;
+            Gain = gain;
+        }
+
+
+    }
+}

+ 18 - 0
TeamAAS-VM/Resources/Languages/Lang.Designer.cs

@@ -5334,6 +5334,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 选择下相机视觉流程 的本地化字符串。
+        /// </summary>
+        public static string 选择下相机视觉流程 {
+            get {
+                return ResourceManager.GetString("选择下相机视觉流程", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 选择产品 的本地化字符串。
         /// </summary>
@@ -5541,6 +5550,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 通过下相机获取P0 的本地化字符串。
+        /// </summary>
+        public static string 通过下相机获取P0 {
+            get {
+                return ResourceManager.GetString("通过下相机获取P0", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 通道数 的本地化字符串。
         /// </summary>

+ 6 - 0
TeamAAS-VM/Resources/Languages/Lang.resx

@@ -2090,4 +2090,10 @@
   <data name="正在初始化光源控制器" xml:space="preserve">
     <value>正在初始化光源控制器</value>
   </data>
+  <data name="通过下相机获取P0" xml:space="preserve">
+    <value>通过下相机获取P0</value>
+  </data>
+  <data name="选择下相机视觉流程" xml:space="preserve">
+    <value>选择下相机视觉流程</value>
+  </data>
 </root>

+ 9 - 0
TeamAAS-VM/TeamAAS-VP.csproj

@@ -590,6 +590,7 @@
     <Compile Include="Models\AlarmRecord.cs" />
     <Compile Include="Models\AnalysisParameters.cs" />
     <Compile Include="Models\AnalysisResult.cs" />
+    <Compile Include="Models\Calibration\FixedUpCameraFindP0Info.cs" />
     <Compile Include="Models\ChessboardInfo.cs" />
     <Compile Include="Models\DataPoint.cs" />
     <Compile Include="Models\Lights\ChannelConfig.cs" />
@@ -763,6 +764,7 @@
     <Compile Include="ValueConverter\RoiToTextConverter.cs" />
     <Compile Include="ValueConverter\StringFormatConverter.cs" />
     <Compile Include="ViewModels\DebugMod\LightManualViewModel.cs" />
+    <Compile Include="ViewModels\Calibration\FixedUpCameraFindP0ViewModel.cs" />
     <Compile Include="ViewModels\Product\PlcPointParamsViewModel.cs" />
     <Compile Include="ViewModels\Setting\AddLightControllerViewModel.cs" />
     <Compile Include="ViewModels\Setting\AddPlcViewModel.cs" />
@@ -855,6 +857,9 @@
     <Compile Include="Views\Calibration\CalibTool.xaml.cs">
       <DependentUpon>CalibTool.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\Calibration\FixedUpCameraFindP0.xaml.cs">
+      <DependentUpon>FixedUpCameraFindP0.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\Calibration\ShowCalibrationResult.xaml.cs">
       <DependentUpon>ShowCalibrationResult.xaml</DependentUpon>
     </Compile>
@@ -1127,6 +1132,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\Calibration\FixedUpCameraFindP0.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\Calibration\ShowCalibrationResult.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 10 - 1
TeamAAS-VM/ViewModels/Calibration/CalibrationAutoViewModel.cs

@@ -221,9 +221,18 @@ namespace TeamAAS_VP.ViewModels.Calibration
         {
             NavigationParameters param = new NavigationParameters();
             param.Add("SelectCalibration", SelectCalibration);
+
             if (SelectCalibration.CameraMount == Enums.CameraMount.MobileDown_XYPlatform)
             {
-                _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationTeachCenterPoint",param);
+                if (SelectCalibration.CalibTechP0Mode == Enums.CalibTechP0Mode.CameraFindP0)
+                {
+                    _regionManager.RequestNavigate("CalibrationRegionContext", "FixedUpCameraFindP0", param);
+                    return;
+                }
+                else
+                {
+                    _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationTeachCenterPoint", param);
+                }
             }
             else if (Robot.Brand == Enums.RobotBrand.XYZ_Platform)
             {

+ 2 - 1
TeamAAS-VM/ViewModels/Calibration/CalibrationBasicsViewModel.cs

@@ -1,4 +1,5 @@
-using Prism.Commands;
+
+using Prism.Commands;
 using Prism.Events;
 using Prism.Ioc;
 using Prism.Mvvm;

+ 33 - 6
TeamAAS-VM/ViewModels/Calibration/CalibrationTeachCenterPointViewModel.cs

@@ -44,7 +44,7 @@ namespace TeamAAS_VP.ViewModels.Calibration
             set { SetProperty(ref _SelectCalibration, value); }
         }
 
-        private bool _IsShowTechHome=false;
+        private bool _IsShowTechHome = false;
 
         public bool IsShowTechHome
         {
@@ -52,6 +52,15 @@ namespace TeamAAS_VP.ViewModels.Calibration
             set { SetProperty(ref _IsShowTechHome, value); }
         }
 
+        private bool _IsShowTechP0ModeSelect = true;
+        /// <summary>
+        /// 是否显示P0模式选择
+        /// </summary>
+        public bool IsShowTechP0ModeSelect
+        {
+            get { return _IsShowTechP0ModeSelect; }
+            set { SetProperty(ref _IsShowTechP0ModeSelect, value); }
+        }
 
         public Management management { get; set; }
 
@@ -91,7 +100,7 @@ namespace TeamAAS_VP.ViewModels.Calibration
         public DelegateCommand TechMarkPointCommand =>
             _TechMarkPointCommand ?? (_TechMarkPointCommand = new DelegateCommand(ExecuteTechMarkPointCommand));
 
-        
+
         #endregion
 
         #region 事件
@@ -133,11 +142,20 @@ namespace TeamAAS_VP.ViewModels.Calibration
         {
             NavigationParameters param = new NavigationParameters();
             param.Add("SelectCalibration", SelectCalibration);
-            if (SelectCalibration.CameraMount== Enums.CameraMount.MobileDown_XYPlatform)
+
+            if (SelectCalibration.CameraMount == Enums.CameraMount.MobileDown_XYPlatform)
             {
-                _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationAuto", param);
+                if (SelectCalibration.CalibTechP0Mode == Enums.CalibTechP0Mode.CameraFindP0)
+                {
+                    _regionManager.RequestNavigate("CalibrationRegionContext", "FixedUpCameraFindP0", param);
+                    return;
+                }
+                else
+                {
+                    _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationAuto", param);
+                }
             }
-            else if (Robot.Brand== Enums.RobotBrand.XYZ_Platform)
+            else if (Robot.Brand == Enums.RobotBrand.XYZ_Platform)
             {
                 _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationAuto", param);
             }
@@ -166,7 +184,7 @@ namespace TeamAAS_VP.ViewModels.Calibration
             try
             {
                 var curpos = await Robot.GetRobotPosAsync();
-                if (SelectCalibration.CenterPoint==null)
+                if (SelectCalibration.CenterPoint == null)
                 {
                     SelectCalibration.CenterPoint = new RPoint();
                 }
@@ -295,6 +313,15 @@ namespace TeamAAS_VP.ViewModels.Calibration
                 {
                     IsShowTechHome = true;
                 }
+
+                if (SelectCalibration.CameraMount == Enums.CameraMount.MobileDown_XYPlatform || Robot.Brand == Enums.RobotBrand.XYZ_Platform || Robot.Brand == Enums.RobotBrand.XYZU_Platform)
+                {
+                    IsShowTechP0ModeSelect = true;
+                }
+                else
+                {
+                    IsShowTechP0ModeSelect = false;
+                }
             }
             else
             {

+ 462 - 0
TeamAAS-VM/ViewModels/Calibration/FixedUpCameraFindP0ViewModel.cs

@@ -0,0 +1,462 @@
+using Cognex.VisionPro;
+using Cognex.VisionPro.ToolBlock;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+using Team.FFFeederService.Interfaces;
+using TeamAAS_VP.Core;
+using TeamAAS_VP.Enums;
+using TeamAAS_VP.Events;
+using TeamAAS_VP.Interfaces;
+using TeamAAS_VP.Models;
+using TeamAAS_VP.Models.Calibration;
+using TeamAAS_VP.Services;
+
+namespace TeamAAS_VP.ViewModels.Calibration
+{
+    public class FixedUpCameraFindP0ViewModel : BindableBase
+    {
+        IRegionManager _regionManager;
+        IRegionNavigationService _regionNavigationService;
+        IContainerProvider _container;
+        IDialogService _dialogService;
+        IEventAggregator _eventAggregator;
+        IConfigService _configService;
+        IRobotService _robotService;
+        ICameraService _cameraService;
+        IFeederService _feederService;
+        ISystemDatabaseService _systemDatabaseService;
+        ICalibrationService _calibrationServvice;
+
+        #region 属性
+
+        private CogToolBlockEditV2 _ToolBlockEdit;
+
+        public CogToolBlockEditV2 ToolBlockEdit
+        {
+            get { return _ToolBlockEdit; }
+            set { SetProperty(ref _ToolBlockEdit, value); }
+        }
+
+
+        private CalibrationInfo _SelectCalibration;
+
+        public CalibrationInfo SelectCalibration
+        {
+            get { return _SelectCalibration; }
+            set { SetProperty(ref _SelectCalibration, value); }
+        }
+
+        private IRobot _Robot;
+
+        public IRobot Robot
+        {
+            get { return _Robot; }
+            set { SetProperty(ref _Robot, value); }
+        }
+
+        private ICamera _Camera;
+
+        public ICamera Camera
+        {
+            get { return _Camera; }
+            set { SetProperty(ref _Camera, value); }
+        }
+
+        private float _ExposureTime;
+        /// <summary>
+        /// 相机曝光时间
+        /// </summary>
+        public float ExposureTime
+        {
+            get { return _ExposureTime; }
+            set
+            {
+                SetProperty(ref _ExposureTime, value);
+                SelectCalibration.ExposureTime = value;
+                if (Camera != null)
+                {
+                    try
+                    {
+                        SelectCalibration.FixedUpCameraFindP0Info.ExposureTime = value;
+                        Camera.SetExposureTime(value);
+                    }
+                    catch (Exception)
+                    {
+
+                    }
+                }
+            }
+        }
+
+        private float _Gain;
+        /// <summary>
+        /// 相机增益
+        /// </summary>
+        public float Gain
+        {
+            get { return _Gain; }
+            set
+            {
+                SetProperty(ref _Gain, value);
+                SelectCalibration.Gain = value;
+                if (Camera != null)
+                {
+                    try
+                    {
+                        SelectCalibration.FixedUpCameraFindP0Info.Gain = value;
+                        Camera.SetGain(value);
+                    }
+                    catch (Exception)
+                    {
+
+                    }
+                }
+            }
+        }
+
+        private ObservableCollection<CameraInfo> _Cameras;
+        public ObservableCollection<CameraInfo> Cameras
+        {
+            get { return _Cameras; }
+            set { SetProperty(ref _Cameras, value); }
+        }
+
+        private CameraInfo _SelectCamera;
+        public CameraInfo SelectCamera
+        {
+            get { return _SelectCamera; }
+            set
+            {
+                SetProperty(ref _SelectCamera, value);
+                if (value != null)
+                {
+                    Camera = _cameraService.GetCamera(value.Id);
+                    SelectCalibration.FixedUpCameraFindP0Info.CameraId = value.Id;
+                    SelectCalibration.FixedUpCameraFindP0Info.CameraId = value.Id;
+                }
+            }
+        }
+
+        private ObservableCollection<CalibrationInfo> _CalibrationList;
+        public ObservableCollection<CalibrationInfo> CalibrationList
+        {
+            get { return _CalibrationList; }
+            set { SetProperty(ref _CalibrationList, value); }
+        }
+
+        private CalibrationInfo _SelectedCalibration;
+        public CalibrationInfo SelectedCalibration
+        {
+            get { return _SelectedCalibration; }
+            set
+            {
+                SetProperty(ref _SelectedCalibration, value);
+            }
+        }
+
+        #endregion
+
+        #region 命令
+        private DelegateCommand _LoadedCommand;
+        public DelegateCommand LoadedCommand =>
+            _LoadedCommand ?? (_LoadedCommand = new DelegateCommand(ExecuteLoadedCommand));
+        private DelegateCommand _NextCommand;
+        public DelegateCommand NextCommand =>
+            _NextCommand ?? (_NextCommand = new DelegateCommand(ExecuteNextCommand));
+
+        private DelegateCommand _BackCommand;
+        public DelegateCommand BackCommand =>
+            _BackCommand ?? (_BackCommand = new DelegateCommand(ExecuteBackCommand));
+
+        private DelegateCommand _RunVisionProcessCommand;
+        public DelegateCommand RunVisionProcessCommand =>
+            _RunVisionProcessCommand ?? (_RunVisionProcessCommand = new DelegateCommand(ExecuteRunVisionProcessCommand));
+
+        private DelegateCommand _FindP0Command;
+        public DelegateCommand FindP0Command =>
+            _FindP0Command ?? (_FindP0Command = new DelegateCommand(ExecuteFindP0Command));
+
+
+        #endregion
+
+        #region 事件
+
+        #endregion
+
+        public FixedUpCameraFindP0ViewModel(IRegionManager regionManager, IEventAggregator ea, IRegionNavigationService regionNavigationService, IContainerProvider container, IDialogService dialogService,
+            IConfigService configService, IRobotService robotService, ICameraService cameraService, IFeederService feederService, ISystemDatabaseService systemDatabaseService, ICalibrationService calibrationService)
+        {
+            _regionManager = regionManager;
+            _regionNavigationService = regionNavigationService;
+            _container = container;
+            _dialogService = dialogService;
+            _eventAggregator = ea;
+            _configService = configService;
+            _robotService = robotService;
+            _cameraService = cameraService;
+            _feederService = feederService;
+            _systemDatabaseService = systemDatabaseService;
+            _calibrationServvice = calibrationService;
+        }
+
+        #region 方法
+        void ExecuteLoadedCommand()
+        {
+            try
+            {
+                if (_systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Operator)
+                {
+                    IsAllowEdit = false;
+                }
+                else
+                {
+                    IsAllowEdit = true;
+                }
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("相机校准加载视觉工具处理界面时出错!", ex);
+                MessageBox.Show(ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 下一步
+        /// </summary>
+        void ExecuteNextCommand()
+        {
+            try
+            {
+                string prcPath = FilePath.CalibrationPath + "//" + SelectCalibration.Name + "//" + "FixedUpCameraTool.vpp";
+                CogSerializer.SaveObjectToFile(ToolBlockEdit.Subject, prcPath);
+                NavigationParameters param = new NavigationParameters();
+                param.Add("SelectCalibration", SelectCalibration);
+                _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationAuto", param);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("相机校准-下相机示教P0界面点击下一步时出错!", ex);
+                MessageBox.Show(ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 上一步
+        /// </summary>
+        void ExecuteBackCommand()
+        {
+            try
+            {
+                NavigationParameters param = new NavigationParameters();
+                param.Add("SelectCalibration", SelectCalibration);
+                _regionManager.RequestNavigate("CalibrationRegionContext", "CalibrationTeachCenterPoint", param);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("相机校准-下相机示教P0界面点击上一步时出错!", ex);
+                MessageBox.Show(ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 运行视觉流程
+        /// </summary>
+        void ExecuteRunVisionProcessCommand()
+        {
+            try
+            {
+                ToolBlockEdit.Subject.Inputs["InputImage"].Value = Camera.Grab();
+                ToolBlockEdit.Subject.Run();
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("相机校准-运行流程时出错时出错", ex);
+                _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
+            }
+        }
+
+        /// <summary>
+        /// 自动计算P0点
+        /// </summary>
+        async void ExecuteFindP0Command()
+        {
+            if (Camera == null)
+            {
+                MessageBox.Show("请先选择相机!");
+                return;
+            }
+            if (SelectedCalibration == null)
+            {
+                MessageBox.Show("请先选择标定!");
+                return;
+            }
+            var result = await CaptureAndProcess();
+            if (result.IsSuccess)
+            {
+                if (SelectCalibration.MarkPoint == null)
+                {
+                    SelectCalibration.MarkPoint = new RPoint();
+                }
+                SelectCalibration.MarkPoint.X = (float) result.X;
+                SelectCalibration.MarkPoint.Y = (float)result.Y;
+                MessageBox.Show($"P0点计算成功!X:{result.X},Y:{result.Y}");
+            }
+            else
+            {
+                MessageBox.Show("未找到P0点,请调整工件位置后重试!");
+            }
+        }
+
+        /// <summary>
+        /// 相机拍照
+        /// </summary>
+        /// <returns></returns>
+        private async Task<(bool IsSuccess, double X, double Y, double U, int ImageWidth, int ImageHeight)> CaptureAndProcess()
+        {
+
+            ICogImage image = null;
+            //采集图像
+            if (Camera != null)
+            {
+                image = Camera.Grab();
+                ToolBlockEdit.Subject.Inputs["InputImage"].Value = image;
+            }
+            ToolBlockEdit.Subject.Run();
+            CogToolBlockTerminalCollection outputCollection = ToolBlockEdit.Subject.Outputs;
+            bool Found = (bool)(outputCollection["Found"].Value);
+            if (Found)
+            {
+                var strpoints = outputCollection["Point"].Value.ToString();
+                string[] items = strpoints.Split(',');
+                double x = double.Parse(items[0]);
+                double y = double.Parse(items[1]);
+
+                //校准转换
+                var calibResult = _calibrationServvice.ConvertPixelToPosition((x, y, 0), null, SelectedCalibration, Robot.Brand);
+                if (calibResult.IsSucceed)
+                {
+                    x = calibResult.X;
+                    y = calibResult.Y;
+                    return (true, x, y, 0, image.Width, image.Height);
+                }
+
+                return (false, 0, 0, 0, image.Width, image.Height);
+            }
+            else
+            {
+                return (false, 0, 0, 0, image.Width, image.Height);
+            }
+        }
+        #endregion
+
+        #region 继承
+        /// <summary>
+        /// 确认导航请求时调用。此方法允许您在导航之前执行一些操作。
+        /// </summary>
+        /// <param name="navigationContext"></param>
+        /// <param name="continuationCallback"></param>
+        public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
+        {
+            continuationCallback(true);
+        }
+
+        /// <summary>
+        /// 接收导航请求时调用。传入导航参数,包含有关导航目标的信息。
+        /// </summary>
+        /// <param name="navigationContext"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        public async void OnNavigatedTo(NavigationContext navigationContext)
+        {
+            SelectCalibration = navigationContext.Parameters.GetValue<CalibrationInfo>("SelectCalibration");
+            if (SelectCalibration.FixedUpCameraFindP0Info == null)
+            {
+                SelectCalibration.FixedUpCameraFindP0Info = new FixedUpCameraFindP0Info();
+            }
+            if (ToolBlockEdit != null)
+            {
+                string prcPath = FilePath.CalibrationPath + "//" + SelectCalibration.Name + "//" + "FixedUpCameraTool.vpp";
+                if (File.Exists(prcPath))
+                {
+                    ToolBlockEdit.Subject = CogSerializer.LoadObjectFromFile(prcPath) as CogToolBlock;
+                }
+                else
+                {
+                    ToolBlockEdit.Subject = CogSerializer.LoadObjectFromFile(FilePath.CalibrationToolblockPath) as CogToolBlock;
+                }
+            }
+
+            if (SelectCalibration.RobotId != Guid.Empty)
+            {
+                Robot = _robotService.GetRobot(SelectCalibration.RobotId);
+            }
+
+            Cameras = new ObservableCollection<CameraInfo>(_configService.GetAllCameras());
+            if (SelectCalibration.FixedUpCameraFindP0Info.CameraId != Guid.Empty)
+            {
+                SelectCamera = Cameras.FirstOrDefault(c => c.Id == SelectCalibration.FixedUpCameraFindP0Info.CameraId);
+
+            }
+            CalibrationList = new ObservableCollection<CalibrationInfo>(_calibrationServvice.GetAllCalibrations());
+            if (SelectCalibration.FixedUpCameraFindP0Info.CalibrationId != Guid.Empty)
+            {
+                SelectCalibration = CalibrationList.FirstOrDefault(c => c.Id == SelectCalibration.FixedUpCameraFindP0Info.CalibrationId);
+            }
+
+            ExposureTime = SelectCalibration.ExposureTime;
+            Gain = SelectCalibration.Gain;
+
+        }
+
+        /// <summary>
+        /// 是否允许导航到此视图模型。
+        /// </summary>
+        /// <param name="navigationContext"></param>
+        /// <returns></returns>
+        public bool IsNavigationTarget(NavigationContext navigationContext)
+        {
+            return true;
+        }
+
+        /// <summary>
+        /// 导航离开此视图模型时调用。您可以在此处执行清理操作或保存状态。
+        /// </summary>
+        /// <param name="navigationContext"></param>
+        public void OnNavigatedFrom(NavigationContext navigationContext)
+        {
+
+        }
+        #endregion
+
+        private bool _IsAllowEdit = false;
+
+        public bool IsAllowEdit
+        {
+            get { return _IsAllowEdit; }
+            set { SetProperty(ref _IsAllowEdit, value); }
+        }
+
+        private void LoginChange(Models.User user)
+        {
+            if (user.userPart == Enums.UserPart.Operator)
+            {
+                IsAllowEdit = false;
+            }
+            else
+            {
+                IsAllowEdit = true;
+            }
+        }
+    }
+}

+ 8 - 7
TeamAAS-VM/Views/Calibration/CalibrationTeachCenterPoint.xaml

@@ -132,19 +132,20 @@
                 <TextBlock Text="{lex:Loc 选择模式,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}"
                            Grid.Row="2"
                            Grid.Column="0"
-                           Visibility="{Binding SelectCalibration.RobotId,Converter={StaticResource RobotIdToVisibiltyConverterInverse}}" />
+                           Visibility="{Binding IsShowTechP0ModeSelect,Converter={StaticResource BooleanToVisibilityConverter}}" />
                 <ComboBox x:Name="myComboBox"
                           Grid.Row="2"
                           Grid.Column="1"
                           Margin="5,10"
                           SelectedItem="{Binding SelectCalibration.CalibTechP0Mode}"
                           ItemsSource="{ext:EnumBindingSource enums:CalibTechP0Mode}"
-                          Visibility="{Binding SelectCalibration.RobotId,Converter={StaticResource RobotIdToVisibiltyConverterInverse}}" />
+                          Visibility="{Binding IsShowTechP0ModeSelect,Converter={StaticResource BooleanToVisibilityConverter}}" />
 
                 <TextBlock x:Name="txt1"
                            Text="{lex:Loc 示教P0,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}"
                            Grid.Row="3"
                            Grid.Column="0"
+                           d:Visibility="Visible"
                            VerticalAlignment="Center">
                     <TextBlock.Style>
                         <Style TargetType="TextBlock">
@@ -179,10 +180,10 @@
                         Command="{Binding TechMarkPointCommand}">
                 </Button>
 
-                <TextBlock Grid.Row="4"
+                <TextBlock Grid.Row="5"
                            Grid.Column="0"
                            Text="{lex:Loc 宽,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
-                <mah:NumericUpDown Grid.Row="4"
+                <mah:NumericUpDown Grid.Row="5"
                                    Grid.Column="1"
                                    Maximum="600"
                                    Minimum="0"
@@ -195,10 +196,10 @@
                                    Value="{Binding SelectCalibration.Width,Mode=TwoWay}" />
 
                 <TextBlock Text="{lex:Loc 高,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}"
-                           Grid.Row="5"
+                           Grid.Row="6"
                            Grid.Column="0" />
 
-                <mah:NumericUpDown Grid.Row="5"
+                <mah:NumericUpDown Grid.Row="6"
                                    Grid.Column="1"
                                    Maximum="600"
                                    Minimum="0"
@@ -209,7 +210,7 @@
                                    materialDesign:HintAssist.Hint="{lex:Loc 图像Y方向}"
                                    materialDesign:HintAssist.HelperText="{lex:Loc 图像Y方向}"
                                    Value="{Binding SelectCalibration.Height,Mode=TwoWay}" />
-                <StackPanel Grid.Row="6"
+                <StackPanel Grid.Row="7"
                             Grid.ColumnSpan="2"
                             Orientation="Horizontal"
                             HorizontalAlignment="Center">

+ 237 - 0
TeamAAS-VM/Views/Calibration/FixedUpCameraFindP0.xaml

@@ -0,0 +1,237 @@
+<UserControl x:Class="TeamAAS_VP.Views.Calibration.FixedUpCameraFindP0"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:prism="http://prismlibrary.com/"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
+             xmlns:wf="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
+             xmlns:vp="clr-namespace:Cognex.VisionPro.ToolBlock;assembly=Cognex.VisionPro.ToolGroup.Controls"
+             xmlns:uControl="clr-namespace:TeamAAS_VP.Controls"
+             xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels.Calibration"
+             xmlns:convert="clr-namespace:TeamAAS_VP.ValueConverter"
+             xmlns:lex="http://wpflocalizeextension.codeplex.com"
+             lex:LocalizeDictionary.DesignCulture="zh-CN"
+             lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
+             lex:ResxLocalizationProvider.DefaultDictionary="Lang"
+             prism:ViewModelLocator.AutoWireViewModel="True"
+             mc:Ignorable="d"
+             d:DataContext="{d:DesignInstance Type=vm:FixedUpCameraFindP0ViewModel}"
+             d:Height="600"
+             d:Width="1024"
+             d:Background="White"
+             FontFamily="{DynamicResource DefaultFont}">
+    <b:Interaction.Triggers>
+        <b:EventTrigger EventName="Loaded">
+            <b:InvokeCommandAction Command="{Binding LoadedCommand}" />
+        </b:EventTrigger>
+    </b:Interaction.Triggers>
+    <UserControl.Resources>
+        <convert:JogConverter x:Key="JogConverter" />
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="auto" />
+            <RowDefinition Height="*" />
+            <RowDefinition Height="auto" />
+        </Grid.RowDefinitions>
+        <Button Grid.Row="0"
+                Content="{materialDesign:PackIcon Kind=ArrowLeftCircle}"
+                Width="50"
+                HorizontalAlignment="Left"
+                VerticalAlignment="Top"
+                ToolTip="{lex:Loc 返回}"
+                Style="{StaticResource MaterialDesignIconButton}"
+                Command="{Binding BackCommand}" />
+        <StackPanel Grid.Row="0"
+                    Orientation="Horizontal"
+                    Margin="50,0"
+                    VerticalAlignment="Center">
+            <materialDesign:PackIcon Kind="CrosshairsGps"
+                                     Width="30"
+                                     Height="30" />
+            <TextBlock Text="{Binding SelectCalibration.Name,Converter={StaticResource StringFormatConverter},ConverterParameter=' [{0}] '}"
+                       VerticalAlignment="Center" />
+            <TextBlock Text="{lex:Loc 校准视觉处理,Converter={StaticResource StringFormatConverter},ConverterParameter='- {0}'}"
+                       VerticalAlignment="Center" />
+        </StackPanel>
+
+        <materialDesign:DrawerHost Grid.Row="1"
+                                   IsEnabled="{Binding IsAllowEdit}"
+                                   OpenMode="Standard"
+                                   x:Name="DrawerHost">
+            <materialDesign:DrawerHost.RightDrawerContent>
+                <uControl:RobotManual x:Name="robotManual" />
+            </materialDesign:DrawerHost.RightDrawerContent>
+
+            <Grid>
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="*" />
+                    <ColumnDefinition Width="auto" />
+                </Grid.ColumnDefinitions>
+                <wf:WindowsFormsHost Grid.Column="0"
+                                     Margin="0,0,0,35">
+                    <vp:CogToolBlockEditV2 x:Name="ToolBlockEditV2" />
+                </wf:WindowsFormsHost>
+                <Button Content="{lex:Loc 运行流程}"
+                        Width="100"
+                        HorizontalAlignment="Left"
+                        VerticalAlignment="Bottom"
+                        Margin="5,3"
+                        Command="{Binding RunVisionProcessCommand}" />
+                <Grid Grid.Column="1">
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="auto" />
+                        <RowDefinition Height="auto" />
+                        <RowDefinition Height="auto" />
+                        <RowDefinition Height="auto" />
+                        <RowDefinition Height="auto" />
+                        <RowDefinition Height="auto" />
+                        <RowDefinition Height="auto" />
+                        <RowDefinition Height="auto" />
+                    </Grid.RowDefinitions>
+                    <Grid.ColumnDefinitions>
+                        <ColumnDefinition Width="auto" />
+                        <ColumnDefinition Width="*" />
+                    </Grid.ColumnDefinitions>
+                    <TextBlock Text="选择下相机:"
+                               FontWeight="Bold"
+                               Grid.Row="0"
+                               VerticalAlignment="Center"
+                               Grid.Column="0" />
+                    <ComboBox Grid.Row="0"
+                              Grid.Column="1"
+                              ItemsSource="{Binding Cameras}"
+                              SelectedItem="{Binding SelectCamera}"
+                              materialDesign:HintAssist.Hint="{lex:Loc 选择相机}">
+                        <ComboBox.ItemTemplate>
+                            <DataTemplate>
+                                <StackPanel Orientation="Horizontal">
+                                    <materialDesign:PackIcon Kind="Camera" />
+                                    <TextBlock Text="{Binding CameraName}"
+                                               Margin="6,0" />
+                                </StackPanel>
+                            </DataTemplate>
+                        </ComboBox.ItemTemplate>
+                    </ComboBox>
+                    <TextBlock Text="{lex:Loc 相机参数设置}"
+                               Grid.Row="1"
+                               FontWeight="Bold"
+                               Margin="0,10"
+                               Grid.ColumnSpan="2" />
+                    <TextBlock Grid.Row="2"
+                               Grid.Column="0"
+                               Margin="5"
+                               VerticalAlignment="Center"
+                               Text="{lex:Loc 曝光时间,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
+                    <mah:NumericUpDown Grid.Row="2"
+                                       Grid.Column="1"
+                                       Margin="5"
+                                       Minimum="35"
+                                       Maximum="999985"
+                                       Interval="35"
+                                       StringFormat="{}{0:N0} us"
+                                       Value="{Binding ExposureTime,Mode=TwoWay}" />
+                    <TextBlock Grid.Row="3"
+                               Grid.Column="0"
+                               Margin="5"
+                               VerticalAlignment="Center"
+                               Text="{lex:Loc 增益,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
+                    <mah:NumericUpDown Grid.Row="3"
+                                       Grid.Column="1"
+                                       Margin="5"
+                                       Minimum="0"
+                                       Maximum="63"
+                                       Interval="1"
+                                       StringFormat="{}{0:N2} db"
+                                       Value="{Binding Gain,Mode=TwoWay}" />
+
+                    <TextBlock Text="选择校准:"
+                               FontWeight="Bold"
+                               Grid.Row="4"
+                               VerticalAlignment="Center"
+                               Grid.Column="0" />
+                    <ComboBox Grid.Row="4"
+                              Grid.Column="1"
+                              ItemsSource="{Binding CalibrationList}"
+                              SelectedItem="{Binding SelectedCalibration}"
+                              materialDesign:HintAssist.Hint="选择校准">
+                        <ComboBox.ItemTemplate>
+                            <DataTemplate>
+                                <StackPanel Orientation="Horizontal">
+                                    <materialDesign:PackIcon Kind="Camera" />
+                                    <TextBlock Text="{Binding Name}"
+                                               Margin="6,0" />
+                                </StackPanel>
+                            </DataTemplate>
+                        </ComboBox.ItemTemplate>
+                    </ComboBox>
+
+                    <TextBlock Text="获取P0点:"
+                               FontWeight="Bold"
+                               Grid.Row="5"
+                               VerticalAlignment="Center"
+                               Grid.Column="0" />
+                    <Button Content="获取P0点"
+                            Grid.Row="5"
+                            Margin="0,10"
+                            Grid.Column="1"
+                            Command="{Binding FindP0Command}" />
+
+
+                    <TextBlock 
+                               Grid.Row="6"
+                               Grid.ColumnSpan="2">
+                        <TextBlock.Text>
+                            <MultiBinding StringFormat="{}P0点 X:{0:F3} Y:{1:F3}}">
+                                <Binding Path="SelectCalibration.MarkPoint.X"
+                                         />
+                                <Binding Path="SelectCalibration.MarkPoint.Y" />
+                            </MultiBinding>
+                        </TextBlock.Text>
+                    </TextBlock>
+
+                    <TextBlock Text="请确保相机已对准标定板中心位置"
+                               Grid.Row="7"
+                               Foreground="Red"
+                               Margin="0,10"
+                               Grid.ColumnSpan="2" />
+
+
+                </Grid>
+            </Grid>
+
+
+        </materialDesign:DrawerHost>
+
+        <StackPanel Orientation="Horizontal"
+                    HorizontalAlignment="Right"
+                    VerticalAlignment="Bottom">
+            <ToggleButton materialDesign:ToggleButtonAssist.OnContent="{materialDesign:PackIcon Kind=ArrowRight}"
+                          Content="{materialDesign:PackIcon Kind=RobotIndustrial}"
+                          IsEnabled="{Binding IsAllowEdit}"
+                          Style="{StaticResource MaterialDesignActionToggleButton}"
+                          ToolTip="{lex:Loc 机器人步进}"
+                          Margin="2,0"
+                          IsChecked="{Binding IsRightDrawerOpen,ElementName=DrawerHost}" />
+        </StackPanel>
+
+        <StackPanel Grid.Row="2"
+                    Orientation="Horizontal"
+                    HorizontalAlignment="Center"
+                    VerticalAlignment="Center"
+                    Margin="20">
+            <Button Content="{lex:Loc 下一步}"
+                    IsEnabled="{Binding IsAllowEdit}"
+                    MinWidth="150"
+                    Margin="10,0"
+                    HorizontalAlignment="Center"
+                    VerticalAlignment="Center"
+                    materialDesign:ButtonAssist.CornerRadius="10"
+                    Style="{StaticResource MaterialDesignRaisedButton}"
+                    Command="{Binding NextCommand}" />
+        </StackPanel>
+    </Grid>
+</UserControl>

+ 15 - 0
TeamAAS-VM/Views/Calibration/FixedUpCameraFindP0.xaml.cs

@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace TeamAAS_VP.Views.Calibration
+{
+    /// <summary>
+    /// Interaction logic for FixedUpCameraFindP0
+    /// </summary>
+    public partial class FixedUpCameraFindP0 : UserControl
+    {
+        public FixedUpCameraFindP0()
+        {
+            InitializeComponent();
+        }
+    }
+}