|
|
@@ -997,8 +997,6 @@ 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_RequestPosition.Address,
|
|
|
addressConfig.In_ScrewTeachExe.Address,
|
|
|
addressConfig.In_PickINC.Address,
|
|
|
@@ -1007,7 +1005,11 @@ namespace TeamAAS_VP.Core
|
|
|
{
|
|
|
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);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (current.IndependentCamerPoints != null && current.IndependentCamerPoints.Count > 0)
|
|
|
{
|
|
|
foreach (var item in current.IndependentCamerPoints)
|
|
|
@@ -1102,8 +1118,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];
|
|
|
@@ -1930,111 +1946,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))
|
|
|
{
|
|
|
@@ -2123,9 +2034,9 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- // 过站检查
|
|
|
else
|
|
|
{
|
|
|
+ // 过站检查
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
{
|
|
|
if (string.Format(addressConfig.In_MesCheck.Address, i).Contains(tuple.nodeId))
|
|
|
@@ -2162,6 +2073,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
|
|
|
{
|
|
|
@@ -2169,6 +2081,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;
|
|
|
}
|
|
|
}
|
|
|
// 上传本站数据
|
|
|
@@ -2182,20 +2095,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)
|