public bool WaitStart(StationTask task, bool dryRun)
        {
            //wait start
            DoStart1?.SetDo(false);
            DoStart2?.SetDo(false);


            if (dryRun)
            {
                return(true);
            }

            //wait start
            while ((!DiStart1.GetDiSts() || !DiStart2.GetDiSts()))
            {
                if (dryRun)
                {
                    return(true);
                }
                Thread.Sleep(100);
                task.JoinIfPause();
                task.AbortIfCancel("cancel trans wait start");
            }
            task.Station.ShowAlarm(string.Empty, LogLevel.None);


            //normal start
            DoStart1?.SetDo();
            DoStart2?.SetDo();

            return(true);
        }
        public static bool SetVio(this IVioEx vioex, StationTask task, bool status = true)
        {
            task?.AbortIfCancel(nameof(SetVio));
            task?.JoinIfPause();

            vioex.Driver.SetDo(vioex.Port, status ? 1 : 0);
            task?.Log($"{vioex.Name} SetVio {vioex.Port} {status} success", LogLevel.Debug);
            return(true);
        }
Example #3
0
        public bool WaitStart(StationTask task)
        {
            //wait start
            while ((!DIStart1.GetDiSts() || !DIStart2.GetDiSts()))
            {
                Thread.Sleep(100);
                task.JoinIfPause();
                task.AbortIfCancel("cancel trans wait start");
            }
            task.Station.ShowAlarm(string.Empty, LogLevel.None);

            return(true);
        }
Example #4
0
        public static bool WaitVio(this IVioEx vioex, StationTask task, bool status = true, int timeout = -1)
        {
            task?.AbortIfCancel(nameof(WaitVio));
            task?.JoinIfPause();

            timeout = timeout < 0 ? int.MaxValue : timeout;

            var err = $"{vioex.Name} WaitVio {vioex.Port} {status}";
            var t   = 0;

            while (t++ <= timeout)
            {
                var sts = 0;
                vioex.DriverCard.GetDo(vioex.Port, out sts);
                if (sts == 1 == status)
                {
                    task?.Log($"{err} success", LogLevel.Debug);
                    return(true);
                }

                if (task != null)
                {
                    task.JoinIfPause();
                    task.AbortIfCancel(nameof(WaitVio));
                }
                else
                {
                    Application.DoEvents();
                }

                Thread.Sleep(1);
            }

            task?.Log($"{err} timeout", LogLevel.Error);
            return(false);
        }