|
|
@@ -1666,6 +1666,8 @@ namespace TeamAAS_VP.Core
|
|
|
#region 扫码枪扫码
|
|
|
if (sysConfig.ScannerUse == true && cameraIndex == 1 && sysConfig.CodeUse2 == true)
|
|
|
{
|
|
|
+ FinalResultStatus = "检测中";
|
|
|
+ FinalResultText = "检测中";
|
|
|
ScanValue = "";
|
|
|
_scanDoneEvent.Reset(); // 重要:先关门
|
|
|
|
|
|
@@ -1742,36 +1744,61 @@ namespace TeamAAS_VP.Core
|
|
|
kb_sn[0] = kbsnitem.Replace("KB=", "").Trim();
|
|
|
SendTaskMessage($"KB:{kb_sn}", MessageLevel.Info);
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- LogHelper.WriteLogMes($"【mes结束QUERY】");
|
|
|
- SendTaskMessage($"mes结束QUERY", MessageLevel.Info);
|
|
|
- var q = await _systemDatabaseService.QueryProductFromMesAsync(model_num[0], color[0]);
|
|
|
- if (!string.IsNullOrEmpty(q))
|
|
|
- {
|
|
|
- ProductWithMes productWithMes = new ProductWithMes();
|
|
|
- ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
- Guid productId = Guid.Empty;
|
|
|
- foreach (var itt in ProductList)
|
|
|
+ string kbpnsnitem = items.FirstOrDefault(f => f.Contains("KB_PN="));
|
|
|
+ if (kbpnsnitem != null)
|
|
|
{
|
|
|
- if (itt.Name == q)
|
|
|
- {
|
|
|
- productId = itt.ID;
|
|
|
- break;
|
|
|
- }
|
|
|
+ kb_pn[0] = kbpnsnitem.Replace("KB_PN=", "").Trim();
|
|
|
+ SendTaskMessage($"KB_PN:{kb_pn[0]}", MessageLevel.Info);
|
|
|
}
|
|
|
- if (currentProduct.ID != productId || productWithMes.ProductKBSN != kb_sn[0])
|
|
|
+ var item1 = await _systemDatabaseService.QueryProductWithMesALLAsync();
|
|
|
+ foreach (var q in item1)
|
|
|
{
|
|
|
-
|
|
|
- _productService.Clear();
|
|
|
- //切换产品
|
|
|
- _productService.LoadProduct(productId);
|
|
|
- _productService.SetCurrentProduct(productId);
|
|
|
- await WritePositionToPlcAsync();
|
|
|
- SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ if (!string.IsNullOrEmpty(q.ProductName))
|
|
|
+ {
|
|
|
+ ProductWithMes productWithMes = new ProductWithMes();
|
|
|
+ ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
+ Guid productId = Guid.Empty;
|
|
|
+ foreach (var itt in ProductList)
|
|
|
+ {
|
|
|
+ if (itt.Name == q.ProductName)
|
|
|
+ {
|
|
|
+ productId = itt.ID;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_configService.GetSystemConfiguration().IsTP_AOI)
|
|
|
+ {
|
|
|
+ if (currentProduct.ID != productId && q.ProductLoad.Contains(kb_pn[0]))
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductKBSN}", MessageLevel.Error);
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (currentProduct.ID != productId && model_num[0].Contains(q.ProductCode))
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductCode}", MessageLevel.Error);
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
|
|
|
+ LogHelper.WriteLogMes($"【mes结束QUERY】");
|
|
|
+ SendTaskMessage($"mes结束QUERY", MessageLevel.Info);
|
|
|
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
|
return;
|
|
|
@@ -1790,6 +1817,8 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
if (sysConfig.ScannerUse == true && cameraIndex == 1 && sysConfig.CodeUse == true)
|
|
|
{
|
|
|
+ FinalResultStatus = "检测中";
|
|
|
+ FinalResultText = "检测中";
|
|
|
ScanValue = "";
|
|
|
_scanDoneEvent.Reset(); // 重要:先关门
|
|
|
|
|
|
@@ -1889,34 +1918,62 @@ namespace TeamAAS_VP.Core
|
|
|
kb_sn[0] = kbsnitem.Replace("KB=", "").Trim();
|
|
|
SendTaskMessage($"KB:{kb_sn[0]}", MessageLevel.Info);
|
|
|
}
|
|
|
- }
|
|
|
- LogHelper.WriteLogMes($"第二次询问mes成功");
|
|
|
- SendTaskMessage($"第二次询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
|
|
|
- var q = await _systemDatabaseService.QueryProductFromMesAsync(model_num[0], color[0]);
|
|
|
- if (!string.IsNullOrEmpty(q))
|
|
|
- {
|
|
|
- ProductWithMes productWithMes = new ProductWithMes();
|
|
|
- ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
- Guid productId = Guid.Empty;
|
|
|
- foreach (var itt in ProductList)
|
|
|
+ string kbpnsnitem = item.FirstOrDefault(f => f.Contains("KB_PN="));
|
|
|
+ if (kbpnsnitem != null)
|
|
|
{
|
|
|
- if (itt.Name == q)
|
|
|
- {
|
|
|
- productId = itt.ID;
|
|
|
- break;
|
|
|
- }
|
|
|
+ kb_pn[0] = kbpnsnitem.Replace("KB_PN=", "").Trim();
|
|
|
+ SendTaskMessage($"KB_PN:{kb_pn[0]}", MessageLevel.Info);
|
|
|
}
|
|
|
- if (currentProduct.ID != productId || productWithMes.ProductKBSN != kb_sn[0])
|
|
|
+
|
|
|
+ var item1 = await _systemDatabaseService.QueryProductWithMesALLAsync();
|
|
|
+ foreach (var q in item1)
|
|
|
{
|
|
|
- //切换产品
|
|
|
- _productService.LoadProduct(productId);
|
|
|
- _productService.SetCurrentProduct(productId);
|
|
|
- await WritePositionToPlcAsync();
|
|
|
- SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ if (!string.IsNullOrEmpty(q.ProductName))
|
|
|
+ {
|
|
|
+ ProductWithMes productWithMes = new ProductWithMes();
|
|
|
+ ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
+ Guid productId = Guid.Empty;
|
|
|
+ foreach (var itt in ProductList)
|
|
|
+ {
|
|
|
+ if (itt.Name == q.ProductName)
|
|
|
+ {
|
|
|
+ productId = itt.ID;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_configService.GetSystemConfiguration().IsTP_AOI)
|
|
|
+ {
|
|
|
+ if (currentProduct.ID != productId && q.ProductLoad.Contains(kb_pn[0]))
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductKBSN}", MessageLevel.Error);
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (currentProduct.ID != productId && model_num[0].Contains(q.ProductCode))
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductCode}", MessageLevel.Error);
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ LogHelper.WriteLogMes($"第二次询问mes成功");
|
|
|
+ SendTaskMessage($"第二次询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
|
}
|
|
|
else
|
|
|
@@ -2009,6 +2066,8 @@ namespace TeamAAS_VP.Core
|
|
|
#region 相机扫码
|
|
|
if (sysConfig.CodeUse == true && cameraIndex == 1)
|
|
|
{
|
|
|
+ FinalResultStatus = "检测中";
|
|
|
+ FinalResultText = "检测中";
|
|
|
var cts = new CancellationTokenSource();
|
|
|
// CameraProcedureId 存储的是具体的视觉流程 Id(ProcedureModel.Id),
|
|
|
// 需要在所有 CameraProcedures 的 ProcedureModels 中查找匹配的流程。
|
|
|
@@ -2135,33 +2194,60 @@ namespace TeamAAS_VP.Core
|
|
|
kb_sn[0] = kbsnitem.Replace("KB=", "").Trim();
|
|
|
SendTaskMessage($"KB:{kb_sn[0]}", MessageLevel.Info);
|
|
|
}
|
|
|
- }
|
|
|
- LogHelper.WriteLogMes($"第二次询问mes成功");
|
|
|
- SendTaskMessage($"第二次询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
|
|
|
- var q = await _systemDatabaseService.QueryProductFromMesAsync(model_num[0], color[0]);
|
|
|
- if (!string.IsNullOrEmpty(q))
|
|
|
- {
|
|
|
- ProductWithMes productWithMes = new ProductWithMes();
|
|
|
- ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
- Guid productId = Guid.Empty;
|
|
|
- foreach (var itt in ProductList)
|
|
|
+ string kbpnsnitem = item.FirstOrDefault(f => f.Contains("KB_PN="));
|
|
|
+ if (kbpnsnitem != null)
|
|
|
{
|
|
|
- if (itt.Name == q)
|
|
|
- {
|
|
|
- productId = itt.ID;
|
|
|
- break;
|
|
|
- }
|
|
|
+ kb_pn[0] = kbpnsnitem.Replace("KB_PN=", "").Trim();
|
|
|
+ SendTaskMessage($"KB_PN:{kb_pn[0]}", MessageLevel.Info);
|
|
|
}
|
|
|
- if (currentProduct.ID != productId || productWithMes.ProductKBSN != kb_sn[0])
|
|
|
+ var item1 = await _systemDatabaseService.QueryProductWithMesALLAsync();
|
|
|
+ foreach (var q in item1)
|
|
|
{
|
|
|
- //切换产品
|
|
|
- _productService.LoadProduct(productId);
|
|
|
- _productService.SetCurrentProduct(productId);
|
|
|
- await WritePositionToPlcAsync();
|
|
|
- SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ if (!string.IsNullOrEmpty(q.ProductName))
|
|
|
+ {
|
|
|
+ ProductWithMes productWithMes = new ProductWithMes();
|
|
|
+ ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
+ Guid productId = Guid.Empty;
|
|
|
+ foreach (var itt in ProductList)
|
|
|
+ {
|
|
|
+ if (itt.Name == q.ProductName)
|
|
|
+ {
|
|
|
+ productId = itt.ID;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_configService.GetSystemConfiguration().IsTP_AOI)
|
|
|
+ {
|
|
|
+ if (currentProduct.ID != productId && q.ProductLoad.Contains(kb_pn[0]))
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductKBSN}", MessageLevel.Error);
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (currentProduct.ID != productId && model_num[0].Contains(q.ProductCode))
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductCode}", MessageLevel.Error);
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ LogHelper.WriteLogMes($"第二次询问mes成功");
|
|
|
+ SendTaskMessage($"第二次询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
|
}
|
|
|
@@ -2210,6 +2296,8 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
if (sysConfig.CodeUse2 == true && cameraIndex == 1)
|
|
|
{
|
|
|
+ FinalResultStatus = "检测中";
|
|
|
+ FinalResultText = "检测中";
|
|
|
var cts = new CancellationTokenSource();
|
|
|
// CameraProcedureId 存储的是具体的视觉流程 Id(ProcedureModel.Id),
|
|
|
// 需要在所有 CameraProcedures 的 ProcedureModels 中查找匹配的流程。
|
|
|
@@ -2312,33 +2400,62 @@ namespace TeamAAS_VP.Core
|
|
|
kb_sn[0] = kbsnitem.Replace("KB=", "").Trim();
|
|
|
SendTaskMessage($"KB:{kb_sn[0]}", MessageLevel.Info);
|
|
|
}
|
|
|
- }
|
|
|
- LogHelper.WriteLogMes($"【mes结束QUERY】");
|
|
|
- SendTaskMessage($"mes结束QUERY", MessageLevel.Info);
|
|
|
|
|
|
- var q = await _systemDatabaseService.QueryProductFromMesAsync(model_num[0], color[0]);
|
|
|
- if (!string.IsNullOrEmpty(q))
|
|
|
- {
|
|
|
- ProductWithMes productWithMes = new ProductWithMes();
|
|
|
- ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
- Guid productId = Guid.Empty;
|
|
|
- foreach (var itt in ProductList)
|
|
|
+ string kbpnsnitem = items.FirstOrDefault(f => f.Contains("KB_PN="));
|
|
|
+ if (kbpnsnitem != null)
|
|
|
{
|
|
|
- if (itt.Name == q)
|
|
|
- {
|
|
|
- productId = itt.ID;
|
|
|
- break;
|
|
|
- }
|
|
|
+ kb_pn[0] = kbpnsnitem.Replace("KB_PN=", "").Trim();
|
|
|
+ SendTaskMessage($"KB_PN:{kb_pn[0]}", MessageLevel.Info);
|
|
|
}
|
|
|
- if (currentProduct.ID != productId || productWithMes.ProductKBSN != kb_sn[0])
|
|
|
+ var item1 = await _systemDatabaseService.QueryProductWithMesALLAsync();
|
|
|
+ foreach (var q in item1)
|
|
|
{
|
|
|
- //切换产品
|
|
|
- _productService.LoadProduct(productId);
|
|
|
- _productService.SetCurrentProduct(productId);
|
|
|
- await WritePositionToPlcAsync();
|
|
|
- SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ if (!string.IsNullOrEmpty(q.ProductName))
|
|
|
+ {
|
|
|
+ ProductWithMes productWithMes = new ProductWithMes();
|
|
|
+ ProductList = new ObservableCollection<ProductModel>(_productService.GetAllProducts());
|
|
|
+ Guid productId = Guid.Empty;
|
|
|
+ foreach (var itt in ProductList)
|
|
|
+ {
|
|
|
+ if (itt.Name == q.ProductName)
|
|
|
+ {
|
|
|
+ productId = itt.ID;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_configService.GetSystemConfiguration().IsTP_AOI)
|
|
|
+ {
|
|
|
+ if (currentProduct.ID != productId && q.ProductLoad.Contains(kb_pn[0]))
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductKBSN}", MessageLevel.Error);
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (currentProduct.ID != productId && model_num[0].Contains(q.ProductCode))
|
|
|
+ {
|
|
|
+ //切换产品
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductCode}", MessageLevel.Error);
|
|
|
+ _productService.LoadProduct(productId);
|
|
|
+ _productService.SetCurrentProduct(productId);
|
|
|
+ await WritePositionToPlcAsync();
|
|
|
+ SendTaskMessage($"切换产品成功", MessageLevel.Debug);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ LogHelper.WriteLogMes($"【mes结束QUERY】");
|
|
|
+ SendTaskMessage($"mes结束QUERY", MessageLevel.Info);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameraPickStatus.Address, (Int16)1);
|
|
|
return;
|
|
|
@@ -2826,6 +2943,8 @@ namespace TeamAAS_VP.Core
|
|
|
//过站检查
|
|
|
if (state == 1)
|
|
|
{
|
|
|
+ FinalResultStatus = "检测中";
|
|
|
+ FinalResultText = "检测中";
|
|
|
//这里缺少从MES获取产品配方的内容,需要补充
|
|
|
_LastMesCheckTime[i] = (await _mesService.GetServerTimeAsync(code, 2)).Now;
|
|
|
DeviceInfo stationConfig2 = new DeviceInfo();
|
|
|
@@ -2967,10 +3086,10 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (currentProduct.ID != productId && q.ProductKBSN == kb_sn[i] && q.ProductColor == color[i] && q.ProductCode == model_num[i])
|
|
|
+ if (currentProduct.ID != productId && model_num[i].Contains(q.ProductCode))
|
|
|
{
|
|
|
//切换产品
|
|
|
- SendTaskMessage($"开始切换产品{q.ProductKBSN}", MessageLevel.Error);
|
|
|
+ SendTaskMessage($"开始切换产品{q.ProductCode}", MessageLevel.Error);
|
|
|
_productService.LoadProduct(productId);
|
|
|
_productService.SetCurrentProduct(productId);
|
|
|
await WritePositionToPlcAsync();
|
|
|
@@ -3269,7 +3388,8 @@ namespace TeamAAS_VP.Core
|
|
|
PROCESS_OUTCOME = item.PhotoPassed == "OK" ? "PASS" : "FAIL",
|
|
|
PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
CTQ_UNIT_OF_MEASURE = "mm",
|
|
|
- ERROR_MESSAGE = item.PhotoPassed == "OK" ? "" : $"{item.PhotoName} OOS",
|
|
|
+ //ERROR_MESSAGE = item.PhotoPassed == "OK" ? "" : $"{item.PhotoName} OOS",
|
|
|
+ ERROR_MESSAGE = item.PhotoPassed == "OK" ? "" : $"{item.PhotoName}_{item.ResultData.Replace(",", ";")}",
|
|
|
PD_ATTR_01 = ProductMainSN,//
|
|
|
PD_ATTR_02 = item.MidLimit,
|
|
|
PD_ATTR_04 = code,
|