wankeda
2025-04-14 291f66df5621f0644ce9d15548eb6590045691f0
´úÂë¹ÜÀí/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("正极"))
            {
                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);
                // åˆ›å»ºä¸€ä¸ªåŒ…含所有 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("正极") ? "正极" : "负极";
                string devicePrefix = roast.DeviceCode.Contains("FJ") ? "负极" : "正极";
                string agvName = $"{devicePrefix}AGV";
                // ä»Žå­˜å‚¨ä¸­æŸ¥æ‰¾æŒ‡å®šåç§°çš„设备
@@ -280,22 +170,25 @@
            }
            // è¯»AGV入料
            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 @@
            }
            // è¯»AGV出料
            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);
        }