From e46aa927d231af83724683c7286d9db503e24cf7 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期二, 10 六月 2025 11:46:20 +0800
Subject: [PATCH] 1
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/CommonConveyorLightJob.cs | 68 +++++++++++++++++++++++-----------
1 files changed, 46 insertions(+), 22 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/CommonConveyorLightJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/CommonConveyorLightJob.cs"
index 99f0584..32caa7f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/CommonConveyorLightJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/CommonConveyorLightJob.cs"
@@ -6,18 +6,30 @@
using HslCommunication.WebSocket;
using Quartz;
using WIDESEAWCS_Common;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
namespace WIDESEAWCS_Tasks
{
+ /// <summary>
+ /// 閫氱敤浼犻�佸甫鐏厜鎺у埗浠诲姟 <br/>
+ /// 浠嶱LC璇诲彇绔欑偣鐘舵�佸拰閲婃斁淇″彿锛屾洿鏂扮伅鍏夌姸鎬佸瓧鍏革紝骞惰缃搴旂殑PLC淇″彿 <br/>
+ /// 涓昏鍔熻兘锛� <br/>
+ /// 1. 璇诲彇PLC涓璂B15.922.0鍜孌B15.924.0鐨�16浣嶅竷灏旀暟缁勪綔涓虹珯鐐圭姸鎬佸拰閲婃斁淇″彿 <br/>
+ /// 2. 鏍规嵁璁惧瀛愮爜鍒嗙粍鏇存柊LightStatusStorage涓殑鐘舵�佸瓧鍏� <br/>
+ /// 3. 鏍规嵁褰撳墠鐏厜鐘舵�佽缃甈LC瀵瑰簲鐨勫畬鎴�/閿欒/宸ヤ綔涓�/璇煶淇″彿 <br/>
+ /// 寮傚父澶勭悊锛氳褰曡澶囦唬鐮佸拰鍚嶇О鐩稿叧鐨勫紓甯镐俊鎭�
+ /// </summary>
[DisallowConcurrentExecution]
public class CommonConveyorLightJob : JobBase, IJob
{
private readonly ITaskRepository _taskRepository;
private readonly WebSocketServer _webSocketServer;
+ private readonly IContainerRepository _containerRepository;
public CommonConveyorLightJob(ITaskRepository taskRepository, WebSocketServer webSocketServer)
{
@@ -28,20 +40,52 @@
public Task Execute(IJobExecutionContext context)
{
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;
try
{
+ bool[] stationStatusArray = otherDevice.Communicator.Read<bool>("DB15.922.0", 16);
+
+ bool[] releaseArray = otherDevice.Communicator.Read<bool>("DB15.924.0", 16);
+
string? dbAddress = otherDevice.DeviceProDTOs.OrderBy(x => x.DeviceProOffset).Select(x => x.DeviceProAddress).FirstOrDefault();
if (!string.IsNullOrEmpty(dbAddress))
{
List<string> deviceChildCodes = otherDevice.DeviceProDTOs.GroupBy(x => x.DeviceChildCode).Select(x => x.Key).ToList();
for (int i = 0; i < deviceChildCodes.Count; i++)
{
+ if (LightStatusStorage.StationStautsDic.ContainsKey(deviceChildCodes[i]))
+ {
+ LightStatusStorage.StationStautsDic[deviceChildCodes[i]] = stationStatusArray[i];
+ }
+ else
+ {
+ LightStatusStorage.StationStautsDic.Add(deviceChildCodes[i], stationStatusArray[i]);
+ }
+
+ if (LightStatusStorage.StationReleaseDic.ContainsKey(deviceChildCodes[i]))
+ {
+ LightStatusStorage.StationReleaseDic[deviceChildCodes[i]] = releaseArray[i];
+ }
+ else
+ {
+ LightStatusStorage.StationReleaseDic.Add(deviceChildCodes[i], releaseArray[i]);
+ }
+
if (!LightStatusStorage.LightStatusDic.ContainsKey(deviceChildCodes[i]))
{
LightStatusStorage.LightStatusDic.Add(deviceChildCodes[i], LightStatusEnum.None);
+ if (otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightCompleted, deviceChildCodes[i]))
+ otherDevice.SetValue(LightStatusEnum.LightCompleted, false, deviceChildCodes[i]);
+
+ if (otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightError, deviceChildCodes[i]))
+ otherDevice.SetValue(LightStatusEnum.LightError, false, deviceChildCodes[i]);
+
+ if (otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightWorking, deviceChildCodes[i]))
+ otherDevice.SetValue(LightStatusEnum.LightWorking, false, deviceChildCodes[i]);
+
+ if (otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightVoice, deviceChildCodes[i]))
+ otherDevice.SetValue(LightStatusEnum.LightVoice, false, deviceChildCodes[i]);
}
else
{
@@ -86,26 +130,6 @@
if (otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightVoice, deviceChildCodes[i]))
otherDevice.SetValue(LightStatusEnum.LightVoice, false, deviceChildCodes[i]);
- }
- else if (LightStatusStorage.LightStatusDic[deviceChildCodes[i]] == LightStatusEnum.ReadyRelease)
- {
- Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress.Contains(deviceChildCodes[i]));
- if (task == null)
- {
- if (!otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightCompleted, deviceChildCodes[i]))
- otherDevice.SetValue(LightStatusEnum.LightCompleted, true, deviceChildCodes[i]);
-
- if (otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightError, deviceChildCodes[i]))
- otherDevice.SetValue(LightStatusEnum.LightError, false, deviceChildCodes[i]);
-
- if (otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightWorking, deviceChildCodes[i]))
- otherDevice.SetValue(LightStatusEnum.LightWorking, false, deviceChildCodes[i]);
-
- if (otherDevice.GetValue<LightStatusEnum, bool>(LightStatusEnum.LightVoice, deviceChildCodes[i]))
- otherDevice.SetValue(LightStatusEnum.LightVoice, false, deviceChildCodes[i]);
-
- //_webSocketServer鍙戦�佹暟鎹�
- }
}
else if (LightStatusStorage.LightStatusDic[deviceChildCodes[i]] == LightStatusEnum.Ready)
{
--
Gitblit v1.9.3