using DbCommon.Enties.DbModels;
using ProjectManagementSystem.Device.CommandCallback;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectManagementSystem.DispatchPack
{
    public static class StationInfoTools
    {
        public static byte GetDBAgvId(this StationInfo info)
        {
            return info.Online ? (byte)info.AgvId : (byte)0;
        }

        public static byte GetDBRunValues(this StationInfo info)
        {
            if(!info.Online)
            {
                return (byte)DBRunValues.Unknow;
            }

            if(info.HasCar)
            {
                return (byte)DBRunValues.StopOnStation;
            }

            if(info.AgvStausValue == (byte)EnumInfoAgvStatus.运行)
            {
                return (byte)DBRunValues.Running;
            }

            if (info.AgvStausValue == (byte)EnumInfoAgvStatus.暂停)
            {
                return (byte)DBRunValues.Pause;
            }

            return (byte)DBRunValues.Unknow;
        }

        public static byte GetDBAgvFalut(this StationInfo info)
        {
            return info.Online ? info.AgvAlarm : (byte)0;
        }
    }

    public enum DBControlValues : int
    {
        NoAction = 0,
        OKRelease = 1,
        NGRelease = 2,
        StopImmediate = 3,
        StopRelease = 4
    }
    public enum DBRunValues : byte
    {
        Unknow = 0,
        Running = 1,
        Pause = 2,
        StopOnStation = 3,
        EmergencyStop = 4
    }
}
