#region << 版 本 注 释 >>
|
/*----------------------------------------------------------------
|
* 命名空间:WIDESEAWCS_TaskInfoService
|
* 创建者:胡童庆
|
* 创建时间:2024/8/2 16:13:36
|
* 版本:V1.0.0
|
* 描述:
|
*
|
* ----------------------------------------------------------------
|
* 修改人:
|
* 修改时间:
|
* 版本:V1.0.1
|
* 修改说明:
|
*
|
*----------------------------------------------------------------*/
|
#endregion << 版 本 注 释 >>
|
|
using AutoMapper;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using NetTaste;
|
using Newtonsoft.Json;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Diagnostics;
|
using System.Diagnostics.CodeAnalysis;
|
using System.Linq;
|
using System.Linq.Expressions;
|
using System.Reflection;
|
using System.Reflection.Metadata;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Comm.Http;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.BaseServices;
|
using WIDESEAWCS_Core.Enums;
|
using WIDESEAWCS_DTO.Enum;
|
using WIDESEAWCS_DTO.TaskInfo;
|
using WIDESEAWCS_ITaskInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob.DTO;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_QuartzJob.Service;
|
using System.Net;
|
using WIDESEAWCS_ISystemServices;
|
|
namespace WIDESEAWCS_TaskInfoService
|
{
|
public class RgvOperationService : ServiceBase<Dt_Task_hty, ITask_HtyRepository>, IRgvOperationService
|
{
|
private readonly IAgvStationService _gvStationService;
|
public RgvOperationService(ITask_HtyRepository BaseDal, IAgvStationService agvStationService) : base(BaseDal)
|
{
|
_gvStationService = agvStationService;
|
}
|
|
|
public WebResponseContent WriteInitialization(SaveModel saveModel)
|
{
|
WebResponseContent webResponse = new WebResponseContent();
|
|
string DeviceName = saveModel.DelKeys[0].ToString(); //设备名称
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
|
SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
|
|
//获取实例
|
DeviceProDTO? RGV_RGVtasktypet = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_RGVtasktypet", "DeviceCommand"); //任务类型
|
//第一步写入任务
|
RgvSetLine(Commonstacker, RGV_RGVtasktypet.DeviceProAddress, (short)3);
|
|
//复位报警
|
DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Resetoperation", "DeviceCommand"); //复位报警信息
|
RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)1);
|
|
//写入自动
|
DeviceProDTO? RGV_DWorkingmode = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand"); //任务id
|
RgvSetLine(Commonstacker, RGV_DWorkingmode.DeviceProAddress, (short)1);
|
|
//写入清除任务
|
RgvSetLine(Commonstacker, RGV_RGVtasktypet.DeviceProAddress, (short)4);
|
|
//反馈确认任务
|
DeviceProDTO? RGV_taskcomplete = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_taskcomplete", "RGV_taskcomplete"); //任务id
|
RgvSetLine(Commonstacker, RGV_taskcomplete.DeviceProAddress, (short)1);
|
|
return webResponse.OK();
|
}
|
|
public WebResponseContent WriteRGVmokuai(SaveModel saveModel)
|
{
|
WebResponseContent webResponse = new WebResponseContent();
|
string DeviceName = saveModel.DelKeys[0].ToString(); //工作类型
|
string DBType = saveModel.DelKeys[1].ToString(); //设备名称
|
short WriteRGVvalue = short.Parse(saveModel.DelKeys[2].ToString()); //写入值
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
|
SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
|
switch (DBType)
|
{
|
case "1": // 工作模式(0手动、1自动)
|
//获取实例
|
DeviceProDTO? RGV_DWorkingmode = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_DWorkingmode", "DeviceCommand"); //任务类型
|
//第一步写入任务
|
RgvSetLine(Commonstacker, RGV_DWorkingmode.DeviceProAddress, WriteRGVvalue);
|
break;
|
case "2": //复位操作(0不复位、1复位)
|
DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Resetoperation", "DeviceCommand"); //任务类型
|
//第一步写入任务
|
RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, WriteRGVvalue);
|
break;
|
case "3": //任务确认完成(0不确定,1确定)
|
DeviceProDTO? RGV_taskcomplete = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_taskcomplete", "RGV_taskcomplete"); //任务类型
|
//第一步写入任务
|
RgvSetLine(Commonstacker, RGV_taskcomplete.DeviceProAddress, WriteRGVvalue);
|
break;
|
case "4": //任务类型(4清除)
|
DeviceProDTO? RGV_RGVtasktypet = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_RGVtasktypet", "DeviceCommand"); //任务类型
|
//第一步写入任务
|
RgvSetLine(Commonstacker, RGV_RGVtasktypet.DeviceProAddress, WriteRGVvalue);
|
break;
|
}
|
return webResponse.OK();
|
}
|
|
/// <summary>
|
/// 手动移动RGV
|
/// </summary>
|
/// <param name="saveModel"></param>
|
/// <returns></returns>
|
public WebResponseContent ManualmovementRGV(SaveModel saveModel)
|
{
|
WebResponseContent webResponse = new WebResponseContent();
|
|
string DeviceName = saveModel.DelKeys[0].ToString(); //设备名称
|
short Nextaddres = short.Parse(saveModel.DelKeys[1].ToString());
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
|
SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
|
|
//获取实例
|
DeviceProDTO? RGV_RGVtasktypet = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_RGVtasktypet", "DeviceCommand"); //任务类型
|
//第一步写入任务
|
RgvSetLine(Commonstacker, RGV_RGVtasktypet.DeviceProAddress, (short)3);
|
|
//目标位置
|
DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_RGVTasklocationt", "DeviceCommand"); //复位报警信息
|
RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)Nextaddres);
|
|
//写入自动
|
DeviceProDTO? RGV_DWorkingmode = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Rgvtaskidt", "DeviceCommand"); //任务id
|
//任务id
|
RgvSetLine(Commonstacker, RGV_DWorkingmode.DeviceProAddress, (short)30001);
|
|
//任务id
|
DeviceProDTO? RGV_taskcomplete = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Lanjiantaskidt", "DeviceCommand"); //任务id
|
RgvSetLine(Commonstacker, RGV_taskcomplete.DeviceProAddress, (short)30001);
|
|
|
return webResponse.OK();
|
}
|
|
/// <summary>
|
/// 写入复位(入库端)
|
/// </summary>
|
public WebResponseContent WriteInReset(SaveModel saveModel)
|
{
|
WebResponseContent webResponse = new WebResponseContent();
|
|
List<AGVStation> rgvdata = _gvStationService.GetInStroller();
|
foreach (AGVStation rgvstation in rgvdata)
|
{
|
string DeviceName = saveModel.DelKeys[0].ToString(); //设备名称
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
|
if (device == null) continue;
|
SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
|
|
//获取需要复位的设备
|
DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Resetoperation", "DeviceCommand"); //复位报警信息
|
RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)1);
|
}
|
return webResponse.OK();
|
}
|
|
/// <summary>
|
/// 写入复位(出库端)
|
/// </summary>
|
public WebResponseContent WriteOutReset(SaveModel saveModel)
|
{
|
WebResponseContent webResponse = new WebResponseContent();
|
List<AGVStation> rgvdata = _gvStationService.GetOutStroller();
|
foreach (AGVStation rgvstation in rgvdata)
|
{
|
string DeviceName = rgvstation.ChildPosiDeviceCode; //设备名称
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == DeviceName);
|
if (device == null) continue;
|
SpeStackerCrane Commonstacker = (SpeStackerCrane)device;
|
|
//获取需要复位的设备
|
DeviceProDTO? RGV_Resetoperation = GetRGVDeviceProDTO(Commonstacker, DeviceName, "RGV_Resetoperation", "DeviceCommand"); //复位报警信息
|
RgvSetLine(Commonstacker, RGV_Resetoperation.DeviceProAddress, (short)1);
|
}
|
return webResponse.OK();
|
}
|
|
|
|
/// <summary>
|
/// 查询RGV设备
|
/// </summary>
|
/// <param name="Commonstacker"></param>
|
/// <param name="SCAddress"></param>
|
/// <param name="Interactivet"></param>
|
/// <returns></returns>
|
public static DeviceProDTO? GetRGVDeviceProDTO(SpeStackerCrane Commonstacker, string SCAddress, string DeviceProParamName, string DeviceProParamType)
|
{
|
return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == DeviceProParamName && x.DeviceProParamType == DeviceProParamType);
|
}
|
/// <summary>
|
/// 读取设备信息
|
/// </summary>
|
/// <param name="conveyorLine"></param>
|
/// <param name="DeviceProDataBlock"></param>
|
/// <returns></returns>
|
public static int GetLine(CommonConveyorLine Commonstacker, string DeviceProDataBlock)
|
{
|
return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
|
}
|
|
/// <summary>
|
/// 写入设备信息
|
/// </summary>
|
/// <param name="conveyorLine"></param>
|
/// <param name="DeviceProDataBlock"></param>
|
/// <returns></returns>
|
public static bool RgvSetLine(SpeStackerCrane Commonstacker, string DeviceProDataBlock, short rgvvalues)
|
{
|
return Commonstacker.Communicator.Write<short>(DeviceProDataBlock, rgvvalues);
|
}
|
|
|
|
}
|
}
|