You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.5 KiB
C#

using Rs.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Commom
{
/// <summary>
/// 重排
/// </summary>
public static class RearrangeManager
{
public static List<TurnoverInfo> GeneralRearrangeTask(TurnoverType fromtray, TurnoverType totray, RsTray tray, TraySlot slot,int floor)
{
int needTakeNum = 0;
List<TurnoverInfo> task = new List<TurnoverInfo>();
//首先判断总列数是奇数还是偶数
if (tray.ColumnNum % 2 == 0)//偶数
{
if (slot.Column+1 > tray.ColumnNum/2)
{
needTakeNum = tray.ColumnNum - slot.Column;
}
else
{
needTakeNum = slot.Column;
}
}
//找到要搬运的行的第一个和最后一个
int last = slot.Index + (tray.ColumnNum - (slot.Column + 1));
int first = slot.Index - slot.Column;
for( int i=0;i<needTakeNum;i++)
{
TurnoverInfo ti = new TurnoverInfo();
ti.Instruction = EInstruction.LoadAndUnload;
ti.FromType = fromtray;
ti.FromIndex = first-1 + i;
ti.FromFloor= floor;
ti.ToType = totray;
ti.ToIndex = last - 1-i;
task.Add(ti);
}
return task;
}
}
}