From 291f66df5621f0644ce9d15548eb6590045691f0 Mon Sep 17 00:00:00 2001 From: wankeda <Administrator@DESKTOP-HAU3ST3> Date: 星期一, 14 四月 2025 09:26:43 +0800 Subject: [PATCH] 添加PDA下发输送线回流任务 --- 代码管理/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RoastJob/CommonRoastJob.cs | 172 ++++++++++---------------------------------------------- 1 files changed, 32 insertions(+), 140 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RoastJob/CommonRoastJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RoastJob/CommonRoastJob.cs" index 44a3ac5..a6e17eb 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RoastJob/CommonRoastJob.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/NEWCode/WIDESEAWCS_Server/WIDESEAWCS_Tasks/RoastJob/CommonRoastJob.cs" @@ -15,116 +15,6 @@ GC.SuppressFinalize(this); } - public Task Execute1(IJobExecutionContext context) - { - CommonRoast roast = (CommonRoast)context.JobDetail.JobDataMap.Get("JobParams"); - AGV agv = null; - if (roast.DeviceName.Contains("姝f瀬")) - { - IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceName == "姝f瀬AGV"); - if (device != null) - { - agv = (AGV)device; - } - else - throw new Exception("No such device found."); - - MatchCollection matches = Regex.Matches(roast.DeviceName, @"\d+"); - int number = int.Parse(matches[0].Value); - // 鍒涘缓涓�涓寘鍚墍鏈� double 鍊肩殑闆嗗悎 - List<double> doubleValues = new List<double>(); - - if (number < 3) - { - doubleValues = new List<double> - { - 8093.6, 8093.7, 3493.6, 3493.7, 8094.0, 8095.0, 8096.0, 8097.0, 8098.0, - 8194.0, 8195.0, 8196.0, 8197.0, 3494.0, 3495.0, 3496.0, 3594.0, 3595.0, - 3596.0, 3597.0, 3598.0, 3599.0, 8192.2, 3592.2 - }; - } - else - { - doubleValues = new List<double> - { - 1693.6, 1693.7, 293.6, 293.6, 1694.0, 1695.0, 1696.0, 1697.0, 1698.0, - 1794.0, 1795.0, 1796.0, 1797.0, 294.0, 295.0, 296.0, 394.0, 395.0, 396.0, - 397.0,398.0,399.0,1792.2,392.2 - }; - } - - if (number < 3) - { - // 鏍规嵁 number 鐨勫�艰皟鏁撮泦鍚堜腑鐨勬瘡涓厓绱� - for (int i = 0; i < doubleValues.Count; i++) - { - doubleValues[i] += (number - 1) * 400; - } - } - else - {// 鏍规嵁 number 鐨勫�艰皟鏁撮泦鍚堜腑鐨勬瘡涓厓绱� - for (int i = 0; i < doubleValues.Count; i++) - { - doubleValues[i] += (number - 3) * 400; - } - } - } - else if (roast.DeviceName.Contains("璐熸瀬")) - { - IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceName == "璐熸瀬AGV"); - if (device != null) - { - agv = (AGV)device; - } - else - throw new Exception("No such device found."); - - MatchCollection matches = Regex.Matches(roast.DeviceName, @"\d+"); - int number = int.Parse(matches[0].Value); - - List<double> doubleValues = new List<double>(); - - if (number < 3) - { - doubleValues = new List<double> - { - 8893.6, 8893.7, 9093.6, 9093.7, 8894.0, 8895.0, 8896.0, 8897.0, 8898.0, - 8994.0, 8995.0, 8996.0, 8997.0, 9094.0, 9095.0, 9096.0, 9194.0, 9195.0, - 9196.0, 9197.0, 9198.0, 9199.0, 8992.2, 9192.2 - }; - } - else - { - doubleValues = new List<double> - { - 4893.6, 4893.7, 5093.6, 5093.6, 4894.0, 4895.0, 4896.0, 4897.0, 4898.0, - 4994.0, 4995.0, 4996.0, 4997.0, 5094.0, 5095.0, 5096.0, 5194.0, 5195.0, - 5196.0, 5197.0, 5198.0, 5199.0, 4992.2, 5192.2 - }; - } - if (number < 3) - { - // 鏍规嵁 number 鐨勫�艰皟鏁撮泦鍚堜腑鐨勬瘡涓厓绱� - for (int i = 0; i < doubleValues.Count; i++) - { - doubleValues[i] += (number - 1) * 400; - } - } - else - { - // 鏍规嵁 number 鐨勫�艰皟鏁撮泦鍚堜腑鐨勬瘡涓厓绱� - for (int i = 0; i < doubleValues.Count; i++) - { - doubleValues[i] += (number - 3) * 400; - } - } - } - else - throw new Exception("No such device found."); - - throw new NotImplementedException(); - } - public Task Execute(IJobExecutionContext context) { try @@ -140,7 +30,7 @@ } // 鏍规嵁璁惧鍚嶇О鍐冲畾鏄鏋佽繕鏄礋鏋� AGV - string devicePrefix = roast.DeviceName.Contains("姝f瀬") ? "姝f瀬" : "璐熸瀬"; + string devicePrefix = roast.DeviceCode.Contains("FJ") ? "璐熸瀬" : "姝f瀬"; string agvName = $"{devicePrefix}AGV"; // 浠庡瓨鍌ㄤ腑鏌ユ壘鎸囧畾鍚嶇О鐨勮澶� @@ -280,22 +170,25 @@ } // 璇籄GV鍏ユ枡 - byte[] RFAGVup = new byte[] - { - agv.Communicator.Read<byte>($"DB1002.{doubleValues[9]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[10]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[11]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[12]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[22]}") - }; + + short RFAGVa = agv.Communicator.Read<byte>($"DB1002.{doubleValues[9]}"); + short RFAGVb = agv.Communicator.Read<byte>($"DB1002.{doubleValues[10]}"); + short RFAGVc = agv.Communicator.Read<byte>($"DB1002.{doubleValues[11]}"); + short RFAGVd = agv.Communicator.Read<byte>($"DB1002.{doubleValues[12]}"); + bool RFAGVe = agv.Communicator.Read<bool>($"DB1002.{doubleValues[22]}"); + // 鍐欑儤鐑ゅ叆鏂� - string[] writeAddressesUp = new string[] { "D1940", "D1941", "D1955", "D1956", "M691" }; - for (int i = 0; i < RFAGVup.Length; i++) - { - roast.Communicator.Write(writeAddressesUp[i], RFAGVup[i]); - } - + //string[] writeAddressesUp = new string[] { "D1940", "D1941", "D1955", "D1956", "M691" }; + //for (int i = 0; i < RFAGVup.Length; i++) + //{ + // roast.Communicator.Write(writeAddressesUp[i], RFAGVup[i]); + //} + roast.Communicator.Write("D1940", RFAGVa); + roast.Communicator.Write("D1941", RFAGVb); + roast.Communicator.Write("D1955", RFAGVc); + roast.Communicator.Write("D1956", RFAGVd); + roast.Communicator.Write("M691", RFAGVe); // 璇荤儤鐑ゅ嚭鏂� short[] RFHKdown = new short[] { @@ -311,24 +204,23 @@ } // 璇籄GV鍑烘枡 - byte[] RFAGVdown = new byte[] - { - agv.Communicator.Read<byte>($"DB1002.{doubleValues[16]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[17]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[18]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[19]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[20]}"), - agv.Communicator.Read<byte>($"DB1002.{doubleValues[21]}") - }; + short RFAGVdowna = agv.Communicator.Read<byte>($"DB1002.{doubleValues[16]}"); + short RFAGVdownb = agv.Communicator.Read<byte>($"DB1002.{doubleValues[17]}"); + short RFAGVdownc = agv.Communicator.Read<byte>($"DB1002.{doubleValues[18]}"); + short RFAGVdownd = agv.Communicator.Read<byte>($"DB1002.{doubleValues[19]}"); + short RFAGVdowne = agv.Communicator.Read<byte>($"DB1002.{doubleValues[20]}"); + short RFAGVdownf = agv.Communicator.Read<byte>($"DB1002.{doubleValues[21]}"); bool RFAGVdowng = agv.Communicator.Read<bool>($"DB1002.{doubleValues[23]}"); // 鍐欑儤鐑ゅ嚭鏂� - string[] writeAddressesDown = new string[] { "D1940", "D1941", "D1957", "D1952", "D1953", "D1958", "M692" }; - for (int i = 0; i < RFAGVdown.Length; i++) - { - roast.Communicator.Write(writeAddressesDown[i], RFAGVdown[i]); - } - roast.Communicator.Write(writeAddressesDown[6], RFAGVdowng); + //string[] writeAddressesDown = new string[] { "D1940", "D1941", "D1957", "D1952", "D1953", "D1958", "M692" }; + roast.Communicator.Write("D1940", RFAGVdowna); + roast.Communicator.Write("D1941", RFAGVdownb); + roast.Communicator.Write("D1957", RFAGVdownc); + roast.Communicator.Write("D1952", RFAGVdownd); + roast.Communicator.Write("D1953", RFAGVdowne); + roast.Communicator.Write("D1958", RFAGVdownf); + roast.Communicator.Write("M692", RFAGVdowng); } -- Gitblit v1.9.3