莫海杰 1 mesiac pred
rodič
commit
56c3329455

+ 1 - 48
SCADA_DAQ/Customer/CustomerEnv.cs

@@ -9,6 +9,7 @@ using SCADA.CommonLib.Data.DIL;
 using SCADA.CommonLib.Helper;
 using SCADA_DAQ.Customer.Machines;
 using SCADA_DAQ.Customer.Models;
+using SCADA_DAQ.Plugin.Machine;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -37,20 +38,6 @@ namespace SCADA_DAQ.Customer
 
         public static int WMSItemUpCount = 0;
 
-        ///// <summary>
-        ///// 键-任务号
-        ///// </summary>
-        //public static Dictionary<string, AppBCTaskModel> WMSTaskDic = new Dictionary<string, AppBCTaskModel>();
-        /////// <summary>
-        /////// 堆垛机1的任务列表1
-        /////// </summary>
-        //public static Dictionary<AppBCTaskModel, WMSMachineTask> WMSTaskList_1_2 { get; set; } = new Dictionary<AppBCTaskModel, WMSMachineTask>();
-
-        /////// <summary>
-        /////// 堆垛机1的任务列表2
-        /////// </summary>
-        //public static Dictionary<AppBCTaskModel, WMSMachineTask> WMSTaskList_3_4 { get; set; } = new Dictionary<AppBCTaskModel, WMSMachineTask>();
-
         /// <summary>
         /// 合并后下架任务列表
         /// </summary>
@@ -61,40 +48,6 @@ namespace SCADA_DAQ.Customer
         /// </summary>
         public static List<AppBCItemUpModel> WMSItemUpList = new List<AppBCItemUpModel>();
 
-        /// <summary>
-        /// 上下架子表
-        /// </summary>
-        //public static List<AppBCItemTaskModel> WMSItemTaskList = new List<AppBCItemTaskModel>();
-
-        /// <summary>
-        /// 多库位待指定任务列表1
-        /// </summary>
-        //public static Dictionary<AppBCTaskModel, List<WMSMachineTask>> WMSNotCheckTaskList_1 { get; set; } = new Dictionary<AppBCTaskModel, List<WMSMachineTask>>();
-
-        ///// <summary>
-        ///// 多库位待指定任务列表2
-        ///// </summary>
-        //public static Dictionary<AppBCTaskModel, List<WMSMachineTask>> WMSNotCheckTaskList_2 { get; set; } = new Dictionary<AppBCTaskModel, List<WMSMachineTask>>();
-
-        ///// <summary>
-        ///// 堆垛机11当前WMS任务
-        ///// </summary>
-        //public static WMSMachineTask WMSCurrentTask11 { get; set; } = new WMSMachineTask();
-
-        ///// <summary>
-        ///// 堆垛机12当前WMS任务
-        ///// 
-        ///// </summary>
-        //public static WMSMachineTask WMSCurrentTask12 { get; set; } = new WMSMachineTask();
-
-        ///// <summary>
-        ///// 堆垛机23当前WMS任务
-        ///// </summary>
-        //public static WMSMachineTask WMSCurrentTask23 { get; set; } = new WMSMachineTask();
-        ///// <summary>
-        ///// 堆垛机24当前WMS任务
-        ///// </summary>
-        //public static WMSMachineTask WMSCurrentTask24 { get; set; } = new WMSMachineTask();
 
         /// <summary>
         /// 堆垛机1半自动任务队列

+ 213 - 155
SCADA_DAQ/Customer/Machines/SampleMachine_ScanCompleted.cs

@@ -34,226 +34,284 @@ namespace SCADA_DAQ.Customer.Machines
             base.ScanCompleted(sender, e);
             if (BaseDevice.DeviceID.StartsWith("输送线"))
             {
-                var op = new OperationBo { StartRow = 2, StartCol = 42, StartLayer = 5, ItemName = "标准_塑料管夹_THPG-342" };
-                var opHex = op.OperToHex();
-                var screen3 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏3");
-  //             if (screen3.GetListenReg("400001") != null)
-  //             {
-  //                 screen3.GetListenReg("400001").WriteReg("标准_塑料管夹_THPG-342");
-  //             }
-
-
-                //var screen4 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏4");
-
-
+                // 写入显示屏
+                WriteScreen();
 
                 #region 按输送线按钮回原位
                 bool lowThenUpShelf(OperationBo ltuOperation)
                 {
-                var flag = false;
-                var craneIsRun = false;
-                if (ltuOperation.Crane == 1)
-                {
-                    craneIsRun = Crane_1IsRun;
-                }
-                else if (ltuOperation.Crane == 2)
-                {
-                    craneIsRun = Crane_2IsRun;
-                }
-                if (base.GetListenReg($"{ltuOperation.Line}#CheckButton").Value == 1 && base.GetListenReg($"{ltuOperation.Crane}#CraneReady").Value == 1 && craneIsRun == false)
-                {
+                    var flag = false;
+                    var craneIsRun = false;
                     if (ltuOperation.Crane == 1)
                     {
-                        Crane_1IsRun = true;
+                        craneIsRun = Crane_1IsRun;
                     }
                     else if (ltuOperation.Crane == 2)
                     {
-                        Crane_2IsRun = true;
+                        craneIsRun = Crane_2IsRun;
                     }
-                    var isWriteRCL = base.GetListenReg($"{ltuOperation.Crane}#CraneFrom_Row").WriteReg(new int[] { ltuOperation.StartRow, ltuOperation.StartCol, ltuOperation.StartLayer, ltuOperation.EndRow, ltuOperation.EndCol, ltuOperation.EndLayer });
-                    if (isWriteRCL)
+                    if (base.GetListenReg($"{ltuOperation.Line}#CheckButton").Value == 1 && base.GetListenReg($"{ltuOperation.Crane}#CraneReady").Value == 1 && craneIsRun == false)
                     {
-                        var isWriteStart = base.GetListenReg($"{ltuOperation.Crane}#CraneStart").WriteReg(1); //堆垛机启动
-                        var isWriteButton = base.GetListenReg($"{ltuOperation.Line}#CheckButton").WriteReg("0"); //输送线按钮复位
-                        if (isWriteStart == true && isWriteButton == true)
+                        if (ltuOperation.Crane == 1)
+                        {
+                            Crane_1IsRun = true;
+                        }
+                        else if (ltuOperation.Crane == 2)
+                        {
+                            Crane_2IsRun = true;
+                        }
+                        var isWriteRCL = base.GetListenReg($"{ltuOperation.Crane}#CraneFrom_Row").WriteReg(new int[] { ltuOperation.StartRow, ltuOperation.StartCol, ltuOperation.StartLayer, ltuOperation.EndRow, ltuOperation.EndCol, ltuOperation.EndLayer });
+                        if (isWriteRCL)
                         {
-                            flag = true;
-                            Env.DAL.App_BC_OperateLog.Insert(
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.OperateNo_Str, ltuOperation.OperateNo),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.MachineTaskId_Int, ltuOperation.MachineTaskId),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.Crane_Str, $"堆垛机{ltuOperation.Crane}"),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.Line_Str, $"输送线{ltuOperation.Line}"),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.StartCol_Int, ltuOperation.StartCol),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.StartRow_Int, ltuOperation.StartRow),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.StartLayer_Int, ltuOperation.StartLayer),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.EndRow_Int, ltuOperation.EndRow),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.EndCol_Int, ltuOperation.EndCol),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.EndLayer_Int, ltuOperation.EndLayer),
-                                new UpdateItem(T_Col_Name.App_BC_OperateLog.Remark_Str, "入库")
-                            );
+                            var isWriteStart = base.GetListenReg($"{ltuOperation.Crane}#CraneStart").WriteReg(1); //堆垛机启动
+                            var isWriteButton = base.GetListenReg($"{ltuOperation.Line}#CheckButton").WriteReg("0"); //输送线按钮复位
+                            if (isWriteStart == true && isWriteButton == true)
+                            {
+                                flag = true;
+                                Env.DAL.App_BC_OperateLog.Insert(
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.OperateNo_Str, ltuOperation.OperateNo),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.MachineTaskId_Int, ltuOperation.MachineTaskId),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.Crane_Str, $"堆垛机{ltuOperation.Crane}"),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.Line_Str, $"输送线{ltuOperation.Line}"),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.StartCol_Int, ltuOperation.StartCol),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.StartRow_Int, ltuOperation.StartRow),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.StartLayer_Int, ltuOperation.StartLayer),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.EndRow_Int, ltuOperation.EndRow),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.EndCol_Int, ltuOperation.EndCol),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.EndLayer_Int, ltuOperation.EndLayer),
+                                    new UpdateItem(T_Col_Name.App_BC_OperateLog.Remark_Str, "入库")
+                                );
+                            }
                         }
                     }
+                    return flag;
                 }
-                return flag;
-            }
-            if (LowThenUpOperation11 != null)
-            {
-                var isOk = lowThenUpShelf(LowThenUpOperation11);
-                if (isOk)
+                if (LowThenUpOperation11 != null)
                 {
-                    LowThenUpOperation11 = null;
+                    var isOk = lowThenUpShelf(LowThenUpOperation11);
+                    if (isOk)
+                    {
+                        LowThenUpOperation11 = null;
+                    }
                 }
-            }
-            if (LowThenUpOperation12 != null)
-            {
-                var isOk = lowThenUpShelf(LowThenUpOperation12);
-                if (isOk)
+                if (LowThenUpOperation12 != null)
                 {
-                    LowThenUpOperation12 = null;
+                    var isOk = lowThenUpShelf(LowThenUpOperation12);
+                    if (isOk)
+                    {
+                        LowThenUpOperation12 = null;
+                    }
                 }
-            }
-            if (LowThenUpOperation23 != null)
-            {
-                var isOk = lowThenUpShelf(LowThenUpOperation23);
-                if (isOk)
+                if (LowThenUpOperation23 != null)
                 {
-                    LowThenUpOperation23 = null;
+                    var isOk = lowThenUpShelf(LowThenUpOperation23);
+                    if (isOk)
+                    {
+                        LowThenUpOperation23 = null;
+                    }
                 }
-            }
-            if (LowThenUpOperation24 != null)
-            {
-                var isOk = lowThenUpShelf(LowThenUpOperation24);
-                if (isOk)
+                if (LowThenUpOperation24 != null)
                 {
-                    LowThenUpOperation24 = null;
+                    var isOk = lowThenUpShelf(LowThenUpOperation24);
+                    if (isOk)
+                    {
+                        LowThenUpOperation24 = null;
+                    }
                 }
-            }
-            #endregion
+                #endregion
 
 
-            #region 从任务队列下发任务到设备
-            if (GetListenReg($"1#CraneReady").Value == 1 && GetListenReg($"1#LineReady").Value == 1 &&
-                CustomerEnv.LowThenUpOperation11 == null && GetListenReg($"2#CheckButton").Value == 0 && Crane_1IsRun == false)
-            {
-                if (OperationCrane1List.Count != 0 && CustomerEnv.CurrentOperationLine1 == null && OperationCrane1List.Where(t => t.IsStart == false && t.Line == 1).ToList().Count != 0
-                    && GetListenReg($"1#LineDone").Value == 0)
+                #region 从任务队列下发任务到设备
+                if (GetListenReg($"1#CraneReady").Value == 1 && GetListenReg($"1#LineReady").Value == 1 &&
+                    CustomerEnv.LowThenUpOperation11 == null && GetListenReg($"2#CheckButton").Value == 0 && Crane_1IsRun == false)
                 {
-                    var currentTask = OperationCrane1List.Where(t => t.IsStart == false && t.Line == 1).First();
-                    var ok = CustomerEnv.CraneLineOperate(this, currentTask);
-                    if (ok == "OK")
+                    if (OperationCrane1List.Count != 0 && CustomerEnv.CurrentOperationLine1 == null && OperationCrane1List.Where(t => t.IsStart == false && t.Line == 1).ToList().Count != 0
+                        && GetListenReg($"1#LineDone").Value == 0)
                     {
-                        currentTask.IsStart = true;
-                        CustomerEnv.CurrentOperationLine1 = currentTask;
-                        OperationCrane1List.Remove(CurrentOperationLine1);
+                        var currentTask = OperationCrane1List.Where(t => t.IsStart == false && t.Line == 1).First();
+                        var ok = CustomerEnv.CraneLineOperate(this, currentTask);
+                        if (ok == "OK")
+                        {
+                            currentTask.IsStart = true;
+                            CustomerEnv.CurrentOperationLine1 = currentTask;
+                            OperationCrane1List.Remove(CurrentOperationLine1);
+                        }
                     }
                 }
-            }
 
-            if (GetListenReg($"1#CraneReady").Value == 1 && GetListenReg($"2#LineReady").Value == 1 &&
-               CustomerEnv.LowThenUpOperation12 == null && GetListenReg($"1#CheckButton").Value == 0 && Crane_1IsRun == false)
-            {
-                if (OperationCrane1List.Count != 0 && CustomerEnv.CurrentOperationLine2 == null && OperationCrane1List.Where(t => t.IsStart == false && t.Line == 2).ToList().Count != 0
-                    && GetListenReg($"2#LineDone").Value == 0)
+                if (GetListenReg($"1#CraneReady").Value == 1 && GetListenReg($"2#LineReady").Value == 1 &&
+                   CustomerEnv.LowThenUpOperation12 == null && GetListenReg($"1#CheckButton").Value == 0 && Crane_1IsRun == false)
                 {
-                    var currentTask = OperationCrane1List.Where(t => t.IsStart == false && t.Line == 2).First();
-                    var ok = CustomerEnv.CraneLineOperate(this, currentTask);
-                    if (ok == "OK")
+                    if (OperationCrane1List.Count != 0 && CustomerEnv.CurrentOperationLine2 == null && OperationCrane1List.Where(t => t.IsStart == false && t.Line == 2).ToList().Count != 0
+                        && GetListenReg($"2#LineDone").Value == 0)
                     {
-                        currentTask.IsStart = true;
-                        CustomerEnv.CurrentOperationLine2 = currentTask;
-                        OperationCrane1List.Remove(CurrentOperationLine2);
+                        var currentTask = OperationCrane1List.Where(t => t.IsStart == false && t.Line == 2).First();
+                        var ok = CustomerEnv.CraneLineOperate(this, currentTask);
+                        if (ok == "OK")
+                        {
+                            currentTask.IsStart = true;
+                            CustomerEnv.CurrentOperationLine2 = currentTask;
+                            OperationCrane1List.Remove(CurrentOperationLine2);
+                        }
                     }
                 }
-            }
 
-            if (GetListenReg($"2#CraneReady").Value == 1 && GetListenReg($"3#LineReady").Value == 1 &&
-                CustomerEnv.LowThenUpOperation23 == null && GetListenReg($"4#CheckButton").Value == 0 && Crane_2IsRun == false)
-            {
-                if (OperationCrane2List.Count != 0 && CustomerEnv.CurrentOperationLine3 == null && OperationCrane2List.Where(t => t.IsStart == false && t.Line == 3).ToList().Count != 0
-                    && GetListenReg($"3#LineDone").Value == 0)
+                if (GetListenReg($"2#CraneReady").Value == 1 && GetListenReg($"3#LineReady").Value == 1 &&
+                    CustomerEnv.LowThenUpOperation23 == null && GetListenReg($"4#CheckButton").Value == 0 && Crane_2IsRun == false)
                 {
-                    var currentTask = OperationCrane2List.Where(t => t.IsStart == false && t.Line == 3).First();
-                    var ok = CustomerEnv.CraneLineOperate(this, currentTask);
-                    if (ok == "OK")
+                    if (OperationCrane2List.Count != 0 && CustomerEnv.CurrentOperationLine3 == null && OperationCrane2List.Where(t => t.IsStart == false && t.Line == 3).ToList().Count != 0
+                        && GetListenReg($"3#LineDone").Value == 0)
                     {
-                        currentTask.IsStart = true;
-                        CustomerEnv.CurrentOperationLine3 = currentTask;
-                        OperationCrane2List.Remove(CurrentOperationLine3);
+                        var currentTask = OperationCrane2List.Where(t => t.IsStart == false && t.Line == 3).First();
+                        var ok = CustomerEnv.CraneLineOperate(this, currentTask);
+                        if (ok == "OK")
+                        {
+                            currentTask.IsStart = true;
+                            CustomerEnv.CurrentOperationLine3 = currentTask;
+                            OperationCrane2List.Remove(CurrentOperationLine3);
+                        }
                     }
                 }
-            }
 
-            if (GetListenReg($"2#CraneReady").Value == 1 && GetListenReg($"4#LineReady").Value == 1 &&
-               CustomerEnv.LowThenUpOperation24 == null && GetListenReg($"3#CheckButton").Value == 0 && Crane_2IsRun == false)
-            {
-                if (OperationCrane2List.Count != 0 && CustomerEnv.CurrentOperationLine4 == null && OperationCrane2List.Where(t => t.IsStart == false && t.Line == 4).ToList().Count != 0
-                    && GetListenReg($"4#LineDone").Value == 0)
+                if (GetListenReg($"2#CraneReady").Value == 1 && GetListenReg($"4#LineReady").Value == 1 &&
+                   CustomerEnv.LowThenUpOperation24 == null && GetListenReg($"3#CheckButton").Value == 0 && Crane_2IsRun == false)
                 {
-                    var currentTask = OperationCrane2List.Where(t => t.IsStart == false && t.Line == 4).First();
-                    var ok = CustomerEnv.CraneLineOperate(this, currentTask);
-                    if (ok == "OK")
+                    if (OperationCrane2List.Count != 0 && CustomerEnv.CurrentOperationLine4 == null && OperationCrane2List.Where(t => t.IsStart == false && t.Line == 4).ToList().Count != 0
+                        && GetListenReg($"4#LineDone").Value == 0)
                     {
-                        currentTask.IsStart = true;
-                        CustomerEnv.CurrentOperationLine4 = currentTask;
-                        OperationCrane2List.Remove(CurrentOperationLine4);
+                        var currentTask = OperationCrane2List.Where(t => t.IsStart == false && t.Line == 4).First();
+                        var ok = CustomerEnv.CraneLineOperate(this, currentTask);
+                        if (ok == "OK")
+                        {
+                            currentTask.IsStart = true;
+                            CustomerEnv.CurrentOperationLine4 = currentTask;
+                            OperationCrane2List.Remove(CurrentOperationLine4);
+                        }
                     }
                 }
-            }
-            #endregion
+                #endregion
 
 
-            #region 堆垛机任务完成执行逻辑
-            if (GetListenReg($"1#LineDone").Value == 1 && GetListenReg($"1#CranePutDone").Value == 1)
-            {
-                var isWriteOK = base.GetListenReg($"1#LineDone").WriteReg("0");
-                var isWriteButton = base.GetListenReg($"1#CheckButton").WriteReg("0"); //输送线按钮复位
-                if (CustomerEnv.CurrentOperationLine1 != null && CustomerEnv.CurrentOperationLine1.IsStart == true)
+                #region 堆垛机任务完成执行逻辑
+                if (GetListenReg($"1#LineDone").Value == 1 && GetListenReg($"1#CranePutDone").Value == 1)
                 {
-                    if (isWriteOK)
+                    var isWriteOK = base.GetListenReg($"1#LineDone").WriteReg("0");
+                    var isWriteButton = base.GetListenReg($"1#CheckButton").WriteReg("0"); //输送线按钮复位
+                    if (CustomerEnv.CurrentOperationLine1 != null && CustomerEnv.CurrentOperationLine1.IsStart == true)
                     {
-                        CurrentOperationLine1 = null;
+                        if (isWriteOK)
+                        {
+                            CurrentOperationLine1 = null;
+                        }
                     }
                 }
-            }
-            else if (GetListenReg($"2#LineDone").Value == 1 && GetListenReg($"1#CranePutDone").Value == 1)
-            {
-                var isWriteOK = base.GetListenReg($"2#LineDone").WriteReg("0");
-                var isWriteButton = base.GetListenReg($"2#CheckButton").WriteReg("0"); //输送线按钮复位
-                if (CustomerEnv.CurrentOperationLine2 != null && CustomerEnv.CurrentOperationLine2.IsStart == true)
+                else if (GetListenReg($"2#LineDone").Value == 1 && GetListenReg($"1#CranePutDone").Value == 1)
                 {
-                    if (isWriteOK)
+                    var isWriteOK = base.GetListenReg($"2#LineDone").WriteReg("0");
+                    var isWriteButton = base.GetListenReg($"2#CheckButton").WriteReg("0"); //输送线按钮复位
+                    if (CustomerEnv.CurrentOperationLine2 != null && CustomerEnv.CurrentOperationLine2.IsStart == true)
                     {
-                        CurrentOperationLine2 = null;
+                        if (isWriteOK)
+                        {
+                            CurrentOperationLine2 = null;
+                        }
                     }
                 }
-            }
-            if (GetListenReg($"3#LineDone").Value == 1 && GetListenReg($"2#CranePutDone").Value == 1)
-            {
-                var isWriteOK = base.GetListenReg($"3#LineDone").WriteReg("0");
-                var isWriteButton = base.GetListenReg($"3#CheckButton").WriteReg("0"); //输送线按钮复位
-                if (CustomerEnv.CurrentOperationLine3 != null && CustomerEnv.CurrentOperationLine3.IsStart == true)
+                if (GetListenReg($"3#LineDone").Value == 1 && GetListenReg($"2#CranePutDone").Value == 1)
                 {
-                    if (isWriteOK)
+                    var isWriteOK = base.GetListenReg($"3#LineDone").WriteReg("0");
+                    var isWriteButton = base.GetListenReg($"3#CheckButton").WriteReg("0"); //输送线按钮复位
+                    if (CustomerEnv.CurrentOperationLine3 != null && CustomerEnv.CurrentOperationLine3.IsStart == true)
                     {
-                        CurrentOperationLine3 = null;
+                        if (isWriteOK)
+                        {
+                            CurrentOperationLine3 = null;
+                        }
                     }
                 }
-            }
-            else if (GetListenReg($"4#LineDone").Value == 1 && GetListenReg($"2#CranePutDone").Value == 1)
-            {
-                var isWriteOK = base.GetListenReg($"4#LineDone").WriteReg("0");
-                var isWriteButton = base.GetListenReg($"4#CheckButton").WriteReg("0"); //输送线按钮复位
-                if (CustomerEnv.CurrentOperationLine4 != null && CustomerEnv.CurrentOperationLine4.IsStart == true)
+                else if (GetListenReg($"4#LineDone").Value == 1 && GetListenReg($"2#CranePutDone").Value == 1)
                 {
-                    if (isWriteOK)
+                    var isWriteOK = base.GetListenReg($"4#LineDone").WriteReg("0");
+                    var isWriteButton = base.GetListenReg($"4#CheckButton").WriteReg("0"); //输送线按钮复位
+                    if (CustomerEnv.CurrentOperationLine4 != null && CustomerEnv.CurrentOperationLine4.IsStart == true)
                     {
-                        CurrentOperationLine4 = null;
+                        if (isWriteOK)
+                        {
+                            CurrentOperationLine4 = null;
+                        }
                     }
                 }
-            }
                 #endregion
 
             }
         }
+
+        private void WriteScreen()
+        {
+            var screen1 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏1");
+            if (screen1?.GetListenReg("ScreenRow1") != null && CurrentOperationLine1 != null)
+            {
+                var rcl = CurrentOperationLine1.RowColLayerFormat();
+                screen1?.GetListenReg("ScreenRow1").WriteReg($"    {rcl}");
+            }
+            if (screen1?.GetListenReg("ScreenRow2") != null && CurrentOperationLine1 != null)
+            {
+                screen1?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine1.ItemName);
+            }
+            if (screen1?.GetListenReg("ScreenRow1") != null && CurrentOperationLine1 == null)
+            {
+                screen1?.GetListenReg("ScreenRow1").WriteReg("    00-000-00");
+                screen1?.GetListenReg("ScreenRow2").WriteReg(" ");
+            }
+
+            var screen2 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏2");
+            if (screen2?.GetListenReg("ScreenRow1") != null && CurrentOperationLine2 != null)
+            {
+                var rcl = CurrentOperationLine2.RowColLayerFormat();
+                screen2?.GetListenReg("ScreenRow1").WriteReg($"    {rcl}");
+            }
+            if (screen2?.GetListenReg("ScreenRow2") != null && CurrentOperationLine2 != null)
+            {
+                screen2?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine2.ItemName);
+            }
+            if (screen2?.GetListenReg("ScreenRow1") != null && CurrentOperationLine2 == null)
+            {
+                screen2?.GetListenReg("ScreenRow1").WriteReg("    00-000-00");
+                screen2?.GetListenReg("ScreenRow2").WriteReg(" ");
+            }
+
+            var screen3 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏3");
+            if (screen3?.GetListenReg("ScreenRow1") != null && CurrentOperationLine3 != null)
+            {
+                var rcl = CurrentOperationLine3.RowColLayerFormat();
+                screen3?.GetListenReg("ScreenRow1").WriteReg($"    {rcl}");
+            }
+            if (screen3?.GetListenReg("ScreenRow2") != null && CurrentOperationLine3 != null)
+            {
+                screen3?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine3.ItemName);
+            }
+            if (screen3?.GetListenReg("ScreenRow1") != null && CurrentOperationLine3 == null)
+            {
+                screen3?.GetListenReg("ScreenRow1").WriteReg("    00-000-00");
+                screen3?.GetListenReg("ScreenRow2").WriteReg(" ");
+            }
+
+            var screen4 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏4");
+            if (screen4?.GetListenReg("ScreenRow1") != null && CurrentOperationLine4 != null)
+            {
+                var rcl = CurrentOperationLine4.RowColLayerFormat();
+                screen4?.GetListenReg("ScreenRow1").WriteReg($"    {rcl}");
+            }
+            if (screen4?.GetListenReg("ScreenRow2") != null && CurrentOperationLine4 != null)
+            {
+                screen4?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine4.ItemName);
+            }
+            if (screen4?.GetListenReg("ScreenRow1") != null && CurrentOperationLine4 == null)
+            {
+                screen4?.GetListenReg("ScreenRow1").WriteReg("    00-000-00");
+                screen4?.GetListenReg("ScreenRow2").WriteReg(" ");
+            }
+
+        }
     }
 }

+ 1 - 40
SCADA_DAQ/Customer/Utils/Screen.cs

@@ -10,51 +10,12 @@ namespace SCADA_DAQ.Customer.Utils
 {
     public static class Screen
     {
-        public static string RowColLayerFormat(OperationBo operation)
+        public static string RowColLayerFormat(this OperationBo operation)
         {
-
             var rowStr = $"0{operation.StartRow}";
             var layerStr = operation.StartLayer < 10 ? "0" + operation.StartLayer.ToString() : operation.StartLayer.ToString();
             var colStr = operation.StartCol < 10 ? "00" + operation.StartCol.ToString() : operation.StartCol < 100 ? "0" + operation.StartCol.ToString() : operation.StartCol.ToString();
             return $"{rowStr}-{colStr}-{layerStr}";
         }
-        public static string[] ToHex(string str)
-        {
-
-            var gbk = Encoding.GetEncoding("GBK");
-            var bytes = gbk.GetBytes(str);
-            string[] hexArray = new string[bytes.Length];
-            for (int i = 0; i < bytes.Length; i++)
-            {
-                hexArray[i] = bytes[i].ToString("X2");
-            }
-            return hexArray;
-        }
-        // ["11","22","33"]["1122","33"]
-        public static string[] List2ToList4(string[] list2)
-        {
-            var list4 = new List<string>();
-            for (int i = 0; i < list2.Length; i += 2)
-            {
-                if (i+1<list2.Length)
-                {
-                    list4.Add(list2[i] + list2[i + 1]);
-                }
-                else
-                {
-                    list4.Add(list2[i]+"00");
-                }
-            }
-            return list4.ToArray();
-        }
-        public static string OperToHex(this OperationBo operation)
-        {
-            var rcl = RowColLayerFormat(operation);
-            var rclHex = List2ToList4(ToHex(rcl));
-            var itemNameHex = List2ToList4(ToHex(operation.ItemName));
-            // 只针对显示屏34
-            var strat = new string[] { "0000", "0000" };
-            return string.Join("",strat.Concat(rclHex).Concat(new string[] { "0000" }).Concat(itemNameHex).Select(t => t).ToList<string>());
-        }
     }
 }