using HTCoreServiceApp.Communicate.DriverSiemensS7;
using HTCoreServiceApp.Communicate.AllenBradleyEIP;
using HTCoreServiceApp.DriverInterface;
using HTCoreServiceApp.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HTCoreServiceApp.Common;
using Newtonsoft.Json.Linq;
using System.Net;
using HTCoreServiceApp.Communicate.ModbusTcp;
//using HTCoreServiceApp.Communicate.OpcUaClient;
using HTCoreServiceApp.Communicate.Modbus;
using HTCoreServiceApp.Communicate.AllenBradleyEIPTag;

namespace HTCoreServiceApp.Communicate
{
    public class CommunicationAdapter
    {
        //List<Argument> argument, List<MetaGroup> metaGroups, List<MetaTag> metaTags  
        public static IDriverEntity GetAdapter(TagGroup tagGroup) 
        {
            var argument = tagGroup.Arguments;
            var driverType = argument.Where(x=>x.PropertyName == "DriverType").First().PropertyValue;
            switch (driverType)
            {
                case "DriverSiemensS7":
                    return new S7ClientExample(tagGroup);
                    break;
                case "AllenBradleyEIP":
                    return new ABClientExample(tagGroup);
                    break;
                case "ModbusTcp":
                    return new ModbusTcpClientExample(tagGroup);
                    break;
                //case "OpcUaClient":
                //    return new OpcUaClientExample(tagGroup);
                //    break;
				case "Modbus":
					return new ModbusClientExample(tagGroup);
					break;
				case "AllenBradleyEIPTag":
					return new ABTagClientExample(tagGroup);
					break;
			}
            return new S7ClientExample(tagGroup);
        }
    }
}
