using EgwProxy.MultiCncLib.CNC;

namespace IOB_WIN_FANUC
{
    /// <summary>
    /// Definizione indirizzo memoria FANUC
    /// </summary>
    public class memAddressFanuc
    {
        #region Public Fields

        /// <summary>
        /// Posizione memoria
        /// </summary>
        public int mPos;

        /// <summary>
        /// Tipo memoria
        /// </summary>
        public FANUC.MemType mType;

        /// <summary>
        /// Tipo valore
        /// </summary>
        public string vType;

        #endregion Public Fields

        #region Public Constructors

        /// <summary>
        /// Inizializza da un formato stringa
        /// </summary>
        /// <param name="strFormat">Stringa TipoMem.Indice.DimMem (es D.1604.DW)</param>
        public memAddressFanuc(string strFormat)
        {
            if (!string.IsNullOrEmpty(strFormat))
            {
                string[] memComp = strFormat.Split('.');
                switch (memComp[0])
                {
                    case "A":
                        mType = FANUC.MemType.A;
                        break;

                    case "C":
                        mType = FANUC.MemType.C;
                        break;

                    case "CM":
                        mType = FANUC.MemType.CM;
                        break;

                    case "D":
                        mType = FANUC.MemType.D;
                        break;

                    case "E":
                        mType = FANUC.MemType.E;
                        break;

                    case "F":
                        mType = FANUC.MemType.F;
                        break;

                    case "G":
                        mType = FANUC.MemType.G;
                        break;

                    case "K":
                        mType = FANUC.MemType.K;
                        break;

                    case "M":
                        mType = FANUC.MemType.M;
                        break;

                    case "N":
                        mType = FANUC.MemType.N;
                        break;

                    case "R":
                        mType = FANUC.MemType.R;
                        break;

                    case "T":
                        mType = FANUC.MemType.T;
                        break;

                    case "X":
                        mType = FANUC.MemType.X;
                        break;

                    case "Y":
                        mType = FANUC.MemType.Y;
                        break;

                    case "Z":
                        mType = FANUC.MemType.Z;
                        break;

                    default:
                        break;
                }
                int.TryParse(memComp[1], out mPos);
                vType = memComp[2];
            }
        }

        #endregion Public Constructors
    }

    /// <summary>
    /// Definizione area memoria FANUC
    /// </summary>
    public class memAreaFanuc
    {
        #region Public Fields

        /// <summary>
        /// Nome area memoria
        /// </summary>
        public string areaName = "";

        /// <summary>
        /// Dimensione array memoria
        /// </summary>
        public int arraySize = 0;

        /// <summary>
        /// Indice inizio array
        /// </summary>
        public int startIdx = 0;

        #endregion Public Fields
    }

}