| | |
| | | List<TaskAssignInfo> taskAssignedList = new List<TaskAssignInfo>(); |
| | | |
| | | #region AGV事件 |
| | | private void OnAGVBatterLvlChanged(SeerAGVDriver agv, float batterLvl) |
| | | private void OnAGVBatteryLvlChanged(SeerAGVDriver agv, float preBatteryLvl, float batteryLvl) |
| | | { |
| | | var bind = Config.AGVBindCollection.FirstOrDefault(u => u.AGVId == agv.Id); |
| | | SeerAGVInitialConfig iConfig = agv.InitialConfig as SeerAGVInitialConfig; |
| | | if (batterLvl <= iConfig.BatteryLvlToCharge) |
| | | if (batteryLvl <= iConfig.BatteryLvlToCharge && preBatteryLvl > iConfig.BatteryLvlToCharge) |
| | | { |
| | | Task.Run(() => |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | if (batterLvl >= iConfig.BatteryLvlChargeDone) |
| | | if (batteryLvl >= iConfig.BatteryLvlChargeDone && preBatteryLvl < iConfig.BatteryLvlChargeDone) |
| | | { |
| | | var position = Config.PositionCollection.FirstOrDefault(u => u.PositionCode == agv.CurrentPosition); |
| | | |
| | | if (position != null && position.Description == PathPositionDefinition.Charge) |
| | | { |
| | | bind.SetAGVStatus(TaskStatus.Available); |
| | | } |
| | | return; |
| | | } |
| | | } |
| | |
| | | //} |
| | | |
| | | bind.SetAGVStatus(TaskStatus.Available); |
| | | LogAsync(DateTime.Now, $"AGV到位{positionCode}", ""); |
| | | |
| | | PathPosition position = Config.PositionCollection.FirstOrDefault(p => p.PositionCode == bind.AGVDest); |
| | | switch (position.Description) |
| | | { |
| | | case PathPositionDefinition.LoadEmptyTray: |
| | | LogAsync(DateTime.Now, $"AGV完成,准备上空Tray", ""); |
| | | Robot_LoadEmptyTray(bind.Id, position); |
| | | break; |
| | | case PathPositionDefinition.LoadFullTray: |
| | | LogAsync(DateTime.Now, $"AGV完成,准备上满Tray", ""); |
| | | Robot_LoadFullTraySnap(bind.Id, position); |
| | | break; |
| | | case PathPositionDefinition.UnloadEmptyTray: |
| | | LogAsync(DateTime.Now, $"AGV完成,准备下空Tray", ""); |
| | | Robot_UnloadEmptyTraySnap(bind.Id, position); |
| | | break; |
| | | case PathPositionDefinition.UnloadFullTray: |
| | | LogAsync(DateTime.Now, $"AGV完成,准备下满Tray", ""); |
| | | Robot_UnloadFullTraySnap(bind.Id, position); |
| | | break; |
| | | default: |
| | |
| | | |
| | | if (machineEmptyTrayDict[msg.Para2] < Config.Machine_EmptyTrayNum) |
| | | { |
| | | bind.RobotIOHandle.Reset(); |
| | | bind.RobotIOHandle.WaitOne(); |
| | | //bind.RobotIOHandle.Reset(); |
| | | //bind.RobotIOHandle.WaitOne(); |
| | | bind.Robot.MonitorHandle.WaitOne(); |
| | | //bind.Robot.IOChangedHandle.WaitOne(); |
| | | Thread.Sleep((bind.Robot.InitialConfig as AuboRobotInitialConfig).ScanInterval); |
| | | |
| | | if (!bind.IsFullTrayFull) |
| | | { |
| | |
| | | { |
| | | bind.CurrentFullTray = int.Parse(msg.Datas[1]); |
| | | |
| | | bind.RobotIOHandle.Reset(); |
| | | bind.RobotIOHandle.WaitOne(); |
| | | //bind.RobotIOHandle.Reset(); |
| | | //bind.RobotIOHandle.WaitOne(); |
| | | bind.Robot.MonitorHandle.WaitOne(); |
| | | //bind.Robot.IOChangedHandle.WaitOne(); |
| | | Thread.Sleep((bind.Robot.InitialConfig as AuboRobotInitialConfig).ScanInterval); |
| | | |
| | | if (!bind.IsFullTrayEmpty) |
| | | { |
| | | Camera_UnloadFullTray(robot.Id, msg.Para2); |
| | | } |
| | | else |
| | | { |
| | | bind.RobotStatus = TaskStatus.Available; |
| | | } |
| | | } |
| | | break; |
| | |
| | | [ProcessMethod("", "Robot_Monitor_FullTrayFull", "机器人监听事件-满Tray区域放满", true)] |
| | | public ProcessResponse Robot_Monitor_FullTrayFull(IOperationConfig config, IDevice device) |
| | | { |
| | | //(device as AuboRobotDriver).IOChangedHandle.Reset(); |
| | | bool isFullTrayFull = config.InputPara[0] == 1; |
| | | var bind = Config.AGVBindCollection.FirstOrDefault(u => u.RobotId == device.Id); |
| | | if (isFullTrayFull) |
| | |
| | | bind.IsFullTrayTaskAssigned = false; |
| | | } |
| | | |
| | | bind.RobotIOHandle.Set(); |
| | | //(device as AuboRobotDriver).IOChangedHandle.Set(); |
| | | |
| | | //bind.RobotIOHandle.Set(); |
| | | |
| | | return new ProcessResponse(true); |
| | | } |
| | |
| | | [ProcessMethod("", "Robot_Monitor_FullTrayEmpty", "机器人监听事件-满Tray区域清空", true)] |
| | | public ProcessResponse Robot_Monitor_FullTrayEmpty(IOperationConfig config, IDevice device) |
| | | { |
| | | //(device as AuboRobotDriver).IOChangedHandle.Reset(); |
| | | bool isFullTrayEmpty = config.InputPara[0] == 0; |
| | | var bind = Config.AGVBindCollection.FirstOrDefault(u => u.RobotId == device.Id); |
| | | bind.IsFullTrayEmpty = isFullTrayEmpty; |
| | | |
| | | bind.RobotIOHandle.Set(); |
| | | //(device as AuboRobotDriver).IOChangedHandle.Set(); |
| | | //bind.RobotIOHandle.Set(); |
| | | |
| | | return new ProcessResponse(true); |
| | | } |
| | |
| | | |
| | | bind.RobotStatus = TaskStatus.Running; |
| | | bind.Robot.SendMsg(RobotMsgAction.Move, RobotMsgParas.LineSnap, position.PositionNo); |
| | | //LogAsync(DateTime.Now, "Robot运动至下满Tray拍照", ""); |
| | | } |
| | | |
| | | //[ProcessMethod("", "Camera_UnloadFullTray", "相机操作卸载满Tray", true)] |