莫海杰 2 weeks ago
parent
commit
57ef75027a
1 changed files with 23 additions and 30 deletions
  1. 23 30
      SCADA_DAQ/Customer/Machines/SampleMachine_ScanCompleted.cs

+ 23 - 30
SCADA_DAQ/Customer/Machines/SampleMachine_ScanCompleted.cs

@@ -1,23 +1,13 @@
 using DBNames;
-using Mysqlx;
-using NPOI.SS.Formula.Functions;
 using SCADA;
 using SCADA.CommonLib.Data.DIL;
-using SCADA.CommonLib.Helper;
-using SCADA.Drive;
 using SCADA_DAQ.Customer.Models;
 using SCADA_DAQ.Customer.Utils;
 using SCADA_DAQ.Plugin.Machine;
-using SCADA_DAQ.Plugin.Machine.Device;
-using SCADA_DAQ.Plugin.Machine.HDAConfig;
 using System;
-using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using static Mysqlx.Expect.Open.Types;
 using static SCADA_DAQ.Customer.CustomerEnv;
+using SCADA.Comm;
 
 namespace SCADA_DAQ.Customer.Machines
 {
@@ -32,10 +22,13 @@ namespace SCADA_DAQ.Customer.Machines
         {
             if (RedundancyService?.RedundancyState == RedundancyStates.Standby) { return; }  //如果是待机模式就不执行下面的逻辑
             base.ScanCompleted(sender, e);
-            if (BaseDevice.DeviceID.StartsWith("输送线"))
+            if (BaseDevice.DeviceID.StartsWith("显示屏"))
             {
                 // 写入显示屏
                 WriteScreen();
+            }
+            if (BaseDevice.DeviceID.StartsWith("输送线"))
+            {
 
                 #region 按输送线按钮回原位
                 bool lowThenUpShelf(OperationBo ltuOperation)
@@ -249,56 +242,56 @@ namespace SCADA_DAQ.Customer.Machines
         private void WriteScreen()
         {
             var screen1 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏1");
-            if (screen1?.GetListenReg("ScreenRow1") != null && CurrentOperationLine1 != null)
+            if (screen1?.ConnectState ==ConnectStates.Connected && CurrentOperationLine1 != null)
             {
                 var rcl = CurrentOperationLine1.RowColLayerFormat();
                 screen1?.GetListenReg("ScreenRow1").WriteReg($"       {rcl}");
-                screen1?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine1.ItemName);
+                screen1?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine1.ItemName ?? "        输送线1");
             }
-            if (screen1?.GetListenReg("ScreenRow1") != null && CurrentOperationLine1 == null)
+            if (screen1?.ConnectState ==ConnectStates.Connected && CurrentOperationLine1 == null)
             {
                 screen1?.GetListenReg("ScreenRow1").WriteReg("       00-000-00");
-                screen1?.GetListenReg("ScreenRow2").WriteReg(" ");
+                screen1?.GetListenReg("ScreenRow2").WriteReg("        输送线1");
             }
 
             var screen2 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏2");
-            if (screen2?.GetListenReg("ScreenRow1") != null && CurrentOperationLine2 != null)
+            if (screen2?.ConnectState ==ConnectStates.Connected && CurrentOperationLine2 != null)
             {
                 var rcl = CurrentOperationLine2.RowColLayerFormat();
                 screen2?.GetListenReg("ScreenRow1").WriteReg($"       {rcl}");
-                screen2?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine2.ItemName);
+                screen2?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine2.ItemName?? "        输送线2");
             }
-            if (screen2?.GetListenReg("ScreenRow1") != null && CurrentOperationLine2 == null)
+            if (screen2?.ConnectState ==ConnectStates.Connected && CurrentOperationLine2 == null)
             {
                 screen2?.GetListenReg("ScreenRow1").WriteReg("       00-000-00");
-                screen2?.GetListenReg("ScreenRow2").WriteReg(" ");
+                screen2?.GetListenReg("ScreenRow2").WriteReg("        输送线2");
             }
 
             var screen3 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏3");
-            if (screen3?.GetListenReg("ScreenRow1") != null && CurrentOperationLine3 != null)
+            if (screen3?.ConnectState ==ConnectStates.Connected && CurrentOperationLine3 != null)
             {
                 var rcl = CurrentOperationLine3.RowColLayerFormat();
                 screen3?.GetListenReg("ScreenRow1").WriteReg($"    {rcl}");
-                screen3?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine3.ItemName);
+                screen3?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine3.ItemName?? "    输送线3");
             }
 
-            if (screen3?.GetListenReg("ScreenRow1") != null && CurrentOperationLine3 == null)
+            if (screen3?.ConnectState ==ConnectStates.Connected && CurrentOperationLine3 == null)
             {
-                screen3?.GetListenReg("ScreenRow1").WriteReg("    00-000-00");
-                screen3?.GetListenReg("ScreenRow2").WriteReg(" ");
+                screen3?.GetListenReg("ScreenRow1").WriteReg("   00-000-00");
+                screen3?.GetListenReg("ScreenRow2").WriteReg("    输送线3");
             }
 
             var screen4 = MachineServer.GetInstance().GetMachine<SampleMachine>("显示屏4");
-            if (screen4?.GetListenReg("ScreenRow1") != null && CurrentOperationLine4 != null)
+            if (screen4?.ConnectState ==ConnectStates.Connected && CurrentOperationLine4 != null)
             {
                 var rcl = CurrentOperationLine4.RowColLayerFormat();
                 screen4?.GetListenReg("ScreenRow1").WriteReg($"    {rcl}");
-                screen4?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine4.ItemName);
+                screen4?.GetListenReg("ScreenRow2").WriteReg(CurrentOperationLine4.ItemName?? "    输送线4");
             }
-            if (screen4?.GetListenReg("ScreenRow1") != null && CurrentOperationLine4 == null)
+            if (screen4?.ConnectState ==ConnectStates.Connected && CurrentOperationLine4 == null)
             {
-                screen4?.GetListenReg("ScreenRow1").WriteReg("    00-000-00");
-                screen4?.GetListenReg("ScreenRow2").WriteReg(" ");
+                screen4?.GetListenReg("ScreenRow1").WriteReg("   00-000-00");
+                screen4?.GetListenReg("ScreenRow2").WriteReg("    输送线4");
             }
 
         }