wanghan 7 ay önce
ebeveyn
işleme
73ae0fabba

+ 7 - 5
TeamAAS-VM/Core/Management.cs

@@ -2253,9 +2253,10 @@ namespace TeamAAS_VP.Core
                                 {
                                     return;
                                 }
-                                //var code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, i));
-                                var code = "CN0NJTYVLXU0061W0001";
-                                string comp = "110RNYV4123456789012345";
+                                var code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, i));
+                                string comp = PartSN;
+                                //code = "CN0NJTYVLXU0061W0001";
+                                //comp = "110RNYV4123456789012345";
                                 //询问mes
                                 if (state == 1)
                                 {
@@ -2265,7 +2266,7 @@ namespace TeamAAS_VP.Core
 
                                     LogHelper.WriteLogMes($"【mes开始QUERY】");
                                     SendTaskMessage($"mes开始QUERY", MessageLevel.Info);
-                                    (bool isSuccess, string response) = await _mesService.StationGetAsync(code, comp, 2);
+                                    (bool isSuccess, string response) = await _mesService.StationGetAsync(i,code, comp, 2);
                                     if (i == 0)
                                     {
                                         SendTaskMessage($"收到当前过站检查请求(当站是否生产)...", MessageLevel.Debug);
@@ -2374,7 +2375,8 @@ namespace TeamAAS_VP.Core
                                     press = p2.PressureNum.ToString();
                                     presstime = p2.PressureTime.ToString();
                                     assypress = assemblyRecord.AssemblyPressure.ToString();
-                                    (bool isSuccess, string response) = await _mesService.SubmitGetAsync(code, comp, gap, press, presstime, assypress, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
+                                    //gap-复检gap参数, press-保压站实际压力值, presstime-保压站保压时间, assypress-组装站实际压力值
+                                    (bool isSuccess, string response) = await _mesService.SubmitGetAsync(i,code, comp, gap, press, presstime, assypress, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
                                     if (isSuccess)
                                     {
                                         LogHelper.WriteLogMes($"上传mes成功");

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

@@ -27,7 +27,7 @@ namespace TeamAAS_VP.Interfaces
         /// - 实现应尊重 <paramref name="cancellationToken"/>,在取消时尽早抛出 <see cref="OperationCanceledException"/> 或返回失败结果。
         /// - 若 <paramref name="sn"/> 无效,应抛出 <see cref="ArgumentNullException"/> 或 <see cref="ArgumentException"/>。
         /// </remarks>
-        Task<(bool IsSuccess, string Response)> StationGetAsync(string sn, string comp, CancellationToken cancellationToken = default);
+        Task<(bool IsSuccess, string Response)> StationGetAsync(int num, string sn, string comp, CancellationToken cancellationToken = default);
 
         /// <summary>
         /// 使用配置的过站(Station)URL 发起 GET 请求,携带序列号(sn)作为查询参数进行过站,并使用指定的超时时间(秒)。
@@ -43,7 +43,7 @@ namespace TeamAAS_VP.Interfaces
         /// - 此重载方便在不使用 <see cref="CancellationToken"/> 的场景中指定超时时间。
         /// - 实现应验证 <paramref name="timeoutInSeconds"/> 为合理值(例如 > 0),否则可抛出 <see cref="ArgumentOutOfRangeException"/>。
         /// </remarks>
-        Task<(bool IsSuccess, string Response)> StationGetAsync(string sn, string comp, double timeoutInSeconds);
+        Task<(bool IsSuccess, string Response)> StationGetAsync(int num, string sn, string comp, double timeoutInSeconds);
 
         /// <summary>
         /// 使用配置的提交(Submit)URL 发起 GET 请求,提交过站结果及时间信息。
@@ -63,7 +63,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 gap, string press, string presstime, string assypress, bool isSuccess, DateTime start_time, DateTime stop_time, CancellationToken cancellationToken = default);
+        Task<(bool IsSuccess, string Response)> SubmitGetAsync(int num, string sn, string comp, string gap, string press, string presstime, string assypress, bool isSuccess, DateTime start_time, DateTime stop_time, CancellationToken cancellationToken = default);
 
         /// <summary>
         /// 使用配置的提交(Submit)URL 发起 GET 请求,提交过站结果及时间信息,并使用指定的超时时间(秒)。
@@ -82,6 +82,6 @@ namespace TeamAAS_VP.Interfaces
         /// - 此重载用于在不传入 <see cref="CancellationToken"/> 的场景中指定超时时间。
         /// - 实现应确保对时间参数与布尔参数进行适当的 URL 编码或格式化。
         /// </remarks>
-        Task<(bool IsSuccess, string Response)> SubmitGetAsync(string sn, string comp, string gap, string press, string presstime, string assypress, bool isSuccess, DateTime start_time, DateTime stop_time, double timeoutInSeconds);
+        Task<(bool IsSuccess, string Response)> SubmitGetAsync(int num, string sn, string comp, string gap, string press, string presstime, string assypress, bool isSuccess, DateTime start_time, DateTime stop_time, double timeoutInSeconds);
     }
 }

+ 43 - 16
TeamAAS-VM/Services/MesService.cs

@@ -76,7 +76,7 @@ namespace TeamAAS_VP.Services
         /// - 捕获 <see cref="OperationCanceledException"/> 返回 "Canceled",捕获其它异常则返回异常消息。
         /// - 若实例已被释放则抛出 <see cref="ObjectDisposedException"/>。
         /// </remarks>
-        public async Task<(bool IsSuccess, string Response)> StationGetAsync(string sn, string comp, CancellationToken cancellationToken = default)
+        public async Task<(bool IsSuccess, string Response)> StationGetAsync(int num, string sn, string comp, CancellationToken cancellationToken = default)
         {
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
@@ -97,13 +97,25 @@ namespace TeamAAS_VP.Services
             }
 
             string url = "";
-            if (device.F == "PTL")
+            string[] station = new string[3];
+            string[] fixtureId = new string[3];
+            station = device.Station.Split(',');
+            fixtureId = device.FixtureId.Split(',');
+
+            if (num == 0)//组装站
             {
-                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&comp={device.comp}:{comp}&p=unit_process_check,message,model";
+                if (device.F == "PTL")
+                {
+                    url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={station[num]}&fixtureid={fixtureId[num]}&sn={sn}&comp={device.comp}:{comp}&p=unit_process_check,message,model";
+                }
+                else
+                {
+                    url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={station[num]}&fixtureid={fixtureId[num]}&sn={sn}&p=unit_process_check,message,model";
+                }
             }
-            else
+            else//保压站
             {
-                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&p=unit_process_check,message,model";
+                url = $"{device.MesUrl}?c=QUERY_RECORD&line={device.Line}&station={station[num]}&fixtureid={fixtureId[num]}&sn={sn}&p=unit_process_check,message,model";
             }
 
             LogHelper.WriteLogMes($"【询问URL】{url}");
@@ -149,11 +161,11 @@ namespace TeamAAS_VP.Services
         /// <param name="sn">序列号(SN)。</param>
         /// <param name="timeoutInSeconds">请求超时,单位为秒。</param>
         /// <returns>与 <see cref="StationGetAsync(string, CancellationToken)"/> 相同的返回语义。</returns>
-        public async Task<(bool IsSuccess, string Response)> StationGetAsync(string sn, string comp, double timeoutInSeconds)
+        public async Task<(bool IsSuccess, string Response)> StationGetAsync(int num, string sn, string comp, double timeoutInSeconds)
         {
             using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutInSeconds)))
             {
-                return await StationGetAsync(sn, comp, cts.Token);
+                return await StationGetAsync(num, sn, comp, cts.Token);
             }
         }
 
@@ -179,7 +191,7 @@ 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 gap,string press,string presstime,string assypress, bool isSuccess, DateTime start_time, DateTime stop_time, CancellationToken cancellationToken = default)
+        public async Task<(bool IsSuccess, string Response)> SubmitGetAsync(int num, string sn, string comp, string gap, string press, string presstime, string assypress, bool isSuccess, DateTime start_time, DateTime stop_time, CancellationToken cancellationToken = default)
         {
             // 如果已经释放,则抛出异常,防止在已释放资源上继续操作。
             if (_disposed) throw new ObjectDisposedException(nameof(MesService));
@@ -201,18 +213,33 @@ namespace TeamAAS_VP.Services
 
             string res = isSuccess ? "PASS" : "FAIL";
             string url = "";
-            if (device.F == "PTL")
+            string[] station = new string[3];
+            string[] fixtureId = new string[3];
+            station = device.Station.Split(',');
+            fixtureId = device.FixtureId.Split(',');
+
+            if (num == 0)//组装站
             {
-                url = $"{device.MesUrl}?c=ADD_RECORD&line={device.Line}&station={device.Station}&fixtureid={device.FixtureId}&sn={sn}&f=PTL&comp={device.comp}:{comp}" +
-                    $"&gap={gap}&pressure={press}&pressure_time={presstime}&assy_pressure={assypress}" +
+                if (device.F == "PTL")
+                {
+                    url = $"{device.MesUrl}?c=ADD_RECORD&line={device.Line}&station={station[num]}&fixtureid={fixtureId[num]}&sn={sn}&f=PTL&comp={device.comp}:{comp}" +
+                    $"&gap={gap}&assy_pressure={assypress}" +
                     $"&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={station[num]}&fixtureid={fixtureId[num]}&sn={sn}&f=PQC" +
+                  $"&gap={gap}&assy_pressure={assypress}" +
+                  $"&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" +
-                    $"&gap={gap}&pressure={press}&pressure_time={presstime}&assy_pressure={assypress}" +
-                    $"&result={res}&start_time={start_time.ToString("yyyy-MM-dd HH:mm:ss")}&stop_time={stop_time.ToString("yyyy-MM-dd HH:mm:ss")}";
+                url = $"{device.MesUrl}?c=ADD_RECORD&line={device.Line}&station={station[num]}&fixtureid={fixtureId[num]}&sn={sn}&f=PQC" +
+                  $"&pressure={press}&pressure_time={presstime}" +
+                  $"&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);
             (bool IsSuccess, string Response) result = (false, string.Empty);
@@ -260,11 +287,11 @@ namespace TeamAAS_VP.Services
         /// <param name="stop_time">结束时间。</param>
         /// <param name="timeoutInSeconds">请求超时,单位为秒。</param>
         /// <returns>与 <see cref="SubmitGetAsync(string, bool, DateTime, DateTime, CancellationToken)"/> 相同的返回语义。</returns>
-        public async Task<(bool IsSuccess, string Response)> SubmitGetAsync(string sn, string comp, string gap, string press, string presstime, string assypress, bool isSuccess, DateTime start_time, DateTime stop_time, double timeoutInSeconds)
+        public async Task<(bool IsSuccess, string Response)> SubmitGetAsync(int num, string sn, string comp, string gap, string press, string presstime, string assypress, bool isSuccess, DateTime start_time, DateTime stop_time, double timeoutInSeconds)
         {
             using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutInSeconds)))
             {
-                return await SubmitGetAsync(sn, comp, gap, press, presstime, assypress, isSuccess, start_time, stop_time, cts.Token);
+                return await SubmitGetAsync(num, sn, comp, gap, press, presstime, assypress, isSuccess, start_time, stop_time, cts.Token);
             }
         }
 

+ 10 - 3
TeamAAS-VM/Services/RemoteCommandService.cs

@@ -1891,22 +1891,29 @@ namespace TeamAAS_VP.Services
                     if (!outputCollection.Contains("Found"))
                     {
                         SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);
-                        await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
                         return (false, "");
                     }
 
+                    // 2. 获取视觉输出结果
+                    bool Found = (bool)(outputCollection["Found"].Value);
+                    if (!Found)
+                    {
+                        SendTaskMessage(Lang.拍照NG, MessageLevel.Debug);
+                        continue;
+                    }
+
+                    SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
+
                     LogHelper.WriteLogInfo("开始获取视觉输出结果");
                     string dis = (string)(outputCollection["Gap"].Value);
                     return (true, dis);
                 }
                 SendTaskMessage(Lang.多次拍照失败, MessageLevel.Alarm);
-                await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
                 return (false, "");
             }
             catch (Exception ex)
             {
                 LogHelper.WriteLogError("执行相机取图并获取单点位时出错!", ex);
-                await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
                 return (false, "");
             }
             finally

+ 1 - 1
TeamAAS-VM/Views/SettingView.xaml

@@ -292,7 +292,7 @@
 
                         <TextBlock Grid.Row="4"
          Grid.Column="0"
-         Text="f:"
+         Text="f(组装站):"
          HorizontalAlignment="Right"
          VerticalAlignment="Center" />
                         <TextBox Grid.Row="4"