LabelMachine.Ledprocess.cs 2.0 KB
using OnlineStore.LoadCSVLibrary;
using System;
using System.Threading;

namespace DeviceLibrary
{
    public partial class LabelMachine
    {
        Led AlarmLed;
        Led RunningLed;

        System.Threading.Timer ledtimer;

        private void LedProcessInit()
        {
            AlarmLed = new Led(Config.DOList[IO_Label_Type.Alarm_Led].GetIOAddr(), DeviceName);
            RunningLed = new Led(Config.DOList[IO_Label_Type.Run_Led].GetIOAddr(), DeviceName);
            ledtimer = new System.Threading.Timer(new TimerCallback(LedProcess), null, 0, 1000);
            GC.KeepAlive(ledtimer);
        }

        void LedProcess(object o)
        {
            AlarmLed.LedState = LedState.off;
            RunningLed.LedState = LedState.off;

            if (runStatus == RunStatus.Running)
            {
                RunningLed.LedState = LedState.on;
                //无法运行,量报警灯
                if (!canRunning)
                {
                    AlarmLed.LedState = LedState.on;
                    RunningLed.LedState = LedState.off;
                }

                if (MoveInfo.MoveStep == MoveStep.Lbl_WaitCheckLabel || MoveInfo.MoveStep == MoveStep.Lbl_WaitCheckLabel2 || IOManager.GetDIValue("", 0, 16).Equals(IO_VALUE.LOW))
                {
                    AlarmLed.LedState = LedState.blink;
                    AlarmBuzzer.ON();
                }
                else
                {

                }
            }
            else if (runStatus == RunStatus.HomeReset)
            {
                RunningLed.LedState = LedState.blink;
            }

            if (alarmType != AlarmType.None)
            {
                AlarmLed.LedState = LedState.on;
            }

            if (UserPause)
            {
                AlarmLed.LedState = LedState.off;
                RunningLed.LedState = LedState.off;
                //StandbyLed.LedState = LedState.blink;

            }
            Led.LedGroup[DeviceName].ForEach((x) => { x.run(); });
        }
    }
}