using DoWhatPlc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace DtWebApi
{
    public partial  class ReadWritePLC
    {
        /// <summary>
        ///<add key="9" value="EngineTypeID"/>
		///<add key = "10" value="EngineID"/>
		///<add key = "11" value="EngineType"/>
		///<add key = "80" value="PartPalletCode"/>
		///<add key = "22" value="PalletInfo"/>
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="EngineTypeID">9</param>
        /// <param name="EngineType">11</param>
        /// <param name="EngineID">10</param>
        /// <param name="PartPallet_Code">80</param>
        public static void GetEngineTypeFromPLC(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code)
        {
            EngineTypeID = 0;
            EngineID = "-2";
            EngineType = "-2";
            PartPallet_Code = 0;

            List<string> tagTypeCodeIDList = new List<string>();
            List<string> opNameList = new List<string>();
            tagTypeCodeIDList.Add("9");
            opNameList.Add(opName);
            tagTypeCodeIDList.Add("10");
            opNameList.Add(opName);
            tagTypeCodeIDList.Add("11");
            opNameList.Add(opName);
            tagTypeCodeIDList.Add("80");
            opNameList.Add(opName);
            List<ReturnValueObject> roList = ReadPLC(tagTypeCodeIDList, opNameList);
            foreach(var item in roList)
            {
                switch(item.TagTypeCodeID)
                {
                    case "9":
                        EngineTypeID = Convert.ToInt32( item.TagValue);
                        break;
                    case "10":
                        EngineID = item.TagValue.ToString();
                        break;
                    case "11":
                        EngineType = item.TagValue.ToString();
                        break;
                    case "80":
                        PartPallet_Code = Convert.ToInt32(item.TagValue);
                        break;
                }
            }
        }
    }
}
