using IOB_UT_NEXT;
using IOB_WIN_OPC_UA.Iob;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IOB_WIN_OPC_UA
{
    public class AdapterFormNext: IOB_WIN_FORM.AdapterForm
    {

        /// <summary>
        /// Avvio MainForm
        /// </summary>
        /// <param name="codIOB"></param>
        public AdapterFormNext(string codIOB): base(codIOB)
        {
        }
        /// <summary>
        /// carica IOB richiesto
        /// </summary>
        protected override async Task loadIobType()
        {
            if (IOBConfFull != null)
            {
                switch (tipoScelto)
                {

                    case tipoAdapter.OpcUa:
                        iobObj = new IobOpc.OpcUa(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaCMS:
                    case tipoAdapter.OpcUaSCM:
                        iobObj = new IobOpc.OpcUaCMS(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaEwon:
                        iobObj = new IobOpc.OpcUaEwon(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaEwonAdige:
                        iobObj = new IobOpc.OpcUaEwonAdige(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaEwonBLM:
                        iobObj = new IobOpc.OpcUaEwonBLM(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaEwonMonti:
                        iobObj = new IobOpc.OpcUaEwonMonti(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaEwonMecolpress:
                        iobObj = new IobOpc.OpcUaEwonMecolpress(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaKwp:
                        iobObj = new IobOpc.OpcUaKpw(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaKwpRama:
                        iobObj = new IobOpc.OpcUaKpwRama(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaImasAeromec:
                        iobObj = new IobOpc.OpcUaImas(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaMBH:
                        iobObj = new IobOpc.OpcUaMBH(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaMBHCimolai:
                        iobObj = new IobOpc.OpcUaMBHCimolai(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaOmron:
                        iobObj = new IobOpc.OpcUaOmron(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaOmronGhidini:
                        iobObj = new IobOpc.OpcUaOmronGhidini(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaOmronIcoel:
                        iobObj = new IobOpc.OpcUaOmronIcoel(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaSiemens:
                        iobObj = new IobOpc.OpcUaSiemens(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaSiemensOMP:
                        iobObj = new IobOpc.OpcUaSiemensOMP(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaSiemensRama:
                        iobObj = new IobOpc.OpcUaSiemensRama(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaSiemensSW:
                        iobObj = new IobOpc.OpcUaSiemensSW(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.OpcUaUlma:
                        iobObj = new IobOpc.OpcUaUlma(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIMULA:
                    case tipoAdapter.ND:
                    default:
                        iobObj = new IOB_WIN_FORM.Iob.Simula(this, IOBConfFull);
                        btnStart.Enabled = false;
                        break;
                }
                if (!await iobInitAsync())
                {
                    return;
                }
                UpdateDisplTypeIobSel();
            }
        }
    }
}
