zly пре 7 месеци
родитељ
комит
1734e78f83

+ 23 - 22
TeamAAS-VM/Core/Cameras/IKapCamera.cs

@@ -656,28 +656,29 @@ namespace TeamAAS_VP.Core.Cameras
         /// </summary>
         public bool SetGain(float gain)
         {
-            _operationSemaphore.Wait();
-            try
-            {
-                if (!IsConnected || _ikDevice.m_hDev.unused == 0)
-                {
-                    return false;
-                }
-
-                // 尝试使用AnalogGain
-                uint res = IKapC.ItkDevSetDouble(_ikDevice.m_hDev, "AnalogGain", gain);
-                if (!CheckIKapC(res))
-                {
-                    // 如果AnalogGain不支持,尝试Gain
-                    res = IKapC.ItkDevSetDouble(_ikDevice.m_hDev, "Gain", gain);
-                    return CheckIKapC(res);
-                }
-                return true;
-            }
-            finally
-            {
-                _operationSemaphore.Release();
-            }
+            //_operationSemaphore.Wait();
+            //try
+            //{
+            //    if (!IsConnected || _ikDevice.m_hDev.unused == 0)
+            //    {
+            //        return false;
+            //    }
+
+            //    尝试使用AnalogGain
+            //    uint res = IKapC.ItkDevSetDouble(_ikDevice.m_hDev, "AnalogGain", gain);
+            //    if (!CheckIKapC(res))
+            //    {
+            //        如果AnalogGain不支持,尝试Gain
+            //       res = IKapC.ItkDevSetDouble(_ikDevice.m_hDev, "Gain", gain);
+            //        return CheckIKapC(res);
+            //    }
+            //    return true;
+            //}
+            //finally
+            //{
+            //    _operationSemaphore.Release();
+            //}
+            return true;
         }
 
         /// <summary>

+ 126 - 31
TeamAAS-VM/Core/Management.cs

@@ -1922,7 +1922,7 @@ namespace TeamAAS_VP.Core
                             }
 
 
-                            if (procIds.Count == 0)
+                            if (procIds.Count == 0 && cameraIndex != currentProduct.PhotoCountStop)
                             {
                                 SendTaskMessage($"Point#{cameraIndex} 未配置任何视觉流程 (CameraProcedureId1/2/3)", MessageLevel.Alarm);
                                 await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
@@ -1932,9 +1932,13 @@ namespace TeamAAS_VP.Core
                             var cameraProcedures = currentProduct.CameraProcedures;
                             if (cameraProcedures == null || cameraProcedures.Count == 0)
                             {
-                                SendTaskMessage($"当前产品未配置 CameraProcedures,无法执行视觉流程", MessageLevel.Alarm);
-                                await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
-                                return;
+                                if(cameraIndex != currentProduct.PhotoCountStop)
+                                {
+                                    SendTaskMessage($"当前产品未配置 CameraProcedures,无法执行视觉流程", MessageLevel.Alarm);
+                                    await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)2);
+                                    return;
+                                }
+                                
                             }
 
                             if (cameraIndex == currentProduct.PhotoCount)
@@ -2296,8 +2300,24 @@ namespace TeamAAS_VP.Core
                                 {
                                     await _remoteCommandService.SetLightBeforePhoto(selectedProcedure);
                                 }
-                                bool Is3dPhoto= Is3D(prcId);
-                                _ImageTaskList.Add(GrabImageEx(cameraIndex, prcId,Is3dPhoto));
+                               
+                               if(sysConfig.PhotosUse==true)
+                                {
+                                    bool Is3dPhoto = Is3D(prcId);
+                                    var tt=await GrabImageEx(cameraIndex, prcId, Is3dPhoto);
+                                    if(tt.IsSucceed==false)
+                                    {
+                                        SendTaskMessage($"图像采集失败!{cameraIndex}: {prcId}", MessageLevel.Alarm);
+                                        return;
+                                    }
+                                    await ExecuteProcedureAsync(cameraIndex, prcId, tt.imges, Is3dPhoto);
+                                }
+                               else
+                                {
+                                    bool Is3dPhoto = Is3D(prcId);
+                                    _ImageTaskList.Add(GrabImageEx(cameraIndex, prcId, Is3dPhoto));
+                                }
+                                 
                                 if (sysConfig.TurnOnAllLightUse == false)
                                 {
                                     await _remoteCommandService.TurnOffLightAfterPhoto(selectedProcedure);
@@ -2328,30 +2348,47 @@ namespace TeamAAS_VP.Core
                             //如果最后一个拍照点,则需要等待前面所有的拍照处理完成
                             if (cameraIndex == currentProduct.PhotoCountStop)
                             {
-                                //等待所有的图像处理流程处理完成
-                                var results = await Task.WhenAll(_PrcTaskList);
-
                                 //结果输出
                                 bool resultFlog = true;
-                                foreach (var item in results)
+                                if (sysConfig.PhotosUse == true)
                                 {
-                                    if (!item.IsSucceed || item.Result == null)
+                                    foreach (var item in lockResultsAll)
                                     {
-                                        resultFlog = false;
-                                        break;
+                                        if (item.PhotoPassed=="NG")
+                                        {
+                                            resultFlog = false;
+                                            break;
+                                        }
+                                        
                                     }
-                                    else
+                                }
+                                else
+                                {
+                                    //等待所有的图像处理流程处理完成
+                                    var results = await Task.WhenAll(_PrcTaskList);
+
+                                    
+                                    foreach (var item in results)
                                     {
-                                        foreach (var item_1 in item.Result)
+                                        if (!item.IsSucceed || item.Result == null)
                                         {
-                                            if (!item_1)
+                                            resultFlog = false;
+                                            break;
+                                        }
+                                        else
+                                        {
+                                            foreach (var item_1 in item.Result)
                                             {
-                                                resultFlog = false;
-                                                break;
+                                                if (!item_1)
+                                                {
+                                                    resultFlog = false;
+                                                    break;
+                                                }
                                             }
                                         }
                                     }
                                 }
+                                
 
                                 //全部OK
                                 if (resultFlog)
@@ -2480,7 +2517,7 @@ namespace TeamAAS_VP.Core
                                     _LastMesCheckTime[i] = (await _mesService.GetServerTimeAsync(code, 2)).Now;
                                     if (homeview.IsNoCode == false)
                                     {
-                                        var device = _configService.GetDeviceInfo();
+                                        var device = _configService.GetDeviceInfo(0);
                                         code = device.XnSN;
                                     }
                                     LogHelper.WriteLogMes($"【mes开始QUERY】");
@@ -2595,7 +2632,7 @@ namespace TeamAAS_VP.Core
                                 else if (state == 2)
                                 {
                                     //获取当前工位的配置
-                                    var stationConfig = _configService.GetDeviceInfo();
+                                    var stationConfig = _configService.GetDeviceInfo(0);
 
                                     List<DataFormCtq> DFC = new List<DataFormCtq>();
                                     SendTaskMessage($"收到{i}上传本站数据请求...", MessageLevel.Debug);
@@ -2636,15 +2673,70 @@ namespace TeamAAS_VP.Core
                                     SendTaskMessage($"mes开始ADD", MessageLevel.Info);
 
                                     StringBuilder submitData = new StringBuilder();
+                                    StringBuilder submitData2 = new StringBuilder();
+                                    StringBuilder submitData3 = new StringBuilder();
+                                    StringBuilder submitData4 = new StringBuilder();
                                     foreach (var item in lockResultsAll)
                                     {
-                                        submitData.Append($"{item.PhotoName}={item.ResultData}");
-                                    }
+                                        //if (submitData.Length < 3500)
+                                        //{
+                                        //    submitData.Append($"{item.PhotoName}={item.ResultData}");
+                                        //}
+                                        string data = $"{item.PhotoName}={item.ResultData}&";
+
+                                        // 按顺序填满,不超过 3500 就加进去
+                                        if (submitData.Length + data.Length <= 3500)
+                                        {
+                                            submitData.Append(data);
+                                        }
+                                        else if (submitData2.Length + data.Length <= 3500)
+                                        {
+                                            submitData2.Append(data);
+                                        }
+                                        else if (submitData3.Length + data.Length <= 3500)
+                                        {
+                                            submitData3.Append(data);
+                                        }
+                                        else if (submitData4.Length + data.Length <= 3500)
+                                        {
+                                            submitData4.Append(data);
+                                        }
+                                        else
+                                        {
+                                            SendTaskMessage($"上传数据数据超出4组最大限制", MessageLevel.Error);
+                                        }
 
+                                    }
+                                    bool allSuccess = true;
                                     ShowMes_Result = resultIndex == 1 ? true : false;
-                                    //(bool isSuccess, string response) = await _mesService.SubmitGetAsync(ProductMainSN, "", MesData.Replace("--", "-"), resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
-                                    (bool isSuccess, string response) = await _mesService.SubmitGetAsync(ProductMainSN, "", submitData.ToString(), resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
-                                    if (isSuccess)
+                                    //(bool isSuccess, string response) = await _mesService.SubmitGetAsync(ProductMainSN, "", submitData.ToString(), resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
+                                    if (submitData.Length > 0)
+                                    {
+                                        string data1 = submitData.ToString().TrimEnd('&');
+                                        (bool isSuccess, string response) = await _mesService.SubmitGetAsync(0,ProductMainSN, "", submitData.ToString(), resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
+                                        allSuccess &= isSuccess;
+                                    }
+                                    if (submitData2.Length > 0)
+                                    {
+                                        string data2 = submitData2.ToString().TrimEnd('&');
+                                        (bool isSuccess, string response) = await _mesService.SubmitGetAsync(1,ProductMainSN, "", submitData2.ToString(), resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
+                                        allSuccess &= isSuccess;
+                                    }
+                                    if (submitData3.Length > 0)
+                                    {
+                                        string data3 = submitData3.ToString().TrimEnd('&');
+                                        (bool isSuccess, string response) = await _mesService.SubmitGetAsync(2,ProductMainSN, "", submitData3.ToString(), resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
+                                        allSuccess &= isSuccess;
+                                    }
+                                    if (submitData4.Length > 0)
+                                    {
+                                        string data4 = submitData4.ToString().TrimEnd('&');
+                                        (bool isSuccess, string response) = await _mesService.SubmitGetAsync(3,ProductMainSN, "", submitData4.ToString(), resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
+                                        allSuccess &= isSuccess;
+                                    }
+
+
+                                    if (allSuccess)
                                     {
                                         LogHelper.WriteLogMes($"上传mes成功");
                                         SendTaskMessage($"上传mes成功", MessageLevel.Debug);
@@ -2660,6 +2752,8 @@ namespace TeamAAS_VP.Core
                                     //是否保存当前的产品记录至CSV?
                                     if (stationConfig.SaveCsv)
                                     {
+                                        string saveppid = "NA";
+                                        if (stationConfig.SaveCsvPPID) saveppid = ppid;
                                         //判断锁付路径字符串是否为空,如果不为空则保存,否则不保存
                                         if (!string.IsNullOrEmpty(stationConfig.SaveCsvPath))
                                         {
@@ -2679,7 +2773,7 @@ namespace TeamAAS_VP.Core
 
                                                 DFC.Add(new DataFormCtq
                                                 {
-                                                    PPID = ppid,
+                                                    PPID = saveppid,
                                                     PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
                                                     PROCESS_START_TIME = _LastMesCheckTime[i].ToString("o"),
                                                     CTQ_NAME = item.PhotoName,
@@ -2716,7 +2810,7 @@ namespace TeamAAS_VP.Core
                                                     {
                                                         DateTime dt = DateTime.Now;
                                                         string filename = $"{ProductMainSN}_{dt.ToString("yyyyMMddHHmmss")}";
-                                                        var device = _configService.GetDeviceInfo();
+                                                        var device = _configService.GetDeviceInfo(i);
                                                         var config = _configService.GetSystemConfiguration();
                                                         string filePath = "";
                                                         (bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN, filename);
@@ -2727,7 +2821,8 @@ namespace TeamAAS_VP.Core
 
                                                             //filePath = $"D:\\Image\\Recored\\{dt.ToString("yyyy-MM")}\\{dt.ToString("MM-dd")}\\{currentProduct.Name}\\{ProductMainSN}";
                                                             filePath = $"{PhotoPath}\\Recored\\{dt.ToString("yyyy-MM")}\\{dt.ToString("MM-dd")}\\{currentProduct.Name}\\{ProductMainSN}";
-                                                            string csvfilename = $"{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
+                                                            string source_csv2 = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
+                                                            //string csvfilename = $"{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}";
                                                             //复制csv
                                                             string source_csv = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DeviceName}_{dt.ToString("yyyy-MM-dd")}.csv";
                                                             //string source_csv1 = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}";
@@ -2748,7 +2843,7 @@ namespace TeamAAS_VP.Core
                                                             if (isAfter20 && isNewDay && !_hasCompressedToday)
                                                             {
                                                                 // 执行压缩
-                                                                CompressionImage(source_csv, csvfilename, device.Station, device.FixtureId);
+                                                                CompressionImage(source_csv2, filename, device.Station, device.FixtureId);
                                                                 _lastCompressDate = dt;
                                                                 _hasCompressedToday = true;
                                                                 LogHelper.WriteLogMes("csv上传数据成功");
@@ -3426,7 +3521,7 @@ namespace TeamAAS_VP.Core
             {
 
 
-                var stationConfig = _configService.GetDeviceInfo();
+                var stationConfig = _configService.GetDeviceInfo(0);
                 if (!stationConfig.EnableMES || !stationConfig.EnableDoubleMes || !stationConfig.SaveCsv)
                 {
                     mesStatus = false;
@@ -3537,7 +3632,7 @@ namespace TeamAAS_VP.Core
             try
             {
                 //获取当前工位的配置
-                var stationConfig = _configService.GetDeviceInfo();
+                var stationConfig = _configService.GetDeviceInfo(0);
                 if (stationConfig == null) return false;
                 //如果保存路径为空,则不保存
                 if (string.IsNullOrEmpty(savePath)) return false;

+ 32 - 0
TeamAAS-VM/Interfaces/IConfigService.cs

@@ -533,5 +533,37 @@ namespace TeamAAS_VP.Interfaces
         /// 保存设备信息配置
         /// </summary>
         void SaveDeviceInfo(DeviceInfo deviceInfo);
+
+        /// <summary>
+        /// 添加新设备
+        /// </summary>
+        /// <returns>新添加的设备</returns>
+        DeviceInfo AddDeviceInfo();
+
+        /// <summary>
+        /// 删除设备
+        /// </summary>
+        /// <param name="deviceNo">设备编号</param>
+        /// <returns>是否删除成功</returns>
+        bool RemoveDeviceInfo(int deviceNo);
+
+        /// <summary>
+        /// 保存所有设备信息列表
+        /// </summary>
+        /// <param name="deviceInfoList">设备信息列表</param>
+        void SaveAllDeviceInfos(IEnumerable<DeviceInfo> deviceInfoList);
+
+        // Device info - 支持多设备
+        /// <summary>
+        /// 获取所有设备信息配置列表
+        /// </summary>
+        /// <returns>设备信息列表的只读集合</returns>
+        IReadOnlyCollection<DeviceInfo> GetAllDeviceInfos();
+
+        /// <summary>
+        /// 根据设备编号获取设备信息
+        /// </summary>
+        /// <param name="deviceNo">设备编号</param>
+        DeviceInfo GetDeviceInfo(int deviceNo);
     }
 }

+ 1 - 1
TeamAAS-VM/Interfaces/IMesService.cs

@@ -104,7 +104,7 @@ namespace TeamAAS_VP.Interfaces
         /// - 若 <paramref name="start_time"/> 晚于 <paramref name="stop_time"/>,实现应记录并视情况返回失败或抛出异常。
         /// - 实现应尊重 <paramref name="cancellationToken"/>,并在取消时尽早中止请求。
         /// </remarks>
-        Task<(bool IsSuccess, string Response)> SubmitGetAsync(string sn, string comp, string mesdata, bool isSuccess, DateTime start_time, DateTime stop_time, CancellationToken cancellationToken = default);
+        Task<(bool IsSuccess, string Response)> SubmitGetAsync(int deviceNo,string sn, string comp, string mesdata, bool isSuccess, DateTime start_time, DateTime stop_time, CancellationToken cancellationToken = default);
 
         /// <summary>
         /// 获取服务器当前时间

+ 6 - 0
TeamAAS-VM/Models/DeviceInfo.cs

@@ -85,6 +85,12 @@ namespace TeamAAS_VP.Models
         /// </summary>
         public bool SaveCsv { get => _saveCsv; set => SetProperty(ref _saveCsv, value); }
 
+        private bool _saveCsvPPID;
+        /// <summary>
+        /// 是否保存CSV文件的PPID,默认不保存
+        /// </summary>
+        public bool SaveCsvPPID { get => _saveCsvPPID; set => SetProperty(ref _saveCsvPPID, value); }
+
         private string _saveCsvPath;
         /// <summary>
         /// 保存的CSV文件路径

+ 19 - 1
TeamAAS-VM/Resources/Languages/Lang.Designer.cs

@@ -19,7 +19,7 @@ namespace TeamAAS_VP.Resources.Languages {
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
     // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     public class Lang {
@@ -105,6 +105,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 CameraBrand_IKap 的本地化字符串。
+        /// </summary>
+        public static string CameraBrand_IKap {
+            get {
+                return ResourceManager.GetString("CameraBrand_IKap", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 大华(MV Viewer) 的本地化字符串。
         /// </summary>
@@ -5325,6 +5334,15 @@ namespace TeamAAS_VP.Resources.Languages {
             }
         }
         
+        /// <summary>
+        ///   查找类似 设备信息 的本地化字符串。
+        /// </summary>
+        public static string 设备信息 {
+            get {
+                return ResourceManager.GetString("设备信息", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 设定参数 的本地化字符串。
         /// </summary>

+ 3 - 0
TeamAAS-VM/Resources/Languages/Lang.en.resx

@@ -2074,4 +2074,7 @@
   <data name="视觉静态精度分析" type="System.Resources.ResXNullRef, System.Windows.Forms">
     <value />
   </data>
+  <data name="设备信息" type="System.Resources.ResXNullRef, System.Windows.Forms">
+    <value />
+  </data>
 </root>

+ 3 - 0
TeamAAS-VM/Resources/Languages/Lang.ja-JP.resx

@@ -2074,4 +2074,7 @@
   <data name="视觉静态精度分析" type="System.Resources.ResXNullRef, System.Windows.Forms">
     <value />
   </data>
+  <data name="设备信息" type="System.Resources.ResXNullRef, System.Windows.Forms">
+    <value />
+  </data>
 </root>

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

@@ -2255,4 +2255,12 @@
     <value>视觉静态精度分析</value>
     <comment>视觉静态精度分析</comment>
   </data>
+  <data name="CameraBrand_IKap" xml:space="preserve">
+    <value>CameraBrand_IKap</value>
+    <comment>CameraBrand_IKap</comment>
+  </data>
+  <data name="设备信息" xml:space="preserve">
+    <value>设备信息</value>
+    <comment>设备信息</comment>
+  </data>
 </root>

+ 3 - 0
TeamAAS-VM/Resources/Languages/Lang.zh-TW.resx

@@ -2074,4 +2074,7 @@
   <data name="视觉静态精度分析" type="System.Resources.ResXNullRef, System.Windows.Forms">
     <value />
   </data>
+  <data name="设备信息" type="System.Resources.ResXNullRef, System.Windows.Forms">
+    <value />
+  </data>
 </root>

+ 137 - 9
TeamAAS-VM/Services/ConfigService.cs

@@ -85,7 +85,8 @@ namespace TeamAAS_VP.Services
         // Device info
         private DeviceInfo _deviceInfo;
 
-        
+        // Device info - 支持多设备
+        private List<DeviceInfo> _deviceInfoList;
         /// <summary>
         /// 注入系统数据库服务(可选),用于记录螺丝批次变更等记录。
         /// </summary>
@@ -256,17 +257,34 @@ namespace TeamAAS_VP.Services
                     FileHelper.WriteJsonFile(_cardReaderConfig, ConfigPaths.CardReaderConfigurationPath);
                 }
 
-                // load device info
+                // load device info list (支持多设备)
                 if (File.Exists(ConfigPaths.DeviceInfoConfigurationPath))
-                    _deviceInfo = FileHelper.ReadJsonFile<DeviceInfo>(ConfigPaths.DeviceInfoConfigurationPath);
-                else
                 {
-                    _deviceInfo = new DeviceInfo();
-                    FileHelper.WriteJsonFile(_deviceInfo, ConfigPaths.DeviceInfoConfigurationPath);
+                    try
+                    {
+                        // 尝试作为列表读取
+                        _deviceInfoList = FileHelper.ReadJsonFile<List<DeviceInfo>>(ConfigPaths.DeviceInfoConfigurationPath);
+                    }
+                    catch
+                    {
+                        // 兼容旧版单个 DeviceInfo,将其转换为列表
+                        var singleDevice = FileHelper.ReadJsonFile<DeviceInfo>(ConfigPaths.DeviceInfoConfigurationPath);
+                        if (singleDevice != null)
+                        {
+                            singleDevice.DeviceNo = 0;
+                            _deviceInfoList = new List<DeviceInfo> { singleDevice };
+                        }
+                        else
+                        {
+                            _deviceInfoList = new List<DeviceInfo> { new DeviceInfo { DeviceNo = 0 } };
+                        }
+                        FileHelper.WriteJsonFile(_deviceInfoList, ConfigPaths.DeviceInfoConfigurationPath);
+                    }
                 }
-                if (_deviceInfo.DataInfo == null)
+                else
                 {
-                    _deviceInfo.DataInfo = new CTQ_Data();
+                    _deviceInfoList = new List<DeviceInfo> { new DeviceInfo { DeviceNo = 0 } };
+                    FileHelper.WriteJsonFile(_deviceInfoList, ConfigPaths.DeviceInfoConfigurationPath);
                 }
             }
         }
@@ -1523,7 +1541,60 @@ namespace TeamAAS_VP.Services
 
         #region DeviceInfo
 
-        
+        /// <summary>
+        /// 获取所有设备信息配置列表
+        /// </summary>
+        /// <returns>设备信息列表的只读集合</returns>
+        public IReadOnlyCollection<DeviceInfo> GetAllDeviceInfos()
+        {
+            lock (_sync)
+            {
+                if (_deviceInfoList == null)
+                {
+                    if (File.Exists(ConfigPaths.DeviceInfoConfigurationPath))
+                    {
+                        try
+                        {
+                            _deviceInfoList = FileHelper.ReadJsonFile<List<DeviceInfo>>(ConfigPaths.DeviceInfoConfigurationPath);
+                        }
+                        catch
+                        {
+                            // 兼容旧版单个 DeviceInfo
+                            var singleDevice = FileHelper.ReadJsonFile<DeviceInfo>(ConfigPaths.DeviceInfoConfigurationPath);
+                            if (singleDevice != null)
+                            {
+                                singleDevice.DeviceNo = 0;
+                                _deviceInfoList = new List<DeviceInfo> { singleDevice };
+                            }
+                            else
+                            {
+                                _deviceInfoList = new List<DeviceInfo> { new DeviceInfo { DeviceNo = 0 } };
+                            }
+                            FileHelper.WriteJsonFile(_deviceInfoList, ConfigPaths.DeviceInfoConfigurationPath);
+                        }
+                    }
+                    else
+                    {
+                        _deviceInfoList = new List<DeviceInfo> { new DeviceInfo { DeviceNo = 0 } };
+                        FileHelper.WriteJsonFile(_deviceInfoList, ConfigPaths.DeviceInfoConfigurationPath);
+                    }
+                }
+                return _deviceInfoList.AsReadOnly();
+            }
+        }
+        /// <summary>
+        /// 根据设备编号获取设备信息
+        /// </summary>
+        /// <param name="deviceNo">设备编号</param>
+        /// <returns>设备信息,若不存在则返回 null</returns>
+        public DeviceInfo GetDeviceInfo(int deviceNo)
+        {
+            lock (_sync)
+            {
+                var allDevices = GetAllDeviceInfos();
+                return allDevices.FirstOrDefault(d => d.DeviceNo == deviceNo);
+            }
+        }
         /// <summary>
         /// 获取设备信息配置
         /// </summary>
@@ -1565,6 +1636,63 @@ namespace TeamAAS_VP.Services
                 FileHelper.WriteJsonFile(_deviceInfo, ConfigPaths.DeviceInfoConfigurationPath);
             }
         }
+
+        /// <summary>
+        /// 添加新设备
+        /// </summary>
+        /// <returns>新添加的设备</returns>
+        public DeviceInfo AddDeviceInfo()
+        {
+            lock (_sync)
+            {
+                if (_deviceInfoList == null)
+                {
+                    _deviceInfoList = new List<DeviceInfo>();
+                }
+
+                // 计算新设备编号
+                int newDeviceNo = _deviceInfoList.Count > 0 ? _deviceInfoList.Max(d => d.DeviceNo) + 1 : 0;
+                var newDevice = new DeviceInfo { DeviceNo = newDeviceNo };
+                _deviceInfoList.Add(newDevice);
+                FileHelper.WriteJsonFile(_deviceInfoList, ConfigPaths.DeviceInfoConfigurationPath);
+                return newDevice;
+            }
+        }
+
+        /// <summary>
+        /// 删除设备
+        /// </summary>
+        /// <param name="deviceNo">设备编号</param>
+        /// <returns>是否删除成功</returns>
+        public bool RemoveDeviceInfo(int deviceNo)
+        {
+            lock (_sync)
+            {
+                if (_deviceInfoList == null) return false;
+                var device = _deviceInfoList.FirstOrDefault(d => d.DeviceNo == deviceNo);
+                if (device != null)
+                {
+                    _deviceInfoList.Remove(device);
+                    FileHelper.WriteJsonFile(_deviceInfoList, ConfigPaths.DeviceInfoConfigurationPath);
+                    return true;
+                }
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// 保存所有设备信息列表
+        /// </summary>
+        /// <param name="deviceInfoList">设备信息列表</param>
+        public void SaveAllDeviceInfos(IEnumerable<DeviceInfo> deviceInfoList)
+        {
+            if (deviceInfoList == null) return;
+            lock (_sync)
+            {
+                _deviceInfoList = deviceInfoList.OrderBy(d => d.DeviceNo).ToList();
+                FileHelper.WriteJsonFile(_deviceInfoList, ConfigPaths.DeviceInfoConfigurationPath);
+            }
+        }
         #endregion
 
         /// <summary>

+ 12 - 10
TeamAAS-VM/Services/MesService.cs

@@ -83,7 +83,7 @@ namespace TeamAAS_VP.Services
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
 
-            var device = _configService.GetDeviceInfo();
+            var device = _configService.GetDeviceInfo(0);
             if (device == null || !device.EnableMES)
             {
                 return (true, "MES功能未启用!");
@@ -194,7 +194,7 @@ namespace TeamAAS_VP.Services
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
 
-            var device = _configService.GetDeviceInfo();
+            var device = _configService.GetDeviceInfo(0);
             if (device == null || !device.EnableMES)
             {
                 return (true, "MES功能未启用!");
@@ -263,12 +263,14 @@ namespace TeamAAS_VP.Services
         /// - 捕获 <see cref="OperationCanceledException"/> 返回 "Canceled",捕获其它异常则返回异常消息。
         /// - 若实例已被释放则抛出 <see cref="ObjectDisposedException"/>。
         /// </remarks>
-        public async Task<(bool IsSuccess, string Response)> SubmitGetAsync(string sn, string comp, string mesdata, bool isSuccess, DateTime start_time, DateTime stop_time, CancellationToken cancellationToken = default)
+        public async Task<(bool IsSuccess, string Response)> SubmitGetAsync(int deviceNo,string sn, string comp, string mesdata, bool isSuccess, DateTime start_time, DateTime stop_time, CancellationToken cancellationToken = default)
         {
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
 
-            var device = _configService.GetDeviceInfo();
+            var device = _configService.GetDeviceInfo(deviceNo);
+            if (device == null)
+                device = _configService.GetDeviceInfo();
             if (device == null || !device.EnableMES)
             {
                 return (true, "MES功能未启用!");
@@ -288,12 +290,12 @@ namespace TeamAAS_VP.Services
             if (device.F == "PTL")
             {
                 url = $"{device.MesUrl}?c=ADD_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&f=PTL&comp={device.comp}:{comp}" +
-                    $"&Mesdata={mesdata}&result={res}&start_time={start_time.ToString("yyyy-MM-dd HH:mm:ss")}&stop_time={stop_time.ToString("yyyy-MM-dd HH:mm:ss")}";
+                    $"&Mesdata{mesdata}result={res}&start_time={start_time.ToString("yyyy-MM-dd HH:mm:ss")}&stop_time={stop_time.ToString("yyyy-MM-dd HH:mm:ss")}";
             }
             else
             {
                 url = $"{device.MesUrl}?c=ADD_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&f=PQC" +
-                    $"&Mesdata={mesdata}&result={res}&start_time={start_time.ToString("yyyy-MM-dd HH:mm:ss")}&stop_time={stop_time.ToString("yyyy-MM-dd HH:mm:ss")}";
+                    $"&Mesdata{mesdata}result={res}&start_time={start_time.ToString("yyyy-MM-dd HH:mm:ss")}&stop_time={stop_time.ToString("yyyy-MM-dd HH:mm:ss")}";
             }
             LogHelper.WriteLogMes($"【上传URL】{url}");
             SendTaskMessage($"【上传URL】{url}", MessageLevel.Info);
@@ -361,7 +363,7 @@ namespace TeamAAS_VP.Services
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
 
-            var device = _configService.GetDeviceInfo();
+            var device = _configService.GetDeviceInfo(0);
             if (device == null || !device.EnableMES)
             {
                 return (true, "MES功能未启用!");
@@ -455,9 +457,9 @@ namespace TeamAAS_VP.Services
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
 
-            var device = _configService.GetDeviceInfo();
+            var device = _configService.GetDeviceInfo(0);
             if (device == null)
-                device = _configService.GetDeviceInfo();
+                device = _configService.GetDeviceInfo(0);
             if (device == null || !device.EnableMES)
             {
                 return (true, DateTime.UtcNow);
@@ -547,7 +549,7 @@ namespace TeamAAS_VP.Services
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
 
-            var device = _configService.GetDeviceInfo();
+            var device = _configService.GetDeviceInfo(0);
             if (device == null || !device.EnableMES)
             {
                 return (true, "MES功能未启用!");

+ 15 - 4
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -2305,7 +2305,7 @@ namespace TeamAAS_VP.Services
                     DateTime nowtime = DateTime.Now;
                     LogHelper.WriteLogInfo("开始采集图像");
                     //var image = camera.Grab();
-                    if (Is3dPhoto = true)
+                    if (Is3dPhoto == true)
                     {
                         image = camera.Grab();
                         image2 = camera.Grab2();
@@ -2322,13 +2322,24 @@ namespace TeamAAS_VP.Services
                     {
                         
                         LogHelper.WriteLogInfo($"采集图像完成;用时:{(DateTime.Now - nowtime).Milliseconds}ms");
-                        if (image == null || image2 == null)
+                        if (image == null )
                         {
 
                             SendTaskMessage(Lang.图像采集失败, MessageLevel.Error);
                             return (false, null, "图像采集失败");
                         }
-                        return (true, new ICogImage[] { image, image2 }, "成功");
+                        if(procedure.PhotoCount>1)
+                        {
+                            if (image2 == null)
+                            {
+
+                                SendTaskMessage(Lang.图像采集失败, MessageLevel.Error);
+                                return (false, null, "图像采集失败");
+                            }
+                            return (true, new ICogImage[] { image, image2 }, "成功");
+                        }
+                        return (true, new ICogImage[] { image}, "成功");
+
                     }
                 }
                 else
@@ -2348,7 +2359,7 @@ namespace TeamAAS_VP.Services
                     DateTime nowtime = DateTime.Now;
                     LogHelper.WriteLogInfo("开始采集图像");
                     //var image = camera.Grab();
-                    if (Is3dPhoto = true)
+                    if (Is3dPhoto == true)
                     {
                         var image = camera.Grab();
                         var image2 = camera.Grab2();

+ 5 - 5
TeamAAS-VM/ViewModels/Product/AdvancedProcedureViewModel.cs

@@ -299,11 +299,11 @@ namespace TeamAAS_VP.ViewModels.Product
                             {
                                 SendTaskMessage($"相机曝光设置失败!", MessageLevel.Error);
                             }
-                            succed = camera.SetGain(SelectProcedure.Gain2);
-                            if (!succed)
-                            {
-                                SendTaskMessage($"相机增益设置失败!", MessageLevel.Error);
-                            }
+                            //succed = camera.SetGain(SelectProcedure.Gain2);
+                            //if (!succed)
+                            //{
+                                //SendTaskMessage($"相机增益设置失败!", MessageLevel.Error);
+                            //}
                             var image2 = camera.Grab();
                             if (image2 != null)
                             {

+ 2 - 1
TeamAAS-VM/ViewModels/Product/CameraParamsViewModel.cs

@@ -712,6 +712,7 @@ namespace TeamAAS_VP.ViewModels.Product
                 {
                     SelectProcedure.ExposureTime = 5000;
                 }
+
                 ExposureTime = SelectProcedure.ExposureTime;
                 ExposureTime2 = SelectProcedure.ExposureTime2;
                 Gain = SelectProcedure.Gain;
@@ -722,7 +723,7 @@ namespace TeamAAS_VP.ViewModels.Product
                 Photo2Light1 = SelectProcedure.Photo2Light1;
                 Photo2Light2 = SelectProcedure.Photo2Light2;
                 Photo2Light3 = SelectProcedure.Photo2Light3;
-
+                PhotoCount = SelectProcedure.PhotoCount;
                 if (Camera != null && !_remoteCommandService.IsExecuting)
                 {
                     Camera.SetExposureTime(ExposureTime);

+ 86 - 4
TeamAAS-VM/ViewModels/SettingViewModel.cs

@@ -396,6 +396,22 @@ namespace TeamAAS_VP.ViewModels
             get { return _SelectProduct; }
             set { SetProperty(ref _SelectProduct, value); }
         }
+
+        // 当前选中的设备信息
+        private DeviceInfo _SelectDeviceInfo;
+        public DeviceInfo SelectDeviceInfo
+        {
+            get { return _SelectDeviceInfo; }
+            set { SetProperty(ref _SelectDeviceInfo, value); }
+        }
+
+        // 设备信息列表
+        private ObservableCollection<DeviceInfo> _DeviceInfoList;
+        public ObservableCollection<DeviceInfo> DeviceInfoList
+        {
+            get { return _DeviceInfoList; }
+            set { SetProperty(ref _DeviceInfoList, value); }
+        }
         #endregion
 
         #region 命令
@@ -514,6 +530,14 @@ namespace TeamAAS_VP.ViewModels
         public DelegateCommand CheckStatusCommand =>
             _CheckStatusCommand ?? (_CheckStatusCommand = new DelegateCommand(ExecuteCheckStatusCommandCommand));
 
+        private DelegateCommand _AddDeviceInfoCommand;
+        public DelegateCommand AddDeviceInfoCommand => _AddDeviceInfoCommand ?? (_AddDeviceInfoCommand = new DelegateCommand(ExecuteAddDeviceInfoCommand));
+
+        private DelegateCommand _RemoveDeviceInfoCommand;
+        public DelegateCommand RemoveDeviceInfoCommand => _RemoveDeviceInfoCommand ?? (_RemoveDeviceInfoCommand = new DelegateCommand(ExecuteRemoveDeviceInfoCommand));
+
+        
+
         #endregion
 
         #region 事件
@@ -1403,9 +1427,16 @@ namespace TeamAAS_VP.ViewModels
                 BgModbus = _configService.GetBgModbusTcp();
             }
 
-            if (DeviceInfo == null)
+            if (DeviceInfoList == null || DeviceInfoList.Count == 0)
             {
-                DeviceInfo = _configService.GetDeviceInfo();
+                // load device info list (支持多设备)
+                var devices = _configService.GetAllDeviceInfos();
+                DeviceInfoList = new ObservableCollection<DeviceInfo>(devices);
+                // 默认选中第一个设备
+                if (DeviceInfoList.Count > 0)
+                {
+                    SelectDeviceInfo = DeviceInfoList[0];
+                }
             }
             if (CardReaderConfig == null)
             {
@@ -1676,9 +1707,10 @@ namespace TeamAAS_VP.ViewModels
         {
             try
             {
-                if (DeviceInfo != null)
+                if (DeviceInfoList != null && DeviceInfoList.Count > 0)
                 {
-                    _configService.SaveDeviceInfo(DeviceInfo);
+                    // 保存所有设备信息
+                    _configService.SaveAllDeviceInfos(DeviceInfoList);
                     _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
                 }
             }
@@ -1688,6 +1720,56 @@ namespace TeamAAS_VP.ViewModels
             }
         }
 
+        /// <summary>
+        /// 添加新设备
+        /// </summary>
+        void ExecuteAddDeviceInfoCommand()
+        {
+            try
+            {
+                var newDevice = _configService.AddDeviceInfo();
+                if (DeviceInfoList == null)
+                {
+                    DeviceInfoList = new ObservableCollection<DeviceInfo>();
+                }
+                DeviceInfoList.Add(newDevice);
+                SelectDeviceInfo = newDevice;
+                _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
+            }
+            catch (Exception ex)
+            {
+                _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
+            }
+        }
+
+        /// <summary>
+        /// 删除当前选中的设备
+        /// </summary>
+        void ExecuteRemoveDeviceInfoCommand()
+        {
+            try
+            {
+                if (SelectDeviceInfo != null && DeviceInfoList != null && DeviceInfoList.Count > 1)
+                {
+                    var deviceNo = SelectDeviceInfo.DeviceNo;
+                    if (_configService.RemoveDeviceInfo(deviceNo))
+                    {
+                        DeviceInfoList.Remove(SelectDeviceInfo);
+                        SelectDeviceInfo = DeviceInfoList.FirstOrDefault();
+                        _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
+                    }
+                }
+                else
+                {
+                    _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "至少保留一个设备", Duration = 2 });
+                }
+            }
+            catch (Exception ex)
+            {
+                _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
+            }
+        }
+
         /// <summary>
         /// 选择CSV存储路径
         /// </summary>

+ 253 - 236
TeamAAS-VM/Views/SettingView.xaml

@@ -494,387 +494,404 @@
                 <TabItem.Header>
                     <StackPanel HorizontalAlignment="Stretch">
                         <materialDesign:PackIcon Width="24"
-                                                 Height="24"
-                                                 HorizontalAlignment="Center"
-                                                 Kind="RouterNetwork" />
+                                     Height="24"
+                                     HorizontalAlignment="Center"
+                                     Kind="RouterNetwork" />
                         <TextBlock Style="{StaticResource TabHeaderTextBlockStyle}"
-                                   FontSize="{DynamicResource Font.Size.Body2}"
-                                   Text="设备信息"
-                                   HorizontalAlignment="Stretch" />
+                       FontSize="{DynamicResource Font.Size.Body2}"
+                       Text="{lex:Loc 设备信息}"
+                       HorizontalAlignment="Stretch" />
                     </StackPanel>
                 </TabItem.Header>
-                <Grid>
+
+                <Grid Margin="16">
                     <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" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
-                        <RowDefinition Height="Auto" />
+                        <RowDefinition Height="50" />
+                        <RowDefinition Height="*" />
                     </Grid.RowDefinitions>
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="auto" />
                         <ColumnDefinition Width="*" />
                     </Grid.ColumnDefinitions>
 
-                    <TextBlock Grid.Row="0"
+                    <!--增删改查按钮-->
+                    <StackPanel Grid.ColumnSpan="2"
+                    IsEnabled="{Binding IsAllowEdit}"
+                    Orientation="Horizontal">
+                        <Button Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
+                    ToolTip="添加设备"
+                    Command="{Binding AddDeviceInfoCommand}">
+                            <materialDesign:PackIcon Kind="Plus" />
+                        </Button>
+                        <Button Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}"
+                    ToolTip="删除设备"
+                    Margin="20,0"
+                    Command="{Binding RemoveDeviceInfoCommand}">
+                            <materialDesign:PackIcon Kind="DeleteForeverOutline" />
+                        </Button>
+                        <Button Style="{StaticResource MaterialDesignFloatingActionMiniSecondaryDarkButton}"
+                    ToolTip="{lex:Loc 保存}"
+                    Command="{Binding SaveDeviceInfoCommand}">
+                            <materialDesign:PackIcon Kind="ContentSaveCheck" />
+                        </Button>
+                    </StackPanel>
+
+                    <!--设备列表-->
+                    <TreeView Grid.Row="1"
+                  Grid.Column="0"
+                  SelectedItemChanged="TreeView_SelectedItemChanged">
+                        <TreeViewItem Header="设备列表"
+                          FontSize="{DynamicResource Font.Size.Title4}"
+                          FontWeight="Bold"
+                          IsExpanded="True"
+                          ItemsSource="{Binding DeviceInfoList}">
+                            <TreeViewItem.ItemTemplate>
+                                <HierarchicalDataTemplate>
+                                    <StackPanel Orientation="Vertical">
+                                        <TextBlock FontSize="{DynamicResource Font.Size.Title4}">
+                                            <TextBlock.Text>
+                                                <MultiBinding StringFormat="设备 {0}">
+                                                    <Binding Path="DeviceNo" />
+                                                </MultiBinding>
+                                            </TextBlock.Text>
+                                        </TextBlock>
+                                        <StackPanel Orientation="Horizontal">
+                                            <TextBlock Text="DeviceName: "
+                                           Style="{StaticResource MaterialDesignCaptionTextBlock}"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+                                            <TextBlock Text="{Binding DeviceName}"
+                                           Style="{StaticResource MaterialDesignCaptionTextBlock}"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal">
+                                            <TextBlock Text="Line: "
+                                           Style="{StaticResource MaterialDesignCaptionTextBlock}"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+                                            <TextBlock Text="{Binding Line}"
+                                           Style="{StaticResource MaterialDesignCaptionTextBlock}"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+                                        </StackPanel>
+                                        <StackPanel Orientation="Horizontal">
+                                            <TextBlock Text="Station: "
+                                           Style="{StaticResource MaterialDesignCaptionTextBlock}"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+                                            <TextBlock Text="{Binding Station}"
+                                           Style="{StaticResource MaterialDesignCaptionTextBlock}"
+                                           FontSize="{DynamicResource Font.Size.Body3}" />
+                                        </StackPanel>
+                                        <Border Height="2"
+                                    Margin="0"
+                                    BorderThickness="2"
+                                    BorderBrush="Green" />
+                                    </StackPanel>
+                                </HierarchicalDataTemplate>
+                            </TreeViewItem.ItemTemplate>
+                        </TreeViewItem>
+                    </TreeView>
+
+                    <!--参数详情-->
+                    <ScrollViewer Grid.Row="1"
+                      Grid.Column="1"
+                      IsEnabled="{Binding IsAllowEdit}"
+                      Margin="20"
+                      Visibility="{Binding SelectDeviceInfo,Converter={StaticResource ObjectToVisibilityConverter}}">
+                        <Grid>
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="auto" />
+                                <RowDefinition Height="auto" />
+                            </Grid.RowDefinitions>
+
+                            <!--设备信息表单-->
+                            <Grid>
+                                <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" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <RowDefinition Height="Auto" />
+                                    <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 Grid.Row="0"
                                Grid.Column="0"
                                Text="设备编号:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBlock Grid.Row="0"
+                                <TextBlock Grid.Row="0"
                                Grid.Column="1"
-                               Text="{Binding DeviceInfo.DeviceNo}"
+                               Text="{Binding SelectDeviceInfo.DeviceNo}"
                                Margin="6,2"
                                VerticalAlignment="Center" />
 
-                    <TextBlock Grid.Row="1"
+                                <TextBlock Grid.Row="1"
                                Grid.Column="0"
                                Text="设备名称:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="1"
+                                <TextBox Grid.Row="1"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DeviceName, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.DeviceName, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="2"
+                                <TextBlock Grid.Row="2"
                                Grid.Column="0"
                                Text="设备描述:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="2"
+                                <TextBox Grid.Row="2"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DeviceDesc, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.DeviceDesc, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="3"
+                                <TextBlock Grid.Row="3"
                                Grid.Column="0"
                                Text="Url:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="3"
+                                <TextBox Grid.Row="3"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.MesUrl, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.MesUrl, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="4"
+                                <TextBlock Grid.Row="4"
                                Grid.Column="0"
                                Text="Line:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="4"
+                                <TextBox Grid.Row="4"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.Line, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.Line, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="5"
+                                <TextBlock Grid.Row="5"
                                Grid.Column="0"
                                Text="Station:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="5"
+                                <TextBox Grid.Row="5"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.Station, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.Station, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="6"
+                                <TextBlock Grid.Row="6"
                                Grid.Column="0"
                                Text="FixtureId:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="6"
+                                <TextBox Grid.Row="6"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.FixtureId, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.FixtureId, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="7"
+                                <TextBlock Grid.Row="7"
                                Grid.Column="0"
                                Text="f:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="7"
+                                <TextBox Grid.Row="7"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.F, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.F, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="8"
+                                <TextBlock Grid.Row="8"
                                Grid.Column="0"
                                Text="comp:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="8"
+                                <TextBox Grid.Row="8"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.comp, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.comp, Mode=TwoWay}"
+                             Margin="6,2" />
+
+                                <TextBlock Grid.Row="9"
+                               Grid.Column="0"
+                               Text="LogUrl:"
+                               HorizontalAlignment="Right"
+                               VerticalAlignment="Center" />
+                                <TextBox Grid.Row="9"
+                             Grid.Column="1"
+                             Text="{Binding SelectDeviceInfo.LogUrl, Mode=TwoWay}"
                              Margin="6,2" />
-                    
-                    <TextBlock Grid.Row="9"
-                       Grid.Column="0"
-                       Text="LogUrl:"
-                       HorizontalAlignment="Right"
-                       VerticalAlignment="Center" />
-                    <TextBox Grid.Row="9"
-                         Grid.Column="1"
-                         Text="{Binding DeviceInfo.LogUrl, Mode=TwoWay}"
-                         Margin="6,2" />
-
-                    <TextBlock Grid.Row="10"
-                       Grid.Column="0"
-                       Text="apikey:"
-                       HorizontalAlignment="Right"
-                       VerticalAlignment="Center" />
-                    <TextBox Grid.Row="10"
-                         Grid.Column="1"
-                         Text="{Binding DeviceInfo.ApiKey, Mode=TwoWay}"
-                         Margin="6,2" />
 
+                                <TextBlock Grid.Row="10"
+                               Grid.Column="0"
+                               Text="apikey:"
+                               HorizontalAlignment="Right"
+                               VerticalAlignment="Center" />
+                                <TextBox Grid.Row="10"
+                             Grid.Column="1"
+                             Text="{Binding SelectDeviceInfo.ApiKey, Mode=TwoWay}"
+                             Margin="6,2" />
 
-                    <TextBlock Grid.Row="11"
+                                <TextBlock Grid.Row="11"
                                Grid.Column="0"
                                Text="启用 MES:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <CheckBox Grid.Row="11"
+                                <CheckBox Grid.Row="11"
                               Grid.Column="1"
-                              IsChecked="{Binding DeviceInfo.EnableMES, Mode=TwoWay}"
+                              IsChecked="{Binding SelectDeviceInfo.EnableMES, Mode=TwoWay}"
                               Command="{Binding CheckStatusCommand}"
                               Margin="6,2" />
-                    <CheckBox Grid.Row="12"
+                                <CheckBox Grid.Row="12"
                               Grid.Column="1"
                               Content="是否启用两次产品编号"
-                              IsChecked="{Binding DeviceInfo.EnableDoubleMes, Mode=TwoWay}"
-                              Margin="6,2" />
-                    <CheckBox Grid.Row="13"
-                              Grid.Column="1"
-                              Content="是否保存CSV文件"
-                              IsChecked="{Binding DeviceInfo.SaveCsv, Mode=TwoWay}"
-                              Command="{Binding CheckStatusCommand}"
+                              IsChecked="{Binding SelectDeviceInfo.EnableDoubleMes, Mode=TwoWay}"
                               Margin="6,2" />
-                    <TextBlock Grid.Row="14"
+                                <StackPanel Grid.Row="13"
+                                Grid.Column="1"
+                                Orientation="Horizontal">
+                                    <CheckBox Content="是否保存CSV文件"
+                                  IsChecked="{Binding SelectDeviceInfo.SaveCsv, Mode=TwoWay}"
+                                  Command="{Binding CheckStatusCommand}"
+                                  Margin="6,2" />
+                                    <CheckBox Content="是否保存ppid"
+                                  IsChecked="{Binding SelectDeviceInfo.SaveCsvPPID, Mode=TwoWay}"
+                                  Margin="6,2" />
+                                </StackPanel>
+                                <TextBlock Grid.Row="14"
                                Grid.Column="0"
                                Text="保存的CSV文件路径:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <DockPanel HorizontalAlignment="Stretch"
+                                <DockPanel HorizontalAlignment="Stretch"
                                Grid.Row="14"
                                Grid.Column="1"
                                Margin="6,2">
-                        <Button DockPanel.Dock="Right"
+                                    <Button DockPanel.Dock="Right"
                                 HorizontalAlignment="Right"
                                 ToolTip="{lex:Loc 选择路径}"
-                                Command="{Binding SelectSaveImagePathCommand}">
-                            <Button.Content>
-                                <materialDesign:PackIcon Kind="FolderOpenOutline" />
-                            </Button.Content>
-                        </Button>
-                        <TextBox  Text="{Binding DeviceInfo.SaveCsvPath, Mode=TwoWay}" />
-
-                    </DockPanel>
-                    <!--CTQ 数据信息-->
-                    <TextBlock Grid.Row="15"
+                                Command="{Binding CurrentRunStatus}">
+                                        <Button.Content>
+                                            <materialDesign:PackIcon Kind="FolderOpenOutline" />
+                                        </Button.Content>
+                                    </Button>
+                                    <TextBox  Text="{Binding SelectDeviceInfo.SaveCsvPath, Mode=TwoWay}" />
+
+                                </DockPanel>
+                                <!--CTQ 数据信息-->
+                                <TextBlock Grid.Row="15"
                                Grid.Column="0"
                                Text="PROCESS_NAME:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="15"
+                                <TextBox Grid.Row="15"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DataInfo.PROCESS_NAME, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.DataInfo.PROCESS_NAME, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="16"
+                                <!--<TextBlock Grid.Row="14"
                                Grid.Column="0"
-                               Text="SUPPLIER_NAME:"
+                               Text="CTQ_LSL(压力下限):"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="16"
+                    <TextBox Grid.Row="14"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DataInfo.SUPPLIER_NAME, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.DataInfo.CTQ_LSL_Pressure, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="17"
+                    <TextBlock Grid.Row="15"
                                Grid.Column="0"
-                               Text="COMMODITY_TYPE:"
+                               Text="CTQ_USL(压力上限):"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="17"
+                    <TextBox Grid.Row="15"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DataInfo.COMMODITY_TYPE, Mode=TwoWay}"
-                             Margin="6,2" />
+                             Text="{Binding SelectDeviceInfo.DataInfo.CTQ_USL_Pressure, Mode=TwoWay}"
+                             Margin="6,2" />-->
 
-                    <TextBlock Grid.Row="18"
+                                <TextBlock Grid.Row="18"
                                Grid.Column="0"
-                               Text="REVISION:"
+                               Text="SUPPLIER_NAME:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="18"
+                                <TextBox Grid.Row="18"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DataInfo.REVISION, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.DataInfo.SUPPLIER_NAME, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="19"
+                                <TextBlock Grid.Row="19"
                                Grid.Column="0"
-                               Text="MFG_LOT#:"
+                               Text="COMMODITY_TYPE:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="19"
+                                <TextBox Grid.Row="19"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DataInfo.MFG_LOT, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.DataInfo.COMMODITY_TYPE, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="20"
+                                <TextBlock Grid.Row="20"
                                Grid.Column="0"
-                               Text="MFG_ASSY_LINE:"
+                               Text="REVISION:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="20"
+                                <TextBox Grid.Row="20"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DataInfo.MFG_ASSY_LINE, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.DataInfo.REVISION, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="21"
+                                <TextBlock Grid.Row="21"
                                Grid.Column="0"
-                               Text="PROCESS_MACHINE_ID:"
+                               Text="MFG_LOT#:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="21"
+                                <TextBox Grid.Row="21"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.DataInfo.PROCESS_MACHINE_ID, Mode=TwoWay}"
+                             Text="{Binding SelectDeviceInfo.DataInfo.MFG_LOT, Mode=TwoWay}"
                              Margin="6,2" />
 
-                    <TextBlock Grid.Row="22"
-                       Grid.Column="0"
-                       Text="虚拟SN:"
-                       HorizontalAlignment="Right"
-                       VerticalAlignment="Center" />
-                    <TextBox Grid.Row="22"
-                         Grid.Column="1"
-                         Text="{Binding DeviceInfo.XnSN, Mode=TwoWay}"
-                         Margin="6,2" />
-
-
-                    <Button Content="保存"
-                            Command="{Binding SaveDeviceInfoCommand}"
-                            Grid.Row="23"
-                            HorizontalAlignment="Center"
-                            Margin="0,10"
-                            Grid.Column="1" />
-                </Grid>
-                <!--<Grid Margin="16">
-                    <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" />
-                        <RowDefinition Height="Auto" />
-                    </Grid.RowDefinitions>
-                    <Grid.ColumnDefinitions>
-                        <ColumnDefinition Width="auto" />
-                        <ColumnDefinition Width="*" />
-                    </Grid.ColumnDefinitions>
-
-                    <TextBlock Grid.Row="0"
-                               Grid.Column="0"
-                               Text="Url:"
-                               HorizontalAlignment="Right"
-                               VerticalAlignment="Center" />
-                    <TextBox Grid.Row="0"
-                             Grid.Column="1"
-                             Text="{Binding DeviceInfo.MesUrl, Mode=TwoWay}"
-                             Margin="6" />
-
-                    <TextBlock Grid.Row="1"
-                               Grid.Column="0"
-                               Text="Line:"
-                               HorizontalAlignment="Right"
-                               VerticalAlignment="Center" />
-                    <TextBox Grid.Row="1"
-                             Grid.Column="1"
-                             Text="{Binding DeviceInfo.Line, Mode=TwoWay}"
-                             Margin="6" />
-
-                    <TextBlock Grid.Row="2"
-                               Grid.Column="0"
-                               Text="Station:"
-                               HorizontalAlignment="Right"
-                               VerticalAlignment="Center" />
-                    <TextBox Grid.Row="2"
-                             Grid.Column="1"
-                             Text="{Binding DeviceInfo.Station, Mode=TwoWay}"
-                             Margin="6" />
-
-
-
-                    <TextBlock Grid.Row="3"
+                                <TextBlock Grid.Row="22"
                                Grid.Column="0"
-                               Text="FixtureId:"
+                               Text="MFG_ASSY_LINE:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="3"
+                                <TextBox Grid.Row="22"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.FixtureId, Mode=TwoWay}"
-                             Margin="6" />
+                             Text="{Binding SelectDeviceInfo.DataInfo.MFG_ASSY_LINE, Mode=TwoWay}"
+                             Margin="6,2" />
 
-                    <TextBlock Grid.Row="5"
-                               Grid.Column="0"
-                               Text="f:"
-                               HorizontalAlignment="Right"
-                               VerticalAlignment="Center" />
-                    <TextBox Grid.Row="5"
-                             Grid.Column="1"
-                             Text="{Binding DeviceInfo.F, Mode=TwoWay}"
-                             Margin="6" />
-                    <TextBlock Grid.Row="6"
+                                <TextBlock Grid.Row="23"
                                Grid.Column="0"
-                               Text="comp:"
+                               Text="PROCESS_MACHINE_ID:"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center" />
-                    <TextBox Grid.Row="6"
+                                <TextBox Grid.Row="23"
                              Grid.Column="1"
-                             Text="{Binding DeviceInfo.comp, Mode=TwoWay}"
-                             Margin="6" />
-
-                    <TextBlock Grid.Row="7"
-                               Grid.Column="0"
-                               Text="启用 MES:"
-                               HorizontalAlignment="Right"
-                               VerticalAlignment="Center" />
-                    <CheckBox Grid.Row="7"
-                              Grid.Column="1"
-                              IsChecked="{Binding DeviceInfo.EnableMES, Mode=TwoWay}"
-                              Margin="6" />
-                    <StackPanel Orientation="Horizontal"
-                                HorizontalAlignment="Right"
-                                Grid.Row="8"
-                                Grid.ColumnSpan="2"
-                                Margin="6">
-                        <Button Style="{StaticResource MaterialDesignRaisedButton}"
-                                Command="{Binding SaveDeviceInfoCommand}">保存</Button>
-                    </StackPanel>
-                </Grid>-->
+                             Text="{Binding SelectDeviceInfo.DataInfo.PROCESS_MACHINE_ID, Mode=TwoWay}"
+                             Margin="6,2" />
+                            </Grid>
+                        </Grid>
+                    </ScrollViewer>
+                </Grid>
             </TabItem>
 
             <!--机器人-->

+ 4 - 0
TeamAAS-VM/Views/SettingView.xaml.cs

@@ -51,6 +51,10 @@ namespace TeamAAS_VP.Views
                 {
                     viewModel.SelectLightController = e.NewValue as LightControllerConfig;
                 }
+                else if (e.NewValue is DeviceInfo)
+                {
+                    viewModel.SelectDeviceInfo = e.NewValue as DeviceInfo;
+                }
             }
             catch (Exception)
             {