TSAVBean.cs 27.9 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 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
using PUSICANLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSA_V.Common;
using TSA_V.LoadCSVLibrary;

namespace TSA_V.DeviceLibrary
{
    public partial class TSAVBean
    {
        public static bool IsDebug = ConfigAppSettings.GetBoolValue(Setting_Init.IsDebug);
        public static string Name = "MASCOT";
        public static int RotateNode_DefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.RotateNode_DefaultPosition);
        public static Dictionary<int, Dictionary<int, NodeInfo>> RotateMap = new Dictionary<int, Dictionary<int, NodeInfo>>();

        public static int DefaultPType = ConfigAppSettings.GetIntValue(Setting_Init.DefaultPointType);
        public static int DefaultPSize = ConfigAppSettings.GetIntValue(Setting_Init.DefaultPointSize);

        public static bool DisableSideCylinder = false;
        public static bool DisableBottomCylinder = false;

        private static string warnMsg = "";
        public static string WarnMsg
        {
            get { return warnMsg; }
            set
            {
                if (!warnMsg.Equals(value) && (!String.IsNullOrEmpty(value)))
                {
                    //StatusClient.instance.SendNew(Color.Red, warnMsg);
                }
                warnMsg = value;
            }
        }
        public static bool IsInPut = false;
        public static bool IsInSuddenDown = false;

        /// <summary>
        /// 工作模式,0=脚踏模式,1=自动模式
        /// </summary>
        public static int WorkMode = ConfigAppSettings.GetIntValue(Setting_Init.WorkMode);
        public static int AuToModeSeconds = ConfigAppSettings.GetIntValue(Setting_Init.AuToModeSeconds);

        public static TSAVStatus Status = TSAVStatus.Wait;
        public static ResetStep resetStep = ResetStep.OpenCan_0;
        public static DateTime LastResetChangeTime = DateTime.Now;

        private static System.Timers.Timer workTimer = null;
        public static WorkInfo Work = new WorkInfo();
        public static bool IsNeedAOI = ConfigAppSettings.GetBoolValue(Setting_Init.IsNeedAOI);
        public static bool IsCanStepMove = false;

        public static int LastStepIndex = 4;
        /// <summary>
        /// 退出工作界面
        /// </summary>
        public static void ExitWork()
        {
            WorkInfo.IsCycleDebug = false;
            Work.WorkType = 0;
            IOManager.IOMove(IOManager.SMEMA_Down, IO_VALUE.LOW);
            IOManager.IOMove(IOManager.SMEMA_Up, IO_VALUE.LOW);
        }
        public static string LoadTSAV()
        {
            LogUtil.info(Name + "开始加载电机配置。。");
            DisableSideCylinder = ConfigAppSettings.GetBoolValue(Setting_Init.DisableSideCylinder);
            DisableBottomCylinder = ConfigAppSettings.GetBoolValue(Setting_Init.DisableBottomCylinder);
            if (workTimer == null)
            {
                workTimer = new System.Timers.Timer();
                workTimer.AutoReset = true;
                workTimer.Enabled = false;
                workTimer.Interval = 300;
                workTimer.Elapsed += workTimer_Elapsed;
            }

            int count = ConfigAppSettings.GetIntValue(Setting_Init.TSAV_Storage_Count);
            RotateMap = new Dictionary<int, Dictionary<int, NodeInfo>>();
            int ceng = 5;
            string sp = "_";
            for (int i = 1; i <= count; i++)
            {
                RotateMap.Add(i, new Dictionary<int, NodeInfo>());
                for (int j = 1; j <= ceng; j++)
                {
                    string str = sp + i + sp + j;
                    uint nodeid = ConfigAppSettings.getUintValue(Setting_Init.RNode_Addr, str);
                    if (!(nodeid <= 0))
                    {
                        NodeInfo node = new NodeInfo(nodeid, "Node:_" + i + "_" + j, "_" + i + "_" + j);
                        RotateMap[i].Add(j, node);
                    }
                }
            }

            if (DefaultPType <= 0 || DefaultPType > 5)
            {
                DefaultPType = 1;
            }
            if (DefaultPSize <= 0 || DefaultPSize > 100)
            {
                DefaultPSize = 4;
            }

            // bool result = GalvanometerManager.OpenPort(Gal_Port);
            Screen[] sc = Screen.AllScreens;
            bool result = sc.Length >= 2;
            if (!result)
            {
                LogUtil.error("振镜初始化失败!");
                return ResourceControl.GetString(ResourceControl.InitXFail, "振镜初始化失败");
            }

            return "";
        }

        public static string GetTime()
        {
            string date = DateTime.Now.ToString("HH:mm");
            return "" + date + "ALARM ";
        }
        public static string StartRun()
        {
            MesUtil.Open();
            if (Status.Equals(TSAVStatus.Wait))
            {
                LogUtil.info(Name + "开始连接Can协议");
                string msg = PUSICANControl.Open();
                if (!msg.Equals(""))
                {
                    LogUtil.error(Name + "Can协议连接失败:" + msg);
                    return ResourceControl.GetString(ResourceControl.CanConnectFail, "Can协议连接失败");
                }
                else
                {
                    LogUtil.info(Name + "连接Can协议成功");
                }
               Thread.Sleep(PUSICANControl.SleepMS);
                resetStep = ResetStep.OpenCan_0;
                LastResetChangeTime = DateTime.Now;
            }
            //判断IO模块是否连接
            if (IOManager.ISConnection().Equals(false))
            {
                LogUtil.info(Name + "IO模块连接失败");
                return ResourceControl.GetString(ResourceControl.IOConnectError, "IO模块连接失败");
            }
            StartReset();

            //启动定时器
            workTimer.Enabled = true;
            return "";
        }

        public static void StartReset()
        {
            if (Status > TSAVStatus.Wait)
            {
                LogUtil.info(Name + "重置中:重置之前先停止所有运动");
                StopMove();
               Thread.Sleep(PUSICANControl.SleepMS);
            }


            WarnMsg = "";
            IsInSuddenDown = false;

            IOManager.IOMove(IOManager.Line_FStart, IO_VALUE.LOW);
            LogUtil.info(Name + "开始重置设备");
            LastResetChangeTime = DateTime.Now;

            Status = TSAVStatus.Reset;

            resetStep = ResetStep.AddNode_1;

           Thread.Sleep(PUSICANControl.SleepMS);
            foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
            {
                foreach (NodeInfo nodeid in map.Values)
                {
                    PUSICANControl.InitNode(nodeid.NodeId);
                }
            }
            PUSICANControl.InitNode(LWidthManager.Line_NodeAddr);
            LogUtil.info(Name + "重置中AddNode_1:InitNode 所有节点  ");
        }
        public delegate bool ShowPointDelegate(ProjectorPInfo p);
        public static event ShowPointDelegate ShowPointEvent;
        public static void ShowPoint(double x, double y, int type = 1, int sizex = 1, int sizey = 1, int penWidth = 2, string name = "")
        {
            ProjectorPInfo p = new ProjectorPInfo((int)x, (int)y, type, sizex, sizey, penWidth, name);
            ShowPointEvent?.Invoke(p);
        }
        /// <summary>
        /// 重置处理中
        /// </summary>
        private static void ResetProcess()
        {
            //判断超时时间
            TimeSpan span = DateTime.Now - LastResetChangeTime;
            bool isTimeOut = false;
            string timeOutMsg = "";
            //如果超过一分钟,需要提示;
            if (span.TotalMinutes > 1)
            {
                isTimeOut = true;
            }
            //LedManager.LedOFFALL();
            if (resetStep.Equals(ResetStep.AddNode_1))
            {
                //   LogUtil.info(Name + "重置中:XYNodeOnline_2  XY已经到待机点,判断旋转轴是否上线");

                resetStep = ResetStep.XYNodeOnline_2;
            }
            else if (resetStep.Equals(ResetStep.XYNodeOnline_2))
            {
                //判断旋转轴是否已经上线
                bool isAllOk = true;
                SLAVE_STATUS rStatus = new SLAVE_STATUS();
                foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
                {
                    foreach (NodeInfo node in map.Values)
                    {

                        PUSICANControl.PUSICO_GetNodeStatus(node.NodeId, ref rStatus);
                        if (!rStatus.Equals(SLAVE_STATUS.SLAVESTATUS_WORK))
                        {
                            timeOutMsg = ResourceControl.GetString(ResourceControl.RNodeOnLine, " 旋转轴[{0}][{1}]上线", node.NodeId, rStatus);
                            isAllOk = false;
                            break;
                        }
                    }
                }
                PUSICANControl.PUSICO_GetNodeStatus(LWidthManager.Line_NodeAddr, ref rStatus);
                if (!rStatus.Equals(SLAVE_STATUS.SLAVESTATUS_WORK))
                {
                    timeOutMsg = ResourceControl.GetString(ResourceControl.RNodeOnLine, " 调宽轴[{0}][{1}]上线", LWidthManager.Line_NodeAddr, rStatus);
                    isAllOk = false;
                }
                if (isAllOk.Equals(true))
                {
                    //初始化所有旋转轴
                    foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
                    {
                        foreach (NodeInfo node in map.Values)
                        {
                            PUSICANControl.InitRNodeConfig(node.NodeId);
                            Thread.Sleep(10);
                        }
                    }
                    PUSICANControl.InitRNodeConfig(LWidthManager.Line_NodeAddr, true);
                    Thread.Sleep(10);
                    //所有轴原点返回
                    foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
                    {
                        foreach (NodeInfo node in map.Values)
                        {
                            PUSICANControl.HomeMove(node.NodeId);
                            Thread.Sleep(10);
                        }
                    }
                    //            PUSICANControl.HomeMove(LWidthManager.Line_NodeAddr);
                    resetStep = ResetStep.XYHomeMove_3;
                    LastResetChangeTime = DateTime.Now;
                    LogUtil.info(Name + "重置中:所有轴已连接, 旋转轴开始原点返回");
                }
            }
            else if (resetStep.Equals(ResetStep.XYHomeMove_3))
            {
                //判断是否都原点返回完成
                bool isAllOk = true;
                foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
                {
                    foreach (NodeInfo node in map.Values)
                    {
                        if (!PUSICANControl.IsHomeEnd(node.NodeId))
                        {
                            timeOutMsg = ResourceControl.GetString(ResourceControl.RNodeGoHome, " 旋转轴[{0}]原点返回完成", node.NodeId);
                            isAllOk = false;
                            break;
                        }
                    }
                }
                //if (!PUSICANControl.IsHomeEnd(LWidthManager.Line_NodeAddr))
                //{
                //    timeOutMsg = ResourceControl.GetString(ResourceControl.RNodeGoHome, " 调宽轴[{0}]原点返回完成", LWidthManager.Line_NodeAddr);
                //    isAllOk = false; 
                //}
                if (isAllOk.Equals(true))
                {

                   Thread.Sleep(PUSICANControl.SleepMS);
                    //初始化所有旋转轴
                    foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
                    {
                        foreach (NodeInfo node in map.Values)
                        {
                            PUSICANControl.DefatutPosMove(node.NodeId, TSAVBean.RotateNode_DefaultPosition, 0);
                        }
                    }

                    //          PuHomeMove(LWidthManager.Line_NodeAddr, LWidthManager.DefaultPosition, 0);
                    LogUtil.info(Name + "重置中:所有旋转轴原点返回完成,开始到待机点:" + TSAVBean.RotateNode_DefaultPosition);
                    resetStep = ResetStep.RNodeOnline_4;
                    LastResetChangeTime = DateTime.Now;
                }
            }
            else if (resetStep.Equals(ResetStep.RNodeOnline_4))
            {
                bool isAllOk = true;
                foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
                {
                    foreach (NodeInfo node in map.Values)
                    {
                        int position = PUSICANControl.GetPosition(node.NodeId);
                        if (!(position.Equals(RotateNode_DefaultPosition)))
                        {
                            timeOutMsg = ResourceControl.GetString(ResourceControl.RNodeToPosition, " 旋转轴[{0}]走到待机点[{1}]", node.NodeId, RotateNode_DefaultPosition);
                            isAllOk = false;
                            break;
                        }
                    }
                }
                //int positiona = PUSICANControl.GetPosition(LWidthManager.Line_NodeAddr);
                //if (!(positiona.Equals(LWidthManager.DefaultPosition)))
                //{
                //    timeOutMsg = ResourceControl.GetString(ResourceControl.RNodeToPosition, " 调宽轴[{0}]走到待机点[{1}]", LWidthManager.Line_NodeAddr, LWidthManager.DefaultPosition);
                //    isAllOk = false; 
                //}
                if (isAllOk.Equals(true))
                {
                    WarnMsg = "";
                    LogUtil.info(Name + "重置完成:所有旋转轴回到待机点!");
                    Status = TSAVStatus.Runing;
                }
            }
            if (isTimeOut)
            {
                WarnMsg = GetTime() + ResourceControl.GetString(ResourceControl.TimeOutMsg, "重置等待[{0}]超时,已等待:{1}分", timeOutMsg, Math.Round(span.TotalMinutes, 1));
                LogUtil.error(Name + WarnMsg);
            }
        }

        public static void StartWork(BoardInfo boardInfo)
        {
            Work.StartWork(boardInfo);
        }
        public static void StopWork()
        {

            if (Status.Equals(TSAVStatus.Reset))
            {
                //Status = TSAVStatus.Wait;
            }
            else
            {

                StopMove();
            }
        }
        private static bool IsProcess = false;
        private static DateTime preShowImageTime = DateTime.Now;
        /// <summary>
        /// 工作定时器
        /// </summary> 
        private static void workTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (IsProcess)
            {
                return;
            }
            IsProcess = true;
            try
            {

                //判断是否收到急停信号
                if ((!Status.Equals(TSAVStatus.Wait)) && IOManager.IOValue(IOManager.SuddenStop).Equals(IO_VALUE.LOW))
                {
                    if (!IsInSuddenDown)
                    {
                        WarnMsg = GetTime() + ResourceControl.GetString(ResourceControl.SuddenDownMsg, "收到急停信号,停止所有运动,设备断开连接");
                        LogUtil.error("收到急停信号,停止所有运动,断开can协议连接");
                        IsInSuddenDown = true;
                        StopWork();
                        //StopMove();
                        PUSICANControl.Close();
                        IOManager.IOMove(IOManager.SMEMA_Up, IO_VALUE.LOW);
                        IOManager.IOMove(IOManager.SMEMA_Down, IO_VALUE.LOW);
                    }
                }
                //急停信号恢复,自动复位
                else if (IOManager.IOValue(IOManager.SuddenStop).Equals(IO_VALUE.HIGH) && IsInSuddenDown)
                {
                    if (Work.WorkType > 0)
                    {
                        WarnMsg = GetTime() + ResourceControl.GetString(ResourceControl.AutoResetMsg, "急停恢复,自动重置设备");
                        LogUtil.error("急停恢复,自动重置设备, 开始连接can协议");
                        string msg = PUSICANControl.Open();
                        if (!msg.Equals(""))
                        {
                            WarnMsg = GetTime() + ResourceControl.GetString(ResourceControl.AutoResetMsg, "急停恢复,自动重置设备") + " " +
                              ResourceControl.GetString(ResourceControl.CanConnectFail, "Can协议连接失败");
                            LogUtil.error(Name + "急停恢复,自动重置设备,设备连接失败:" + msg);
                        }
                        else
                        {
                            LogUtil.info(Name + "连接Can协议成功");
                            IsInSuddenDown = false;
                            StartReset();
                        }
                    }
                }

                if (!IsInSuddenDown)
                {
                    if (Status.Equals(TSAVStatus.Reset))
                    {
                        ResetProcess();
                    }
                    else if (Status.Equals(TSAVStatus.Runing))
                    {
                        //正在工作中
                        if (Work.IsWorking)
                        {
                            WorkProcess();
                        }

                        else if (LineStep.moveType.Equals(1))
                        {
                            LineProcess();
                        }
                        else
                        {
                            StartLineCheck();
                        }

                    }
                    CheckPusicanAlarm();
                }
                //  IOManager.IOMove(IOManager.Warmer_Work, IO_VALUE.LOW); 
            }
            catch (Exception ex)
            {
                LogUtil.error("workTimer_Elapsed出现错误:" + ex.ToString());
            }
            IsProcess = false;
        }
        private static void WorkProcess()
        {
            if (Work.IsWaitMove)
            {
                //判断是否正在运动
                CheckWorkWait();
            }
            if (!(Work.IsWaitMove))
            {
                TimeSpan span = DateTime.Now - Work.endWorkTime;
                bool IsFootOk = IOManager.IOValue(IOManager.Footrest_Single).Equals(IO_VALUE.HIGH) && (WorkMode.Equals(0));
                if (Work.WorkType.Equals(1))
                {
                    //等待脚踏板信号
                    if (IsFootOk
                        || (span.TotalSeconds > AuToModeSeconds && IsDebug)
                        || (span.TotalSeconds > AuToModeSeconds && WorkMode.Equals(1))
                        )
                    {
                        Work.MoveToNextPoint(true);
                    }
                }
                else if (Work.WorkType.Equals(2) || Work.WorkType.Equals(3))
                {
                    if (Work.WorkType.Equals(2))
                    {
                        if (IsFootOk || (span.TotalSeconds > Work.currPoint.WeldTime + 6 && IsDebug
                             || (span.TotalSeconds > Work.currPoint.WeldTime + 6 && WorkMode.Equals(1))))
                        {
                            Work.MoveToNextPoint(true);
                        }
                    }
                    else if (Work.WorkType.Equals(3))
                    {
                        if (IsFootOk || (span.TotalSeconds > 8 && IsDebug
                             || (span.TotalSeconds > 8 && WorkMode.Equals(1))))
                        {
                            Work.MoveToNextPoint(true);
                        }
                    }
                }
            }
        }
        private static DateTime preCheckTime = DateTime.Now;
        /// <summary>
        /// 验证是否 堵转,堵转需要断电
        /// </summary>
        private static void CheckPusicanAlarm()
        {
            if (IsInSuddenDown)
            {
                return;
            }
            TimeSpan span = DateTime.Now - preCheckTime;
            if (span.TotalSeconds < 10)
            { return; }
            preCheckTime = DateTime.Now;


            foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
            {
                foreach (NodeInfo node in map.Values)
                {
                    if (PUSICANControl.IsDuZhuan(node.NodeId))
                    {
                        LogUtil.error(Name + " 发现旋转轴[" + node.NodeId + "]堵转,清除一下控制器状态,重新读取一下堵转状态");
                        Thread.Sleep(PUSICANControl.SleepMS);
                        //清除一下状态,在重新读一次 
                        if (!TSAVBean.Status.Equals(TSAVStatus.Reset))
                        {
                            PUSICANControl.ClearStatus(node.NodeId);
                        }
                       Thread.Sleep(PUSICANControl.SleepMS);
                        if (PUSICANControl.IsDuZhuan(node.NodeId))
                        {
                            WarnMsg = GetTime() + ResourceControl.GetString(ResourceControl.DuZhuanMsg, " 旋转轴[{0}]堵转,需要重置", node.NodeId);
                            LogUtil.error(Name + " " + WarnMsg);
                            return;
                        }
                    }
                }
            }
        }
        public static bool NextPoint(bool isNext, bool isResetBoard)
        {
            if (Status.Equals(TSAVStatus.Runing))
            {
                if (!Work.IsWorking)
                {
                    //StartWork(BoardManager.CurrBoard);
                    return false;
                }
                if (Work.IsWaitMove)
                {
                    //判断是否正在运动
                    CheckWorkWait();
                }
                if (!(Work.IsWaitMove))
                {
                    Work.MoveToNextPoint(isNext, isResetBoard);
                    return true;
                }
            }
            return false;
        }

        public static void StopRun()
        {
            StopMove();
            //停止红外线灯
            //   IOManager.IOMove(IOManager.Inerared_Lamp, IO_VALUE.LOW);
            IOManager.IOMove(IOManager.SMEMA_Down, IO_VALUE.LOW);
            IOManager.IOMove(IOManager.SMEMA_Up, IO_VALUE.LOW);
            workTimer.Enabled = false;
            //PUSICANControl.Close();
            Status = TSAVStatus.Wait;
            MesUtil.Close();
        }

        public static void StopMove()
        {
            LogUtil.info("StopMove,停止所有运动");
            BottomCylinderDown(false);
            CylinderMove(IOManager.StopCylinder_Down, IOManager.StopCylinder_Up, false);
            SideCyliderBack(false );
            Work.StopWork();
            LineStep.EndMove();

            IOManager.IOMove(IOManager.Line_FStart, IO_VALUE.LOW);
            LogUtil.info("StopMove,开始停止所有旋转轴");

            foreach (Dictionary<int, NodeInfo> map in RotateMap.Values)
            {
                foreach (NodeInfo nodeid in map.Values)
                {
                    if (PUSICANControl.IsBusy(nodeid.NodeId))
                    {
                        PUSICANControl.StopMove(nodeid.NodeId);
                        Thread.Sleep(PUSICANControl.SleepMS);
                    }
                }
            }
        }
        private static void CheckWorkWait()
        {
            try
            {
                TimeSpan span = DateTime.Now - Work.LastSetpTime;
                List<WaitResultInfo> list = Work.waitList;
                string waitMsg = "";
                bool isOk = WaitResultInfo.GetWaitResult(list, span, false, out waitMsg);
                if (isOk)
                {
                    Work.EndWait();
                }
                if (Work.IsWaitMove)
                {
                    if (span.TotalSeconds > 30)
                    {
                        WarnMsg = GetTime() + ResourceControl.GetString(ResourceControl.WaitTimeOutMsg, "组装中,等待【{0}】超时 已等待[{1}]秒", waitMsg, Math.Round(span.TotalSeconds, 0));
                        LogUtil.error(WarnMsg);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.error("出错:" + ex.ToString());
            }
        }



        //public static double X_Min = (double)ConfigAppSettings.GetNumValue(Setting_Init.XAxis_MinValue);
        //public static double X_Max = (double)ConfigAppSettings.GetNumValue(Setting_Init.XAxis_MaxValue);
        //public static double Y_Min = (double)ConfigAppSettings.GetNumValue(Setting_Init.YAxis_MinValue);
        //public static double Y_Max = (double)ConfigAppSettings.GetNumValue(Setting_Init.YAxis_MaxValue);
        public static double X_Min = 1;
        public static double X_Max = 1920;
        public static double Y_Min = 1;
        public static double Y_Max = 1080;
        public static double X_ChangeValue = 1;
        public static double Y_ChangeValue = 1;
        /// <summary>
        /// 判断是否是有效的地址
        /// </summary> 
        public static bool IsValidPosition(double x, double y)
        {
            if (X_Min <= x && x <= X_Max && Y_Min <= y && y <= Y_Max)
            {
                return true;
            }
            return false;
        }


        public static string GetShowMsg()
        {
            string ShowMsg = "";
            if (TSAVBean.IsInSuddenDown)
            {
                ShowMsg = ResourceControl.GetString(ResourceControl.DeviceInSuddenStop, "设备急停中");
            }
            else if (TSAVBean.Status.Equals(TSAVStatus.Wait))
            {
                ShowMsg = ResourceControl.GetString(ResourceControl.DeviceNotStart, "设备未启动");
            }
            else if (TSAVBean.Status.Equals(TSAVStatus.Reset))
            {
                ShowMsg = ResourceControl.GetString(ResourceControl.DeviceInGohome, "设备正在原点返回中");
            }
            else if (TSAVBean.Status.Equals(TSAVStatus.Runing))
            {
                string msg = ResourceControl.GetString(ResourceControl.DeviceInWork, "设备工作中");
                string lineMsg = ResourceControl.GetString(ResourceControl.LineTurn, "流水线转动中"); 
                if (TSAVBean.Work.IsWorking)
                {
                    TimeSpan span = DateTime.Now - TSAVBean.Work.beginWorkTime;
                    int count = TSAVBean.Work.BoardCount;
                    string time = span.Hours.ToString().PadLeft(2, '0') + ":" + span.Minutes.ToString().PadLeft(2, '0') + ":" + span.Seconds.ToString().PadLeft(2, '0');
                    ShowMsg = ResourceControl.GetString(ResourceControl.WorkInfoMsg, "已工作{0},{1}块电路板", time, count) + "\r\n" + TSAVBean.WarnMsg;
                }
                else if (TSAVBean.LineStep.moveType.Equals(1))
                {
                    ShowMsg = lineMsg + "\r\n" + TSAVBean.WarnMsg;
                }
                else
                {
                    ShowMsg = msg + "\r\n" + TSAVBean.WarnMsg;
                } 
            }
            return ShowMsg;
        }
    }
    public class NodeInfo
    {
        public NodeInfo(uint nodeId, string name, string str)
        {
            this.NodeId = nodeId;
            this.NodeName = name;
            this.NodeStr = str;
        }
        public uint NodeId { get; set; }

        public string NodeName { get; set; }

        public string NodeStr { get; set; }
    }
}