From 5da3a276b7847187a7c155ee069d3cd4c9e58074 Mon Sep 17 00:00:00 2001
From: HuBingJie <3146306518@qq.com>
Date: 星期日, 07 十二月 2025 23:28:14 +0800
Subject: [PATCH] 1
---
代码管理/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs | 863 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 854 insertions(+), 9 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs"
index 5e75a4c..e2a6bc2 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RgvoperainformService.cs"
@@ -1,4 +1,4 @@
-锘�#region << 鐗� 鏈� 娉� 閲� >>
+#region << 鐗� 鏈� 娉� 閲� >>
/*----------------------------------------------------------------
* 鍛藉悕绌洪棿锛歐IDESEAWCS_TaskInfoService
* 鍒涘缓鑰咃細鑳$搴�
@@ -25,6 +25,7 @@
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using Quartz.Util;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -40,7 +41,9 @@
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm.Http;
+using WIDESEA_Common.Log;
using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_DTO.Enum;
@@ -58,9 +61,10 @@
{
public class RgvoperainformService : ServiceBase<Dt_Task_hty, ITask_HtyRepository>, IRgvoperainformService
{
- private readonly IAgvStationService _gvStationService;
+ private readonly IAgvStationService _agvStationService;
private readonly IServiceProvider _serviceProvider;
private static bool _isMonitoring = false;
+ private readonly IRepository<DeviceAlarmLog> _deviceAlarmLog;
//private static CancellationTokenSource _cancellationTokenSource;
// 鍦ㄧ被绾у埆娣诲姞鐙珛鐨勭洃鎺х姸鎬�
@@ -74,10 +78,11 @@
private CancellationTokenSource _outboundCancellationTokenSource;
private CancellationTokenSource _inboundCancellationTokenSource;
private CancellationTokenSource _safetyDoorCancellationTokenSource;
- public RgvoperainformService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, IServiceProvider serviceProvider) : base(BaseDal)
+ public RgvoperainformService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService, IServiceProvider serviceProvider, IRepository<DeviceAlarmLog> deviceAlarmLog) : base(BaseDal)
{
- _gvStationService = agvStationService;
+ _agvStationService = agvStationService;
_serviceProvider = serviceProvider;
+ _deviceAlarmLog = deviceAlarmLog;
}
@@ -659,7 +664,7 @@
int zhi = 1002011;
try
{
-
+
switch (operationType)
{
case "cs": //鍒濆鍖�
@@ -693,14 +698,39 @@
DeviceProParamName = "RGV_Risingsignalplace";
DeviceProParamType = "DeviceCommand";
zhi = parameter;
- break;
- case "xj": //涓嬮檷
+ DeviceProDTO? RGV_Resetoperationss1 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType); //涓婂崌
+ RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationss1.DeviceProAddress, (short)zhi);
+ //DeviceProDTO? RGV_Resetoperationss2 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, "RGV_Risingsignalplace", "ReadDeviceCommand"); //涓婂崌鍒颁綅淇″彿
+ // int resss = 0;
+ // while (resss == 0)
+ // {
+ // Thread.Sleep(2000);
+ // resss = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperationss2.DeviceProAddress);
+ // }
+ // DeviceProDTO? RGV_Resetoperationss3 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType); //涓婂崌
+ // RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationss3.DeviceProAddress, 0);
+ return webResponse.OK();
+
+ case "xj": //涓嬮檷
DeviceProParamName = "RGV_Descentsignal";
DeviceProParamType = "DeviceCommand";
zhi = parameter;
- break;
+ DeviceProDTO? RGV_Resetoperationxj1 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType); //涓嬮檷
+ RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationxj1.DeviceProAddress, (short)zhi);
+ //DeviceProDTO? RGV_Resetoperationxj2 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, "RGV_Descentsignal", "ReadDeviceCommand"); //涓嬮檷鍒颁綅淇″彿
+ //int resxj = 0;
+ //while (resxj == 0)
+ //{
+ // Thread.Sleep(2000);
+ // resxj = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperationxj2.DeviceProAddress);
+ //}
+ //DeviceProDTO? RGV_Resetoperationxj3 = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, deviceName, DeviceProParamName, DeviceProParamType); //涓婂崌
+ //RgvOperationService.RgvSetLine(Commonstacker, RGV_Resetoperationxj3.DeviceProAddress, 0);
+ return webResponse.OK();
case "dz": //鍦板潃
- DeviceProParamName = "RGV_RGVTasklocationt";
+
+ if (!YiDongPD(Commonstacker, parameter)) { return webResponse.Error("鐩爣鍦板潃琚崰鐢ㄦ垨鏉′欢涓嶆弧瓒筹紝绂佹绉诲姩"); }
+ DeviceProParamName = "RGV_RGVTasklocationt";
DeviceProParamType = "DeviceCommand";
zhi = parameter;
//鑾峰彇瀹炰緥
@@ -753,6 +783,657 @@
return webResponse.Error("璁惧鎿嶄綔澶辫触");
}
+ }
+
+ /// <summary>
+ /// 1銆佸垽鏂瓙杞﹀尯鍩�
+ /// 2銆佸垽鏂瓙杞﹀綋鍓嶄綅缃�
+ /// 3銆佸垽鏂瓙杞﹁鍘荤殑浣嶇疆
+ /// 4銆佹牴鎹瓙杞﹁鍘荤殑涓鸿幏鍙栨瘝杞︿綅缃�
+ ///
+ /// </summary>
+ /// <param name="device">瑕佺Щ鍔ㄧ殑璁惧</param>
+ /// <param name="parameter">瑕佸幓鐨勭洰鏍囧湴鍧�</param>
+ /// <returns></returns>
+
+ private bool YiDongPD(SpeStackerCrane Commonstacker, int parameter)
+ {
+
+ //鍏ュ簱璁惧
+ List<string> InDevices = new List<string> { "RGV104", "RGV107" };
+ //鍑哄簱璁惧
+ List<string> OutDevices = new List<string> {"RGV116", "RGV111"};
+
+ Dictionary<int, string> HCJ = new Dictionary<int, string>
+ {
+ { 1061, "HCJ106" },
+ { 1021, "HCJ102" },
+ { 1131, "HCJ113" },
+ { 1171, "HCJ117" },
+ };
+
+ AGVStation RGVTaskdevice = _agvStationService.Corridorequipment(Commonstacker.DeviceCode); //鏍规嵁璁惧鑾峰彇鍒板唴瀹�
+
+ //鏍规嵁瀛愯溅鑾峰彇鍒版瘝杞﹁澶�
+ // 鏍规嵁瀛愯溅鑾峰彇鍒版瘝杞﹁澶�
+ AGVStation Mu1 = _agvStationService.GetMothervehicle(RGVTaskdevice.MotherCarDeviceCode);
+ AGVStation Mu2 = _agvStationService.GetMothervehicle(RGVTaskdevice.MotherCardeputy);
+
+ // 鑾峰彇瀛愯溅浣嶇疆
+ int zhicheWZ = GetzicheWZ(Commonstacker, Commonstacker.DeviceCode);
+
+ // 缁熶竴鐩爣鍗犵敤妫�鏌ワ紙鎵弿鍏跺畠 RGV 鏄惁鍦ㄥ悓涓�鐩爣鍦板潃锛�
+ bool IsAddressOccupied(int addr)
+ {
+ var allCodes = InDevices.Concat(OutDevices).Where(code => code != Commonstacker.DeviceCode).ToList();
+ foreach (var code in allCodes)
+ {
+ var dev = Storage.Devices.FirstOrDefault(x => x.DeviceCode == code) as SpeStackerCrane;
+ if (dev == null) continue;
+ try
+ {
+ DeviceProDTO? locDto = RgvOperationService.GetRGVDeviceProDTO(dev, code, "RGVCurrentlocation", "RGVCurrentlocation");
+ if (locDto == null) continue;
+ int loc = RgvOperationService.GetLine(dev, locDto.DeviceProAddress);
+ if (loc == addr) return true; // 鐩爣琚崰鐢�
+ }
+ catch
+ {
+ // 璇诲彇寮傚父涓嶅綋浣滃崰鐢紝閬垮厤璇嫆
+ }
+ }
+ return false;
+ }
+
+ // 鐩爣琚叾浠� RGV 鍗犵敤鍒欑姝�
+ if (IsAddressOccupied(parameter)) return false;
+
+ if (RGVTaskdevice.Station_Area == 6) // 澶栦晶
+ {
+ if (zhicheWZ == RGVTaskdevice.WaitmomentOne) // 绛夊緟鐐�1
+ {
+ // 鍒ゆ柇澶栦晶灏忚溅鏄惁鍦� HCJ 涓�
+ var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
+ int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
+
+ //鍒ゆ柇浼犺繘鏉ヨ澶囨槸鍚︽槸鍏ュ簱
+ if (InDevices.Contains(Commonstacker.DeviceCode))
+ {
+ if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
+ {
+ return false;
+ }
+ }
+
+ if (parameter == Mu1.ZicheMotherinlaw) //姣�1
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (parameter == Mu2.ZicheMotherinlaw) // 姣�2
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && mu2 != Mu2.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (parameter == RGVTaskdevice.HCJStorageaddress)
+ {
+ string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu2.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }else if(parameter == 1021 || parameter == 1171)
+ {
+ if (RGVTaskdevice.ChildPosiDeviceCode == "RGV116" && Mucheywhaddres("HCJ102"))
+ {
+ return true;
+ }
+ string hcj = HCJ[parameter];
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+
+ }
+ }
+ }
+ else if (zhicheWZ == RGVTaskdevice.WaitmomentTwo) // 绛夊緟鐐�2
+ {
+ // 鍒ゆ柇澶栦晶灏忚溅鏄惁鍦� HCJ 涓�
+ var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
+ int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
+
+ //鍒ゆ柇浼犺繘鏉ヨ澶囨槸鍚︽槸鍏ュ簱
+ if (InDevices.Contains(Commonstacker.DeviceCode))
+ {
+ if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
+ {
+ return false;
+ }
+ }
+
+ if (parameter == Mu1.ZicheMotherinlaw)
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (parameter == Mu2.ZicheMotherinlaw)
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (parameter == RGVTaskdevice.HCJStorageaddress)
+ {
+ string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu2.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (parameter == 1021 || parameter == 1171)
+ {
+ string hcj = HCJ[parameter];
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode) && Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+
+ }
+ }
+ }
+ }
+ else if (RGVTaskdevice.Station_Area == 5) // 鍐呬晶
+ {
+ if (zhicheWZ == RGVTaskdevice.WaitmomentOne) // 绛夊緟鐐�1
+ {
+ // 鍒ゆ柇澶栦晶灏忚溅鏄惁鍦� HCJ 涓�
+ var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
+ int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
+
+ //鍒ゆ柇浼犺繘鏉ヨ澶囨槸鍚︽槸鍏ュ簱
+ if (InDevices.Contains(Commonstacker.DeviceCode))
+ {
+ if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
+ {
+ return false;
+ }
+ }
+
+ if (parameter == Mu1.ZicheMotherinlaw) //姣�1
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (parameter == Mu2.ZicheMotherinlaw) // 姣�2
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }else if (parameter == RGVTaskdevice.HCJStorageaddress)
+ {
+ string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
+ if (Mucheywhaddres(hcj))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+
+ }
+ }
+ }
+ else if (zhicheWZ == RGVTaskdevice.WaitmomentTwo) // 绛夊緟鐐�2
+ {
+ // 鍒ゆ柇澶栦晶灏忚溅鏄惁鍦� HCJ 涓�
+ var zichestation = _agvStationService.OutGetZicheDeepHCJ(RGVTaskdevice.HCJStorageaddress);
+ int waiziche = GetEquipmentlocation(zichestation.ChildPosiDeviceCode);
+
+ //鍒ゆ柇浼犺繘鏉ヨ澶囨槸鍚︽槸鍏ュ簱
+ if (InDevices.Contains(Commonstacker.DeviceCode))
+ {
+ if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1021) && waiziche != zichestation.HCJStorageaddress))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (!((waiziche == zichestation.WaitmomentOne || waiziche == zichestation.WaitmomentTwo || waiziche == zichestation.MotherCardeputy || waiziche == zichestation.MotherCarDeviceCode || waiziche == 1171) && waiziche != zichestation.HCJStorageaddress))
+ {
+ return false;
+ }
+ }
+
+ if (parameter == Mu1.ZicheMotherinlaw)
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.ZicheMotherinlaw && mu1 != Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (parameter == Mu2.ZicheMotherinlaw)
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (parameter == RGVTaskdevice.HCJStorageaddress)
+ {
+ string hcj = HCJ[RGVTaskdevice.HCJStorageaddress];
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode)&&Mucheywhaddres(hcj))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 != Mu1.ZicheMotherinlaw && mu1 == Mu1.Motherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ int taraddress = parameter;
+ int mu1 = GetEquipmentlocation(Mu1.ChildPosiDeviceCode);
+ int mu2 = GetEquipmentlocation(Mu2.ChildPosiDeviceCode);
+
+ if (Mucheywhaddres(Mu1.ChildPosiDeviceCode) && Mucheywhaddres(Mu2.ChildPosiDeviceCode))//鍒ゆ柇鏄惁鏈夎揣
+ {
+ if (mu1 == Mu1.Motherinlaw && mu1 != Mu1.ZicheMotherinlaw && mu2 == Mu2.Motherinlaw && mu2 != Mu2.ZicheMotherinlaw && !IsAddressOccupied(Mu1.ZicheMotherinlaw))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+
+ }
+ }
+ }
+ }
+
+ // 榛樿锛氭湭琚嫤鎴笖鐩爣鏈崰鐢� -> 鏀捐
+ return true;
+
+ }
+
+ /// <summary>
+ /// 浼犲叆璁惧锛岃繑鍥炲綋鍓嶈澶囦俊鎭�
+ /// </summary>
+ /// <param name="ChildPosiDeviceCode">璁惧</param>
+ /// <returns></returns>
+ public static int GetEquipmentInformation(string ChildPosiDeviceCode)
+ {
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
+ SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
+ if (speStackerCrane == null)
+ {
+ Console.WriteLine($"璇诲彇鍒拌澶囦负绌�,璁惧缂栧彿锛歿ChildPosiDeviceCode},003");
+ return 0;
+ }
+ DeviceProDTO? deviceProDTOGZMS = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RgvCraneAutoStatus" && x.DeviceProParamType == "RgvCraneAutoStatus");
+ int GZMS = RGVGetLine(speStackerCrane, deviceProDTOGZMS.DeviceProAddress);
+
+ DeviceProDTO? deviceProDTORWZT = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGV_Rgvtaskstutas" && x.DeviceProParamType == "RGV_Rgvtaskstutas");
+ int RWZT = RGVGetLine(speStackerCrane, deviceProDTORWZT.DeviceProAddress);
+
+ DeviceProDTO? deviceProDTOBJGC = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVStepprocess" && x.DeviceProParamType == "RGVStepprocess");
+ int BJGC = RGVGetLine(speStackerCrane, deviceProDTOBJGC.DeviceProAddress);
+
+ DeviceProDTO? deviceProDTOWZ = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVCurrentlocation" && x.DeviceProParamType == "RGVCurrentlocation");
+ int WZ = RGVGetLine(speStackerCrane, deviceProDTOWZ.DeviceProAddress);
+
+
+ if (GZMS == 1 && RWZT == 0 && BJGC == 0)
+ {
+ return WZ;
+ }
+ else
+ {
+ return 0;
+ }
+
+ }
+
+ public static bool Mucheywhaddres(string DeviceCode)
+ {
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceCode);
+ SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
+
+ DeviceProDTO? deviceProDTO = Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeviceCode && x.DeviceProParamName == "RgvEquipmentStatus" && x.DeviceProParamType == "RgvEquipmentStatus");
+ int MCGStatus = RGVGetLine(Commonstacker, deviceProDTO.DeviceProAddress);
+ if (MCGStatus == (int)RgvEquipmentStatus.NoCargo)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// RGV璁惧鐘舵��
+ /// </summary>
+ public enum RgvEquipmentStatus
+ {
+ /// <summary>
+ /// 鏃犺揣
+ /// </summary>
+ [Description("鏃犺揣")]
+ NoCargo,
+ /// <summary>
+ /// 鏈夎揣
+ /// </summary>
+ [Description("鏈夎揣")]
+ HasCargo,
+ /// <summary>
+ /// 鏈煡
+ /// </summary>
+ [Description("鏈煡")]
+ Unkonw = 6
+
+ }
+
+ /// <summary>
+ /// 浼犲叆璁惧锛岃幏鍙栧綋鍓嶄綅缃綅缃�
+ /// </summary>
+ /// <param name="ChildPosiDeviceCode">璁惧</param>
+ /// <returns></returns>
+ public static int GetEquipmentlocation(string ChildPosiDeviceCode)
+ {
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
+ SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
+ if (speStackerCrane == null) return 0;
+ DeviceProDTO? deviceProDTO = speStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == ChildPosiDeviceCode && x.DeviceProParamName == "RGVCurrentlocation" && x.DeviceProParamType == "RGVCurrentlocation");
+ int MCGStatus = RGVGetLine(speStackerCrane, deviceProDTO.DeviceProAddress);
+ return MCGStatus;
+ }
+
+ public static int RGVGetLine(SpeStackerCrane Commonstacker, string DeviceProDataBlock)
+ {
+ return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
+ }
+
+ /// <summary>
+ /// 鑾峰彇鍒板瓙杞︿綅缃�
+ /// </summary>
+ /// <param name="commonstacker"></param>
+ /// <param name="deviceCode"></param>
+ /// <returns></returns>
+
+ private int GetzicheWZ(SpeStackerCrane commonstacker, string deviceCode)
+ {
+ DeviceProDTO? RGVCurrentlocation = RgvOperationService.GetRGVDeviceProDTO(commonstacker, commonstacker.DeviceCode, "RGVCurrentlocation", "RGVCurrentlocation");
+ return RgvOperationService.GetLine(commonstacker, RGVCurrentlocation.DeviceProAddress);
}
@@ -838,6 +1519,170 @@
return webResponse.Error("璁惧鎿嶄綔澶辫触");
}
}
+
+ /// <summary>
+ /// 鏌ョ湅鎶ヨ
+ /// </summary>
+ public WebResponseContent LogAlarmToDatabase(string JobDeviceName)
+ {
+ // 璁惧鍒嗙被 - 鍚堝苟鐗堟湰
+ var deviceCategories = new Dictionary<string, List<string>>
+ {
+ ["MotherCar"] = new List<string> { "RGV112", "RGV110", "RGV114", "RGV115", "RGV103", "RGV105", "RGV108", "RGV109" },
+ ["TransferCar"] = new List<string> { "RGV116", "RGV111", "RGV104", "RGV107" },
+ ["ExternalRGV"] = new List<string> { "RGV118", "RGV101" }
+ };
+
+ WebResponseContent webResponse = new WebResponseContent();
+ string DeviceName = JobDeviceName; //璁惧鍚嶇О
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
+ if (device == null) return webResponse.Error();
+ SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
+ DeviceProDTO? RGV_Resetoperation = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Faultcode", "ReadDeviceCommand");
+ DeviceProDTO? RGVCurrentlocation = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGVCurrentlocation", "RGVCurrentlocation");
+ DeviceProDTO? RGV_Rgvtaskid = RgvOperationService.GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Rgvtaskid", "ReadDeviceCommand");
+
+
+ int baoj = RgvOperationService.GetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress);
+
+ if (baoj<=0)
+ {
+ return null;
+ }
+ int Currentlocation = RgvOperationService.GetLine(Commonstacker, RGVCurrentlocation.DeviceProAddress);
+ int Rgvtaskid = RgvOperationService.GetLine(Commonstacker, RGV_Rgvtaskid.DeviceProAddress);
+
+ string alarmMessage = "";
+ if (deviceCategories["MotherCar"].Contains(DeviceName))
+ {
+ // 姣嶈溅涓撶敤鎶ヨ澶勭悊閫昏緫
+ alarmMessage = HandleMotherCarAlarm(baoj);
+ }
+ else if (deviceCategories["TransferCar"].Contains(DeviceName))
+ {
+ // 瀛愯溅涓撶敤鎶ヨ澶勭悊閫昏緫
+ alarmMessage = HandleTransferCarAlarm(baoj);
+ }
+ else if (deviceCategories["ExternalRGV"].Contains(DeviceName))
+ {
+ // 澶栧彛RGV涓撶敤鎶ヨ澶勭悊閫昏緫
+ alarmMessage = HandleExternalRGVAlarm(baoj);
+ }
+
+ // 鍐欏叆鏂囨湰鏃ュ織锛堟寜璁惧鍒嗙粍/鎸夋棩鍒囧垎锛�
+ var logContent = $"璁惧:{DeviceName} | 鎶ヨ鐮�:{baoj} | 鎶ヨ鎻忚堪:{alarmMessage} | 褰撳墠浣嶇疆:{Currentlocation} | 浠诲姟鍙�:{Rgvtaskid}";
+ // groupName: Alarm锛宭ogName: 璁惧鍚�
+ WriteLog.Write_Log("Alarm", DeviceName, logContent, new
+ {
+ DeviceCode = DeviceName,
+ AlarmCode = baoj,
+ AlarmContent = alarmMessage,
+ DeviceLocation = Currentlocation,
+ TaskNum = Rgvtaskid,
+ Time = DateTime.Now
+ });
+ return webResponse.OK();
+ }
+
+
+ // 鎶ヨ浠g爜鏄犲皠鏂规硶
+ private string HandleExternalRGVAlarm(int alarmCode)
+ {
+ var alarmMessages = new Dictionary<int, string>
+{
+ {0, "鏃犳姤璀�"},
+ {1, "RGV灏忚溅鎬ュ仠琚寜涓�"},
+ {2, "姝h浆闆疯揪鎶ヨ"},
+ {3, "鍙嶈浆闆疯揪鎶ヨ"},
+ {4, "鍓嶈繘闄愪綅鎶ヨ"},
+ {5, "鍚庨��闄愪綅鎶ヨ"},
+ {6, ""},
+ {7, "PLC妯″潡鏁呴殰"},
+ {8, "PLC鎵╁睍妯″潡鏁呴殰"},
+ {9, "绉伴噸妯″潡鏁呴殰"},
+ {10, "鎵爜瀹氫綅鏁呴殰"},
+ {11, "RGV闀挎椂闂寸┖杞晠闅�"},
+ {12, "鐩殑鍦颁笉绛変簬瀹為檯浣嶇疆鏁呴殰"},
+ {13, "涓庢�绘帶閫氳鏁呴殰"},
+ {14, "鍓嶉浄杈惧睆钄借鍛�"},
+ {15, "鍚庨浄杈惧睆钄借鍛�"},
+ {16, "琛岃蛋鍙橀鍣ㄦ晠闅�"},
+ {17, "浼哥缉鍙夊彉棰戝櫒鏁呴殰"},
+ {18, "娑插帇鍗曞厓杩囪浇淇濇姢鏁呴殰"},
+ {19, "娑插帇涓婂崌瓒呮椂鎶ヨ"},
+ {20, "娑插帇涓嬮檷瓒呮椂鎶ヨ"},
+ {21, "浼哥缉鍙変几鍑鸿秴鏃舵姤璀�"},
+ {22, "浼哥缉鍙夌缉鍥炶秴鏃舵姤璀�"},
+ {23, "澶栧舰妫�娴嬫姤璀�"},
+ {24, "绉伴噸瓒呴噸鎶ヨ"},
+ {25, "璐у弶浼稿嚭鏋侀檺闄愪綅鎶ヨ"},
+ {26, "璐у弶缂╁洖鏋侀檺闄愪綅鎶ヨ"},
+ {27, "鍙栬揣鏃惰嚜韬湁璐х墿鎶ヨ"},
+ {28, "鏀捐揣鏃惰嚜韬棤璐х墿鎶ヨ"},
+ {29, "璐у弶鏈洖鍒板垵濮嬩綅鎶ヨ"},
+ {30, "瑙﹀彂浠呯Щ鍔ㄥ懡浠ゆ椂璐у弶涓嶅湪鍒濆浣嶆姤璀�"},
+ {31, "璐у弶鍒拌揪鍒濆浣嶄絾涓綅浼犳劅鍣ㄦ湭妫�娴嬪埌鎶ヨ"},
+ {32, "琛岃蛋杞存病鍒颁綅绂佹璐у弶浼稿嚭"},
+ {33, "鍙栬揣寮傚父鎶ヨ"},
+ {34, "鏀捐揣寮傚父鎶ヨ"},
+ {35, "澶栧瀷妫�娴�-鍓嶈秴鍑烘姤璀�"},
+ {36, "澶栧瀷妫�娴�-鍚庤秴鍑烘姤璀�"},
+ {37, "澶栧瀷妫�娴�-宸﹁秴鍑烘姤璀�"},
+ {38, "澶栧瀷妫�娴�-鍙宠秴鍑烘姤璀�"},
+ {39, "澶栧瀷妫�娴�-涓婅秴鍑烘姤璀�"}
+};
+
+ return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "鏈煡鎶ヨ浠g爜";
+ }
+
+
+ private string HandleTransferCarAlarm(int alarmCode)
+ {
+ var alarmMessages = new Dictionary<int, string>
+ {
+ {0, "鏃犳姤璀�"},
+ {1, "RGV灏忚溅鎬ュ仠琚寜涓�"},
+ {2, "鍓嶈繘闄愪綅鎶ヨ"},
+ {3, "鍚庨��闄愪綅鎶ヨ"},
+ {4, "PLC鎽稿潡鏁呴殰"},
+ {5, "PLC鎵╁睍妯″潡鏁呴殰"},
+ {6, "鎵爜瀹氫綅鏁呴殰"},
+ {7, "RGV闀挎椂闂寸┖杞晠闅�"},
+ {8, "鐩殑鍦颁笉绛変簬瀹為檯浣嶇疆鏁呴殰"},
+ {9, "涓庢�绘帶閫氳鏁呴殰"},
+ {10, "琛岃蛋鍙橀鍣ㄦ晠闅�"},
+ {11, "娑插帇鍗曞厓杩囪浇淇濇姢鏁呴殰"},
+ {12, "娑插帇涓婂崌瓒呮椂鎶ヨ"},
+ {13, "娑插帇涓嬮檷瓒呮椂鎶ヨ"},
+ {14, "鍙栬揣鏃惰嚜韬湁璐х墿鎶ヨ"},
+ {15, "鏀捐揣鏃惰嚜韬棤璐х墿鎶ヨ"},
+ {16, "鍙栬揣妫�娴嬩笉鍒拌揣鐗╂姤璀�"}
+ };
+
+ return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "鏈煡鎶ヨ浠g爜";
+ }
+
+ private string HandleMotherCarAlarm(int alarmCode)
+ {
+ var alarmMessages = new Dictionary<int, string>
+ {
+ {0, "鏃犳姤璀�"},
+ {1, "RGV灏忚溅鎬ュ仠琚寜涓�"},
+ {2, "鍓嶈繘闄愪綅鎶ヨ"},
+ {3, "鍚庨��闄愪綅鎶ヨ"},
+ {4, "PLC鎽稿潡鏁呴殰"},
+ {5, "PLC鎵╁睍妯″潡鏁呴殰"},
+ {6, "RGV闀挎椂闂寸┖杞晠闅�"},
+ {7, "鐩殑鍦颁笉绛変簬瀹為檯浣嶇疆鏁呴殰"},
+ {8, "涓庢�绘帶閫氳鏁呴殰"},
+ {9, "琛岃蛋鍙橀鍣ㄦ晠闅�"},
+ {10, "鍙栬揣鏃惰嚜韬湁璐х墿鎶ヨ"},
+ {11, "鏀捐揣鏃惰嚜韬棤璐х墿鎶ヨ"},
+ {12, "鍋滄鏃朵綅缃繃鍐叉姤璀�"}
+ };
+
+ return alarmMessages.ContainsKey(alarmCode) ? alarmMessages[alarmCode] : "鏈煡鎶ヨ浠g爜";
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3