src/A032.Config/ConfigFrm.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/A032.Process/AGVBindUnit.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/A032.Process/ProcessControl.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/A032.Process/ProcessControl_Method.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/Bro.Common.Model/Base/OperationConfigBase.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/Bro.Device.AuboRobot/AuboRobotDriver.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/Bro.Device.SeerAGV/SeerAGVConfig.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/Bro.Device.SeerAGV/SeerAGVDriver.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/A032.Config/ConfigFrm.cs
@@ -227,7 +227,7 @@ private void OnProcessLog(DateTime dt, string prefix, string msg) { RecordMsg(dt.ToString("yyyyMMdd HH:mm:ss") + "\r\n" + prefix + "\r\n" + msg + "\r\n"); RecordMsg(dt.ToString("yyyyMMdd HH:mm:ss.fff") + "\r\n" + prefix + "\r\n" + (string.IsNullOrWhiteSpace(msg) ? "" : (msg + "\r\n"))); } private void btnStopProcess_Click(object sender, EventArgs e) src/A032.Process/AGVBindUnit.cs
@@ -182,8 +182,14 @@ [JsonIgnore] public bool IsEmptyTrayTaskAssigned { get; set; } [Browsable(false)] [JsonIgnore] //[Browsable(false)] //[JsonIgnore] //public ManualResetEvent FullTrayFullHandle { get; set; } = new ManualResetEvent(false); //[Browsable(false)] //[JsonIgnore] //public ManualResetEvent FullTrayEmptyHandle { get; set; } = new ManualResetEvent(false); public ManualResetEvent RobotIOHandle { get; set; } = new ManualResetEvent(false); public AGVBindUnit() src/A032.Process/ProcessControl.cs
@@ -370,6 +370,8 @@ robot.InitialConfig = c; RobotDict[robot.InitialConfig.ID] = robot; robot.OnLog = OnDeviceLog; robot.OnMsgReceived = OnRobotMsgReceived; robot.OnMonitorAlarm -= OnMonitorAlarm; @@ -388,9 +390,10 @@ agv.InitialConfig = c; AGVDict[agv.InitialConfig.ID] = agv; agv.OnLog = OnDeviceLog; agv.OnAGVPositoinChanged = OnAGVPositionChanged; agv.OnAGVTaskStatusChanged = OnAGVTaskStatusChanged; agv.OnAGVBatteryLvlChanged = OnAGVBatterLvlChanged; agv.OnAGVBatteryLvlChanged = OnAGVBatteryLvlChanged; }); } src/A032.Process/ProcessControl_Method.cs
@@ -27,11 +27,11 @@ 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(() => { @@ -57,9 +57,14 @@ 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; } } @@ -105,19 +110,25 @@ //} 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: @@ -183,8 +194,11 @@ 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) { @@ -206,12 +220,19 @@ { 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; @@ -387,6 +408,7 @@ [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) @@ -425,7 +447,9 @@ bind.IsFullTrayTaskAssigned = false; } bind.RobotIOHandle.Set(); //(device as AuboRobotDriver).IOChangedHandle.Set(); //bind.RobotIOHandle.Set(); return new ProcessResponse(true); } @@ -433,11 +457,13 @@ [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); } @@ -1194,6 +1220,7 @@ bind.RobotStatus = TaskStatus.Running; bind.Robot.SendMsg(RobotMsgAction.Move, RobotMsgParas.LineSnap, position.PositionNo); //LogAsync(DateTime.Now, "Robot运动至下满Tray拍照", ""); } //[ProcessMethod("", "Camera_UnloadFullTray", "相机操作卸载满Tray", true)] src/Bro.Common.Model/Base/OperationConfigBase.cs
@@ -35,8 +35,10 @@ /// 输入参数 /// </summary> [JsonIgnore] [Browsable(false)] public List<int> InputPara { get; set; } [Category("输入配置")] [Description("输入参数配置")] [TypeConverter(typeof(SimpleCollectionConvert<int>))] public List<int> InputPara { get; set; } = new List<int>(); [Category("启用配置")] src/Bro.Device.AuboRobot/AuboRobotDriver.cs
@@ -82,6 +82,7 @@ #endregion TcpClient client = new TcpClient(); NetworkStream stream = null; byte[] buffer = new byte[1024]; private void OnConnect(IAsyncResult ar) @@ -89,7 +90,8 @@ try { client.EndConnect(ar); client.GetStream().BeginRead(buffer, 0, buffer.Length, OnDateReceived, null); stream = client.GetStream(); stream.BeginRead(buffer, 0, buffer.Length, OnDataReceived, null); } catch (Exception ex) { @@ -103,20 +105,21 @@ } } private void OnDateReceived(IAsyncResult ar) private void OnDataReceived(IAsyncResult ar) { try { int dataLength = client.GetStream().EndRead(ar); int dataLength = stream.EndRead(ar); if (dataLength > 0) { byte[] data = buffer.Take(dataLength).ToArray(); string dataStr = System.Text.Encoding.ASCII.GetString(data).Trim(); //OnLog?.BeginInvoke(DateTime.Now, this, $"{Name}接收数据:{dataStr}", null, null); AnalyzeData(dataStr); client.GetStream().BeginRead(buffer, 0, buffer.Length, OnDateReceived, null); stream.BeginRead(buffer, 0, buffer.Length, OnDataReceived, null); } else { @@ -192,7 +195,7 @@ newValues.Add(int.Parse(resultStr[i].ToString())); } monitorHandle.Set(); MonitorHandle.Set(); } else { @@ -232,6 +235,7 @@ msg.Datas = new List<string>((paras ?? new List<float>()).ConvertAll(i => i.ToString())); OnLog?.BeginInvoke(DateTime.Now, this, $"{Name}发送指令:{msg.GetDisplayText()}", null, null); SendMsg(msg, true); } @@ -246,6 +250,7 @@ } bool canMonitor = true; object monitorLock = new object(); public void SendMsg(RobotMsg msg, bool isWaitReply = true, bool isMonitorMsg = false) { if (isWaitReply) @@ -256,6 +261,8 @@ byte[] bytes = msg.GetMsgBytes(IConfig.Seperator, IConfig.EndChar); lock (monitorLock) { if (!isMonitorMsg) { canMonitor = false; @@ -266,7 +273,8 @@ //lock (this) { client.GetStream().Write(bytes, 0, bytes.Length); stream.Write(bytes, 0, bytes.Length); } } if (isWaitReply) @@ -286,12 +294,15 @@ protected List<int> oldValues = new List<int>(); List<int> newValues = new List<int>(); AutoResetEvent monitorHandle = new AutoResetEvent(false); public ManualResetEvent MonitorHandle { get; set; } = new ManualResetEvent(false); //public ManualResetEvent IOChangedHandle { get; set; } = new ManualResetEvent(true); public List<int> GetMonitorValues(int startAddress, int length) { MonitorHandle.Reset(); scanMsg.ID = SID; SendMsg(scanMsg, true, true); monitorHandle.WaitOne(IConfig.ReplyTimeout); MonitorHandle.WaitOne(IConfig.ReplyTimeout); return newValues; } src/Bro.Device.SeerAGV/SeerAGVConfig.cs
@@ -76,7 +76,7 @@ } public class SeerMessage public class SeerMessage : IComplexDisplay { private byte[] frame = null; public byte[] Frame @@ -151,6 +151,11 @@ return msg; } public string GetDisplayText() { return ""; } } //public enum RobotPort @@ -171,7 +176,7 @@ PauseTask = 0x0BB9, TaskOrder = 0x0BEB, QueryBattery = 0x2AFF, QueryBattery = 0x03EF, } public enum AGVTaskStatus src/Bro.Device.SeerAGV/SeerAGVDriver.cs
@@ -19,7 +19,7 @@ { public Action<SeerAGVDriver, string> OnAGVPositoinChanged; public Action<SeerAGVDriver, AGVTaskStatus> OnAGVTaskStatusChanged; public Action<SeerAGVDriver, float> OnAGVBatteryLvlChanged; public Action<SeerAGVDriver, float, float> OnAGVBatteryLvlChanged; SeerAGVInitialConfig IConfig { @@ -152,8 +152,9 @@ { if (batteryLvl != value) { float pre = batteryLvl; batteryLvl = value; OnAGVBatteryLvlChanged?.Invoke(this, batteryLvl); OnAGVBatteryLvlChanged?.Invoke(this, pre, batteryLvl); } } } @@ -275,6 +276,8 @@ { CurrentPosition = ""; SeerMessage msg = new SeerMessage((int)AGVCode.TaskOrder, SID, JsonConvert.SerializeObject(new { id = dest })); OnLog?.BeginInvoke(DateTime.Now, this, $"{Name}行驶向 {dest}", null, null); SendMsg(client_Guide, IConfig.GuidePort, msg); } }