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

namespace AR.Device
{

    public class CSequence : AR.StateMachineSequence
    {
        public CSequence(int stepLen = 255) : base(stepLen) { }

        public void Clear(ESMStep idx)
        {
            base.Clear((int)idx);
        }
        public int Get(ESMStep idx)
        {
            return base.Get((int)idx);
        }

        public void Set(ESMStep idx, byte value)
        {
            base.Set((int)idx, value);
        }


        public void Update(ESMStep idx, int incValue = 1)
        {
            base.Update((int)idx, incValue);
        }
        public TimeSpan GetTime(ESMStep idx = 0)
        {
            return base.GetTime((int)idx);
        }
        public int GetData(ESMStep idx)
        {
            return base.GetData((int)idx);
        }
        public void ClearData(ESMStep idx) { base.ClearData((int)idx); }
        public void AddData(ESMStep idx, byte value = 1)
        {
            base.AddData((int)idx, value);
        }
        public void SetData(ESMStep idx, byte value)
        {
            _runseqdata[(int)idx] = value;
        }
    }

    public class CStateMachine : AR.StateMachine
    {
        /// <summary>
        /// Sequece Value / data
        /// </summary>
        public CSequence seq;
        public ESMStep PrePauseStep = ESMStep.NOTSET;
        public CStateMachine()
        {
            seq = new CSequence(255);
        }

        public new ESMStep Step { get { return (ESMStep)base.Step; } }
        public void SetNewStep(ESMStep newstep_, Boolean force = false)
        {
            //일시중지라면 중지전의 상태를 백업한다
            if (newstep_ == ESMStep.PAUSE && this.Step != ESMStep.PAUSE && this.Step != ESMStep.WAITSTART) PrePauseStep = this.Step;
            base.SetNewStep((byte)newstep_, force);
        }

        public new ESMStep getNewStep
        {
            get
            {
                return (ESMStep)newstep_;
            }
        }
        public new ESMStep getOldStep
        {
            get
            {
                return (ESMStep)oldstep_;
            }
        }
    }
}
