using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using AR;
namespace Project
{
    public partial class FMain
    {
        void _DIO_OUTPUT_VALUE_CHANGED(eDOName pin, Boolean value)
        {
            if (pin == eDOName.PORTL_MOT_RUN)
            {
                VAR.TIME[(int)eVarTime.JOBEVENT] = DateTime.Now;
                hmi1.arVar_Port[0].MotorRun = value;
            }
            else if (pin == eDOName.PORTC_MOT_RUN)
            {
                //VAR.TIME[(int)eVarTime.JOBEVENT] = DateTime.Now;
                hmi1.arVar_Port[1].MotorRun = value;
            }
            else if (pin == eDOName.PORTR_MOT_RUN)
            {
                VAR.TIME[(int)eVarTime.JOBEVENT] = DateTime.Now;
                hmi1.arVar_Port[2].MotorRun = value;
            }

            else if (pin == eDOName.PORTL_MOT_DIR)
            {

                hmi1.arVar_Port[0].MotorDir = !value;
            }
            else if (pin == eDOName.PORTC_MOT_DIR)
                hmi1.arVar_Port[1].MotorDir = !value;
            else if (pin == eDOName.PORTR_MOT_DIR)
            {

                hmi1.arVar_Port[2].MotorDir = !value;
            }

            //피커 백큠 동작 상태(front)
            //else if (pin == eDOName.PICK_VAC1) loader1.arVar_Picker[0].VacOutput[0] = value;
            //else if (pin == eDOName.PICK_VAC2) loader1.arVar_Picker[0].VacOutput[1] = value;
            //else if (pin == eDOName.PICK_VAC3) loader1.arVar_Picker[0].VacOutput[2] = value;
            //else if (pin == eDOName.PICK_VAC4) loader1.arVar_Picker[0].VacOutput[3] = value;

            //출력상태에 따라서 버튼의 LED를 켠다
            else if (pin == eDOName.SOL_AIR)
            {
                DIO.SetOutput(eDOName.BUT_AIRF, value);

                if (value == false)
                    PUB.flag.set(eVarBool.FG_PK_ITEMON, false, "DO");
                hmi1.arDIAir = value;  //AIR상태를 표시
            }
            else if (pin == eDOName.LEFT_CONV)
            {
                VAR.TIME[(int)eVarTime.JOBEVENT] = DateTime.Now;
                if (value)
                {
                    VAR.TIME[eVarTime.CONVL_START] = DateTime.Now;
                }
                else
                {
                    VAR.TIME[eVarTime.CONVL_START] = new DateTime(1982, 11, 23);
                    VAR.DBL[eVarDBL.CONVL_RUNTIME] = 0;
                }

                PUB.log.Add($"LEFT_CONV : {value}");
            }
            else if (pin == eDOName.RIGHT_CONV)
            {
                VAR.TIME[(int)eVarTime.JOBEVENT] = DateTime.Now;
                PUB.log.Add($"RIGHT_CONV : {value}");
                if (value)
                {
                    VAR.TIME[eVarTime.CONVR_START] = DateTime.Now;
                }
                else
                {
                    VAR.TIME[eVarTime.CONVR_START] = new DateTime(1982, 11, 23);
                    VAR.DBL[eVarDBL.CONVR_RUNTIME] = 0;
                }

            }
            else if (pin == eDOName.BUZZER)
            {
                if (value)
                    PUB.BuzzerTime = DateTime.Now;
                else
                    PUB.BuzzerTime = new DateTime(1982, 11, 23);
            }

        }

    }
}
