using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AR;

namespace Project
{
	public partial class FMain
	{


		void _Display_Interval_500ms()
		{

            //홈진행중에는 모델쪽을 건드릴수 없게 한다
            toolStripButton7.Enabled = !PUB.sm.Step.ToString().StartsWith("HOME");
            //현재시간표시
            if (PUB.sm.Step == eSMStep.INIT)
				lbTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
			else
				lbTime.Text = PUB.sm.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss");

			//키엔스 데이터를 바로 표시한다.
			tbBarcodeF.Text = KeyenceBarcodeDataF;
            tbBarcodeR.Text = KeyenceBarcodeDataR;

            lbCntLeft.Text = $"{VAR.I32[eVarInt32.LPickOfCount]}";
			lbCntRight.Text = $"{VAR.I32[eVarInt32.RPickOfCount]}";
			lbCntPicker.Text = $"{VAR.I32[eVarInt32.PickOfCount]}";
			//lbCntPrnL.Text = $"{SETTING.Counter.CountPrintL}";
			//lbCnrPrnR.Text = $"{SETTING.Counter.CountPrintR}";

			if (AR.SETTING.Data.Enable_SpeedLimit)
				grpProgress.Text = $"작업 수량(속도제한:{AR.SETTING.Data.LimitSpeed})";
			else
				grpProgress.Text = $"작업 수량";

			//display Room Light
			btLightRoom.BackColor = DIO.GetIOOutput(eDOName.ROOMLIGHT) ? Color.Gold : SystemColors.Control;

			//상태를 DB에 저장한다.
			EEMStatus.UpdateStatusSQL(PUB.sm.Step);

            //컨베이어 가동시간계싼
            if(DIO.GetIOOutput(eDOName.LEFT_CONV) && VAR.TIME[eVarTime.CONVL_START].Year != 1982)
            {
                var t = (DateTime.Now - VAR.TIME[eVarTime.CONVL_START]).TotalSeconds;
                if (t > 999) t = 999;
                VAR.DBL[eVarDBL.CONVL_RUNTIME] = t;
            }

            if (DIO.GetIOOutput(eDOName.RIGHT_CONV) && VAR.TIME[eVarTime.CONVR_START].Year != 1982)
            {
                var t = (DateTime.Now - VAR.TIME[eVarTime.CONVR_START]).TotalSeconds;
                if (t > 999) t = 999;
                VAR.DBL[eVarDBL.CONVR_RUNTIME] = t;
            }
        }
	}
}