#region << 版 本 注 释 >>
|
/*----------------------------------------------------------------
|
* 命名空间:WIDESEAWCS_Tasks.ConveyorLineJob
|
* 创建者:胡童庆
|
* 创建时间:2024/8/2 16:13:36
|
* 版本:V1.0.0
|
* 描述:
|
*
|
* ----------------------------------------------------------------
|
* 修改人:
|
* 修改时间:
|
* 版本:V1.0.1
|
* 修改说明:
|
*
|
*----------------------------------------------------------------*/
|
#endregion << 版 本 注 释 >>
|
|
using AutoMapper;
|
using HslCommunication;
|
using Microsoft.Extensions.Logging;
|
using Newtonsoft.Json;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
using Quartz;
|
using SixLabors.ImageSharp.Drawing;
|
using SqlSugar;
|
using System.Diagnostics.CodeAnalysis;
|
using System.Reflection;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_BasicInfoRepository;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core.Caches;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_Core.HttpContextUser;
|
using WIDESEAWCS_DTO.Enum;
|
using WIDESEAWCS_IBasicInfoRepository;
|
using WIDESEAWCS_IBasicInfoService;
|
using WIDESEAWCS_ITaskInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.BasicInfo;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_QuartzJob.DeviceBase;
|
using WIDESEAWCS_QuartzJob.DTO;
|
using WIDESEAWCS_QuartzJob.Models;
|
using WIDESEAWCS_QuartzJob.Service;
|
using WIDESEAWCS_SignalR;
|
using WIDESEAWCS_TaskInfoRepository;
|
using WIDESEAWCS_Tasks.ConveyorLineJob;
|
using WIDESEAWCS_Tasks.RGVJob;
|
using WIDESEAWCS_Tasks.StackerCraneJob;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
[DisallowConcurrentExecution]
|
public class CommonRGV_FirstFloorJob : JobBase, IJob
|
{
|
private readonly ITaskService _taskService;
|
private readonly ITask_HtyRepository _task_HtyRepository;
|
private readonly ITaskRepository _taskRepository;
|
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
|
private readonly IRouterService _routerService;
|
private readonly IDt_StationManagerService _stationManagerService;
|
private readonly IDt_StationManagerRepository _stationManagerRepository;
|
private readonly IMapper _mapper;
|
private readonly WIDESEAWCS_Core.Caches.ICacheService _cacheService;
|
private readonly INoticeService _noticeService;
|
private static List<string>? userTokenIds;
|
private static List<int>? userIds;
|
|
public CommonRGV_FirstFloorJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IDt_StationManagerService stationManagerService, IMapper mapper, WIDESEAWCS_Core.Caches.ICacheService cacheService, INoticeService noticeService, ITaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ITask_HtyRepository task_HtyRepository)
|
{
|
_taskService = taskService;
|
_taskExecuteDetailService = taskExecuteDetailService;
|
_routerService = routerService;
|
_stationManagerService = stationManagerService;
|
_mapper = mapper;
|
_cacheService = cacheService;
|
_noticeService = noticeService;
|
_taskRepository = taskRepository;
|
_stationManagerRepository = stationManagerRepository;
|
_task_HtyRepository = task_HtyRepository;
|
}
|
|
public Task Execute(IJobExecutionContext context)
|
{
|
//Console.WriteLine(DateTime.Now.ToString() + ",线程ID:" + Thread.CurrentThread.ManagedThreadId);
|
try
|
{
|
//用这种方式能确保类型转换不会有问题
|
//bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
|
|
//if (flag && value != null && value is CommonRGV_FirstFloor device)
|
//{
|
IDevice? commonRGVFirst = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "RGV01");
|
IDevice? commonRGVSecond = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "RGV02");
|
|
#region RGV01调度
|
if (commonRGVFirst != null && commonRGVFirst is CommonRGV_FirstFloor FirstRgv)//这样能看出来传参到底哪里有问题
|
{
|
if (FirstRgv.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.WorkCompleted))
|
{
|
RGVTaskFinish(FirstRgv, FirstRgv.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum));
|
}
|
if (FirstRgv.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !FirstRgv.GetValue<RGVDBName, bool>(RGVDBName.Fault) && !FirstRgv.GetValue<RGVDBName, bool>(RGVDBName.Running))
|
{
|
Dt_Task? task = GetTask(FirstRgv, FirstRgv.GetValue<RGVDBName, bool>(RGVDBName.InStock));
|
if (task != null)
|
{
|
var IsExecutingTask = DispatchExecutingTask(FirstRgv, task);
|
if (IsExecutingTask != null)
|
{
|
RGVTaskCommand? rgvTaskCommand = ConvertToRGVTaskCommand(IsExecutingTask);
|
if (rgvTaskCommand != null)
|
{
|
Thread.Sleep(1000);
|
bool sendFlag = SendCommand(FirstRgv, rgvTaskCommand);
|
if (sendFlag)
|
{
|
if (IsExecutingTask.Remark != null)
|
{
|
IsExecutingTask.RGVName = "RGV02";
|
IsExecutingTask.CurrentAddress = IsExecutingTask.Remark;
|
IsExecutingTask.Remark = "";
|
Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == IsExecutingTask.NextAddress);
|
IsExecutingTask.SourceStation = IsExecutingTask.CurrentAddress=="1025"?10:7;
|
if (IsExecutingTask.TaskType == (int)TaskInboundTypeEnum.Inbound)
|
{
|
IsExecutingTask.TargetStation = station.stationRemark;
|
}
|
else
|
{
|
IsExecutingTask.TargetStation = station.remark;
|
}
|
IsExecutingTask.TaskState = (int)TaskInStatusEnum.RGV_TransFer;
|
_taskRepository.UpdateData(IsExecutingTask);
|
Thread.Sleep(1000);
|
}
|
else
|
{
|
IsExecutingTask.RGVName = FirstRgv.DeviceCode;
|
_taskRepository.UpdateData(IsExecutingTask);
|
_taskService.UpdateTaskStatusToNext(IsExecutingTask.TaskNum);
|
Thread.Sleep(1000);
|
}
|
}
|
}
|
}
|
}
|
else
|
{
|
Dt_Task taskNew = null;
|
taskNew = GetTransFerTask(FirstRgv);
|
if (taskNew == null)
|
{
|
taskNew = DispatchTask(FirstRgv);
|
}
|
if (taskNew != null)
|
{
|
RGVTaskCommand? rgvTaskCommand = ConvertToRGVTaskCommand(taskNew);
|
if (rgvTaskCommand != null)
|
{
|
Thread.Sleep(1000);
|
bool sendFlag = SendCommand(FirstRgv, rgvTaskCommand);
|
if (sendFlag)
|
{
|
if (taskNew.TaskState == (int)TaskInStatusEnum.RGV_TransFerFInish)
|
{
|
taskNew.TaskState = (int)TaskInStatusEnum.RGV_InExecuting;
|
_taskRepository.UpdateData(taskNew);
|
Thread.Sleep(1000);
|
}
|
else if (taskNew.TaskState == (int)TaskOutStatusEnum.RGV_TransFerFInish)
|
{
|
taskNew.TaskState = (int)TaskOutStatusEnum.RGV_OutExecuting;
|
_taskRepository.UpdateData(taskNew);
|
Thread.Sleep(1000);
|
}
|
else if (taskNew.Remark != null)
|
{
|
taskNew.RGVName = "RGV02";
|
taskNew.CurrentAddress = taskNew.Remark;
|
taskNew.Remark = "";
|
taskNew.TaskState = (int)TaskOutStatusEnum.RGV_TransFer;
|
Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == taskNew.NextAddress);
|
taskNew.SourceStation = taskNew.CurrentAddress == "1025" ? 10 : 7;
|
if (taskNew.TaskType == (int)TaskInboundTypeEnum.Inbound)
|
{
|
taskNew.TargetStation = station.stationRemark;
|
}
|
else
|
{
|
taskNew.TargetStation = station.remark;
|
}
|
_taskRepository.UpdateData(taskNew);
|
Thread.Sleep(1000);
|
}
|
else
|
{
|
taskNew.RGVName = FirstRgv.DeviceCode;
|
_taskRepository.UpdateData(taskNew);
|
_taskService.UpdateTaskStatusToNext(taskNew.TaskNum);
|
Thread.Sleep(1000);
|
}
|
}
|
}
|
}
|
}
|
}
|
#region 调用事件总线通知前端
|
|
var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken");
|
if (tokenInfos != null && tokenInfos.Any())
|
{
|
var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList();
|
var userIds = tokenInfos?.Select(x => x.UserId).ToList();
|
string RGVAutoStatus(bool AutoStatus) => AutoStatus switch
|
{
|
true => "联机模式",
|
false => "单机模式",
|
};
|
string RGVWorkStatus(bool WorkStatus) => WorkStatus switch
|
{
|
true => "运行中",
|
false => "待机",
|
};
|
string RGVStatus(bool Status) => Status switch
|
{
|
true => "故障",
|
false => "正常",
|
};
|
object obj = new
|
{
|
Automatic = RGVAutoStatus(FirstRgv.GetValue<RGVDBName, bool>(RGVDBName.Automatic)),
|
Fault = RGVStatus(FirstRgv.GetValue<RGVDBName, bool>(RGVDBName.Fault)),
|
Running = RGVWorkStatus(FirstRgv.GetValue<RGVDBName, bool>(RGVDBName.Running)),
|
LevelPoint = FirstRgv.GetValue<RGVDBName, int>(RGVDBName.LevelPoint),
|
CurrentTaskNum = FirstRgv.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum),
|
RGVAlarm = FirstRgv.GetValue<RGVDBName, uint>(RGVDBName.RGVAlarm),
|
FirstRgv.DeviceCode,
|
FirstRgv.DeviceName,
|
};
|
_noticeService.RGVData(userIds?.FirstOrDefault(), userTokenIds, new { FirstRgv.DeviceName, data = obj });
|
}
|
|
|
#endregion 调用事件总线通知前端
|
}
|
else
|
{
|
//if (commonRGVFirst == null)
|
// Console.WriteLine($"RGV01未找到设备对象的值");
|
//else
|
// Console.WriteLine($"RGV01设备对象类型错误");
|
}
|
|
#endregion
|
|
#region RGV02调度
|
if (commonRGVSecond != null && commonRGVSecond is CommonRGV_FirstFloor SecondRgv)//这样能看出来传参到底哪里有问题
|
{
|
if (SecondRgv.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.WorkCompleted))
|
{
|
RGVTaskFinish(SecondRgv, SecondRgv.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum));
|
}
|
if (SecondRgv.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !SecondRgv.GetValue<RGVDBName, bool>(RGVDBName.Fault) && !SecondRgv.GetValue<RGVDBName, bool>(RGVDBName.Running))
|
{
|
Dt_Task? task = GetTask(SecondRgv, SecondRgv.GetValue<RGVDBName, bool>(RGVDBName.InStock));
|
if (task != null)
|
{
|
var IsExecutingTask = DispatchExecutingTask(SecondRgv, task);
|
if (IsExecutingTask != null)
|
{
|
RGVTaskCommand? rgvTaskCommand = ConvertToRGVTaskCommand(IsExecutingTask);
|
if (rgvTaskCommand != null)
|
{
|
Thread.Sleep(1000);
|
bool sendFlag = SendCommand(SecondRgv, rgvTaskCommand);
|
if (sendFlag)
|
{
|
if (IsExecutingTask.Remark != null)
|
{
|
IsExecutingTask.RGVName = "RGV01";
|
IsExecutingTask.CurrentAddress = IsExecutingTask.Remark;
|
IsExecutingTask.Remark = "";
|
IsExecutingTask.TaskState = (int)TaskInStatusEnum.RGV_TransFer;
|
_taskRepository.UpdateData(IsExecutingTask);
|
Thread.Sleep(1000);
|
}
|
else
|
{
|
IsExecutingTask.RGVName = SecondRgv.DeviceCode;
|
_taskRepository.UpdateData(IsExecutingTask);
|
_taskService.UpdateTaskStatusToNext(IsExecutingTask.TaskNum);
|
Thread.Sleep(1000);
|
}
|
}
|
}
|
}
|
}
|
else
|
{
|
Dt_Task taskNew = null;
|
taskNew = GetTransFerTask(SecondRgv);
|
if (taskNew == null)
|
{
|
taskNew = DispatchTask(SecondRgv);
|
}
|
|
if (taskNew != null)
|
{
|
RGVTaskCommand? rgvTaskCommand = ConvertToRGVTaskCommand(taskNew);
|
if (rgvTaskCommand != null)
|
{
|
Thread.Sleep(1000);
|
bool sendFlag = SendCommand(SecondRgv, rgvTaskCommand);
|
if (sendFlag)
|
{
|
if (taskNew.TaskState == (int)TaskInStatusEnum.RGV_TransFerFInish)
|
{
|
taskNew.TaskState = (int)TaskInStatusEnum.RGV_InExecuting;
|
_taskRepository.UpdateData(taskNew);
|
Thread.Sleep(1000);
|
}
|
else if (taskNew.TaskState == (int)TaskOutStatusEnum.RGV_TransFerFInish)
|
{
|
taskNew.TaskState = (int)TaskOutStatusEnum.RGV_OutExecuting;
|
_taskRepository.UpdateData(taskNew);
|
Thread.Sleep(1000);
|
}
|
else if (taskNew.Remark != null)
|
{
|
taskNew.RGVName = "RGV01";
|
taskNew.CurrentAddress = taskNew.Remark;
|
taskNew.Remark = "";
|
taskNew.TaskState = (int)TaskOutStatusEnum.RGV_TransFer;
|
_taskRepository.UpdateData(taskNew);
|
Thread.Sleep(1000);
|
}
|
else
|
{
|
taskNew.RGVName = SecondRgv.DeviceCode;
|
_taskRepository.UpdateData(taskNew);
|
_taskService.UpdateTaskStatusToNext(taskNew.TaskNum);
|
Thread.Sleep(1000);
|
}
|
}
|
}
|
}
|
}
|
}
|
#region 调用事件总线通知前端
|
|
var tokenInfos = _cacheService.Get<List<UserInfo>>("Cache_UserToken");
|
if (tokenInfos != null && tokenInfos.Any())
|
{
|
var userTokenIds = tokenInfos?.Select(x => x.Token_ID).ToList();
|
var userIds = tokenInfos?.Select(x => x.UserId).ToList();
|
string RGVAutoStatus(bool AutoStatus) => AutoStatus switch
|
{
|
true => "联机模式",
|
false => "单机模式",
|
};
|
string RGVWorkStatus(bool WorkStatus) => WorkStatus switch
|
{
|
true => "运行中",
|
false => "待机",
|
};
|
string RGVStatus(bool Status) => Status switch
|
{
|
true => "故障",
|
false => "正常",
|
};
|
object obj = new
|
{
|
Automatic = RGVAutoStatus(SecondRgv.GetValue<RGVDBName, bool>(RGVDBName.Automatic)),
|
Fault = RGVStatus(SecondRgv.GetValue<RGVDBName, bool>(RGVDBName.Fault)),
|
Running = RGVWorkStatus(SecondRgv.GetValue<RGVDBName, bool>(RGVDBName.Running)),
|
LevelPoint = SecondRgv.GetValue<RGVDBName, int>(RGVDBName.LevelPoint),
|
CurrentTaskNum = SecondRgv.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum),
|
RGVAlarm = SecondRgv.GetValue<RGVDBName, uint>(RGVDBName.RGVAlarm),
|
SecondRgv.DeviceCode,
|
SecondRgv.DeviceName,
|
};
|
_noticeService.RGVData(userIds?.FirstOrDefault(), userTokenIds, new { SecondRgv.DeviceName, data = obj });
|
}
|
|
|
#endregion 调用事件总线通知前端
|
}
|
else
|
{
|
//if (commonRGVSecond == null)
|
// Console.WriteLine($"RGV02未找到设备对象的值");
|
//else
|
// Console.WriteLine($"RGV02设备对象类型错误");
|
}
|
#endregion
|
//}
|
}
|
catch (Exception ex)
|
{
|
WriteError("CommonStackerStationCraneJob", "test", ex);
|
}
|
return Task.CompletedTask;
|
}
|
|
public Dt_Task DispatchExecutingTask(CommonRGV_FirstFloor commonRGV, Dt_Task task)
|
{
|
try
|
{
|
if (commonRGV.DeviceCode == "RGV01")
|
{
|
CommonRGV_FirstFloor? commonRGVSecond = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "RGV02") as CommonRGV_FirstFloor;
|
if (commonRGVSecond != null)
|
{
|
if (commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault))
|
{
|
var taskSecond = _taskRepository.QueryFirst(x => x.RGVName == "RGV02" && x.TaskNum == commonRGVSecond.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum) && ((x.TaskType == (int)TaskInboundTypeEnum.Inbound && x.TaskState < 230) || (x.TaskType == (int)TaskOutboundTypeEnum.Outbound)));
|
if (taskSecond != null)
|
{
|
if (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_Indispatch || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_InAwaitWMS || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || task.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
if (task.TargetStation- taskSecond.SourceStation > 1 && task.TargetStation - taskSecond.TargetStation > 1)
|
{
|
LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
|
if (task.Remark != null)
|
{
|
return GetDispatchExecutingTask(taskSecond);
|
}
|
|
return task;
|
}
|
}
|
}
|
else if (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
|
{
|
if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || task.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
if (task.TargetStation - taskSecond.TargetStation > 1)
|
{
|
LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
if (task.Remark != null)
|
{
|
return GetDispatchExecutingTask(taskSecond);
|
}
|
return task;
|
}
|
}
|
}
|
return null;
|
}
|
else
|
{
|
if (commonRGVSecond.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) > 35000)
|
{
|
RGVTaskCommand command = new RGVTaskCommand()
|
{
|
PickupLocation = (byte)Convert.ToSByte(15),
|
TaskNum = Convert.ToInt16(1000),
|
TaskType = (byte)Convert.ToSByte(1)
|
};
|
SendCommand(commonRGVSecond, command);
|
}
|
LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
return task;
|
}
|
}
|
}
|
return task;
|
}
|
else
|
{
|
CommonRGV_FirstFloor? commonRGVFirst = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "RGV01") as CommonRGV_FirstFloor;
|
if (commonRGVFirst != null)
|
{
|
|
if (commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault))
|
{
|
var taskSecond = _taskRepository.QueryFirst(x => x.RGVName == "RGV01" && x.TaskNum == commonRGVFirst.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum)&&((x.TaskType==(int)TaskInboundTypeEnum.Inbound&&x.TaskState<230)||(x.TaskType == (int)TaskOutboundTypeEnum.Outbound)));
|
if (taskSecond != null)
|
{
|
|
if (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_Indispatch || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_InAwaitWMS || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || task.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
if (taskSecond.SourceStation - task.TargetStation > 1 && taskSecond.TargetStation - task.TargetStation > 1)
|
{
|
LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
|
if (task.Remark != null)
|
{
|
return GetDispatchExecutingTask(taskSecond);
|
}
|
return task;
|
}
|
}
|
}
|
else if (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
|
{
|
if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || task.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
if (taskSecond.TargetStation - task.TargetStation > 1)
|
{
|
LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
|
if (task.Remark != null)
|
{
|
return GetDispatchExecutingTask(taskSecond);
|
}
|
return task;
|
}
|
}
|
}
|
return null;
|
}
|
else
|
{
|
if (commonRGVFirst.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) < 420000)
|
{
|
RGVTaskCommand command = new RGVTaskCommand()
|
{
|
PickupLocation = (byte)Convert.ToSByte(26),
|
TaskNum = Convert.ToInt16(1000),
|
TaskType = (byte)Convert.ToSByte(1)
|
};
|
SendCommand(commonRGVFirst, command);
|
}
|
LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
return task;
|
}
|
}
|
}
|
return task;
|
}
|
}
|
catch (Exception ex)
|
{
|
WriteInfo("调度任务异常日志", ex.Message + Environment.NewLine + ex.StackTrace);
|
return null;
|
}
|
}
|
|
public Dt_Task DispatchTask(CommonRGV_FirstFloor commonRGV)
|
{
|
try
|
{
|
var tasks = _taskService.QueryRGVTask();
|
Dt_Task task;
|
if (tasks.Count() == 0)
|
{
|
return null;
|
}
|
if (commonRGV.DeviceCode == "RGV01")
|
{
|
CommonRGV_FirstFloor? commonRGVSecond = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "RGV02") as CommonRGV_FirstFloor;
|
if (commonRGVSecond != null)
|
{
|
if (commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault))
|
{
|
var taskSecond = _taskRepository.QueryFirst(x => x.RGVName == "RGV02" && x.TaskNum == commonRGVSecond.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum));
|
if (taskSecond != null)
|
{
|
#region
|
//if (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
//{
|
|
// //task = tasks.FirstOrDefault(x =>(x.SourceStation- taskSecond.TargetStation > 1 && x.SourceStation - taskSecond.SourceStation > 1&&x.TaskType==(int)TaskInboundTypeEnum.Inbound) ||(x.SourceStation - taskSecond.TargetStation > 1 && x.TargetStation - taskSecond.SourceStation > 1 && x.SourceStation - taskSecond.SourceStation > 1 && x.TargetStation - taskSecond.TargetStation > 1&&x.TaskType== (int)TaskOutboundTypeEnum.Outbound));
|
// //if (task == null)
|
// //{
|
// // task = tasks.FirstOrDefault(x => (x.SourceStation - taskSecond.TargetStation > 1 && x.SourceStation - taskSecond.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - taskSecond.TargetStation > 1 && x.TargetStation - taskSecond.SourceStation > 1 && x.SourceStation - taskSecond.SourceStation > 1 && x.TargetStation - taskSecond.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
|
// //}
|
|
// task = GetDispatchTask(tasks, taskSecond);
|
|
// LogAndWarn("执行调度任务控制", $"【{commonRGVSecond.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
|
// Thread.Sleep(1000);
|
// return task;
|
//}
|
//else if (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
|
//{
|
// task = tasks.FirstOrDefault(x => x.SourceStation - taskSecond.TargetStation> 1 &&x.TargetStation - taskSecond.TargetStation > 1);
|
|
// LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
// Thread.Sleep(1000);
|
// return task;
|
//}
|
//return null;
|
#endregion
|
|
task = GetDispatchTask(tasks, taskSecond);
|
|
LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
|
return task;
|
}
|
else
|
{
|
var taskNews = tasks.Where(x => (x.TaskType == (int)TaskInboundTypeEnum.Inbound && Convert.ToInt32(x.SourceAddress) < 1015) || (x.TaskType == (int)TaskOutboundTypeEnum.Outbound && (x.Roadway == "SC01" || x.Roadway == "SC02" || x.Roadway == "SC03"))||x.RGVName=="RGV01").ToList();
|
if (taskNews.Count== 0)
|
{
|
return null;
|
}
|
|
if (commonRGVSecond.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) > 35000)
|
{
|
RGVTaskCommand command = new RGVTaskCommand()
|
{
|
PickupLocation = (byte)Convert.ToSByte(15),
|
TaskNum = Convert.ToInt16(1000),
|
TaskType = (byte)Convert.ToSByte(1)
|
};
|
SendCommand(commonRGVSecond, command);
|
}
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV01") != null)
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVSecond.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV01").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return taskNews.FirstOrDefault(x => x.RGVName == "RGV01");
|
}
|
else
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVSecond.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName != "RGV02").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return taskNews.FirstOrDefault(x => x.RGVName != "RGV02");
|
}
|
}
|
}
|
else
|
{
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV01") != null)
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVSecond.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV01").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV01");
|
}
|
else
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVSecond.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName != "RGV02").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName != "RGV02");
|
}
|
}
|
}
|
else
|
{
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV01") != null)
|
{
|
LogAndWarn("调度任务控制", $"【未找到RGV02设备信息】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV01").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV01");
|
}
|
else
|
{
|
LogAndWarn("调度任务控制", $"【未找到RGV02设备信息】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName != "RGV02").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName != "RGV02");
|
}
|
}
|
}
|
else
|
{
|
CommonRGV_FirstFloor? commonRGVFirst = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "RGV01") as CommonRGV_FirstFloor;
|
if (commonRGVFirst != null)
|
{
|
if (commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault))
|
{
|
var taskFirst = _taskRepository.QueryFirst(x => x.RGVName == "RGV01" && x.TaskNum == commonRGVFirst.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum));
|
if (taskFirst != null)
|
{
|
#region
|
//if (taskFirst.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || taskFirst.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || taskFirst.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
//{
|
|
// //task = tasks.FirstOrDefault(x => (x.SourceStation - taskFirst.TargetStation > 1 && x.SourceStation - taskFirst.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - taskFirst.TargetStation > 1 && x.TargetStation - taskFirst.SourceStation > 1 && x.SourceStation - taskFirst.SourceStation > 1 && x.TargetStation - taskFirst.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
|
|
// task = GetDispatchTask(tasks, taskFirst);
|
|
// LogAndWarn("执行调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskFirst)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
// Thread.Sleep(1000);
|
|
// return task;
|
//}
|
//else if (taskFirst.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || taskFirst.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
|
//{
|
// task = tasks.FirstOrDefault(x => taskFirst.TargetStation - x.SourceStation > 1 && taskFirst.TargetStation - x.TargetStation > 1);
|
|
// LogAndWarn("执行调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskFirst)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
// Thread.Sleep(1000);
|
// return task;
|
//}
|
//return null;
|
#endregion
|
|
task = GetDispatchTask(tasks, taskFirst);
|
|
LogAndWarn("执行调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskFirst)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
|
return task;
|
}
|
else
|
{
|
var taskNews = tasks.Where(x => (x.TaskType == (int)TaskInboundTypeEnum.Inbound && Convert.ToInt32(x.SourceAddress) > 1015) || (x.TaskType == (int)TaskOutboundTypeEnum.Outbound && (x.Roadway == "SC04" || x.Roadway == "SC05" || x.Roadway == "SC06"))||x.RGVName=="RGV02").ToList();
|
if (taskNews.Count == 0)
|
{
|
return null;
|
}
|
if (commonRGVFirst.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) < 420000)
|
{
|
RGVTaskCommand command = new RGVTaskCommand()
|
{
|
PickupLocation = (byte)Convert.ToSByte(26),
|
TaskNum = Convert.ToInt16(1000),
|
TaskType = (byte)Convert.ToSByte(1)
|
};
|
SendCommand(commonRGVFirst, command);
|
}
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV02") != null)
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV02").TaskNum)}】】");
|
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV02");
|
}
|
else
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName != "RGV01").TaskNum)}】】");
|
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName != "RGV01");
|
}
|
}
|
}
|
else
|
{
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV02") != null)
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV02").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV02");
|
}
|
else
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName != "RGV01").TaskNum)}】】");
|
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName != "RGV01");
|
}
|
}
|
}
|
else
|
{
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV02") != null)
|
{
|
LogAndWarn("调度任务控制", $"【未找到RGV01设备信息】 返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV02").TaskNum)}】】");
|
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV02");
|
}
|
else
|
{
|
LogAndWarn("调度任务控制", $"【未找到RGV01设备信息】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName != "RGV01").TaskNum)}】】");
|
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName != "RGV01");
|
}
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
WriteInfo("调度任务异常日志", ex.Message+Environment.NewLine+ex.StackTrace);
|
return null;
|
}
|
}
|
|
public Dt_Task GetTransFerTask(CommonRGV_FirstFloor commonRGV)
|
{
|
try
|
{
|
var tasks = _taskRepository.QueryData(x=>x.TaskState==(int)TaskInStatusEnum.RGV_TransFerFInish|| x.TaskState == (int)TaskOutStatusEnum.RGV_TransFerFInish);
|
Dt_Task task;
|
if (tasks.Count() == 0)
|
{
|
return null;
|
}
|
if (commonRGV.DeviceCode == "RGV01")
|
{
|
CommonRGV_FirstFloor? commonRGVSecond = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "RGV02") as CommonRGV_FirstFloor;
|
if (commonRGVSecond != null)
|
{
|
if (commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault))
|
{
|
var taskSecond = _taskRepository.QueryFirst(x => x.RGVName == "RGV02" && x.TaskNum == commonRGVSecond.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum));
|
if (taskSecond != null)
|
{
|
if (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
task = tasks.FirstOrDefault(x => ((x.SourceStation - taskSecond.TargetStation > 1 && x.SourceStation - taskSecond.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - taskSecond.TargetStation > 1 && x.TargetStation - taskSecond.SourceStation > 1 && x.SourceStation - taskSecond.SourceStation > 1 && x.TargetStation - taskSecond.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound))&&x.RGVName=="RGV01");
|
|
|
LogAndWarn("执行调度任务控制", $"【{commonRGVSecond.DeviceCode}工作模式:【{commonRGV.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
|
Thread.Sleep(1000);
|
return task;
|
}
|
else if (taskSecond.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || taskSecond.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
|
{
|
task = tasks.FirstOrDefault(x => x.SourceStation - taskSecond.TargetStation > 1 && x.TargetStation - taskSecond.TargetStation > 1 && x.RGVName == "RGV01");
|
|
LogAndWarn("执行调度任务控制", $"【{commonRGV.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVSecond.DeviceCode}】任务【{JsonConvert.SerializeObject(taskSecond)}】{commonRGVSecond.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
return task;
|
}
|
return null;
|
}
|
else
|
{
|
if (commonRGVSecond.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) > 35000)
|
{
|
RGVTaskCommand command = new RGVTaskCommand()
|
{
|
PickupLocation = (byte)Convert.ToSByte(15),
|
TaskNum = Convert.ToInt16(1000),
|
TaskType = (byte)Convert.ToSByte(1)
|
};
|
SendCommand(commonRGVSecond, command);
|
}
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV01") != null)
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVSecond.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV01").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV01");
|
}
|
}
|
}
|
else
|
{
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV01") != null)
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVSecond.DeviceCode}工作模式:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVSecond.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV01").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV01");
|
}
|
|
}
|
}
|
else
|
{
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV01") != null)
|
{
|
LogAndWarn("调度任务控制", $"【未找到RGV02设备信息】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV01").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV01");
|
}
|
}
|
return null;
|
}
|
else
|
{
|
CommonRGV_FirstFloor? commonRGVFirst = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "RGV01") as CommonRGV_FirstFloor;
|
if (commonRGVFirst != null)
|
{
|
if (commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic) && !commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault))
|
{
|
var taskFirst = _taskRepository.QueryFirst(x => x.RGVName == "RGV01" && x.TaskNum == commonRGVFirst.GetValue<RGVDBName, short>(RGVDBName.RGVTaskNum));
|
if (taskFirst != null)
|
{
|
if (taskFirst.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || taskFirst.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || taskFirst.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
|
task = tasks.FirstOrDefault(x => ((x.SourceStation - taskFirst.TargetStation > 1 && x.SourceStation - taskFirst.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - taskFirst.TargetStation > 1 && x.TargetStation - taskFirst.SourceStation > 1 && x.SourceStation - taskFirst.SourceStation > 1 && x.TargetStation - taskFirst.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound))&&x.RGVName=="RGV02");
|
|
task = GetDispatchTask(tasks, taskFirst);
|
|
LogAndWarn("执行调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskFirst)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
|
return task;
|
}
|
else if (taskFirst.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || taskFirst.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
|
{
|
task = tasks.FirstOrDefault(x => taskFirst.TargetStation - x.SourceStation > 1 && taskFirst.TargetStation - x.TargetStation > 1 && x.RGVName == "RGV02");
|
|
LogAndWarn("执行调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】【{commonRGVFirst.DeviceCode}】任务【{JsonConvert.SerializeObject(taskFirst)}】{commonRGVFirst.DeviceCode}返回任务:【{JsonConvert.SerializeObject(task.TaskNum)}】】");
|
Thread.Sleep(1000);
|
return task;
|
}
|
return null;
|
}
|
else
|
{
|
if (commonRGVFirst.GetValue<RGVDBName, int>(RGVDBName.LevelPoint) < 420000)
|
{
|
RGVTaskCommand command = new RGVTaskCommand()
|
{
|
PickupLocation = (byte)Convert.ToSByte(26),
|
TaskNum = Convert.ToInt16(1000),
|
TaskType = (byte)Convert.ToSByte(1)
|
};
|
SendCommand(commonRGVFirst, command);
|
}
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV02") != null)
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV02").TaskNum)}】】");
|
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV02");
|
}
|
}
|
}
|
else
|
{
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV02") != null)
|
{
|
LogAndWarn("调度任务控制", $"【{commonRGVFirst.DeviceCode}工作模式:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Automatic)}】作业状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Running)}】设备状态:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.Fault)}】是否有货:【{commonRGVFirst.GetValue<RGVDBName, bool>(RGVDBName.InStock)}】返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV02").TaskNum)}】】");
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV02");
|
}
|
}
|
}
|
else
|
{
|
if (tasks.FirstOrDefault(x => x.RGVName == "RGV02") != null)
|
{
|
LogAndWarn("调度任务控制", $"【未找到RGV01设备信息】 返回任务:【{JsonConvert.SerializeObject(tasks.FirstOrDefault(x => x.RGVName == "RGV02").TaskNum)}】】");
|
|
Thread.Sleep(1000);
|
return tasks.FirstOrDefault(x => x.RGVName == "RGV02");
|
}
|
}
|
return null;
|
}
|
}
|
catch (Exception ex)
|
{
|
WriteInfo("调度任务异常日志", ex.Message + Environment.NewLine + ex.StackTrace);
|
return null;
|
}
|
}
|
|
/// <summary>
|
/// RGV任务完成
|
/// </summary>
|
/// <param name="commonRGV"></param>
|
/// <param name="TaskNum"></param>
|
public void RGVTaskFinish(CommonRGV_FirstFloor commonRGV, int TaskNum)
|
{
|
if (commonRGV != null)
|
{
|
WriteInfo("RGV任务完成", $"{commonRGV.DeviceName}完成任务号{TaskNum}");
|
var task = _taskRepository.QueryFirst(x => x.TaskNum == TaskNum);
|
if (task != null)
|
{
|
if (task.TaskState == (int)TaskInStatusEnum.RGV_Indispatch)
|
{
|
Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress);
|
if (stationManager != null)
|
{
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
|
if (device != null)
|
{
|
CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
|
Thread.Sleep(100);
|
DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode && x.DeviceProParamName == "ConveyorLineBarcode").FirstOrDefault();
|
|
var x = conveyorLine.Communicator.Read(devicePro.DeviceProAddress, 10);
|
|
string Barcode = Encoding.UTF8.GetString(x);
|
|
if (Barcode == null || Barcode == "" || Barcode.Trim().Contains("\0"))
|
{
|
commonRGV.SetValue(StackerCraneDBName.PutcargoLocation, Convert.ToSByte(stationManager.stationRemark));
|
commonRGV.SetValue(StackerCraneDBName.TaskNum, Convert.ToInt16(task.TaskNum));
|
commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(4));
|
|
task.ModifyDate = DateTime.Now;
|
task.Modifier = "System";
|
|
Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task);
|
task_Hty.TaskId = 0;
|
task_Hty.OperateType = (int)OperateTypeEnum.异常退回;
|
|
_taskRepository.DeleteData(task);
|
_task_HtyRepository.AddData(task_Hty);
|
return;
|
}
|
var content = _taskService.RGVTaskCompleted(TaskNum, Barcode);
|
}
|
}
|
}
|
else
|
{
|
if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting)
|
{
|
Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress && x.stationType == 7);
|
if (stationManager != null)
|
{
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
|
if (device != null)
|
{
|
CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
|
Thread.Sleep(100);
|
conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTargetAddress, Convert.ToInt16(stationManager.stationNextChildCode), stationManager.stationChildCode);
|
Thread.Sleep(100);
|
conveyorLine.SetValue(ConveyorLineDBName.ConveyorLineTaskNum, Convert.ToInt16(1000), stationManager.stationChildCode);
|
Thread.Sleep(100);
|
conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(2), stationManager.stationChildCode);
|
}
|
}
|
}
|
var content = _taskService.RGVTaskCompleted(TaskNum);
|
}
|
}
|
}
|
}
|
|
/// <summary>
|
/// 获取任务
|
/// </summary>
|
/// <param name="commonRGV">堆垛机对象</param>
|
/// <returns></returns>
|
private Dt_Task? GetTask(CommonRGV_FirstFloor commonRGV, bool InStock)
|
{
|
if (InStock)
|
{
|
return _taskService.QueryRGVExecutingTask(commonRGV.DeviceCode);
|
}
|
return null;
|
}
|
|
public Dt_Task? GetDispatchTask(List<Dt_Task> tasks, Dt_Task oldtask)
|
{
|
Dt_Task y = tasks.Where(x => x.Remark != null && ((x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound))).First();
|
if (y == null)
|
{
|
if (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || oldtask.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
|
return tasks.FirstOrDefault(x => (x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
|
}
|
else if (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || oldtask.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
|
{
|
return tasks.FirstOrDefault(x => x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.TargetStation > 1);
|
}
|
return null;
|
}
|
else
|
{
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1001");
|
if (device != null)
|
{
|
CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
|
var stationManager = _stationManagerRepository.QueryData(x => x.stationType == 15);
|
if (stationManager.Count() > 0)
|
{
|
string next = null;
|
foreach (var item in stationManager)
|
{
|
short x = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, item.stationChildCode);
|
var structs = BitConverter.GetBytes(x).ToArray().ToBoolArray();
|
if (structs[2])
|
{
|
next = item.stationChildCode;
|
break;
|
}
|
}
|
if (next != null)
|
{
|
oldtask.Remark = next;
|
_taskRepository.UpdateData(y);
|
return y;
|
}
|
}
|
}
|
if (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_Outdispatch || oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish || oldtask.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
|
return tasks.FirstOrDefault(x => (x.SourceStation - oldtask.TargetStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TaskType == (int)TaskInboundTypeEnum.Inbound) || (x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.SourceStation > 1 && x.SourceStation - oldtask.SourceStation > 1 && x.TargetStation - oldtask.TargetStation > 1 && x.TaskType == (int)TaskOutboundTypeEnum.Outbound));
|
}
|
else if (oldtask.TaskState == (int)TaskOutStatusEnum.RGV_OutExecuting || oldtask.TaskState == (int)TaskInStatusEnum.RGV_InExecuting)
|
{
|
return tasks.FirstOrDefault(x => x.SourceStation - oldtask.TargetStation > 1 && x.TargetStation - oldtask.TargetStation > 1);
|
}
|
return null;
|
}
|
}
|
|
public Dt_Task? GetDispatchExecutingTask(Dt_Task oldtask)
|
{
|
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1001");
|
if (device != null)
|
{
|
CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
|
var stationManager = _stationManagerRepository.QueryData(x => x.stationType == 15);
|
if (stationManager.Count() > 0)
|
{
|
string next = null;
|
foreach (var item in stationManager)
|
{
|
short x = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.InteractiveSignal, item.stationChildCode);
|
var structs = BitConverter.GetBytes(x).ToArray().ToBoolArray();
|
if (structs[2])
|
{
|
next = item.stationChildCode;
|
break;
|
}
|
}
|
if (next != null)
|
{
|
oldtask.Remark = next;
|
_taskRepository.UpdateData(oldtask);
|
return oldtask;
|
}
|
}
|
}
|
return null;
|
}
|
|
/// <summary>
|
/// 任务实体转换成命令Model
|
/// </summary>
|
/// <param name="task">任务实体</param>
|
/// <returns></returns>
|
/// <exception cref="Exception"></exception>
|
public RGVTaskCommand? ConvertToRGVTaskCommand([NotNull] Dt_Task task)
|
{
|
RGVTaskCommand rgvTaskCommand = new RGVTaskCommand();
|
|
rgvTaskCommand.TaskNum = Convert.ToInt16(task.TaskNum);
|
if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//判断是否是入库任务
|
{
|
if (task.TaskState == (int)TaskInStatusEnum.InNew)
|
{
|
Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.SourceAddress);
|
rgvTaskCommand.TaskType = (byte)Convert.ToSByte(3);
|
rgvTaskCommand.PickupLocation = (byte)Convert.ToSByte(stationManager.stationRemark);
|
}
|
else if (task.TaskState == (int)TaskInStatusEnum.RGV_TransFerFInish)
|
{
|
Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress);
|
Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress);
|
rgvTaskCommand.TaskType = (byte)Convert.ToSByte(5);
|
rgvTaskCommand.PickupLocation = (byte)Convert.ToSByte(stationManagerStart.stationRemark);
|
rgvTaskCommand.PutcargoLocation = (byte)Convert.ToSByte(stationManagerEnd.stationRemark);
|
}
|
else if (task.TaskState == (int)TaskInStatusEnum.RGV_IndispatchFinish)
|
{
|
if (task.Remark != null && (task.Roadway == "SC01" || task.Roadway == "SC06"))
|
{
|
Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.Remark);
|
rgvTaskCommand.TaskType = (byte)Convert.ToSByte(4);
|
rgvTaskCommand.PutcargoLocation = (byte)Convert.ToSByte(stationManager.stationRemark);
|
}
|
else
|
{
|
Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress);
|
rgvTaskCommand.TaskType = (byte)Convert.ToSByte(4);
|
rgvTaskCommand.PutcargoLocation = (byte)Convert.ToSByte(stationManager.stationRemark);
|
}
|
}
|
else
|
{
|
return null;
|
}
|
}
|
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
|
{
|
|
if (task.TaskState == (int)TaskOutStatusEnum.Line_OutFinish)
|
{
|
if (task.Remark != null && (task.Roadway == "SC01" || task.Roadway == "SC06"))
|
{
|
Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress);
|
Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.Remark);
|
rgvTaskCommand.TaskType = (byte)Convert.ToSByte(5);
|
rgvTaskCommand.PickupLocation = (byte)Convert.ToSByte(stationManagerStart.stationRemark);
|
rgvTaskCommand.PutcargoLocation = (byte)Convert.ToSByte(stationManagerEnd.stationRemark);
|
}
|
else
|
{
|
Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress);
|
rgvTaskCommand.TaskType = (byte)Convert.ToSByte(3);
|
rgvTaskCommand.PickupLocation = (byte)Convert.ToSByte(stationManager.stationRemark);
|
}
|
}
|
else if (task.TaskState == (int)TaskOutStatusEnum.RGV_TransFerFInish)
|
{
|
Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress);
|
Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress);
|
rgvTaskCommand.TaskType = (byte)Convert.ToSByte(5);
|
rgvTaskCommand.PickupLocation = (byte)Convert.ToSByte(stationManagerStart.stationRemark);
|
rgvTaskCommand.PutcargoLocation = (byte)Convert.ToSByte(stationManagerEnd.stationRemark);
|
}
|
else if (task.TaskState == (int)TaskOutStatusEnum.RGV_OutdispatchFinish)
|
{
|
Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.NextAddress);
|
rgvTaskCommand.TaskType = (byte)Convert.ToSByte(4);
|
rgvTaskCommand.PutcargoLocation = (byte)Convert.ToSByte(stationManager.stationRemark);
|
}
|
else
|
{
|
return null;
|
}
|
}
|
|
return rgvTaskCommand;
|
}
|
|
public bool SendCommand(CommonRGV_FirstFloor commonRGV, RGVTaskCommand? rgvTaskCommand)
|
{
|
commonRGV.SetValue(StackerCraneDBName.TaskNum, rgvTaskCommand.TaskNum);
|
Thread.Sleep(100);
|
commonRGV.SetValue(StackerCraneDBName.PutcargoLocation, rgvTaskCommand.PutcargoLocation);
|
Thread.Sleep(100);
|
commonRGV.SetValue(StackerCraneDBName.PickupLocation, rgvTaskCommand.PickupLocation);
|
Thread.Sleep(100);
|
commonRGV.SetValue(StackerCraneDBName.TaskType, Convert.ToSByte(rgvTaskCommand.TaskType));
|
for (int i = 0; i < 6; i++)
|
{
|
|
if (commonRGV.GetValue<StackerCraneDBName, short>(StackerCraneDBName.TaskNum) == rgvTaskCommand.TaskNum && commonRGV.GetValue<StackerCraneDBName, byte>(StackerCraneDBName.TaskType) == rgvTaskCommand.TaskType && commonRGV.GetValue<StackerCraneDBName, byte>(StackerCraneDBName.PutcargoLocation) == rgvTaskCommand.PutcargoLocation && commonRGV.GetValue<StackerCraneDBName, byte>(StackerCraneDBName.PickupLocation) == rgvTaskCommand.PickupLocation)
|
{
|
WriteInfo(commonRGV.DeviceName, $"写入任务成功写入次数{i}写入任务【{JsonConvert.SerializeObject(rgvTaskCommand)}】");
|
return true;
|
}
|
if (commonRGV.GetValue<StackerCraneDBName, short>(StackerCraneDBName.TaskNum) == rgvTaskCommand.TaskNum)
|
{
|
commonRGV.SetValue(StackerCraneDBName.TaskNum, rgvTaskCommand.TaskNum);
|
Thread.Sleep(100);
|
}
|
if (commonRGV.GetValue<StackerCraneDBName, short>(StackerCraneDBName.PutcargoLocation) == rgvTaskCommand.PutcargoLocation)
|
{
|
commonRGV.SetValue(StackerCraneDBName.PutcargoLocation, rgvTaskCommand.PutcargoLocation);
|
}
|
if (commonRGV.GetValue<StackerCraneDBName, short>(StackerCraneDBName.PickupLocation) == rgvTaskCommand.PickupLocation)
|
{
|
commonRGV.SetValue(StackerCraneDBName.PickupLocation, rgvTaskCommand.PickupLocation);
|
}
|
if (commonRGV.GetValue<StackerCraneDBName, short>(StackerCraneDBName.TaskType) == rgvTaskCommand.TaskType)
|
{
|
commonRGV.SetValue(StackerCraneDBName.TaskType, rgvTaskCommand.TaskType);
|
}
|
}
|
WriteInfo(commonRGV.DeviceName, $"RGV任务写入失败【{JsonConvert.SerializeObject(rgvTaskCommand)}】");
|
return false;
|
}
|
|
public void LogAndWarn(string deviceName, string log, string color = "red")
|
{
|
ConsoleHelper.WriteWarningLine(log);
|
_noticeService.Logs(userTokenIds, new { deviceName, log = log, time = DateTime.Now.ToString("G"), color = color });
|
WriteInfo(deviceName, log);
|
}
|
}
|
}
|