using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_DTO.PlacedBlockDTO;
|
using WIDESEAWCS_DTO.TaskInfo;
|
using WIDESEAWCS_IBasicInfoService;
|
|
namespace WIDESEAWCS_BasicInfoService
|
{
|
public class ExceptionPlaceBlockService
|
{
|
public ContainerSize ContainerSize { get; private set; }
|
|
/// <summary>
|
/// 最小横向Y坐标限制(毫米)
|
/// </summary>
|
public static int MinY = AppSettings.GetValue("MinY").ObjToInt();
|
|
/// <summary>
|
/// 最大Y坐标限制(毫米)
|
/// </summary>
|
public const int MaxY = 600;
|
|
public ExceptionPlaceBlockService(ContainerSize containerSize)
|
{
|
ContainerSize = containerSize;
|
}
|
|
public TaskPosition ExceptionPlaceBlock(int length, int width, int height, int count)
|
{
|
int tempLength = length;
|
int tempWidth = width;
|
if (length < width)
|
{
|
length = tempWidth;
|
width = tempLength;
|
}
|
|
int takePositionX = 0;
|
int takePositionY = 0;
|
int takePositionZ = 0;
|
int putPositionX = 0;
|
int putPositionY = 0;
|
int putPositionZ = 0;
|
|
Point3D deviceCenter = new Point3D(530 / 2, 920 / 2, 0);
|
if (length <= 920) //横向双吸
|
{
|
deviceCenter = new Point3D(530 / 2, 130 / 2, 0);
|
}
|
|
takePositionX = width / 2 - deviceCenter.X - MinY / 2;
|
takePositionY = length / 2 - deviceCenter.Y;
|
takePositionZ = 10;
|
|
putPositionX = ContainerSize.Width / 2 - deviceCenter.X;
|
putPositionY = takePositionY;
|
putPositionZ = count * height;
|
|
if (takePositionY < MinY)
|
{
|
takePositionY = 0;
|
putPositionY = MinY;
|
}
|
else if (putPositionY > MaxY)
|
{
|
int moreY = putPositionY - MaxY;
|
if (takePositionY - moreY > 0)
|
{
|
takePositionY -= moreY;
|
putPositionY = MaxY;
|
}
|
}
|
|
TaskPosition taskPosition = new TaskPosition()
|
{
|
PositionR = 1,
|
TakePositionX = takePositionX,
|
TakePositionY = takePositionY,
|
TakePositionZ = takePositionZ,
|
PutPositionX = putPositionX,
|
PutPositionY = putPositionY,
|
PutPositionZ = putPositionZ,
|
TakeCenterPositionX = takePositionX,
|
TakeCenterPositionY = takePositionY,
|
TakeCenterPositionZ = takePositionZ,
|
PutCenterPositionX = putPositionX,
|
PutCenterPositionY = putPositionY,
|
PutCenterPositionZ = putPositionZ,
|
PositionX = putPositionX,
|
PositionY = putPositionY,
|
PositionZ = putPositionZ
|
};
|
|
return taskPosition;
|
}
|
}
|
}
|