1
z8018
2 天以前 6e7f192546903b04d2d37e852dd9b248e938c790
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -34,6 +34,16 @@
namespace WIDESEAWCS_Tasks
{
    /// <summary>
    /// é€šç”¨è¾“送线任务,负责处理输送线设备的通信与任务执行
    /// </summary>
    /// <remarks>
    /// 1. é€šè¿‡PLC通信读取设备状态和条码信息 <br/>
    /// 2. æ ¹æ®æ¡ç æŸ¥è¯¢äº§å“ä¿¡æ¯å’ŒåŽ»å‘å·¥ä½ <br/>
    /// 3. å°†äº§å“å°ºå¯¸å’ŒåŽ»å‘ä¿¡æ¯å†™å…¥PLC <br/>
    /// 4. å¤„理异常情况并记录错误日志
    /// </remarks>
    /// <attribute>[DisallowConcurrentExecution]</attribute>
    [DisallowConcurrentExecution]
    public class CommonConveyorLineJob : JobBase, IJob
    {
@@ -59,10 +69,8 @@
            try
            {
                bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
                if (flag && value != null && value is OtherDevice)
                if (flag && value != null && value is OtherDevice otherDevice)
                {
                    OtherDevice otherDevice = (OtherDevice)value;
                    bool request = otherDevice.Communicator.Read<bool>("DB15.22.0");   //申请
                    bool response = otherDevice.Communicator.Read<bool>("DB15.22.1");   //应答
@@ -82,15 +90,13 @@
                        barcode = otherDevice.Communicator.Read<string>("DB15.32");   //条码
                        List<byte> bytes = otherDevice.Communicator.Read("DB15.34", 40).ToList();
                        //List<byte> bytes = otherDevice.Communicator.Read("DB15.34", 40).ToList();
                        byte[] temp = bytes.ToArray().SelectMiddle(0, bytes.IndexOf(0));
                        //byte[] temp = bytes.ToArray().SelectMiddle(0, bytes.IndexOf(0));
                        barcode = Encoding.Default.GetString(temp);
                        //barcode = Encoding.Default.GetString(temp);
                        string pattern = @"\d+";  // åŒ¹é…æ•°å­—
                        Match match = Regex.Match(barcode, pattern);
                        string barcodeNumber = match.Value;
                        string barcodeNumber = barcode;
                        if (!string.IsNullOrEmpty(barcodeNumber))
                        {
@@ -99,9 +105,19 @@
                            if (toplc > 0)//获取到有效去向
                            {
                                otherDevice.Communicator.Write("DB15.10", productInfo.Length);
                                otherDevice.Communicator.Write("DB15.14", productInfo.Width);
                                otherDevice.Communicator.Write("DB15.18", productInfo.Height);
                                if (toplc == 1 && productInfo.Length < productInfo.Width)
                                {
                                    otherDevice.Communicator.Write("DB15.10", productInfo.Width);
                                    otherDevice.Communicator.Write("DB15.14", productInfo.Length);
                                    otherDevice.Communicator.Write("DB15.18", productInfo.Height);
                                }
                                else
                                {
                                    otherDevice.Communicator.Write("DB15.10", productInfo.Length);
                                    otherDevice.Communicator.Write("DB15.14", productInfo.Width);
                                    otherDevice.Communicator.Write("DB15.18", productInfo.Height);
                                }
                                otherDevice.Communicator.Write("DB15.6", toplc);   //写入去向
                                otherDevice.Communicator.Write("DB15.0", true);