using Masuit.Tools;
using PVDEMCS.Common.Constant;

namespace PVDEMCS
{
    public class Test
    {
        public static void CreateData(DateTime startDateTime, string id, Action<string, string, DateTime> action)
        {
            var states = new string[] { EquipmentState.Run, EquipmentState.Stop, EquipmentState.Alarm };
            var random = new Random();
            while (true)
            {
                var val1 = random.Next(states.Length);
                if (val1 == states.Length)
                {
                    val1 -= 1;
                }
                //state
                var state = states[val1];
                //当前时间
                var dt = startDateTime.AddSeconds(random.Next(500, 25000));
                if (dt >= DateTime.Now)
                {
                    break;
                }
                action?.Invoke(id, state, dt);
                startDateTime = dt;
                Thread.Sleep(10);
            }
        }

    }
}
