using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob;
using WIDESEA_Common.Log;
using System.Xml.Linq;
using SixLabors.ImageSharp;
namespace WIDESEAWCS_Tasks.StackerCraneJob
{
public class GetDeviceAddress
{
///
/// 传入设备,获取当前位置位置
///
/// 设备
///
public static int GetEquipmentlocation(string ChildPosiDeviceCode)
{
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
return getStackerObject.RGVCurrentlocation;
}
///
/// 传入设备,返回当前设备信息
///
/// 设备
///
public static int GetEquipmentInformation(string ChildPosiDeviceCode)
{
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
{
return getStackerObject.RGVCurrentlocation;
}
else
{
return 0;
}
}
///
/// 传入设备,返回当前设备信息(入库母车,需要加入是否有货判断)
///
/// 设备
///
public static int GetEquipmentInMuche(string ChildPosiDeviceCode)
{
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction && getStackerObject.RgvCraneStatusValue == RgvEquipmentStatus.NoCargo)
{
return getStackerObject.RGVCurrentlocation;
}
else
{
return 0;
}
}
///
/// 传入设备编号,判断设备状态是否可进入
///
///
///
public static bool ReturnCurrentStatus(string ChildPosiDeviceCode)
{
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
{
return true;
}
else
{
return false;
}
}
///
/// 查询HCJ站台设备
///
///
///
///
///
public static DeviceProDTO? GetDeviceProDTO(CommonStackerCrane Commonstacker, string SCAddress, string Interactivet)
{
return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "ReadDeviceCommand");
}
///
/// 查询RGV设备
///
///
///
///
///
public static DeviceProDTO? GetRGVDeviceProDTO(SpeStackerCrane Commonstacker, string SCAddress, string Interactivet)
{
return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "ReadDeviceCommand");
}
///
/// 读取设备信息
///
///
///
///
public static int GetLine(CommonStackerCrane Commonstacker, string DeviceProDataBlock)
{
return Commonstacker.Communicator.Read(DeviceProDataBlock);
}
public static int RGVGetLine(SpeStackerCrane Commonstacker, string DeviceProDataBlock)
{
return Commonstacker.Communicator.Read(DeviceProDataBlock);
}
///
/// 日志记录
///
/// 设备名称
/// 文件名称
/// 日志类型
/// 内容
public void wcsWriteLog(string SCLLinStack,string Filename, string Logtype, string Magessadd)
{
WriteLog.Write_Log(SCLLinStack, Filename, Logtype, new { 信息 = Magessadd });
}
///
/// 传入站台编号,判断是否有货
///
/// 站台编号
public static bool HCJIsstock(string Platformnumber)
{
//获取需要区分是否去入库与去不合格载货台任务
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "HCJ2000");
CommonStackerCrane Commonstacker = (CommonStackerCrane)device;
DeviceProDTO? deviceProDTO = GetDeviceProDTO(Commonstacker, Platformnumber.ToString(), "HCJ_GoodsStatus");
int HCJGStatus = GetLine(Commonstacker, deviceProDTO.DeviceProAddress);
if (HCJGStatus == 0) //为无货
{
return true;
}
else
{
return false;
}
}
}
}