From 17e4c7e3e7b3ef60d9da6de3b2a39a14a53c38a0 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期三, 12 三月 2025 14:11:33 +0800
Subject: [PATCH] 1

---
 WIDESEAWCS_Server/WIDESEAWCS_Tasks/TestJob.cs |   60 +++++++++++++++++++++++++-----------------------------------
 1 files changed, 25 insertions(+), 35 deletions(-)

diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TestJob.cs b/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TestJob.cs
index 089b050..0a4e601 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TestJob.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_Tasks/TestJob.cs
@@ -2,6 +2,8 @@
 using HslCommunication.Core;
 using Microsoft.VisualBasic.FileIO;
 using Quartz;
+using Quartz.Impl;
+using Quartz.Spi;
 using SixLabors.ImageSharp.PixelFormats;
 using System;
 using System.Collections.Generic;
@@ -14,7 +16,9 @@
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
+using WIDESEAWCS_Tasks.StackerCraneJob;
 
 namespace WIDESEAWCS_Tasks
 {
@@ -27,45 +31,31 @@
             {
                 CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
 
-                Console.Out.WriteLine(commonStackerCrane.DeviceName + "鐘舵��:" + commonStackerCrane.StackerCraneStatusDes);
+                //1.SendCommand鏂规硶绀轰緥
+                //鍫嗗灈鏈哄懡浠ゅ璞★紝缁ф壙DeviceCommand
+                StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand();
+                //璋冪敤鍙戦�佷换鍔″懡浠ゆ柟娉�
+                commonStackerCrane.SendCommand(stackerCraneTaskCommand);
 
-                Console.Out.WriteLine(commonStackerCrane.DeviceName + "鎵嬭嚜鍔ㄧ姸鎬�:" + commonStackerCrane.StackerCraneAutoStatusDes);
+                //2.GetValue鏂规硶绀轰緥
+                //璋冪敤璇诲彇PLC鏁版嵁鏂规硶锛孲tackerCraneDBName涓烘灇涓剧被鍨嬶紝StackerCraneDBName.CurrentTaskNum涓烘灇涓惧��
+                commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.CurrentTaskNum);
 
-                Console.Out.WriteLine(commonStackerCrane.DeviceName + "浣滀笟鐘舵��:" + commonStackerCrane.StackerCraneWorkStatusDes);
+                //3.SetValue鏂规硶绀轰緥
+                //璋冪敤鍐欏叆PLC鏁版嵁鏂规硶锛孲tackerCraneDBName涓烘灇涓剧被鍨嬶紝StackerCraneDBName.CurrentTaskNum涓烘灇涓惧�硷紝121涓哄啓鍏ョ殑鏁版嵁
+                commonStackerCrane.SetValue(StackerCraneDBName.CurrentTaskNum, 121);
 
-                //Console.Out.WriteLine(commonStackerCrane.DeviceName + "褰撳墠浠诲姟鍙�:" + commonStackerCrane.GetValue<StackerCraneDBName, int>(StackerCraneDBName.CurrentTaskNum));
+                //4.璋冪敤浠诲姟瀹屾垚浜嬩欢鐩戞祴鏂规硶
+                commonStackerCrane.CheckStackerCraneTaskCompleted();
 
-                //commonStackerCrane.SetValue(StackerCraneDBName.CurrentTaskNum, DateTime.Now.Second);
-
-                //OperateResult<TimeSpan> operateResult = commonStackerCrane.Communicator.Wait("DB1.18", 1000, 60000, 1);
-                //Console.Out.WriteLine(operateResult.Serialize());
-
-                byte[] bytes = commonStackerCrane.Communicator.Read("DB1.1", 2);
-                Console.Out.WriteLine(bytes.ToBoolArray().ToList().Serialize());
-
-                bool[] bools = new bool[] { true, false, true };
-                byte[] bytes1 = bools.ToByteArray();
-                Console.Out.WriteLine(bytes1.ToList().Serialize());
-
-                //StackerCraneCommand stackerCraneCommand = new StackerCraneCommand()
-                //{
-                //    TaskNum = 999,
-                //    WorkType = 1,
-                //    TrayType = 2,
-                //    StartRow = 12,
-                //    StartColumn = 13,
-                //    StartLayer = 14,
-                //    EndRow = 22,
-                //    EndColumn = 23,
-                //    EndLayer = 24,
-                //};
-
-                //bool flag = commonStackerCrane.SendCommand(stackerCraneCommand);
-                //Console.Out.WriteLine(flag);
-
-                //StackerCraneCommand stackerCraneCommand2 = new StackerCraneCommand();
-                //stackerCraneCommand2 = commonStackerCrane.Communicator.ReadCustomer<StackerCraneCommand>("DB2.2");
-                //Console.Out.WriteLine(stackerCraneCommand2.Serialize());
+                //5.浣跨敤CommonStackerCrane涓瑿ommunicator灞炴�х洿鎺ヨ鍐橮LC鍦板潃鐨勫��
+                string plcProtocolAddress = "DB1.0";//PLC閫氳鍗忚鐨勫湴鍧�锛屽彲鐩存帴浣跨敤婧愬湴鍧�璇诲彇
+                DeviceProDTO? deviceProDTO = commonStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(StackerCraneDBName.CurrentTaskNum));//PLC閫氳鍗忚鐨勫湴鍧�锛屼篃鍙�氳繃[鍗忚淇℃伅灞炴��(DeviceProDTOs)]锛屽幓鏌ヨ鍒扮浉鍏崇殑婧愬湴鍧�
+                if (deviceProDTO != null) 
+                {
+                    commonStackerCrane.Communicator.Read<short>(plcProtocolAddress);
+                    commonStackerCrane.Communicator.Read<short>(deviceProDTO.DeviceProAddress);
+                }
 
                 Console.Out.WriteLine(DateTime.Now);
 

--
Gitblit v1.9.3