|
|
@@ -997,16 +997,18 @@ namespace TeamAAS_VP.Core
|
|
|
addressConfig.In_FixedCameraPickExe.Address,
|
|
|
addressConfig.In_FixedCameraPutExe.Address,
|
|
|
addressConfig.In_FixedCameracheckExe.Address,
|
|
|
- addressConfig.In_WorkStart.Address,
|
|
|
- addressConfig.In_WorkDone.Address,
|
|
|
- //addressConfig.In_MesCheck.Address,
|
|
|
addressConfig.In_RequestPosition.Address,
|
|
|
addressConfig.In_ScrewTeachExe.Address,
|
|
|
addressConfig.In_PickINC.Address,
|
|
|
};
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
{
|
|
|
- monitorNodeIds.Add(string.Format(addressConfig.In_MesCheck.Address,i));
|
|
|
+ monitorNodeIds.Add(string.Format(addressConfig.In_MesCheck.Address, i));
|
|
|
+ }
|
|
|
+ for (int i = 0; i < 7; i++)
|
|
|
+ {
|
|
|
+ monitorNodeIds.Add(string.Format(addressConfig.In_WorkStart.Address, i));
|
|
|
+ monitorNodeIds.Add(string.Format(addressConfig.In_WorkDone.Address, i));
|
|
|
}
|
|
|
//订阅PLC地址变化
|
|
|
plc.SubscribeNodes("AutoSensor", monitorNodeIds, PlcCommandTrigger);
|
|
|
@@ -1067,6 +1069,20 @@ namespace TeamAAS_VP.Core
|
|
|
await item.WriteToPlcAddress(addressConfig.Out_CheckCamera, plc);
|
|
|
}
|
|
|
}
|
|
|
+ if (current.RemovePoints != null && current.RemovePoints.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in current.RemovePoints)
|
|
|
+ {
|
|
|
+ await item.WriteToPlcAddress(addressConfig.Out_RemovePos, plc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (current.PressurePlacePoints != null && current.PressurePlacePoints.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in current.PressurePlacePoints)
|
|
|
+ {
|
|
|
+ await item.WriteToPlcAddress(addressConfig.Out_PressurePlace, plc);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1077,7 +1093,7 @@ namespace TeamAAS_VP.Core
|
|
|
/// 移动向下相机拍照结果
|
|
|
/// </summary>
|
|
|
OpenCvSharp.Point3f[] UpCameraPutResults = new OpenCvSharp.Point3f[10];
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 二次定位相机的工具坐标
|
|
|
/// </summary>
|
|
|
@@ -1093,8 +1109,8 @@ namespace TeamAAS_VP.Core
|
|
|
bool _LastFixedCameraPickExe = false;
|
|
|
bool _LastFixedCameraPutExe = false;
|
|
|
bool _LastFixedCameracheckExe = false;
|
|
|
- Int16 _LastWorkStart = 0;
|
|
|
- Int16 _LastWorkDone = 0;
|
|
|
+ Int16[] _LastWorkStart = new Int16[7];
|
|
|
+ Int16[] _LastWorkDone = new Int16[7];
|
|
|
Int16 _LastRequestPosition = 0;
|
|
|
Int16 _LastPickINC = 0;
|
|
|
Int16[] _LastMesCheck = new Int16[10];
|
|
|
@@ -1112,7 +1128,7 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var addressConfig = _configService.GetPlcAddresses();
|
|
|
var plc = _plcService.GetPlcByNumber(addressConfig.PlcNo) as OpcUaClientPLC;
|
|
|
if (plc == null || !plc.IsConnected) return;
|
|
|
@@ -1246,7 +1262,7 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_DownCameraStatus.Address, (Int16)2);
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -1573,7 +1589,7 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
var currentPosition = robot.GetRobotPos();
|
|
|
|
|
|
-
|
|
|
+
|
|
|
//如果上相机2的流程id为空,则表示只有一个上相机
|
|
|
if (currentProduct.MoveDownCamera2LockPhotoProcedureId == Guid.Empty)
|
|
|
{
|
|
|
@@ -1647,7 +1663,7 @@ namespace TeamAAS_VP.Core
|
|
|
float centerX = (float)(visionResults[0].X + visionResults[1].X) / 2;
|
|
|
float centerY = (float)(visionResults[0].Y + visionResults[1].Y) / 2;
|
|
|
_MoveCameraAngle = Common.CalculateAngleBetweenPointsDegrees(new PointF((float)visionResults[0].X, (float)visionResults[0].Y), new PointF((float)visionResults[1].X, (float)visionResults[1].Y));
|
|
|
- UpCameraPutResults[cameraIndex] = new OpenCvSharp.Point3f(centerX, centerY,(float)_MoveCameraAngle);
|
|
|
+ UpCameraPutResults[cameraIndex] = new OpenCvSharp.Point3f(centerX, centerY, (float)_MoveCameraAngle);
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_UpCameraPutStatus.Address, (Int16)1);
|
|
|
return;
|
|
|
}
|
|
|
@@ -1787,111 +1803,6 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 开始锁付
|
|
|
- else if (addressConfig.In_WorkStart.Address.Contains(tuple.nodeId))
|
|
|
- {
|
|
|
- if (tuple.value is Int16 state)
|
|
|
- {
|
|
|
- if (_LastWorkStart != state)
|
|
|
- {
|
|
|
- _LastWorkStart = state;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (state == 1)
|
|
|
- {
|
|
|
- SendTaskMessage($"收到开始锁付信号...", MessageLevel.Debug);
|
|
|
- //位置编号
|
|
|
- Int16 positionIndex = plc.ReadNode<Int16>(addressConfig.In_ProductNum.Address);
|
|
|
- SendTaskMessage($"编号:{positionIndex}", MessageLevel.Info);
|
|
|
-
|
|
|
- var code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, positionIndex));
|
|
|
- // 开始采集压力值
|
|
|
- StartPressureCollection(currentProduct.Name, code, positionIndex);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SendTaskMessage($"开始锁付信号已关闭", MessageLevel.Alarm);
|
|
|
- // 关闭时的处理(如需)可放在这里
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 停止锁付
|
|
|
- else if (addressConfig.In_WorkDone.Address.Contains(tuple.nodeId))
|
|
|
- {
|
|
|
- if (tuple.value is Int16 state)
|
|
|
- {
|
|
|
- if (_LastWorkDone != state)
|
|
|
- {
|
|
|
- _LastWorkDone = state;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (state == 1 || state == 2)
|
|
|
- {
|
|
|
- SendTaskMessage($"收到停止锁付信号...", MessageLevel.Debug);
|
|
|
- //位置编号
|
|
|
- Int16 positionIndex = plc.ReadNode<Int16>(addressConfig.In_ProductNum.Address);
|
|
|
- SendTaskMessage($"编号:{positionIndex}", MessageLevel.Info);
|
|
|
- //获取当前锁付点
|
|
|
- //var screwPoint = currentProduct.ScrewPoints.FirstOrDefault(p => p.Number == positionIndex);
|
|
|
- ////获取当前的机器人点位
|
|
|
- //var robot = _robotService.GetAllRobots().FirstOrDefault();
|
|
|
- //var currentPosition = robot.GetRobotPos();
|
|
|
- ////读取压力值
|
|
|
- //float pressure = plc.ReadNode<float>(addressConfig.In_PressureValue.Address);
|
|
|
-
|
|
|
-
|
|
|
- //await Task.Delay(60);
|
|
|
- ////获取电批结果
|
|
|
- //bool isSucced = ScrewDriver.GetData();
|
|
|
- //LockResult lockResult = new LockResult();
|
|
|
- //lockResult.ScrewdriverGetDataSucceed = isSucced;
|
|
|
- //lockResult.Number = positionIndex;
|
|
|
- //lockResult.LockPassed = ScrewDriver.Success;
|
|
|
- //lockResult.ProductNumber = _productService.CurrentProductCode;
|
|
|
- //lockResult.LockTurns = (float)ScrewDriver.Truns;
|
|
|
- //lockResult.LockTorque = (float)ScrewDriver.TorqueValue;
|
|
|
- //lockResult.LockDuration = (float)ScrewDriver.FinalTime;
|
|
|
- //lockResult.ScrewdriverProgramNumber = ScrewDriver.ProgramNumber;
|
|
|
- //lockResult.ResultDetails = ScrewDriver.ErrorInfo;
|
|
|
- //lockResult.Pressure = pressure;
|
|
|
- //lockResult.TargetTorque = ScrewDriver.TargetTorque;
|
|
|
- //lockResult.TargetTurnsUpperLimit = ScrewDriver.TargetTurnsUpperLimit;
|
|
|
- //lockResult.TargetTurnsLowerLimit = ScrewDriver.TargetTurnsLowerLimit;
|
|
|
- //lockResult.TargetLockSpeed = ScrewDriver.TargetLockSpeed;
|
|
|
- //lockResult.StartPositionX = currentPosition.X;
|
|
|
- //lockResult.StartPositionY = currentPosition.Y;
|
|
|
- //lockResult.StartPositionZ = screwPoint.Z_Position_Start;
|
|
|
- //lockResult.EndPositionZ = currentPosition.Z;
|
|
|
- //lockResult.LockDescentSpeed = screwPoint.Z_Velocity_Stop;
|
|
|
- //lockResult.FeederNumber = screwPoint != null ? screwPoint.Feeder : 0;
|
|
|
- //lockResult.NozzleNumber = "";
|
|
|
- //lockResult.OperatorName = _systemDatabaseService.GetCurrentUser().UserName;
|
|
|
- //lockResult.ProductImagePath = "";
|
|
|
- //lockResult.WaveDatas = ScrewDriver.WaveDatas;
|
|
|
- //App.Current.Dispatcher.Invoke(() =>
|
|
|
- //{
|
|
|
- // _eventAggregator.GetEvent<LockFinishNotification>().Publish(lockResult);
|
|
|
- //});
|
|
|
- //await _systemDatabaseService.RecordLockResultAsync(lockResult);
|
|
|
- await plc.WriteNodeAsync(addressConfig.In_WorkDone.Address, (Int16)0);
|
|
|
- var code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, positionIndex));
|
|
|
- // 停止采集压力并保存
|
|
|
- await StopAndSavePressureCollectionAsync(currentProduct.Name, code, positionIndex);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SendTaskMessage($"停止锁付信号已关闭", MessageLevel.Alarm);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
// 多相机坐标合并
|
|
|
else if (addressConfig.In_RequestPosition.Address.Contains(tuple.nodeId))
|
|
|
{
|
|
|
@@ -1919,17 +1830,17 @@ namespace TeamAAS_VP.Core
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- double upCameraX=0, upCameraY=0,upCameraU=0;
|
|
|
+ double upCameraX = 0, upCameraY = 0, upCameraU = 0;
|
|
|
upCameraX = UpCameraPutResults[1].X;
|
|
|
- upCameraY= UpCameraPutResults[1].Y;
|
|
|
- upCameraU= UpCameraPutResults[1].Z;
|
|
|
+ upCameraY = UpCameraPutResults[1].Y;
|
|
|
+ upCameraU = UpCameraPutResults[1].Z;
|
|
|
//如果下相机拍照的次数是1,则判断用时拍照的相机是几个
|
|
|
int upCameraNum = _configService.GetSystemConfiguration().UpCameraPutNum;
|
|
|
if (upCameraNum == 2)
|
|
|
{
|
|
|
- upCameraX = (UpCameraPutResults[1].X+ UpCameraPutResults[2].X) / 2;
|
|
|
- upCameraY= (UpCameraPutResults[1].Y + UpCameraPutResults[2].Y) / 2;
|
|
|
- upCameraU= Common.CalculateAngleBetweenPointsDegrees(new PointF((float)UpCameraPutResults[1].X, (float)UpCameraPutResults[1].Y), new PointF((float)UpCameraPutResults[2].X, (float)UpCameraPutResults[2].Y));
|
|
|
+ upCameraX = (UpCameraPutResults[1].X + UpCameraPutResults[2].X) / 2;
|
|
|
+ upCameraY = (UpCameraPutResults[1].Y + UpCameraPutResults[2].Y) / 2;
|
|
|
+ upCameraU = Common.CalculateAngleBetweenPointsDegrees(new PointF((float)UpCameraPutResults[1].X, (float)UpCameraPutResults[1].Y), new PointF((float)UpCameraPutResults[2].X, (float)UpCameraPutResults[2].Y));
|
|
|
}
|
|
|
|
|
|
var point = currentProduct.ScrewPoints[0].Clone();
|
|
|
@@ -1956,7 +1867,6 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// 螺丝供料器螺丝递减
|
|
|
else if (addressConfig.In_PickINC.Address.Contains(tuple.nodeId))
|
|
|
{
|
|
|
@@ -1979,9 +1889,9 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- // 过站检查
|
|
|
else
|
|
|
{
|
|
|
+ // 过站检查
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
{
|
|
|
if (string.Format(addressConfig.In_MesCheck.Address, i).Contains(tuple.nodeId))
|
|
|
@@ -2018,6 +1928,7 @@ namespace TeamAAS_VP.Core
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)1);
|
|
|
+ return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -2025,6 +1936,7 @@ namespace TeamAAS_VP.Core
|
|
|
await plc.WriteNodeAsync(addressConfig.Out_ScrewFeederIsChanged.Address, (Int16)1); //不发生改变
|
|
|
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)0);
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
// 上传本站数据
|
|
|
@@ -2038,20 +1950,138 @@ namespace TeamAAS_VP.Core
|
|
|
CTtime = DateTime.UtcNow.Subtract(_LastMesCheckTime[i]).TotalSeconds;
|
|
|
}
|
|
|
|
|
|
- (bool isSuccess, string response) = await _mesService.SubmitGetAsync(code, true, _LastMesCheckTime[i], DateTime.Now);
|
|
|
+ //读取产品结果
|
|
|
+ Int16 resultIndex = plc.ReadNode<Int16>(addressConfig.In_Result.Address);
|
|
|
+
|
|
|
+ //目前只记录当前站
|
|
|
+ if (i == 0)
|
|
|
+ await _systemDatabaseService.RecordProductionAsync(new ProductionRecord()
|
|
|
+ {
|
|
|
+ ProductName = currentProduct.Name,
|
|
|
+ ProductCode = code,
|
|
|
+ DeviceId = i,
|
|
|
+ DeviceName = "",
|
|
|
+ Category = resultIndex == 1 ? "OK" : "NG",
|
|
|
+ Quantity = 1,
|
|
|
+ Remark = $"TotalSeconds:{DateTime.UtcNow.Subtract(_LastMesCheckTime[i]).TotalSeconds.ToString("F2")}",
|
|
|
+ });
|
|
|
+
|
|
|
+ (bool isSuccess, string response) = await _mesService.SubmitGetAsync(code, resultIndex == 1 ? true : false, _LastMesCheckTime[i], DateTime.UtcNow);
|
|
|
//假设上传成功,这里缺少上传失败的处理
|
|
|
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)3);
|
|
|
+ return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SendTaskMessage($"{i}过站检查信号:state={state},处理为默认状态", MessageLevel.Alarm);
|
|
|
await plc.WriteNodeAsync(string.Format(addressConfig.Out_MesStatus.Address, i), (Int16)0);
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //开始/停止 组装/锁附
|
|
|
+ for (int i = 0; i < 7; i++)
|
|
|
+ {
|
|
|
+ //开始组装
|
|
|
+ if (string.Format(addressConfig.In_WorkStart.Address, i).Contains(tuple.nodeId))
|
|
|
+ {
|
|
|
+ if (tuple.value is Int16 state)
|
|
|
+ {
|
|
|
+ if (_LastWorkStart[i] != state)
|
|
|
+ {
|
|
|
+ _LastWorkStart[i] = state;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (state == 1)
|
|
|
+ {
|
|
|
+ SendTaskMessage($"收到开始组装信号[{i}]...", MessageLevel.Debug);
|
|
|
|
|
|
+ var code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, i));
|
|
|
+ // 开始采集压力值
|
|
|
+ StartPressureCollection(currentProduct.Name, code, i);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SendTaskMessage($"开始锁付信号[{i}]已关闭", MessageLevel.Alarm);
|
|
|
+ // 关闭时的处理(如需)可放在这里
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //停止组装
|
|
|
+ else if (string.Format(addressConfig.In_WorkStart.Address, i).Contains(tuple.nodeId))
|
|
|
+ {
|
|
|
+ if (tuple.value is Int16 state)
|
|
|
+ {
|
|
|
+ if (_LastWorkDone[i] != state)
|
|
|
+ {
|
|
|
+ _LastWorkDone[i] = state;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (state == 1 || state == 2)
|
|
|
+ {
|
|
|
+ SendTaskMessage($"收到停止锁付信号[{i}]...", MessageLevel.Debug);
|
|
|
+ //获取当前锁付点
|
|
|
+ //var screwPoint = currentProduct.ScrewPoints.FirstOrDefault(p => p.Number == positionIndex);
|
|
|
+ ////获取当前的机器人点位
|
|
|
+ //var robot = _robotService.GetAllRobots().FirstOrDefault();
|
|
|
+ //var currentPosition = robot.GetRobotPos();
|
|
|
+ ////读取压力值
|
|
|
+ //float pressure = plc.ReadNode<float>(addressConfig.In_PressureValue.Address);
|
|
|
+
|
|
|
+
|
|
|
+ //await Task.Delay(60);
|
|
|
+ ////获取电批结果
|
|
|
+ //bool isSucced = ScrewDriver.GetData();
|
|
|
+ //LockResult lockResult = new LockResult();
|
|
|
+ //lockResult.ScrewdriverGetDataSucceed = isSucced;
|
|
|
+ //lockResult.Number = positionIndex;
|
|
|
+ //lockResult.LockPassed = ScrewDriver.Success;
|
|
|
+ //lockResult.ProductNumber = _productService.CurrentProductCode;
|
|
|
+ //lockResult.LockTurns = (float)ScrewDriver.Truns;
|
|
|
+ //lockResult.LockTorque = (float)ScrewDriver.TorqueValue;
|
|
|
+ //lockResult.LockDuration = (float)ScrewDriver.FinalTime;
|
|
|
+ //lockResult.ScrewdriverProgramNumber = ScrewDriver.ProgramNumber;
|
|
|
+ //lockResult.ResultDetails = ScrewDriver.ErrorInfo;
|
|
|
+ //lockResult.Pressure = pressure;
|
|
|
+ //lockResult.TargetTorque = ScrewDriver.TargetTorque;
|
|
|
+ //lockResult.TargetTurnsUpperLimit = ScrewDriver.TargetTurnsUpperLimit;
|
|
|
+ //lockResult.TargetTurnsLowerLimit = ScrewDriver.TargetTurnsLowerLimit;
|
|
|
+ //lockResult.TargetLockSpeed = ScrewDriver.TargetLockSpeed;
|
|
|
+ //lockResult.StartPositionX = currentPosition.X;
|
|
|
+ //lockResult.StartPositionY = currentPosition.Y;
|
|
|
+ //lockResult.StartPositionZ = screwPoint.Z_Position_Start;
|
|
|
+ //lockResult.EndPositionZ = currentPosition.Z;
|
|
|
+ //lockResult.LockDescentSpeed = screwPoint.Z_Velocity_Stop;
|
|
|
+ //lockResult.FeederNumber = screwPoint != null ? screwPoint.Feeder : 0;
|
|
|
+ //lockResult.NozzleNumber = "";
|
|
|
+ //lockResult.OperatorName = _systemDatabaseService.GetCurrentUser().UserName;
|
|
|
+ //lockResult.ProductImagePath = "";
|
|
|
+ //lockResult.WaveDatas = ScrewDriver.WaveDatas;
|
|
|
+ //App.Current.Dispatcher.Invoke(() =>
|
|
|
+ //{
|
|
|
+ // _eventAggregator.GetEvent<LockFinishNotification>().Publish(lockResult);
|
|
|
+ //});
|
|
|
+ //await _systemDatabaseService.RecordLockResultAsync(lockResult);
|
|
|
+ await plc.WriteNodeAsync(addressConfig.In_WorkDone.Address, (Int16)0);
|
|
|
+ var code = plc.ReadNode<string>(string.Format(addressConfig.In_Code.Address, i));
|
|
|
+ // 停止采集压力并保存
|
|
|
+ await StopAndSavePressureCollectionAsync(currentProduct.Name, code, i);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SendTaskMessage($"停止锁付信号[{i}]已关闭", MessageLevel.Alarm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|