| | |
| | | try |
| | | { |
| | | // 读åä»»å¡äº¤äºåé置交äºçç¶æ |
| | | int taskInteractive = agv.Communicator.Read<int>(taskInteractiveR); // 1表示æ¶å° |
| | | int taskInteractiveW = agv.Communicator.Read<int>(taskInteractiveW1); // 0åå§/1ä¸å/2åæ¶/3æ´æ¹ |
| | | int resetTaskInteractiveW = agv.Communicator.Read<int>(resetTaskW); |
| | | int resetTaskInteractiver = agv.Communicator.Read<int>(resetTaskInteractiveR); |
| | | int taskInteractive = agv.Communicator.Read<Int16>(taskInteractiveR); // 1表示æ¶å° |
| | | int taskInteractiveW = agv.Communicator.Read<Int16>(taskInteractiveW1); // 0åå§/1ä¸å/2åæ¶/3æ´æ¹ |
| | | int resetTaskInteractiveW = agv.Communicator.Read<Int16>(resetTaskW); |
| | | int resetTaskInteractiver = agv.Communicator.Read<Int16>(resetTaskInteractiveR); |
| | | |
| | | // å¤çä»»å¡äº¤äºWåé置交äºWä¸ä¸º0çæ
åµ |
| | | if (isTrue1 && name1 == agv.DeviceName) |
| | | { |
| | | if (taskInteractiveW != 0 || resetTaskInteractiveW != 0 || taskInteractive != 0) |
| | | { |
| | | agv.Communicator.Write(resetTaskW, 1); |
| | | agv.Communicator.Write<UInt16>(resetTaskW, 1); |
| | | Task.Delay(2000).Wait(); |
| | | resetTaskInteractiveW = agv.Communicator.Read<int>(resetTaskW); |
| | | resetTaskInteractiveW = agv.Communicator.Read<Int16>(resetTaskW); |
| | | |
| | | if (resetTaskInteractiveW == 1) |
| | | { |
| | | agv.Communicator.Write(resetTaskW, 0); |
| | | agv.Communicator.Write(taskInteractiveW1, 0); |
| | | agv.Communicator.Write<UInt16>(resetTaskW, 0); |
| | | agv.Communicator.Write<UInt16>(taskInteractiveW1, 0); |
| | | Task.Delay(2000).Wait(); |
| | | } |
| | | return; |
| | |
| | | // 妿é置交äºR为1ï¼åé置任å¡äº¤äºW |
| | | if (resetTaskInteractiver == 1) |
| | | { |
| | | agv.Communicator.Write(taskInteractiveW1, 0); |
| | | agv.Communicator.Write<UInt16>(taskInteractiveW1, 0); |
| | | for (int i = 0; i < 5; i++) |
| | | { |
| | | Task.Delay(300).Wait(); // ç¨Task.Delay代æ¿Thread.Sleepï¼ä»¥é¿å
线ç¨é»å¡ |
| | | int agvNumber = agv.Communicator.Read<int>(taskInteractiveW1); |
| | | int agvNumber = agv.Communicator.Read<Int16>(taskInteractiveW1); |
| | | if (agvNumber != 0) |
| | | { |
| | | agv.Communicator.Write(taskInteractiveW1, 0); |
| | | agv.Communicator.Write<UInt16>(taskInteractiveW1, 0); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | // æ£æ¥ä»»å¡IDæ¯å¦åå
¥æ£ç¡® |
| | | string taskId = agv.Communicator.Read<string>(taskID); |
| | | if (taskId != agvTask.TaskNum.ToString()) |
| | | string numberPart = taskId.Split('-')[1]; |
| | | if (numberPart != agvTask.TaskNum.ToString()) |
| | | { |
| | | throw new Exception($"ç»AGVåå
¥ä»»å¡å¤±è´¥,ä»»å¡å·{agvTask.TaskNum}"); |
| | | } |
| | |
| | | if (string.IsNullOrEmpty(rel)) |
| | | { |
| | | // åå
¥ä»»å¡ç¡®è®¤ä¿¡å·1 |
| | | agv.Communicator.Write(taskInteractiveW1, 1); |
| | | agv.Communicator.Write<UInt16>(taskInteractiveW1, 1); |
| | | Task.Delay(1000).Wait(); |
| | | |
| | | // 读åAGVçç¡®è®¤ä¿¡å· |
| | | int readTask1Ok = agv.Communicator.Read<int>(taskInteractiveR); |
| | | int readTask1Ok = agv.Communicator.Read<Int16>(taskInteractiveR); |
| | | if (readTask1Ok == 1) |
| | | { |
| | | // åå
¥WCSç确认信å·0 |
| | | agv.Communicator.Write(taskInteractiveW1, 0); |
| | | agv.Communicator.Write<UInt16>(taskInteractiveW1, 0); |
| | | Task.Delay(2000).Wait(); |
| | | |
| | | // 忬¡è¯»åAGVçç¡®è®¤ä¿¡å· |
| | | int readTask0Ok = agv.Communicator.Read<int>(taskInteractiveR); |
| | | int readTask0Ok = agv.Communicator.Read<Int16>(taskInteractiveR); |
| | | if (readTask0Ok == 0) |
| | | { |
| | | // æ´æ°ä»»å¡ç¶æå¹¶ä¿å |
| | |
| | | else if (readTask1Ok == 11) |
| | | { |
| | | // å¤çä»»å¡å¼å¸¸æ
åµ |
| | | agv.Communicator.Write(taskInteractiveW1, 0); |
| | | agv.Communicator.Write<UInt16>(taskInteractiveW1, 0); |
| | | Task.Delay(2000).Wait(); |
| | | int readTask0Error = agv.Communicator.Read<int>(taskInteractiveR); |
| | | |
| | |
| | | public static string TaskWrite(AGV client, Dt_Task agvTask, AGVJobEnum jobEnum) |
| | | { |
| | | List<byte> sendData = new List<byte>(); |
| | | string tmp = agvTask.TaskNum.ToString(); |
| | | string tmp = "KH-" + agvTask.TaskNum.ToString(); |
| | | List<byte> taskID = Encoding.Default.GetBytes(tmp).ToList();//ä»»å¡ID |
| | | taskID.Insert(0, 30); |
| | | taskID.Insert(1, Convert.ToByte(tmp.Length)); |
| | |
| | | Array.Reverse(taskType); |
| | | sendData.AddRange(taskType); |
| | | |
| | | List<byte> containerType = Encoding.Default.GetBytes(agvTask.PalletCode).ToList(); |
| | | List<byte> containerType = Encoding.Default.GetBytes(agvTask.Barcode).ToList(); |
| | | containerType.Insert(0, 30); |
| | | containerType.Insert(1, Convert.ToByte(agvTask.PalletCode.Length)); |
| | | containerType.Insert(1, Convert.ToByte(agvTask.Barcode.Length)); |
| | | |
| | | for (int i = 0; i < 30 - agvTask.PalletCode.Length; i++) |
| | | for (int i = 0; i < 30 - agvTask.Barcode.Length; i++) |
| | | { |
| | | containerType.Add(0); |
| | | } |