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

namespace IOB_WIN_SIEMENS
{
    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.SIEMENS:
                        iobObj = new IobSiemens.Siemens(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_APROCHIM:
                        iobObj = new IobSiemens.SiemensAprochim(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_AT2001:
                        iobObj = new IobSiemens.SiemensAt2001(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_COMECA:
                        iobObj = new IobSiemens.SiemensComeca(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_COMUR:
                        iobObj = new IobSiemens.SiemensComur(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_COSMAP:
                        iobObj = new IobSiemens.SiemensCosmap(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_FAPE:
                        iobObj = new IobSiemens.SiemensFape(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_FAPE_2:
                        iobObj = new IobSiemens.SiemensFapeV2(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_INGENIA:
                        iobObj = new IobSiemens.SiemensIngenia(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_LASCO:
                        iobObj = new IobSiemens.SiemensLasco(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_NWSE:
                        iobObj = new IobSiemens.SiemensNWSE(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_PRESSOIL_CEI:
                        iobObj = new IobSiemens.SiemensPressoilCei(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_ROBOTSERVICE:
                        iobObj = new IobSiemens.SiemensRobotService(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_SAET:
                        iobObj = new IobSiemens.SiemensSaet(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_SIMEC:
                        iobObj = new IobSiemens.SiemensSimec(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIEMENS_TORRI:
                        iobObj = new IobSiemens.SiemensTorri(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();
            }
        }
    }
}
