StoreMachine.cs 23.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DeviceLibrary
{
    //using Msg = LMsg;
    [Flags]
    public enum MachineSideE {Right=1,Left=2 }
    
    public partial class StoreMachine : IRobot<Store_ConfigBase> 
    {
        public string Name { get; set; } = "SISO";
        private bool _canRunning = true;
        public bool canRunning
        {
            get { return _canRunning; }
            set
            {
                if (_canRunning != value) {
                    Msg.setlogones();
                }
                _canRunning = value;
            }
        }
        public bool isBusy { get => boxTransport.IsComplateOrFree; }
        public bool isAlarm { get => hasAlarm; }
        public bool isRunning { get => mstart; }

        public RunStatus runStatus { get; set; } = RunStatus.Stop;
        public Store_ConfigBase Config { get; set; }
        public Robot_Config MainConfig { get; set; }
        public event EventHandler<bool> PauseEvent;
        bool _userpause = false;
        public bool UserPause
        {
            get => _userpause; set
            {
                _userpause = value;
                if (value)
                {
                    DeviceSuddenStop();
                }
            }
        }
        public MsgService Msg;
        public bool AutoInOutTestMode { get; set; } = false;
        public MachineSideE MachineSide { get; set; }

        public Dictionary<string, ACStorePosition> StorePosition = new Dictionary<string, ACStorePosition>();

        public MoveInfo ResetMoveInfo;
        /// <summary>
        /// 右侧移动信息
        /// </summary>
        public MoveInfo StoreMoveInfo;
        public MoveInfo AIOTMoveInfo;        
        public delegate void ProcessMsg(List<Msg> msg);
        public event ProcessMsg ProcessMsgEvent;

        internal AxisBean Middle_Axis;
        public AxisBean UpDown_Axis;
        internal AxisBean InOut_Axis;
        internal AxisBean Comp_Axis;
        internal AxisBean Door_Axis;


        ReelTransport boxTransport;
        public DoorControl door;
        public bool boxTransportIsFree { get => boxTransport.IsComplateOrFree; }
        public event Action<string, StoreMoveType, bool> InOutEndProcessEvent;

        ServerCommunication ServerCM;
        /// <summary>
        /// 开始运行的时间
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 是否在急停中
        /// </summary>
        public bool isInSuddenDown = false;

        List<string> _positionNumList = null;
        public List<string> PositionNumList
        {
            get
            {
                if (_positionNumList == null)
                    _positionNumList = StorePosition.Keys.ToList();
                return _positionNumList;
            }
        }

        public StoreMachine(Store_ConfigBase _config, Robot_Config mainConfig, MachineSideE machineSide, out string msg) {
            msg = "";
            Config = _config;
            MainConfig = mainConfig;
            MachineSide = machineSide;
            Msg = new MsgService(MachineSide);
            Name = machineSide.ToString() + "-SISO";
            crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
            StoreMoveInfo = new MoveInfo(crc.GetString("Res0138","进出库调度"),machineSide);
            StoreMoveInfo.SetStateDelegate(StoreState);
            ResetMoveInfo = new MoveInfo(crc.GetString("Res0139","重置"), machineSide);
            AIOTMoveInfo = new MoveInfo(crc.GetString("Res0140","出入库测试"), machineSide);
            ServerCM = new ServerCommunication(this);
            ServerCM.InStoreEvent += ServerCM_InStoreEvent1;
            ServerCM.OutStoreEvent += ServerCM_OutStoreEvent;
            #region 初始化伺服轴
            Middle_Axis = new AxisBean(Config.Middle_Axis, Name,machineSide);
            Middle_Axis.ForceSafeCheck = true;
            Middle_Axis.interference += Middle_Axis_interference;
            UpDown_Axis = new AxisBean(Config.UpDown_Axis, Name, machineSide);
            UpDown_Axis.interference += UpDown_Axis_interference;
            InOut_Axis = new AxisBean(Config.InOut_Axis, Name, machineSide);
            InOut_Axis.ForceSafeCheck = true;
            InOut_Axis.interference += InOut_Axis_interference;
            Comp_Axis = new AxisBean(Config.Comp_Axis, Name, machineSide);
            Door_Axis = new AxisBean(Config.Door_Axis, Name, machineSide);
            Crc_LanguageChangeEvent(null, EventArgs.Empty);
            #endregion
            boxTransport = new ReelTransport(Config, this);
            boxTransport.DoorControl += BoxTransport_DoorControl;
            boxTransport.InOutEndProcessEvent += delegate (string posid, StoreMoveType storeMoveType, bool arg4)
            {
                InOutEndProcessEvent?.Invoke(posid, storeMoveType, arg4);
            };

            door = new DoorControl(Name, Config);
            string baseDir = Application.StartupPath;
            string positionConfigFile = Path.Combine(baseDir, "StoreConfig\\"+machineSide.ToString()+"\\linePositions.csv");
            if (File.Exists(positionConfigFile))
            {
                LogUtil.info($"加载{Name}位置文件:" + positionConfigFile);
                StorePosition = StorePosition.Concat(CSVPositionReader<ACStorePosition>.AddCSVFile(positionConfigFile)).ToDictionary(k => k.Key, v => v.Value);
            }
            else
            {
                msg += Name+ crc.GetString("Res0141","找不到库位配置文件") + "\n";
            }
            string fixpositionConfigFile = Path.Combine(baseDir, "StoreConfig\\" + machineSide.ToString() + "\\fixPositions.csv");
            if (File.Exists(fixpositionConfigFile))
            {
                haveFixpos = true;
                LogUtil.info($"加载{Name}校准库位文件:" + fixpositionConfigFile);
                StorePosition = StorePosition.Concat(CSVPositionReader<ACStorePosition>.AddCSVFile(fixpositionConfigFile)).ToDictionary(k => k.Key, v => v.Value);
            }
            IOMonitor.RegisterIO(IO_Type.Reset_BTN, RobotManage.Config, IO_VALUE.HIGH, Reset_BTN, 2500, 100);
        }

        private bool BoxTransport_DoorControl(bool arg)
        {
            if (arg)
            {
                if (door.DoorIsOpen())
                    return true;
                else
                {
                    door.OpenDoor(null);
                    return false;
                }
            }
            else {
                if (door.DoorIsClose())
                    return true;
                else
                {
                    door.CloseDoor(null);
                    return false;
                }
            }
        }

        private void ServerCM_OutStoreEvent(JobInfo jobInfo)
        {
            AddOutStoreTask(jobInfo.PosId, jobInfo.plateW, jobInfo.plateH);
        }

        private bool ServerCM_InStoreEvent1(JobInfo jobInfo, bool ng, string msg)
        {
            if (ng) {
                StoreMoveInfo.MoveParam.IsNg = true;
                StoreMoveInfo.MoveParam.NgMsg = msg;
                StoreMoveInfo.NextMoveStep(MoveStep.Wait);
                StoreMoveInfo.WaitList.Add(WaitResultInfo.WaitMsg(msg, MsgLevel.alarm));
                StoreMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
                return true;
            } else {
                return StartInStore(jobInfo, StoreMoveInfo);
            }
        }
        public bool StartInStore(JobInfo jobInfo,MoveInfo moveInfo)
        {
            if (moveInfo.MoveStep == MoveStep.InWaitServerCallback)
            {
                moveInfo.MoveParam.WareCode = jobInfo.WareNum;
                moveInfo.MoveParam.PosID = jobInfo.PosId;
                moveInfo.MoveParam.PlateH = jobInfo.plateH;
                moveInfo.MoveParam.PlateW = jobInfo.plateW;
                moveInfo.NextMoveStep(MoveStep.StoreIn01);
                moveInfo.log($"料盘等待入库:{moveInfo.MoveParam.ToStr()}");
                return true;
            }
            return false;
        }
        private void Crc_LanguageChangeEvent(object sender, EventArgs e)
        {
            StoreMoveInfo.Name = crc.GetString("Res0138","进出库调度");
            ResetMoveInfo.Name =  crc.GetString("Res0139","重置");
            AIOTMoveInfo.Name =  crc.GetString("Res0140","出入库测试");
        }
        private (bool, string) InOut_Axis_interference(int from, int to)
        {
            if (to != Config.InOut_P2)
                return (false, "");

            var updownindoor = UpDown_Axis.IsInPosition(Config.UpDown_P2) || UpDown_Axis.IsInPosition(Config.UpDown_P3);
            var ismiddleatdoor = Middle_Axis.IsInPosition(Config.Middle_P1) || Middle_Axis.IsInPosition(Config.Middle_P2);
            if (ismiddleatdoor && updownindoor && IOValue(SIO_Type.Door_Open,Config).Equals(IO_VALUE.HIGH))
            {
                return (false, "");
            }
            else
                return (true, crc.GetString("Res0142","单料门没有打开进出轴无法伸出"));
            return (false, "");
        }
        private (bool, string) Middle_Axis_interference(int from, int to)
        {
            if (RobotManage.DisableUpdownProtect)
                return (false, "");

            if (InOut_Axis.IsInPosition(Config.InOut_P1))
                return (false, "");

            return (true, crc.GetString("Res0143","进出轴不在待机点时无法移动旋转轴"));
        }

        private (bool, string) UpDown_Axis_interference(int from, int to)
        {
            if (RobotManage.DisableUpdownProtect)
                return (false, "");

            if (InOut_Axis.IsInPosition(Config.InOut_P1))
                return (false, "");

            return (true, crc.GetString("Res0144","进出轴不在待机点时无法移动升降轴"));
        }
        public volatile bool hasAlarm = false;
        /// <summary>
        /// 整机启动变量,设置为false后将退出线程,只在停止时调用
        /// </summary>
        volatile bool mstart=false;
        public void Run() {
            mstart = true;
            PauseEvent?.Invoke(null, false);
            while (mstart) {
                try
                {
                    canRunning = DeviceCheck();
                    if (canRunning)
                    {
                        canRunning = SafeCheck();
                        //if (canRunning && !lastSafeCheckStatus){}
                        //lastSafeCheckStatus = canRunning;
                    }
                    Thread.Sleep(200);
                    if (!canRunning || !mstart)
                        continue;
                    if (runStatus == RunStatus.Running)
                    {
                        boxTransport.Process();
                        if (AutoInOutTestMode)
                            AutoInOutTestProcess();
                        else
                            StoreProcess();
                    }
                    else if (runStatus == RunStatus.HomeReset)
                    {
                        HomeReset();
                    }
                }
                catch (Exception ex)
                {
                    Msg.add(ex.ToString(), MsgLevel.alarm);
                    Msg.setlogones();
                }
                finally {
                    var m = Msg.get()[MachineSide];
                    ProcessMsgEvent?.Invoke(m);
                    ServerCM.ProcessMsg(m);
                    StoreStatus currnetstoreStatus= StoreStatus.None;
                    if (m.Find((aa) => aa.msgLevel == MsgLevel.alarm) == null)
                    {
                        hasAlarm = false;
                        AlarmBuzzer.OFF();
                        if (ServerCM.storeStatus != StoreStatus.InStoreExecute
                            && ServerCM.storeStatus != StoreStatus.OutStoreExecute
                            && ServerCM.storeStatus != StoreStatus.ResetMove && ServerCM.storeStatus != StoreStatus.StoreOnline)
                        {
                            LogUtil.info($"{MachineSide} test storeStatus is {ServerCM.storeStatus} change to StoreOnline");
                            currnetstoreStatus = StoreStatus.StoreOnline;
                        }
                    }
                    else {
                        hasAlarm = true;
                        AlarmBuzzer.ON();
                        currnetstoreStatus = isInSuddenDown ? StoreStatus.SuddenStop : StoreStatus.Warning;
                    }
                    //ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
                    if (!UserPause)
                        Msg.clear();
                    else
                        currnetstoreStatus = StoreStatus.Debugging;

                    if (currnetstoreStatus!=StoreStatus.None)
                        ServerCM.storeStatus = currnetstoreStatus;
                }
            }
            LogUtil.info($"{MachineSide}主线程已退出.");
        }
        public void Start() {
            if (ConfigHelper.Config.Get($"Device_{MachineSide}_Disable", false))
            {
                LogUtil.info($"{MachineSide}料仓被禁用,不启动.");
                return;
            }
            UserPause = false;
            Run();
        }
        public void Stop() {
            LogUtil.info(Name + ":Stop.");
            mstart = false;
            UserPause = false;
            AutoInOutTest = false;
            Thread.Sleep(300);
            Alarm(AlarmType.None);
            StopMove(true);

            PauseEvent?.Invoke(null, false);
        }
        public void ShutDown()
        {
            LogUtil.info(Name+":开始关闭系统.");
            door.Dispose();
            ServerCM.Dispose();
        }
        public void BeginHomeReset(bool firstRun=false) {
            if (!firstRun)
            {
                StopMove();
                Thread.Sleep(500);
            }
            OpenAllServo();
            boxTransport.Unlock();
            Alarm(AlarmType.None);
            runStatus = RunStatus.HomeReset;
            ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
            ResetMoveInfo.log("开始回原");
            ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
        }
        //强制回原
        bool forceHome=true;
        void HomeReset()
        {
            if (CheckWait(ResetMoveInfo))
                return;

            switch (ResetMoveInfo.MoveStep)
            {
                case MoveStep.H01_HomeReset:
                    ResetMoveInfo.log("开始回原");
                    ServerCM.storeStatus = StoreStatus.ResetMove;                      
                    Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
                    ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_01);                    
                    break;
                case MoveStep.H02_HomeReset_01:
                    ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
                    ResetMoveInfo.log("进出轴,批量轴回原,料串检测杆退回避让端");
                    InOut_Axis.HomeMove(ResetMoveInfo, forceHome);
                    door.CloseDoor(ResetMoveInfo);
                    break;
                case MoveStep.H02_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H03_HomeReset);
                    break;
                case MoveStep.H03_HomeReset:                    
                    ResetMoveInfo.NextMoveStep(MoveStep.H04_HomeReset);
                    ResetMoveInfo.log("旋转轴,升降轴,回原,料叉P1待机点");
                    InOut_Axis.AbsMove(ResetMoveInfo, Config.InOut_P1, Config.InOut_P1_speed);
                    Middle_Axis.HomeMove(ResetMoveInfo, forceHome);
                    UpDown_Axis.HomeMove(ResetMoveInfo, forceHome);                    
                   break;
                case MoveStep.H04_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H05_HomeReset);
                    break;
                case MoveStep.H05_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H06_HomeReset);
                    ResetMoveInfo.log("旋转轴,升降轴,到P1待机点");
                    Middle_Axis.AbsMove(ResetMoveInfo, Config.Middle_P1, Config.Middle_P1_speed);
                    UpDown_Axis.AbsMove(ResetMoveInfo, Config.UpDown_P1, Config.UpDown_P1_speed);
                    break;
                case MoveStep.H06_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H07_HomeReset);
                    ResetMoveInfo.log("压紧轴回原");
                    Comp_Axis.HomeMove(ResetMoveInfo, forceHome);
                    break;
                case MoveStep.H07_HomeReset:
                    if (IOValue(SIO_Type.Door_Tray_Check, Config).Equals(IO_VALUE.HIGH))
                    {
                        Msg.add(crc.GetString("Res0145","回原时舱门口有料无法继续"), MsgLevel.alarm);
                    }
                    else {
                        ResetMoveInfo.NextMoveStep(MoveStep.H08_HomeReset);
                    }
                    break;
                case MoveStep.H08_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H09_HomeReset);
                    ResetMoveInfo.log("假设有料盘,送到单料口");
                    door.OpenDoor(ResetMoveInfo);
                    break;
                case MoveStep.H09_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H10_HomeReset);
                    ResetMoveInfo.log("旋转轴,升降轴,到P2,压紧轴p1");
                    Middle_Axis.AbsMove(ResetMoveInfo, Config.Middle_P2, Config.Middle_P2_speed);
                    UpDown_Axis.AbsMove(ResetMoveInfo, Config.UpDown_P2, Config.UpDown_P2_speed);
                    Comp_Axis.AbsMove(ResetMoveInfo, Config.Comp_P1, Config.Comp_P1_speed);
                    break;
                case MoveStep.H10_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H11_HomeReset);
                    if (IOValue(SIO_Type.Door_Tray_Check, Config).Equals(IO_VALUE.HIGH))
                    {
                        Msg.add(crc.GetString("Res0145","回原时舱门口有料无法继续"), MsgLevel.alarm);
                    }
                    else
                    {
                        ResetMoveInfo.log("进出轴到p2单料们放料点");
                        InOut_Axis.AbsMove(ResetMoveInfo, Config.InOut_P2, Config.InOut_P2_speed);
                    }                    
                    break;
                case MoveStep.H11_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H12_HomeReset);
                    ResetMoveInfo.log("升降轴,到P3低点");
                    UpDown_Axis.AbsMove(ResetMoveInfo, Config.UpDown_P3, Config.UpDown_P3_speed);
                    break;
                case MoveStep.H12_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.H13_HomeReset);
                    InOut_Axis.AbsMove(ResetMoveInfo, Config.InOut_P1, Config.InOut_P1_speed);
                    break;
                case MoveStep.H13_HomeReset:
                    ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
                    ResetMoveInfo.log("关闭单料门");
                    door.CloseDoor(ResetMoveInfo);
                    break;
                case MoveStep.H14_HomeReset:
                    break;
                case MoveStep.H15_HomeReset:
                    break;
                case MoveStep.H16_HomeReset:
                    break;
                case MoveStep.HEND_HomeReset:
                    forceHome = false;
                    StoreMoveInfo.NewMove(MoveStep.Wait);
                    boxTransport.Reset();
                    ResetMoveInfo.log("回原完成");
                    ResetMoveInfo.EndMove();

                    runStatus = RunStatus.Running;
                    ServerCM.storeStatus = StoreStatus.StoreOnline;
                    break;
            }
        }
        public bool IgnoreSafecheck { get; set; }
        public bool haveFixpos { get; private set; }

        public bool IgnoreGratingSignal = false;

        bool lastSafeCheckStatus = true;
        bool SafeCheck() {
            bool ok = true;
            var ignorestring = "[" + crc.GetString("Res0146","已忽略") + "]";
            if (IOValue(IO_Type.BackDoor_Check,MainConfig).Equals(IO_VALUE.LOW))
            {
                if (!IgnoreSafecheck)// && IOValue(IO_Type.NGDoor_Open).Equals(IO_VALUE.HIGH))
                {
                    ok = false;
                    UserPause = true;
                }
                Msg.add(crc.GetString("Res0147","后维护被打开") + (ok ? ignorestring : ""), MsgLevel.warning);
            }            
            if (!lastSafeCheckStatus && ok)
            {
                SafetyDevice.ResumeAll();
            }
            lastSafeCheckStatus = ok;
            return ok;
        }

        void DeviceSuddenStop() {           
            if (lastSafeCheckStatus)
            {
                AxisBean.StopMultiAxis(AxisBean.List[MachineSide]);
                MoveInfo.List[MachineSide].ForEach((m) => { m.CanWhileCount = 5; });
                SafetyDevice.PauseAll();
                if (runStatus == RunStatus.HomeReset)
                {
                    ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
                }
            }
        }

        /// <summary>
        /// 最后一次气压检测变为0的时间
        /// </summary>
        DateTime lastAirCloseTime = DateTime.MinValue;

        internal DateTime checkAlarmTime = DateTime.Now;
        public bool DeviceCheck() {
            bool ok = true;
            isInSuddenDown = IOValue(IO_Type.SuddenStop_BTN,RobotManage.Config).Equals(IO_VALUE.LOW);
            if (UserPause)
            {
                Msg.add(crc.GetString("Res0133","系统暂停"), MsgLevel.warning);
                DeviceSuddenStop();
                lastSafeCheckStatus = false;
                ok = false;
                return ok;
            }
            else if (isInSuddenDown)
            {
                Alarm(AlarmType.SuddenStop);
                Msg.add(crc.GetString("Res0134","急停中"), MsgLevel.alarm);
                ok = false;
            }
            else if (alarmType != AlarmType.None) {
                {
                    Msg.add(crc.GetString("Res0148","系统需要重置"), MsgLevel.alarm,ErrInfo.SuddenStop);
                    ok = false;
                }
            }
            if (AutoInOutTestMode)
            {
                Msg.add(crc.GetString("Res0149","进出库调试模式"), MsgLevel.info);
                //ok = false;
            }
            
            if (alarmType!=AlarmType.SuddenStop)
            {
                TimeSpan span = DateTime.Now - checkAlarmTime;
                if (span.TotalSeconds > 2)
                {
                    checkAlarmTime = DateTime.Now;
                    foreach (ConfigMoveAxis configMoveAxis in Config.moveAxisList)
                    {
                        if (AxisManager.GetAlarmStatus(configMoveAxis.DeviceName, configMoveAxis.GetAxisValue()) == 1)
                        {
                            Msg.add(crc.GetString(configMoveAxis.ProName, configMoveAxis.Explain) + $"[{configMoveAxis.GetAxisValue()}]:"
                                + crc.GetString("Res0150","运动报警"), MsgLevel.alarm, ErrInfo.SuddenStop);
                            ok = false;
                        }
                    }
                }
            }
            return ok;
        }

        public void IgnoreX09() {
            boxTransport.IgnoreX09 = true;
            LogUtil.info("按下X09忽略");
        }
    }
}