|
|
@@ -1293,12 +1293,12 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
|
|
|
//获取产品编码
|
|
|
- //_productService.CurrentProductCode = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, 0));
|
|
|
- ////如果产品编码为空,则以当前的时间戳作为编码
|
|
|
- //if (string.IsNullOrEmpty(_productService.CurrentProductCode))
|
|
|
- //{
|
|
|
- // _productService.CurrentProductCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
|
- //}
|
|
|
+ _productService.CurrentProductCode = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, 0));
|
|
|
+ //如果产品编码为空,则以当前的时间戳作为编码
|
|
|
+ if (string.IsNullOrEmpty(_productService.CurrentProductCode))
|
|
|
+ {
|
|
|
+ _productService.CurrentProductCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");
|
|
|
+ }
|
|
|
|
|
|
// 触发下相机拍照
|
|
|
if (addressConfig.In_DowmCameraExe.Address.Contains(tuple.nodeId))
|
|
|
@@ -1861,7 +1861,7 @@ namespace TeamAAS_VP.Core
|
|
|
await plc.WriteNodeAsync(addressConfig.In_WorkDone.Address, (Int16)0);
|
|
|
// 停止采集压力并保存
|
|
|
await StopAndSavePressureCollectionAsync(currentProduct.Name, _productService.CurrentProductCode, positionIndex);
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
SendTaskMessage(Lang.停止锁付信号已关闭, MessageLevel.Alarm);
|
|
|
@@ -2040,6 +2040,7 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+ var systemConfig = _configService.GetSystemConfiguration();
|
|
|
|
|
|
string code = "";
|
|
|
//plc启用的模式
|
|
|
@@ -2075,6 +2076,22 @@ namespace TeamAAS_VP.Core
|
|
|
code = code.ToUpper();
|
|
|
if (!string.IsNullOrEmpty(code))
|
|
|
{
|
|
|
+ if (systemConfig.IsBasePartCodeChooseScrew)//是否基于零件码,判断是不是当站要打的螺丝
|
|
|
+ {
|
|
|
+ var val = CheckCode(code, systemConfig.ChooseScrewModel);
|
|
|
+ if (val)
|
|
|
+ {
|
|
|
+ SendTaskMessage($"是当站螺丝:{code}", MessageLevel.Info);
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_QrCodePhotoResault.Address, (Int16)1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SendTaskMessage($"不是当站螺丝:{code}", MessageLevel.Info);
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_QrCodePhotoResault.Address, (Int16)2);
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
SendTaskMessage($"二维码扫码成功:{code}", MessageLevel.Info);
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_QrCodePhotoResault.Address, (Int16)1);
|
|
|
}
|
|
|
@@ -2104,338 +2121,338 @@ namespace TeamAAS_VP.Core
|
|
|
//询问mes
|
|
|
if (state == 1)
|
|
|
{
|
|
|
- //这里缺少从MES获取产品配方的内容,需要补充
|
|
|
-
|
|
|
- _LastMesCheckTime[i] = (await _mesService.GetServerTimeAsync(i, code, 2)).Now;
|
|
|
-
|
|
|
- //获取当前工位的配置
|
|
|
- var stationConfig = _configService.GetDeviceInfo(i);
|
|
|
- if (stationConfig.EnableDoubleMes)
|
|
|
+ if (_configService.GetDeviceInfo().EnableMES)
|
|
|
{
|
|
|
- SendTaskMessage($"收到{i}:{stationConfig.DeviceName}过站检查请求(当站是否生产)(当前需要双MES验证)...", MessageLevel.Debug);
|
|
|
+ //这里缺少从MES获取产品配方的内容,需要补充
|
|
|
+ if (i == 0)
|
|
|
+ {
|
|
|
+ SendTaskMessage($"收到当前过站检查请求(当站是否生产)...", MessageLevel.Debug);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SendTaskMessage($"收到{i}过站检查请求(当站是否生产)...", MessageLevel.Debug);
|
|
|
+ }
|
|
|
|
|
|
+ _LastMesCheckTime[i] = DateTime.UtcNow;
|
|
|
LogHelper.WriteLogMes($"【mes开始QUERY】");
|
|
|
SendTaskMessage($"mes开始QUERY", MessageLevel.Info);
|
|
|
- (bool isSuccess, string response) = await _mesService.StationGetExAsync(i, code, "", 2);//基于电池的SN获取产品SN,询问mes
|
|
|
- if (isSuccess)
|
|
|
+ if (systemConfig.IsBasePartCodeGetSN)//是否基于零件码,判断是否过站
|
|
|
{
|
|
|
- LogHelper.WriteLogMes($"询问mes成功");
|
|
|
- SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
|
|
|
- string ProductMainSN_Temp = "";
|
|
|
- if (response != "MES功能未启用!")
|
|
|
+ (bool isSuccess, string response) = await _mesService.StationGetExAsync(code, "", 2);//基于电池的SN获取产品SN,询问mes
|
|
|
+ if (isSuccess)
|
|
|
{
|
|
|
+ string ProductMainSN_Temp = "";
|
|
|
+ LogHelper.WriteLogMes($"询问mes成功");
|
|
|
+ SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
|
|
|
+
|
|
|
string[] item = response.Split('\n');
|
|
|
- //获取过度件sn
|
|
|
- string snItem = item.FirstOrDefault(f => f.Contains("sn="));
|
|
|
- if (snItem != null)
|
|
|
+ if (item[2].Contains("sn="))
|
|
|
{
|
|
|
- ProductMainSN_Temp = snItem.Replace("sn=", "").Trim();
|
|
|
- SendTaskMessage($"过度件sn:{ProductMainSN_Temp}", MessageLevel.Info);
|
|
|
+ ProductMainSN_Temp = item[2].Replace("sn=", "");
|
|
|
+ SendTaskMessage($"流程sn:{ProductMainSN_Temp}", MessageLevel.Info);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- (bool isSuccess2, string response2) = await _mesService.StationGetAsync(i, ProductMainSN_Temp, "", 2);//询问mes
|
|
|
- if (isSuccess2)
|
|
|
- {
|
|
|
- LogHelper.WriteLogMes($"第二次询问mes成功");
|
|
|
- SendTaskMessage($"第二次询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
- if (response2 != "MES功能未启用!")
|
|
|
+ LogHelper.WriteLogMes($"询问mes成功");
|
|
|
+ SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
|
|
|
+
|
|
|
+ //20260214,螺丝机特别版
|
|
|
+ (bool isSuccess2, string response2) = await _mesService.StationGetAsync(ProductMainSN_Temp, "", 2);//询问mes
|
|
|
+ if (isSuccess2)
|
|
|
{
|
|
|
- string[] item = response2.Split('\n');
|
|
|
- //获取产品主sn和wo用于后续上传数据使用
|
|
|
- string snItem = item.FirstOrDefault(f => f.Contains("sn="));
|
|
|
- string woItem = item.FirstOrDefault(f => f.Contains("wo="));
|
|
|
- if (snItem != null)
|
|
|
+ LogHelper.WriteLogMes($"询问mes成功");
|
|
|
+ SendTaskMessage($"询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
+
|
|
|
+ item = response2.Split('\n');
|
|
|
+ if (item[3].Contains("sn="))
|
|
|
{
|
|
|
- ProductMainSN[i] = snItem.Replace("sn=", "").Trim();
|
|
|
- if (i == 0)
|
|
|
- {
|
|
|
- _productService.CurrentProductCode = ProductMainSN[i];
|
|
|
- }
|
|
|
+ ProductMainSN[i] = item[3].Replace("sn=", "");
|
|
|
SendTaskMessage($"产品主sn:{ProductMainSN[i]}", MessageLevel.Info);
|
|
|
}
|
|
|
- if (woItem != null)
|
|
|
+ if (item[5].Contains("wo="))
|
|
|
{
|
|
|
- wo = woItem.Replace("wo=", "").Trim();
|
|
|
+ wo = item[5].Replace("wo=", "");
|
|
|
SendTaskMessage($"产品主wo:{wo}", MessageLevel.Info);
|
|
|
}
|
|
|
+
|
|
|
+ LogHelper.WriteLogMes($"第二次询问mes成功");
|
|
|
+ SendTaskMessage($"第二次询问mes成功:{response2}", MessageLevel.Debug);
|
|
|
+
|
|
|
+ //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)1);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogMes($"第二次询问mes失败");
|
|
|
+ SendTaskMessage($"第二次询问mes失败:{response2}", MessageLevel.Error);
|
|
|
|
|
|
- //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
- await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
- await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)1);
|
|
|
+ //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LogHelper.WriteLogMes($"第二次询问mes失败");
|
|
|
- SendTaskMessage($"第二次询问mes失败:{response2}", MessageLevel.Error);
|
|
|
+ LogHelper.WriteLogMes($"询问mes失败");
|
|
|
+ SendTaskMessage($"询问mes失败:{response}", MessageLevel.Error);
|
|
|
|
|
|
//产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else //直接基于RFID询问是否过站
|
|
|
{
|
|
|
- //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
- await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
- await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
-
|
|
|
- LogHelper.WriteLogMes($"询问mes失败");
|
|
|
- SendTaskMessage($"询问mes失败:{response}", MessageLevel.Error);
|
|
|
-
|
|
|
- //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
- await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
- await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
- }
|
|
|
- LogHelper.WriteLogMes($"【mes结束QUERY】");
|
|
|
- SendTaskMessage($"mes结束QUERY", MessageLevel.Info);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SendTaskMessage($"收到{i}:{stationConfig.DeviceName}过站检查请求(当站是否生产)(当前不需要双MES验证)...", MessageLevel.Debug);
|
|
|
-
|
|
|
- LogHelper.WriteLogMes($"【mes开始QUERY】");
|
|
|
- SendTaskMessage($"mes开始QUERY", MessageLevel.Info);
|
|
|
- (bool isSuccess, string response) = await _mesService.StationGetAsync(i, code, "", 2);//询问mes
|
|
|
- if (isSuccess)
|
|
|
- {
|
|
|
- if (response != "MES功能未启用!")
|
|
|
+ (bool isSuccess, string response) = await _mesService.StationGetAsync(code, "", 2);//询问mes
|
|
|
+ if (isSuccess)
|
|
|
{
|
|
|
- string[] item = response.Split('\n');
|
|
|
- //获取产品主sn和wo用于后续上传数据使用
|
|
|
- string snItem = item.FirstOrDefault(f => f.Contains("sn="));
|
|
|
- string woItem = item.FirstOrDefault(f => f.Contains("wo="));
|
|
|
- if (snItem != null)
|
|
|
+ LogHelper.WriteLogMes($"询问mes成功");
|
|
|
+ SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
|
|
|
+
|
|
|
+ var item = response.Split('\n');
|
|
|
+ if (item[3].Contains("sn="))
|
|
|
{
|
|
|
- ProductMainSN[i] = snItem.Replace("sn=", "").Trim();
|
|
|
- if (i == 0)
|
|
|
- {
|
|
|
- _productService.CurrentProductCode = ProductMainSN[i];
|
|
|
- }
|
|
|
+ ProductMainSN[i] = item[3].Replace("sn=", "");
|
|
|
SendTaskMessage($"产品主sn:{ProductMainSN[i]}", MessageLevel.Info);
|
|
|
}
|
|
|
- if (woItem != null)
|
|
|
+ if (item[5].Contains("wo="))
|
|
|
{
|
|
|
- wo = woItem.Replace("wo=", "").Trim();
|
|
|
+ wo = item[5].Replace("wo=", "");
|
|
|
SendTaskMessage($"产品主wo:{wo}", MessageLevel.Info);
|
|
|
}
|
|
|
+
|
|
|
+ //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)1);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogMes($"询问mes失败");
|
|
|
+ SendTaskMessage($"询问mes失败:{response}", MessageLevel.Error);
|
|
|
|
|
|
- LogHelper.WriteLogMes($"询问mes成功");
|
|
|
- SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
|
|
|
- //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
- await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
- await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- LogHelper.WriteLogMes($"询问mes失败");
|
|
|
- SendTaskMessage($"询问mes失败:{response}", MessageLevel.Error);
|
|
|
- //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
- await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
- await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
+ //产品发生改变并且供料器发生了变化时,需要通知PLC进行取料更改
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
LogHelper.WriteLogMes($"【mes结束QUERY】");
|
|
|
SendTaskMessage($"mes结束QUERY", MessageLevel.Info);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogMes($"【未启用mes】");
|
|
|
+ SendTaskMessage($"未启用mes", MessageLevel.Info);
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)1);
|
|
|
+ }
|
|
|
}
|
|
|
// 上传本站数据
|
|
|
else if (state == 2)
|
|
|
{
|
|
|
- DFC.Clear();
|
|
|
+ if (_configService.GetDeviceInfo().EnableMES == true)
|
|
|
+ {
|
|
|
+ DFC.Clear();
|
|
|
|
|
|
- //获取当前工位的配置
|
|
|
- var stationConfig = _configService.GetDeviceInfo(i);
|
|
|
- SendTaskMessage($"收到{i}:{stationConfig.DeviceName}上传本站数据请求...", MessageLevel.Debug);
|
|
|
- //从服务器中获取当前时间
|
|
|
- var serverTimeResult = await _mesService.GetServerTimeAsync(i, code, 2);
|
|
|
+ //获取当前工位的配置
|
|
|
+ var stationConfig = _configService.GetDeviceInfo(0);
|
|
|
+ SendTaskMessage($"收到{i}:{stationConfig.DeviceName}上传本站数据请求...", MessageLevel.Debug);
|
|
|
+ //从服务器中获取当前时间
|
|
|
+ var serverTimeResult = await _mesService.GetServerTimeAsync(i, code, 2);
|
|
|
|
|
|
- //这里缺少上传MES的本站数据结果及开始和结束时间,需要补充
|
|
|
+ //这里缺少上传MES的本站数据结果及开始和结束时间,需要补充
|
|
|
|
|
|
- if (i == 0)
|
|
|
- {
|
|
|
- CTtime = serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds;
|
|
|
- }
|
|
|
+ if (i == 0)
|
|
|
+ {
|
|
|
+ CTtime = serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds;
|
|
|
+ }
|
|
|
|
|
|
- //读取产品结果
|
|
|
- Int16 resultIndex = plc.ReadNode<Int16>(string.Format(addressConfig.In_Result.Address, i));
|
|
|
+ //读取产品结果
|
|
|
+ Int16 resultIndex = plc.ReadNode<Int16>(string.Format(addressConfig.In_Result.Address, i));
|
|
|
|
|
|
- //目前只记录当前站
|
|
|
- if (i == 0)
|
|
|
- await _systemDatabaseService.RecordProductionAsync(new ProductionRecord()
|
|
|
+ //目前只记录当前站
|
|
|
+ if (i == 0)
|
|
|
+ await _systemDatabaseService.RecordProductionAsync(new ProductionRecord()
|
|
|
+ {
|
|
|
+ ProductName = currentProduct.Name,
|
|
|
+ ProductCode = ProductMainSN[i],
|
|
|
+ DeviceId = i,
|
|
|
+ DeviceName = "",
|
|
|
+ Category = resultIndex == 1 ? "OK" : "NG",
|
|
|
+ Quantity = 1,
|
|
|
+ Remark = $"TotalSeconds:{serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds.ToString("F2")}",
|
|
|
+ });
|
|
|
+
|
|
|
+ LogHelper.WriteLogMes($"【mes开始ADD】");
|
|
|
+ SendTaskMessage($"mes开始ADD", MessageLevel.Info);
|
|
|
+ //上传mes
|
|
|
+ string torque = string.Join(",", torqueList);
|
|
|
+ string pressure = string.Join(",", pressureList);
|
|
|
+ string turn = string.Join(",", turnList);
|
|
|
+ //这里现在上传的结果都是锁付站的,如果存在其他附属站的数据需要上传时,将不适用,要根据实际情况进行调整
|
|
|
+ (bool isSuccess, string response) = await _mesService.SubmitGetAsync(ProductMainSN[i], "", torque, pressure, turn, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
|
|
|
+ if (isSuccess)
|
|
|
{
|
|
|
- ProductName = currentProduct.Name,
|
|
|
- ProductCode = ProductMainSN[i],
|
|
|
- DeviceId = i,
|
|
|
- DeviceName = "",
|
|
|
- Category = resultIndex == 1 ? "OK" : "NG",
|
|
|
- Quantity = 1,
|
|
|
- Remark = $"TotalSeconds:{serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds.ToString("F2")}",
|
|
|
- });
|
|
|
-
|
|
|
- LogHelper.WriteLogMes($"【mes开始ADD】");
|
|
|
- SendTaskMessage($"mes开始ADD", MessageLevel.Info);
|
|
|
- //上传mes
|
|
|
- string torque = string.Join(",", torqueList);
|
|
|
- string pressure = string.Join(",", pressureList);
|
|
|
- string turn = string.Join(",", turnList);
|
|
|
- //这里现在上传的结果都是锁付站的,如果存在其他附属站的数据需要上传时,将不适用,要根据实际情况进行调整
|
|
|
- (bool isSuccess, string response) = await _mesService.SubmitGetAsync(i, ProductMainSN[i], "", torque, pressure, turn, resultIndex == 1 ? true : false, _LastMesCheckTime[i], serverTimeResult.Now);
|
|
|
- if (isSuccess)
|
|
|
- {
|
|
|
- LogHelper.WriteLogMes($"上传mes成功");
|
|
|
- SendTaskMessage($"上传mes成功", MessageLevel.Debug);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- LogHelper.WriteLogMes($"上传mes失败");
|
|
|
- SendTaskMessage($"上传mes失败", MessageLevel.Error);
|
|
|
- }
|
|
|
- await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
|
|
|
+ LogHelper.WriteLogMes($"上传mes成功");
|
|
|
+ SendTaskMessage($"上传mes成功", MessageLevel.Debug);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogMes($"上传mes失败");
|
|
|
+ SendTaskMessage($"上传mes失败", MessageLevel.Error);
|
|
|
+ }
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
|
|
|
|
|
|
- //是否保存当前的产品记录至CSV?
|
|
|
- if (stationConfig.SaveCsv)
|
|
|
- {
|
|
|
- //判断锁付路径字符串是否为空,如果不为空则保存,否则不保存
|
|
|
- if (!string.IsNullOrEmpty(stationConfig.SaveCsvPath))
|
|
|
+ //是否保存当前的产品记录至CSV?
|
|
|
+ if (stationConfig.SaveCsv)
|
|
|
{
|
|
|
- bool recordResult = false;
|
|
|
- if (i == 0)
|
|
|
+ //判断锁付路径字符串是否为空,如果不为空则保存,否则不保存
|
|
|
+ if (!string.IsNullOrEmpty(stationConfig.SaveCsvPath))
|
|
|
{
|
|
|
- foreach (var lockResult in lockResultsAll)
|
|
|
+ bool recordResult = false;
|
|
|
+ if (i == 0)
|
|
|
{
|
|
|
- bool torqueRes, turnRes, pressureRes;
|
|
|
- if (lockResult.LockTorque >= lockResult.TargetTorqueLowerLimit && lockResult.LockTorque <= lockResult.TargetTorqueUpperLimit)
|
|
|
- {
|
|
|
- torqueRes = true;
|
|
|
- }
|
|
|
- else torqueRes = false;
|
|
|
- if (lockResult.Pressure >= stationConfig.DataInfo.CTQ_LSL_Pressure && lockResult.Pressure <= stationConfig.DataInfo.CTQ_USL_Pressure)
|
|
|
- {
|
|
|
- pressureRes = true;
|
|
|
- }
|
|
|
- else pressureRes = false;
|
|
|
- if (lockResult.LockTurns >= lockResult.TargetTurnsLowerLimit && lockResult.LockTurns <= lockResult.TargetTurnsUpperLimit)
|
|
|
+ foreach (var lockResult in lockResultsAll)
|
|
|
{
|
|
|
- turnRes = true;
|
|
|
+ bool torqueRes, turnRes, pressureRes;
|
|
|
+ if (lockResult.LockTorque >= lockResult.TargetTorqueLowerLimit && lockResult.LockTorque <= lockResult.TargetTorqueUpperLimit)
|
|
|
+ {
|
|
|
+ torqueRes = true;
|
|
|
+ }
|
|
|
+ else torqueRes = false;
|
|
|
+ if (lockResult.Pressure >= stationConfig.DataInfo.CTQ_LSL_Pressure && lockResult.Pressure <= stationConfig.DataInfo.CTQ_USL_Pressure)
|
|
|
+ {
|
|
|
+ pressureRes = true;
|
|
|
+ }
|
|
|
+ else pressureRes = false;
|
|
|
+ if (lockResult.LockTurns >= lockResult.TargetTurnsLowerLimit && lockResult.LockTurns <= lockResult.TargetTurnsUpperLimit)
|
|
|
+ {
|
|
|
+ turnRes = true;
|
|
|
+ }
|
|
|
+ else turnRes = false;
|
|
|
+ DFC.Add(new DataFormCtq
|
|
|
+ {
|
|
|
+ PPID = ProductMainSN[i],
|
|
|
+ PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
+ PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
+ CTQ_NAME = "Torque",
|
|
|
+ CTQ_VALUE = lockResult.LockTorque,
|
|
|
+ CTQ_LSL = lockResult.TargetTorqueLowerLimit,
|
|
|
+ CTQ_USL = lockResult.TargetTorqueUpperLimit,
|
|
|
+ PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
+ SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
+ COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
+ REVISION = stationConfig.DataInfo.REVISION,
|
|
|
+ WO = wo,
|
|
|
+ MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
+ MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
+ PROCESS_OUTCOME = torqueRes ? "PASS" : "FAIL",
|
|
|
+ PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
+ CTQ_UNIT_OF_MEASURE = "kgf.cm",
|
|
|
+ ERROR_MESSAGE = torqueRes ? "" : "Torque_Spec OOS"
|
|
|
+ });
|
|
|
+ DFC.Add(new DataFormCtq
|
|
|
+ {
|
|
|
+ PPID = ProductMainSN[i],
|
|
|
+ PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
+ PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
+ CTQ_NAME = "Turn",
|
|
|
+ CTQ_VALUE = lockResult.LockTurns,
|
|
|
+ CTQ_LSL = lockResult.TargetTurnsLowerLimit,
|
|
|
+ CTQ_USL = lockResult.TargetTurnsUpperLimit,
|
|
|
+ PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
+ SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
+ COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
+ REVISION = stationConfig.DataInfo.REVISION,
|
|
|
+ WO = wo,
|
|
|
+ MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
+ MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
+ PROCESS_OUTCOME = turnRes ? "PASS" : "FAIL",
|
|
|
+ PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
+ CTQ_UNIT_OF_MEASURE = "圈",
|
|
|
+ ERROR_MESSAGE = turnRes ? "" : "Turn_Spec OOS"
|
|
|
+ });
|
|
|
+ DFC.Add(new DataFormCtq
|
|
|
+ {
|
|
|
+ PPID = ProductMainSN[i],
|
|
|
+ PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
+ PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
+ CTQ_NAME = "Pressure",
|
|
|
+ CTQ_VALUE = lockResult.Pressure,
|
|
|
+ CTQ_LSL = stationConfig.DataInfo.CTQ_LSL_Pressure,
|
|
|
+ CTQ_USL = stationConfig.DataInfo.CTQ_USL_Pressure,
|
|
|
+ PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
+ SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
+ COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
+ REVISION = stationConfig.DataInfo.REVISION,
|
|
|
+ WO = wo,
|
|
|
+ MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
+ MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
+ PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
|
|
|
+ PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
+ CTQ_UNIT_OF_MEASURE = "N",
|
|
|
+ ERROR_MESSAGE = pressureRes ? "" : "Pressure_Spec OOS"
|
|
|
+ });
|
|
|
}
|
|
|
- else turnRes = false;
|
|
|
- DFC.Add(new DataFormCtq
|
|
|
- {
|
|
|
- PPID = ProductMainSN[i],
|
|
|
- PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
- PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
- CTQ_NAME = "Torque",
|
|
|
- CTQ_VALUE = lockResult.LockTorque,
|
|
|
- CTQ_LSL = lockResult.TargetTorqueLowerLimit,
|
|
|
- CTQ_USL = lockResult.TargetTorqueUpperLimit,
|
|
|
- PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
- SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
- COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
- REVISION = stationConfig.DataInfo.REVISION,
|
|
|
- WO = wo,
|
|
|
- MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
- MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
- PROCESS_OUTCOME = torqueRes ? "PASS" : "FAIL",
|
|
|
- PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
- CTQ_UNIT_OF_MEASURE = "kgf.cm",
|
|
|
- ERROR_MESSAGE = torqueRes ? "" : "Torque_Spec OOS"
|
|
|
- });
|
|
|
- DFC.Add(new DataFormCtq
|
|
|
- {
|
|
|
- PPID = ProductMainSN[i],
|
|
|
- PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
- PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
- CTQ_NAME = "Turn",
|
|
|
- CTQ_VALUE = lockResult.LockTurns,
|
|
|
- CTQ_LSL = lockResult.TargetTurnsLowerLimit,
|
|
|
- CTQ_USL = lockResult.TargetTurnsUpperLimit,
|
|
|
- PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
- SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
- COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
- REVISION = stationConfig.DataInfo.REVISION,
|
|
|
- WO = wo,
|
|
|
- MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
- MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
- PROCESS_OUTCOME = turnRes ? "PASS" : "FAIL",
|
|
|
- PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
- CTQ_UNIT_OF_MEASURE = "圈",
|
|
|
- ERROR_MESSAGE = turnRes ? "" : "Turn_Spec OOS"
|
|
|
- });
|
|
|
- DFC.Add(new DataFormCtq
|
|
|
- {
|
|
|
- PPID = ProductMainSN[i],
|
|
|
- PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
- PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
- CTQ_NAME = "Pressure",
|
|
|
- CTQ_VALUE = lockResult.Pressure,
|
|
|
- CTQ_LSL = stationConfig.DataInfo.CTQ_LSL_Pressure,
|
|
|
- CTQ_USL = stationConfig.DataInfo.CTQ_USL_Pressure,
|
|
|
- PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
- SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
- COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
- REVISION = stationConfig.DataInfo.REVISION,
|
|
|
- WO = wo,
|
|
|
- MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
- MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
- PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
|
|
|
- PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
- CTQ_UNIT_OF_MEASURE = "N",
|
|
|
- ERROR_MESSAGE = pressureRes ? "" : "Pressure_Spec OOS"
|
|
|
- });
|
|
|
}
|
|
|
- }
|
|
|
- //else
|
|
|
- //{
|
|
|
- // DFC.Add(new DataFormCtq
|
|
|
- // {
|
|
|
- // PPID = ProductMainSN[i],
|
|
|
- // PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
- // PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
- // CTQ_NAME = "Pressure",
|
|
|
- // CTQ_VALUE = lockResult.Pressure,
|
|
|
- // CTQ_LSL = stationConfig.DataInfo.CTQ_LSL_Pressure,
|
|
|
- // CTQ_USL = stationConfig.DataInfo.CTQ_USL_Pressure,
|
|
|
- // PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
- // SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
- // COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
- // REVISION = stationConfig.DataInfo.REVISION,
|
|
|
- // WO = wo,
|
|
|
- // MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
- // MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
- // PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
|
|
|
- // PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
- // CTQ_UNIT_OF_MEASURE = "N",
|
|
|
- // ERROR_MESSAGE = pressureRes ? "" : "Pressure_Spec OOS"
|
|
|
- // });
|
|
|
- // //压力值
|
|
|
- // //dataItems.Add("Pressure", pressure);
|
|
|
- // recordResult = RecordOtherStationResult(i, dataItems, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
|
|
|
- //}
|
|
|
- recordResult = RecordStationResult(i, DFC, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
|
|
|
- if (recordResult)
|
|
|
- {
|
|
|
- SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存成功", MessageLevel.Debug);
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // DFC.Add(new DataFormCtq
|
|
|
+ // {
|
|
|
+ // PPID = ProductMainSN[i],
|
|
|
+ // PROCESS_NAME = stationConfig.DataInfo.PROCESS_NAME,
|
|
|
+ // PROCESS_START_TIME = _LastMesCheckTime[i].ToString(),
|
|
|
+ // CTQ_NAME = "Pressure",
|
|
|
+ // CTQ_VALUE = lockResult.Pressure,
|
|
|
+ // CTQ_LSL = stationConfig.DataInfo.CTQ_LSL_Pressure,
|
|
|
+ // CTQ_USL = stationConfig.DataInfo.CTQ_USL_Pressure,
|
|
|
+ // PROCESS_END_TIME = serverTimeResult.Now.ToString(),
|
|
|
+ // SUPPLIER_NAME = stationConfig.DataInfo.SUPPLIER_NAME,
|
|
|
+ // COMMODITY_TYPE = stationConfig.DataInfo.COMMODITY_TYPE,
|
|
|
+ // REVISION = stationConfig.DataInfo.REVISION,
|
|
|
+ // WO = wo,
|
|
|
+ // MFG_LOT = stationConfig.DataInfo.MFG_LOT,
|
|
|
+ // MFG_ASSY_LINE = stationConfig.DataInfo.MFG_ASSY_LINE,
|
|
|
+ // PROCESS_OUTCOME = pressureRes ? "PASS" : "FAIL",
|
|
|
+ // PROCESS_MACHINE_ID = stationConfig.DataInfo.PROCESS_MACHINE_ID,
|
|
|
+ // CTQ_UNIT_OF_MEASURE = "N",
|
|
|
+ // ERROR_MESSAGE = pressureRes ? "" : "Pressure_Spec OOS"
|
|
|
+ // });
|
|
|
+ // //压力值
|
|
|
+ // //dataItems.Add("Pressure", pressure);
|
|
|
+ // recordResult = RecordOtherStationResult(i, dataItems, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
|
|
|
+ //}
|
|
|
+ recordResult = RecordStationResult(i, DFC, ProductMainSN[i], serverTimeResult.Now.Subtract(_LastMesCheckTime[i]).TotalSeconds, _LastMesCheckTime[i], stationConfig.SaveCsvPath);
|
|
|
+ if (recordResult)
|
|
|
+ {
|
|
|
+ SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存成功", MessageLevel.Debug);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存失败", MessageLevel.Error);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存失败", MessageLevel.Error);
|
|
|
+ SendTaskMessage($"{i}:{stationConfig.DeviceName}工位未配置保存路径,无法保存产品记录", MessageLevel.Error);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SendTaskMessage($"{i}:{stationConfig.DeviceName}工位未配置保存路径,无法保存产品记录", MessageLevel.Error);
|
|
|
+ SendTaskMessage($"{i}:{stationConfig.DeviceName}工位未配置保存产品记录", MessageLevel.Debug);
|
|
|
}
|
|
|
+
|
|
|
+ WriteProductLog(lockResultsAll, ProductMainSN[i], CTtime);
|
|
|
+
|
|
|
+ LogHelper.WriteLogMes($"【mes结束ADD】");
|
|
|
+ SendTaskMessage($"mes结束ADD", MessageLevel.Info);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SendTaskMessage($"{i}:{stationConfig.DeviceName}工位未配置保存产品记录", MessageLevel.Debug);
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
|
|
|
}
|
|
|
-
|
|
|
- LogHelper.WriteLogMes($"【mes结束ADD】");
|
|
|
- SendTaskMessage($"mes结束ADD", MessageLevel.Info);
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
SendTaskMessage($"{i}过站检查信号:state={state},处理为默认状态", MessageLevel.Alarm);
|
|
|
@@ -2623,6 +2640,52 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 判断是否符合当站
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="data"></param>
|
|
|
+ /// <param name="checkData"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool CheckCode(string data, string checkData)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (data.Length != checkData.Length)
|
|
|
+ {
|
|
|
+ var len = checkData.Length - data.Length;
|
|
|
+ LogHelper.WriteLogMes($"判断是否符合当站失败,字符长度差{len}");
|
|
|
+ SendTaskMessage($"判断是否符合当站失败,字符长度差{len}", MessageLevel.Error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ int count = checkData.Length;
|
|
|
+ for (int i = 0; i < count; i++)
|
|
|
+ {
|
|
|
+ if (checkData[i] == '*')//不需要检测的部分
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data[i] != checkData[i])//有值不一致
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogMes($"判断是否符合当站失败,第{i}个字符,不一致");
|
|
|
+ SendTaskMessage($"判断是否符合当站失败,第{i}个字符,不一致", MessageLevel.Error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogMes($"判断是否符合当站失败,{ex}");
|
|
|
+ SendTaskMessage($"判断是否符合当站失败,{ex}", MessageLevel.Error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
#region vm启动检测
|
|
|
|
|
|
/// <summary>
|