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

namespace IOB_WIN_MBUS
{
    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.MODBUS_TCP:
                        iobObj = new IobModbusTCP.ModbusTCP(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_CEDAX:
                        iobObj = new IobModbusTCP.ModbusTCPCedax(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_CENTERFRIGO:
                        iobObj = new IobModbusTCP.ModbusTCPCenterfrigo(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_FIMAT:
                        iobObj = new IobModbusTCP.ModbusTCPFimat(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_FRER:
                        iobObj = new IobModbusTCP.ModbusTCPFrer(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_HAM:
                        iobObj = new IobModbusTCP.ModbusTCPHam(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_HELPI:
                        iobObj = new IobModbusTCP.ModbusTCPHelpi(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_IMAS_AEROMEC:
                        iobObj = new IobModbusTCP.ModbusTCPImaxAeromec(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_RIMOR:
                        iobObj = new IobModbusTCP.ModbusTCPRimor(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_SAIM:
                        iobObj = new IobModbusTCP.ModbusTCPSaim(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.MODBUS_TCP_ZETAPACK:
                        iobObj = new IobModbusTCP.ModbusTCPZetapack(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();
            }
        }
    }
}
