using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace iSTP_Embedded
{
    public static class EmbeddedError
    {
        private static List<string> Fulltext = new List<string>();
        private static List<string> ShortText = new List<string>();
        private static List<string> Source = new List<string>();
        private static State_e State;

        public enum State_e
        {
            Normal,
            Critical
        }

        public static bool isActive { get; private set; }

        public static void Add(string source, string shortText, string fullText, bool iscritical = false)
        {
            Fulltext.Add(fullText);
            ShortText.Add(shortText);
            Source.Add(source);
            isActive = true;

            if (iscritical)
                State = State_e.Critical;
            else
                State = State_e.Normal;
        }

        public static State_e GetMsg(out List<string[]> errors)
        {
            isActive = false;
            errors = new List<string[]>();
            for (int i = 0; i < Fulltext.Count; i++ )
                errors.Add(new string[]
                {
                    string.Format("Climatic chamber controller: Source[{0}] -> ShortText = {1}", Source[i], ShortText[i]),
                    string.Format("Climatic chamber controller: Source[{0}] -> ShortText = {1} -> FullText = {2}", Source[i], ShortText[i], Fulltext[i])
                });

            Source.Clear();
            ShortText.Clear();
            Fulltext.Clear();

            return State;
        }
    }
}
