using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Common.TaskEnum;
|
|
namespace WIDESEAWCS_Common.TaskEnum
|
{
|
public static class TaskEnumHelper
|
{
|
public static List<int> GetEnumIndexList(this Type type)
|
{
|
if (type is null) throw new ArgumentNullException("type");
|
if (!type.IsEnum) return new List<int>();
|
return Enum.GetValues(type).Cast<int>().ToList();
|
}
|
|
public static TaskTypeGroup GetTaskTypeGroup(this int taskType)
|
{
|
if (!int.TryParse(Enum.Parse<TaskAGVCarryTypeEnum>(taskType.ToString()).ToString(), out int result))
|
{
|
return TaskTypeGroup.CarryGroup;
|
}
|
else
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public static TaskStateGroup GetTaskStateGroup(this int taskState)
|
{
|
if (!int.TryParse(Enum.Parse<TaskAGVCarryStatusEnum>(taskState.ToString()).ToString(), out int result))
|
{
|
return TaskStateGroup.CarryGroup;
|
}
|
else
|
{
|
throw new NotImplementedException();
|
}
|
}
|
|
public static int GetNextNotCompletedStatus<T>(this int currentStatus) where T : Enum
|
{
|
Type type = typeof(T);
|
if (type is null) throw new ArgumentNullException();
|
if (!type.IsEnum) return 0;
|
if (type == typeof(TaskAGVCarryStatusEnum))
|
{
|
return type.GetEnumIndexList().Where(x => x > currentStatus && x < (int)TaskAGVCarryStatusEnum.AGV_CarryFinish).OrderBy(x => x).FirstOrDefault();
|
}
|
else
|
{
|
throw new NotImplementedException();
|
}
|
}
|
}
|
}
|