|
@@ -88,6 +88,8 @@ namespace TeamAAS_VP.Core
|
|
|
/// 当天是否上传过csv
|
|
/// 当天是否上传过csv
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
private bool _hasCompressedToday = false;
|
|
private bool _hasCompressedToday = false;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
#region 属性
|
|
#region 属性
|
|
@@ -239,12 +241,17 @@ namespace TeamAAS_VP.Core
|
|
|
get { return _Yield; }
|
|
get { return _Yield; }
|
|
|
set { SetProperty(ref _Yield, value); }
|
|
set { SetProperty(ref _Yield, value); }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private ObservableCollection<ProductModel> _ProductList;
|
|
private ObservableCollection<ProductModel> _ProductList;
|
|
|
public ObservableCollection<ProductModel> ProductList
|
|
public ObservableCollection<ProductModel> ProductList
|
|
|
{
|
|
{
|
|
|
get { return _ProductList; }
|
|
get { return _ProductList; }
|
|
|
set { SetProperty(ref _ProductList, value); }
|
|
set { SetProperty(ref _ProductList, value); }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public static int uphhour=0;
|
|
|
|
|
+ public static int uphnumber=0;
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
#region 命令
|
|
#region 命令
|
|
@@ -1099,7 +1106,7 @@ namespace TeamAAS_VP.Core
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
public async Task WritePositionToPlcAsync()
|
|
public async Task WritePositionToPlcAsync()
|
|
|
- {
|
|
|
|
|
|
|
+ {
|
|
|
var addressConfig = _configService.GetPlcAddresses();
|
|
var addressConfig = _configService.GetPlcAddresses();
|
|
|
var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
if (plc == null || !plc.IsConnected) return;
|
|
if (plc == null || !plc.IsConnected) return;
|
|
@@ -1155,6 +1162,7 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
{
|
|
|
await item.WriteToPlcAddress(addressConfig.Out_RemovePos, plc);
|
|
await item.WriteToPlcAddress(addressConfig.Out_RemovePos, plc);
|
|
|
}
|
|
}
|
|
|
|
|
+ await plc.WriteNodeAsync(addressConfig.Out_RemovePos_Num.Address, (Int16)current.RemovePoints.Count);
|
|
|
}
|
|
}
|
|
|
if (current.PressurePlacePoints != null && current.PressurePlacePoints.Count > 0)
|
|
if (current.PressurePlacePoints != null && current.PressurePlacePoints.Count > 0)
|
|
|
{
|
|
{
|
|
@@ -1277,6 +1285,8 @@ namespace TeamAAS_VP.Core
|
|
|
/// 复检结果
|
|
/// 复检结果
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
Dictionary<string, string> gapDict = new Dictionary<string, string>();
|
|
Dictionary<string, string> gapDict = new Dictionary<string, string>();
|
|
|
|
|
+
|
|
|
|
|
+ List<string> fileresult { get; set; } = new List<string>();
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// 二次定位相机的工具坐标
|
|
/// 二次定位相机的工具坐标
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -1371,6 +1381,7 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
var currentPosition = robot.GetRobotPos();
|
|
var currentPosition = robot.GetRobotPos();
|
|
|
|
|
+ var current = _productService.GetCurrentProduct();
|
|
|
|
|
|
|
|
//如果下相机拍照的次数是1,则判断用时拍照的相机是几个
|
|
//如果下相机拍照的次数是1,则判断用时拍照的相机是几个
|
|
|
int downCameraNum = _configService.GetSystemConfiguration().DowmCameraNum;
|
|
int downCameraNum = _configService.GetSystemConfiguration().DowmCameraNum;
|
|
@@ -1452,6 +1463,13 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
{
|
|
|
float toolX = (float)(visionResults[0].X + visionResults[1].X) / 2;
|
|
float toolX = (float)(visionResults[0].X + visionResults[1].X) / 2;
|
|
|
float toolY = (float)(visionResults[0].Y + visionResults[1].Y) / 2;
|
|
float toolY = (float)(visionResults[0].Y + visionResults[1].Y) / 2;
|
|
|
|
|
+
|
|
|
|
|
+ float deltaX = (float)(visionResults[1].X - visionResults[0].X);
|
|
|
|
|
+ float deltaY = (float)(visionResults[1].Y - visionResults[0].Y);
|
|
|
|
|
+ float distance = (float)Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
|
|
|
+
|
|
|
|
|
+ SendTaskMessage($"屏幕长度: {distance:F4}", MessageLevel.Info);
|
|
|
|
|
+
|
|
|
_FixedUpCameraAngle = Common.CalculateAngleBetweenPointsDegrees(new PointF((float)visionResults[0].X, (float)visionResults[0].Y), new PointF((float)visionResults[1].X, (float)visionResults[1].Y));
|
|
_FixedUpCameraAngle = Common.CalculateAngleBetweenPointsDegrees(new PointF((float)visionResults[0].X, (float)visionResults[0].Y), new PointF((float)visionResults[1].X, (float)visionResults[1].Y));
|
|
|
SendTaskMessage($"屏幕中心点位:{toolX:F3},{toolY:F4},{_FixedUpCameraAngle:F4}", MessageLevel.Info);
|
|
SendTaskMessage($"屏幕中心点位:{toolX:F3},{toolY:F4},{_FixedUpCameraAngle:F4}", MessageLevel.Info);
|
|
|
SendTaskMessage($"当前机器人点位:{currentPosition.X:F3},{currentPosition.Y:F4},{currentPosition.U:F4}", MessageLevel.Info);
|
|
SendTaskMessage($"当前机器人点位:{currentPosition.X:F3},{currentPosition.Y:F4},{currentPosition.U:F4}", MessageLevel.Info);
|
|
@@ -1460,6 +1478,22 @@ namespace TeamAAS_VP.Core
|
|
|
//以LCD的的上边中心创建工具坐标
|
|
//以LCD的的上边中心创建工具坐标
|
|
|
DownTool.ComputeTool(currentPosition.X, currentPosition.Y, currentPosition.U, DowmCameraResults[0].X, DowmCameraResults[0].Y);
|
|
DownTool.ComputeTool(currentPosition.X, currentPosition.Y, currentPosition.U, DowmCameraResults[0].X, DowmCameraResults[0].Y);
|
|
|
SendTaskMessage($"屏幕Tool:{DownTool.X:F3},{DownTool.Y:F4}", MessageLevel.Info);
|
|
SendTaskMessage($"屏幕Tool:{DownTool.X:F3},{DownTool.Y:F4}", MessageLevel.Info);
|
|
|
|
|
+
|
|
|
|
|
+ if (current.Reference_coordinate.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ float offsetX = toolX - current.Reference_coordinate[0].X_Position;
|
|
|
|
|
+ float offsetY = toolY - current.Reference_coordinate[0].Y_Position;
|
|
|
|
|
+ float offsetAngle = (float)_FixedUpCameraAngle - current.Reference_coordinate[0].U_Position;
|
|
|
|
|
+ SendTaskMessage($"屏幕偏移量:X:{offsetX},Y:{offsetY},U:{offsetAngle}", MessageLevel.Debug);
|
|
|
|
|
+
|
|
|
|
|
+ foreach (var item in current.RemovePoints)
|
|
|
|
|
+ {
|
|
|
|
|
+ item.X_Position += offsetX;
|
|
|
|
|
+ item.Y_Position += offsetY;
|
|
|
|
|
+ item.U_Position += offsetAngle;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)1);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1601,45 +1635,6 @@ namespace TeamAAS_VP.Core
|
|
|
//相机的编号
|
|
//相机的编号
|
|
|
Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.In_DowmCameraNum.Address);
|
|
Int16 cameraIndex = plc.ReadNode<Int16>(addressConfig.In_DowmCameraNum.Address);
|
|
|
SendTaskMessage($"编号:{cameraIndex}", MessageLevel.Info);
|
|
SendTaskMessage($"编号:{cameraIndex}", MessageLevel.Info);
|
|
|
-
|
|
|
|
|
- // 获取流程
|
|
|
|
|
- //var process = _productService.GetCurrentProductProcedureModelById(currentProduct.FixedUpCamera1ProcedureId);
|
|
|
|
|
- //if (process == null)
|
|
|
|
|
- //{
|
|
|
|
|
- // SendTaskMessage($"固定向上相机1视觉流程,流程ID:{currentProduct.FixedUpCamera1ProcedureId}", MessageLevel.Alarm);
|
|
|
|
|
- // await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)2);
|
|
|
|
|
- // return;
|
|
|
|
|
- //}
|
|
|
|
|
-
|
|
|
|
|
- //// 获取机器人当前坐标
|
|
|
|
|
- //var robot = _robotService.GetAllRobots().FirstOrDefault();
|
|
|
|
|
- //if (robot == null)
|
|
|
|
|
- //{
|
|
|
|
|
- // SendTaskMessage($"未找到机器人,无法执行上相机锁附/组装拍照视觉任务", MessageLevel.Alarm);
|
|
|
|
|
- // await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)2);
|
|
|
|
|
- // return;
|
|
|
|
|
-
|
|
|
|
|
- //}
|
|
|
|
|
- //var currentPosition = robot.GetRobotPos();
|
|
|
|
|
-
|
|
|
|
|
- //// 执行视觉任务
|
|
|
|
|
- //var _cts = new CancellationTokenSource();
|
|
|
|
|
- //var visionResult = await _remoteCommandService.ExecutePhotoGetSinglePoint(process, null, null, _cts.Token);
|
|
|
|
|
- //if (visionResult.IsSucceed)
|
|
|
|
|
- //{
|
|
|
|
|
- // //披头偏差
|
|
|
|
|
- // float offsetX = (float)(visionResult.X - currentPosition.X);
|
|
|
|
|
- // float offsetY = (float)(visionResult.Y - currentPosition.Y);
|
|
|
|
|
-
|
|
|
|
|
- // DowmCameraResults[cameraIndex] = new PointF(offsetX, offsetY);
|
|
|
|
|
- // await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)1);
|
|
|
|
|
- // return;
|
|
|
|
|
- //}
|
|
|
|
|
- //else
|
|
|
|
|
- //{
|
|
|
|
|
- // await plc.WriteNodeAsync(addressConfig.Out_ScrewTeachOk.Address, (Int16)2);
|
|
|
|
|
- // return;
|
|
|
|
|
- //}
|
|
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -2336,35 +2331,29 @@ namespace TeamAAS_VP.Core
|
|
|
gapDict.Add("Gap2", visionResults[1].distance.Split(',')[1]);
|
|
gapDict.Add("Gap2", visionResults[1].distance.Split(',')[1]);
|
|
|
gapDict.Add("Gap3", visionResults[2].distance.Split(',')[1]);
|
|
gapDict.Add("Gap3", visionResults[2].distance.Split(',')[1]);
|
|
|
gapDict.Add("Gap4", visionResults[3].distance.Split(',')[1]);
|
|
gapDict.Add("Gap4", visionResults[3].distance.Split(',')[1]);
|
|
|
|
|
+ gapDict.Add("Gap5", visionResults[1].distance.Split(',')[2]);
|
|
|
|
|
+ gapDict.Add("Gap6", visionResults[3].distance.Split(',')[2]);
|
|
|
//gapString = $"{visionResults[0].distance.Split(',')[1]},{visionResults[1].distance.Split(',')[1]},{visionResults[2].distance.Split(',')[1]},{visionResults[3].distance.Split(',')[1]}";
|
|
//gapString = $"{visionResults[0].distance.Split(',')[1]},{visionResults[1].distance.Split(',')[1]},{visionResults[2].distance.Split(',')[1]},{visionResults[3].distance.Split(',')[1]}";
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)1);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- string res1 = "", res2 = "", res3 = "", res4 = "";
|
|
|
|
|
- if (visionResults[0].IsSucceed)
|
|
|
|
|
- {
|
|
|
|
|
- res1 = visionResults[0].distance.Split(',')[1];
|
|
|
|
|
- }
|
|
|
|
|
- if (visionResults[1].IsSucceed)
|
|
|
|
|
- {
|
|
|
|
|
- res2 = visionResults[1].distance.Split(',')[1];
|
|
|
|
|
- }
|
|
|
|
|
- if (visionResults[2].IsSucceed)
|
|
|
|
|
- {
|
|
|
|
|
- res3 = visionResults[2].distance.Split(',')[1];
|
|
|
|
|
- }
|
|
|
|
|
- if (visionResults[3].IsSucceed)
|
|
|
|
|
- {
|
|
|
|
|
- res4 = visionResults[3].distance.Split(',')[1];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ string res1 = "", res2 = "", res3 = "", res4 = "", res5 = "", res6 = "";
|
|
|
|
|
+ res1 = visionResults[0].distance.Split(',')[1];
|
|
|
|
|
+ res2 = visionResults[1].distance.Split(',')[1];
|
|
|
|
|
+ res3 = visionResults[2].distance.Split(',')[1];
|
|
|
|
|
+ res4 = visionResults[3].distance.Split(',')[1];
|
|
|
|
|
+ res5 = visionResults[1].distance.Split(',')[2];
|
|
|
|
|
+ res6 = visionResults[3].distance.Split(',')[2];
|
|
|
SendTaskMessage($"固定相机检测NG", MessageLevel.Error);
|
|
SendTaskMessage($"固定相机检测NG", MessageLevel.Error);
|
|
|
gapDict.Clear();
|
|
gapDict.Clear();
|
|
|
gapDict.Add("Gap1", res1);
|
|
gapDict.Add("Gap1", res1);
|
|
|
gapDict.Add("Gap2", res2);
|
|
gapDict.Add("Gap2", res2);
|
|
|
gapDict.Add("Gap3", res3);
|
|
gapDict.Add("Gap3", res3);
|
|
|
gapDict.Add("Gap4", res4);
|
|
gapDict.Add("Gap4", res4);
|
|
|
|
|
+ gapDict.Add("Gap5", res5);
|
|
|
|
|
+ gapDict.Add("Gap6", res6);
|
|
|
//gapString = $"{res1},{res2},{res3},{res4}";
|
|
//gapString = $"{res1},{res2},{res3},{res4}";
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
await plc.WriteNodeAsync(addressConfig.Out_FixedCameracheckStatus.Address, (Int16)2);
|
|
|
return;
|
|
return;
|
|
@@ -2885,13 +2874,7 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
{
|
|
|
revision[i] = revisionItem.Replace("stage=", "").Trim();
|
|
revision[i] = revisionItem.Replace("stage=", "").Trim();
|
|
|
SendTaskMessage($"stage:{revision[i]}", MessageLevel.Info);
|
|
SendTaskMessage($"stage:{revision[i]}", MessageLevel.Info);
|
|
|
- }
|
|
|
|
|
- //if (QRcode != camerasn)
|
|
|
|
|
- //{
|
|
|
|
|
- // SendTaskMessage($"Camera_SN与相机获取sn不一致", MessageLevel.Alarm);
|
|
|
|
|
- // await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)2);
|
|
|
|
|
- // return;
|
|
|
|
|
- //}
|
|
|
|
|
|
|
+ }
|
|
|
LogHelper.WriteLogMes($"询问mes成功");
|
|
LogHelper.WriteLogMes($"询问mes成功");
|
|
|
SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
|
|
SendTaskMessage($"询问mes成功:{response}", MessageLevel.Debug);
|
|
|
|
|
|
|
@@ -2976,7 +2959,7 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
|
|
//读取产品结果
|
|
//读取产品结果
|
|
|
Int16 resultIndex = plc.ReadNode<Int16>(string.Format(addressConfig.In_Result.Address, i));
|
|
Int16 resultIndex = plc.ReadNode<Int16>(string.Format(addressConfig.In_Result.Address, i));
|
|
|
- resultIndex = 1;
|
|
|
|
|
|
|
+ //resultIndex = 1;
|
|
|
|
|
|
|
|
#region 组装结果显示列表信息
|
|
#region 组装结果显示列表信息
|
|
|
AssemblyRecord assemblyRecord = new AssemblyRecord();
|
|
AssemblyRecord assemblyRecord = new AssemblyRecord();
|
|
@@ -3023,6 +3006,7 @@ namespace TeamAAS_VP.Core
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
await _systemDatabaseService.RecordAssemblyAsync(assemblyRecord);
|
|
await _systemDatabaseService.RecordAssemblyAsync(assemblyRecord);
|
|
|
|
|
+
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
LogHelper.WriteLogMes($"【mes开始ADD】");
|
|
LogHelper.WriteLogMes($"【mes开始ADD】");
|
|
@@ -3037,21 +3021,24 @@ namespace TeamAAS_VP.Core
|
|
|
assypress = currentPressure[0].ToString("F2");
|
|
assypress = currentPressure[0].ToString("F2");
|
|
|
if (currentPressure[0] >= currentProduct.GlobalParamEx.AssemblyPressure.PressureDownLimit && currentPressure[0] <= currentProduct.GlobalParamEx.AssemblyPressure.PressureUpLimit)
|
|
if (currentPressure[0] >= currentProduct.GlobalParamEx.AssemblyPressure.PressureDownLimit && currentPressure[0] <= currentProduct.GlobalParamEx.AssemblyPressure.PressureUpLimit)
|
|
|
{
|
|
{
|
|
|
- resultIndex = 1;
|
|
|
|
|
|
|
+ //resultIndex = 1;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- resultIndex = 2;
|
|
|
|
|
|
|
+ if (!fileresult.Contains("AssyPressure1_File"))
|
|
|
|
|
+ {
|
|
|
|
|
+ fileresult.Add($"AssyPressure1_File");
|
|
|
|
|
+ }
|
|
|
|
|
+ //resultIndex = 2;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
|
{
|
|
{
|
|
|
- assypress = "0";
|
|
|
|
|
- resultIndex = 2;
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
data = gapDict.Copy();
|
|
data = gapDict.Copy();
|
|
|
data.Add("AssyPressure1", assypress);
|
|
data.Add("AssyPressure1", assypress);
|
|
|
- SendTaskMessage($"Gap1:{gapDict["Gap1"]},Gap2:{gapDict["Gap2"]},Gap3:{gapDict["Gap3"]},Gap4:{gapDict["Gap4"]},组装压力:{assypress}", MessageLevel.Info);
|
|
|
|
|
|
|
+ SendTaskMessage($"Gap1:{gapDict["Gap1"]},Gap2:{gapDict["Gap2"]},Gap3:{gapDict["Gap3"]},Gap4:{gapDict["Gap4"]},Gap5:{gapDict["Gap5"]},Gap6:{gapDict["Gap6"]},组装压力:{assypress}", MessageLevel.Info);
|
|
|
#region CSV数据
|
|
#region CSV数据
|
|
|
bool assyPresRes;
|
|
bool assyPresRes;
|
|
|
if (currentPressure[0] >= currentProduct.GlobalParamEx.AssemblyPressure.PressureDownLimit && currentPressure[0] <= currentProduct.GlobalParamEx.AssemblyPressure.PressureUpLimit)
|
|
if (currentPressure[0] >= currentProduct.GlobalParamEx.AssemblyPressure.PressureDownLimit && currentPressure[0] <= currentProduct.GlobalParamEx.AssemblyPressure.PressureUpLimit)
|
|
@@ -3071,21 +3058,55 @@ namespace TeamAAS_VP.Core
|
|
|
upLimitValue = currentProduct.GlobalParamEx.Gap1UpLimit.ToString("F3");
|
|
upLimitValue = currentProduct.GlobalParamEx.Gap1UpLimit.ToString("F3");
|
|
|
downLimitValue = currentProduct.GlobalParamEx.Gap1DownLimit.ToString("F3");
|
|
downLimitValue = currentProduct.GlobalParamEx.Gap1DownLimit.ToString("F3");
|
|
|
midValue = ((currentProduct.GlobalParamEx.Gap1UpLimit + currentProduct.GlobalParamEx.Gap1DownLimit) / 2).ToString("F3");
|
|
midValue = ((currentProduct.GlobalParamEx.Gap1UpLimit + currentProduct.GlobalParamEx.Gap1DownLimit) / 2).ToString("F3");
|
|
|
|
|
+ if (Convert.ToDouble(item.Value) > Convert.ToDouble(upLimitValue) && Convert.ToDouble(item.Value) < Convert.ToDouble(downLimitValue) && !fileresult.Contains("Gap1_File"))
|
|
|
|
|
+ {
|
|
|
|
|
+ fileresult.Add($"Gap1_File");
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
case "Gap2":
|
|
case "Gap2":
|
|
|
upLimitValue = currentProduct.GlobalParamEx.Gap2UpLimit.ToString("F3");
|
|
upLimitValue = currentProduct.GlobalParamEx.Gap2UpLimit.ToString("F3");
|
|
|
downLimitValue = currentProduct.GlobalParamEx.Gap2DownLimit.ToString("F3");
|
|
downLimitValue = currentProduct.GlobalParamEx.Gap2DownLimit.ToString("F3");
|
|
|
midValue = ((currentProduct.GlobalParamEx.Gap2UpLimit + currentProduct.GlobalParamEx.Gap2DownLimit) / 2).ToString("F3");
|
|
midValue = ((currentProduct.GlobalParamEx.Gap2UpLimit + currentProduct.GlobalParamEx.Gap2DownLimit) / 2).ToString("F3");
|
|
|
|
|
+ if (Convert.ToDouble(item.Value) > Convert.ToDouble(upLimitValue) && Convert.ToDouble(item.Value) < Convert.ToDouble(downLimitValue) && !fileresult.Contains("Gap2_File"))
|
|
|
|
|
+ {
|
|
|
|
|
+ fileresult.Add($"Gap2_File");
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
case "Gap3":
|
|
case "Gap3":
|
|
|
upLimitValue = currentProduct.GlobalParamEx.Gap3UpLimit.ToString("F3");
|
|
upLimitValue = currentProduct.GlobalParamEx.Gap3UpLimit.ToString("F3");
|
|
|
downLimitValue = currentProduct.GlobalParamEx.Gap3DownLimit.ToString("F3");
|
|
downLimitValue = currentProduct.GlobalParamEx.Gap3DownLimit.ToString("F3");
|
|
|
midValue = ((currentProduct.GlobalParamEx.Gap3UpLimit + currentProduct.GlobalParamEx.Gap3DownLimit) / 2).ToString("F3");
|
|
midValue = ((currentProduct.GlobalParamEx.Gap3UpLimit + currentProduct.GlobalParamEx.Gap3DownLimit) / 2).ToString("F3");
|
|
|
|
|
+ if (Convert.ToDouble(item.Value) > Convert.ToDouble(upLimitValue) && Convert.ToDouble(item.Value) < Convert.ToDouble(downLimitValue) && !fileresult.Contains("Gap3_File"))
|
|
|
|
|
+ {
|
|
|
|
|
+ fileresult.Add($"Gap3_File");
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
case "Gap4":
|
|
case "Gap4":
|
|
|
upLimitValue = currentProduct.GlobalParamEx.Gap4UpLimit.ToString("F3");
|
|
upLimitValue = currentProduct.GlobalParamEx.Gap4UpLimit.ToString("F3");
|
|
|
downLimitValue = currentProduct.GlobalParamEx.Gap4DownLimit.ToString("F3");
|
|
downLimitValue = currentProduct.GlobalParamEx.Gap4DownLimit.ToString("F3");
|
|
|
midValue = ((currentProduct.GlobalParamEx.Gap4UpLimit + currentProduct.GlobalParamEx.Gap4DownLimit) / 2).ToString("F3");
|
|
midValue = ((currentProduct.GlobalParamEx.Gap4UpLimit + currentProduct.GlobalParamEx.Gap4DownLimit) / 2).ToString("F3");
|
|
|
|
|
+ if (Convert.ToDouble(item.Value) > Convert.ToDouble(upLimitValue) && Convert.ToDouble(item.Value) < Convert.ToDouble(downLimitValue) && !fileresult.Contains("Gap4_File"))
|
|
|
|
|
+ {
|
|
|
|
|
+ fileresult.Add($"Gap4_File");
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "Gap5":
|
|
|
|
|
+ upLimitValue = currentProduct.GlobalParamEx.Gap5UpLimit.ToString("F3");
|
|
|
|
|
+ downLimitValue = currentProduct.GlobalParamEx.Gap5DownLimit.ToString("F3");
|
|
|
|
|
+ midValue = ((currentProduct.GlobalParamEx.Gap5UpLimit + currentProduct.GlobalParamEx.Gap5DownLimit) / 2).ToString("F3");
|
|
|
|
|
+ if (Convert.ToDouble(item.Value) > Convert.ToDouble(upLimitValue) && Convert.ToDouble(item.Value) < Convert.ToDouble(downLimitValue) && !fileresult.Contains("Gap5_File"))
|
|
|
|
|
+ {
|
|
|
|
|
+ fileresult.Add($"Gap5_File");
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "Gap6":
|
|
|
|
|
+ upLimitValue = currentProduct.GlobalParamEx.Gap6UpLimit.ToString("F3");
|
|
|
|
|
+ downLimitValue = currentProduct.GlobalParamEx.Gap6DownLimit.ToString("F3");
|
|
|
|
|
+ midValue = ((currentProduct.GlobalParamEx.Gap6UpLimit + currentProduct.GlobalParamEx.Gap6DownLimit) / 2).ToString("F3");
|
|
|
|
|
+ if (Convert.ToDouble(item.Value) > Convert.ToDouble(upLimitValue) && Convert.ToDouble(item.Value) < Convert.ToDouble(downLimitValue) && !fileresult.Contains("Gap6_File"))
|
|
|
|
|
+ {
|
|
|
|
|
+ fileresult.Add($"Gap6_File");
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
DFC.Add(new DataFormCtq
|
|
DFC.Add(new DataFormCtq
|
|
@@ -3152,17 +3173,20 @@ namespace TeamAAS_VP.Core
|
|
|
press = currentPressure[1].ToString("F2");
|
|
press = currentPressure[1].ToString("F2");
|
|
|
if (currentPressure[1] >= currentProduct.GlobalParamEx.DownPressure.PressureDownLimit && currentPressure[1] <= currentProduct.GlobalParamEx.DownPressure.PressureUpLimit)
|
|
if (currentPressure[1] >= currentProduct.GlobalParamEx.DownPressure.PressureDownLimit && currentPressure[1] <= currentProduct.GlobalParamEx.DownPressure.PressureUpLimit)
|
|
|
{
|
|
{
|
|
|
- resultIndex = 1;
|
|
|
|
|
|
|
+ //resultIndex = 1;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- resultIndex = 2;
|
|
|
|
|
|
|
+ if (!fileresult.Contains("Pressure1_File"))
|
|
|
|
|
+ {
|
|
|
|
|
+ fileresult.Add($"Pressure1_File");
|
|
|
|
|
+ }
|
|
|
|
|
+ // resultIndex = 2;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
|
{
|
|
{
|
|
|
- press = "0";
|
|
|
|
|
- resultIndex = 2;
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
presstime = currentProduct.GlobalParamEx.DownPressure.PressureTime.ToString();
|
|
presstime = currentProduct.GlobalParamEx.DownPressure.PressureTime.ToString();
|
|
|
data.Add("Pressure1", press);
|
|
data.Add("Pressure1", press);
|
|
@@ -3235,7 +3259,7 @@ namespace TeamAAS_VP.Core
|
|
|
#endregion
|
|
#endregion
|
|
|
}
|
|
}
|
|
|
//gap-复检gap参数, press-保压站实际压力值, presstime-保压站保压时间, assypress-组装站实际压力值
|
|
//gap-复检gap参数, press-保压站实际压力值, presstime-保压站保压时间, assypress-组装站实际压力值
|
|
|
- (bool isSuccess, string response) = await _mesService.SubmitGetAsync(i, ProductMainSN[i], comp, resultIndex == 1 ? true : false, data, _LastMesCheckTime[i], serverTimeResult.Now);
|
|
|
|
|
|
|
+ (bool isSuccess, string response) = await _mesService.SubmitGetAsync(i, ProductMainSN[i], comp, resultIndex == 1 ? true : false, data,fileresult, _LastMesCheckTime[i], serverTimeResult.Now);
|
|
|
if (!stationConfig.EnableMES || isSuccess)
|
|
if (!stationConfig.EnableMES || isSuccess)
|
|
|
{
|
|
{
|
|
|
LogHelper.WriteLogMes($"上传mes成功");
|
|
LogHelper.WriteLogMes($"上传mes成功");
|
|
@@ -3289,7 +3313,7 @@ namespace TeamAAS_VP.Core
|
|
|
string target_log = Path.Combine(filePath, Path.GetFileName(source_log));
|
|
string target_log = Path.Combine(filePath, Path.GetFileName(source_log));
|
|
|
File.Copy(source_log, target_log, true);
|
|
File.Copy(source_log, target_log, true);
|
|
|
//判断是否保存锁付曲线
|
|
//判断是否保存锁付曲线
|
|
|
- if (pressureSensorConfig.IsSavePressureCurve)
|
|
|
|
|
|
|
+ if (pressureSensorConfig.IsSavePressureCurve&&i!=0)
|
|
|
{
|
|
{
|
|
|
string target_Directory = filePath + "\\压力曲线\\";
|
|
string target_Directory = filePath + "\\压力曲线\\";
|
|
|
string source_Torque_Image = pressureSensorConfig.PressureCurvePath + $"\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
|
|
string source_Torque_Image = pressureSensorConfig.PressureCurvePath + $"\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
|
|
@@ -3367,6 +3391,7 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
LogHelper.WriteLogMes($"【mes结束ADD】");
|
|
LogHelper.WriteLogMes($"【mes结束ADD】");
|
|
|
SendTaskMessage($"mes结束ADD", MessageLevel.Info);
|
|
SendTaskMessage($"mes结束ADD", MessageLevel.Info);
|
|
|
|
|
+ fileresult.Clear();
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -3436,9 +3461,20 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
|
|
//await Task.Delay(60);
|
|
//await Task.Delay(60);
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.In_WorkDone.Address, i), (Int16)0);
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.In_WorkDone.Address, i), (Int16)0);
|
|
|
- var code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, i));
|
|
|
|
|
// 停止采集压力并保存
|
|
// 停止采集压力并保存
|
|
|
await StopAndSavePressureCollectionAsync(currentProduct.Name, ProductMainSN[i], i);
|
|
await StopAndSavePressureCollectionAsync(currentProduct.Name, ProductMainSN[i], i);
|
|
|
|
|
+
|
|
|
|
|
+ if (i == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (pressure <= currentProduct.GlobalParamEx.DownPressure.PressureDownLimit || pressure >= currentProduct.GlobalParamEx.DownPressure.PressureUpLimit)
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.In_WorkDone.Address, i), (Int16)4);//NG
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ await plc.WriteNodeAsync(string.Format(addressConfig.In_WorkDone.Address, i), (Int16)3);//OK
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -3858,10 +3894,54 @@ namespace TeamAAS_VP.Core
|
|
|
string tempDirPath = Path.Combine(savePath, datePath, $"{stationIndex}_{timestamp.ToString("yyyy-MM-dd")}_temp");
|
|
string tempDirPath = Path.Combine(savePath, datePath, $"{stationIndex}_{timestamp.ToString("yyyy-MM-dd")}_temp");
|
|
|
string tempFileName = $"{stationIndex}_{timestamp.ToString("yyyy-MM-dd_HH-mm-ss-fff")}_temp.csv";
|
|
string tempFileName = $"{stationIndex}_{timestamp.ToString("yyyy-MM-dd_HH-mm-ss-fff")}_temp.csv";
|
|
|
RecordStationResult(stationIndex, dfcs, productMainSN, ct, timestamp, tempFileName, false);
|
|
RecordStationResult(stationIndex, dfcs, productMainSN, ct, timestamp, tempFileName, false);
|
|
|
- return false;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public async Task<string> CheckConsecutiveLowCapacityAsync(string productName, int consecutiveHours, int targetPerHour)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 1. 获取你已有的按小时统计的产能数据
|
|
|
|
|
+ var records = await _systemDatabaseService.GetDailyProductionByHourAndCategoryAsync(productName);
|
|
|
|
|
+
|
|
|
|
|
+ // 连续计数初始化
|
|
|
|
|
+ int consecutiveFail = 0;
|
|
|
|
|
+ int firstFailHour = -1;
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 遍历 0~23 小时,检查每小时总产能
|
|
|
|
|
+ for (int hour = 0; hour < 24; hour++)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 当前小时总产能 = 该小时所有分类数量相加,没有数据 = 0
|
|
|
|
|
+ int currentCapacity = 0;
|
|
|
|
|
+ if (records.TryGetValue(hour, out var categoryDict))
|
|
|
|
|
+ {
|
|
|
|
|
+ currentCapacity = categoryDict.Sum(kv => kv.Value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 判断是否不达标
|
|
|
|
|
+ if (currentCapacity < targetPerHour)
|
|
|
|
|
+ {
|
|
|
|
|
+ consecutiveFail++;
|
|
|
|
|
+ if (firstFailHour == -1)
|
|
|
|
|
+ firstFailHour = hour;
|
|
|
|
|
+
|
|
|
|
|
+ if (consecutiveFail >= consecutiveHours)
|
|
|
|
|
+ {
|
|
|
|
|
+ int endHour = firstFailHour + consecutiveHours - 1;
|
|
|
|
|
+ return $"⚠️ 报警:{productName} 自 {firstFailHour:D2}:00 至 {endHour:D2}:59 连续{consecutiveHours}小时产能未达到{targetPerHour},请关注!";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ // 达标,重置连续计数
|
|
|
|
|
+ consecutiveFail = 0;
|
|
|
|
|
+ firstFailHour = -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 无报警
|
|
|
|
|
+ return string.Empty;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
#region 压缩图片文件夹
|
|
#region 压缩图片文件夹
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// 压缩文件
|
|
/// 压缩文件
|