using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.Input;
using HBLConsole.Service;
using System.Threading;
using HBLConsole.Business.Devices;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using HBLConsole.Communication;
using HBLConsole.Model;

namespace HBLConsole.ViewModel
{
    public class DebugViewModel : ViewModelBase
    {
        public DebugViewModel()
        {
            WindowName = "调试模式";
            SimOrderCommand = new RelayCommand(() => { ActionManagerment.GetInstance.Send("SimOrder"); });

            InitCommand = new RelayCommand(() => { MORKS.GetInstance.DeviceInit(); });
            ProcessCondition();
            ThreadManagerment.GetInstance.StartLong(new Action(() =>
            {
                NoodleCount = MORKS.GetInstance.mORKS.RBTakeNoodleTask.Count;
                BowlCount = MORKS.GetInstance.mORKS.TakeBowlTask.Count;
                Thread.Sleep(1000);
            }), "数据监控");
        }

        private void ProcessCondition()
        {
            ProcessConditions process = new ProcessConditions();
            process.ProcessTitl = "机器人";
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = false });
            processConditions.Add(process);

            process = new ProcessConditions();
            process.ProcessTitl = "取完机构";
            process.Conditions.Add(new Condition() { ConditionName = "机器人空闲", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "温度到达", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "取面中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "取碗中", ConditionMet = false });
            process.Conditions.Add(new Condition() { ConditionName = "到面中", ConditionMet = true });
            process.Conditions.Add(new Condition() { ConditionName = "出餐中", ConditionMet = true });
            processConditions.Add(process);
        }


        public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
        private static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
        {
            StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
        }


        public RelayCommand SimOrderCommand { get; set; }

        public RelayCommand InitCommand { get; set; }

        public static int NoodleCount { get { return _mNoodleCount; } set { _mNoodleCount = value; OnStaticPropertyChanged(); } }
        private static int _mNoodleCount;


        public static int BowlCount { get { return _mBowlCount; } set { _mBowlCount = value; OnStaticPropertyChanged(); } }
        private static int _mBowlCount;



    }
}
