StoreStep.cs 18.1 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
using log4net;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Text;

using System.Windows.Forms;

namespace OnlineStore.DeviceLibrary
{

    /// <summary>
    /// 等待启动/已经停止,初始化完成, 正常运行中,可以进行新的处理,忙碌,重置
    /// </summary>
    public enum StoreRunStatus
    {
        /// <summary>
        /// 等待启动/已经停止
        /// </summary>
        Wait = 0,
        ///// <summary>
        /////  初始化 ,原点返回状态中,只有流水线使用
        ///// </summary>
        HomeMoving = 1,

        /// <summary>
        /// 设备正在重置中,请稍后
        /// </summary>
        Reset = 2,
        /// <summary>
        /// 正常运行中,可以进行新的处理
        /// </summary>
        Runing = 3,

        /// <summary>
        /// 正在忙碌中,请稍后
        /// </summary>
        Busy = 4,

    }
    /// <summary>
    ///1=设备联机(正常就绪)(入库后,BOX恢复原始状态)(出库后,移载装置恢复原始状态),
    ///2=急停,3=故障,4=警告,5=调试
    /// 6=入库执行中,7=入仓完成,8=入仓失败
    /// 9=出库执行,10=出仓完成,11=出库失败
    /// </summary>
    public enum StoreStatus
    {
        /// <summary>
        /// 1=设备联机(正常就绪)(入库后,BOX恢复原始状态)(出库后,移载装置恢复原始状态),
        /// </summary>
        StoreOnline = 1,
        /// <summary>
        ///2=急停中
        /// </summary>
        SuddenStop = 2,
        /// <summary>
        /// 3=故障中
        /// </summary>
        InTrouble = 3,
        /// <summary>
        /// 4=警告
        /// </summary>
        Warning = 4,
        /// <summary>
        /// 5=设备调试中 
        /// </summary>
        Debugging = 5,
        /// <summary>
        /// 6=入库执行中 
        /// </summary>
        InStoreExecute = 6,
        /// <summary>
        /// 7= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态) 
        /// </summary>
        InStoreEnd = 7,
        /// <summary>
        /// 8=入库失败
        /// </summary>
        InStoreFaild = 8,
        /// <summary>
        /// 9=出库执行中",
        /// </summary>
        OutStoreExecute = 9,
        /// <summary>
        ///10= 出仓位完成( 料盘已经放到Box门口) 
        /// </summary>
        OutStoreBoxEnd = 10,
        /// <summary>
        /// 12=移栽出库移栽过程中(移栽完成后变成OnLine)
        /// </summary>
        OutMoveExecute = 12,
        /// <summary>
        ///11=出库失败
        /// </summary>
        OutStoreFaild = 11,
        /// <summary>
        /// 重置中(原点返回和重置都发此状态)
        /// </summary>
        ResetMove = 13,
    }

    /// <summary>
    /// 料仓运动状态(当料仓状态=busy时,才会有此运动状态)
    /// </summary>
    public enum StoreMoveStep
    {
        /// <summary>
        /// 无操作,等待状态
        /// </summary>
        Wait = 0,
        #region 料仓复位 011 开始

        /// <summary>
        /// BOX复位:进出轴回原点
        /// </summary>
        BOX_H01_InOutBack = 011,

        /// <summary>
        /// BOX复位:进出轴回原点
        /// </summary>
        BOX_H02_InoutToP1,

        /// <summary>
        /// BOX复位:其他轴回原点
        /// </summary>
        BOX_H03_OtherAxisHome,

        /// <summary>
        ///  BOX复位:升降轴,旋转轴,压紧轴原点返回
        /// </summary>
        BOX_H04_OtherAxisBack,
        #endregion

        #region 料仓内部入库步骤 200开始

        /// <summary>
        /// 入库:进出轴返回P1
        /// </summary>
        SI_01_InoutToP1 = 201,
        /// <summary>
        /// 入库: 升降轴,旋转轴到P1,压紧轴到P3
        /// </summary>
        SI_02_AxisBack,

        /// <summary>
        /// 入库:进出轴到P2( 进料口取料点)
        /// </summary>
        SI_03_InoutToP2,
        /// <summary>
        /// 入库:升降轴到P7( 进料口取料缓冲点)压紧轴到P2(压紧点)
        /// </summary>
        SI_04_GetReel,

        /// <summary>
        /// 入库:进出轴返回P1
        /// </summary>
        SI_05_InoutToP1,

        /// <summary>
        /// 入库:移动到库位点,旋转轴到P2( 库位点),升降轴到P3(库位入库前点)
        /// </summary>
        SI_06_ToPos,
        /// <summary>
        /// 入库:进出轴到P3(库位取放料点)
        /// </summary>
        SI_07_InoutToP3,
        /// <summary>
        /// 入库:升降轴到P4( 库位入料缓冲点)压紧轴到P3( 压紧前点)
        /// </summary>
        SI_08_PutReel,
        /// <summary>
        /// 入库:进出轴返回P1
        /// </summary>
        SI_09_InoutToP1,
        /// <summary>
        /// 入库:旋转轴,升降轴,压紧轴到待机点P1
        /// </summary>
        SI_10_GoBack,


        /// <summary>
        /// 入库NG料:移动到出料口,旋转轴到P11,升降轴到P12高点
        /// </summary>
        SI_21_ToOutDoor,
        /// <summary>
        /// 入库NG料:打开出料口门
        /// </summary>
        SI_22_OpenOutDoor,
        /// <summary>
        /// 入库NG料:进出轴到_P11-出料口取放料点
        /// </summary>
        SI_23_InoutToP11,
        /// <summary>
        /// 入库NG料:升降轴到_P11-出料口-低点,压紧轴到压紧前点P3
        /// </summary>
        SI_24_PurReel,
        /// <summary>
        /// 入库NG料:进出轴返回待机点P1
        /// </summary>
        SI_25_InoutToP1,
        /// <summary>
        /// 入库NG料:升降轴,旋转轴,压紧轴返回P1,关闭出料口门
        /// </summary>
        SI_26_GoBack,
        #endregion

        #region 料仓内部出库  500 开始



        /// <summary>
        ///料仓出库:进出轴到P1
        /// </summary>
        SO_01_InoutBack = 501,

        /// <summary>
        ///  料仓出库:压紧轴到压紧前点P3 ,旋转轴到库位点P2,轴2(上下) 至P5(库位出库前点) 
        /// </summary>
        SO_02_ToPosition,
        /// <summary>
        ///  料仓出库:进出轴到库位P3
        /// </summary>
        SO_03_InoutToP3,

        /// <summary>
        ///料仓出库:升降轴到P6,轴4( 压紧) 至P2(压紧点)
        /// </summary>
        SO_04_GetReel,

        /// <summary>
        ///料仓出库:进出轴返回P1
        /// </summary>
        SO_05_InoutBack,


        /// <summary>
        /// 料仓出库:旋转轴至P1,升降轴至P2  
        /// </summary>
        SO_06_ToDoor,
        /// <summary>
        /// 料仓出库:进出轴到P2
        /// /// </summary>
        SO_07_InoutToP2,
        /// <summary>
        /// 料仓出库: 放下物品 升降轴至P1,压紧轴到P3
        /// </summary>
        SO_08_PutReel,
        /// <summary>
        /// 料仓出库: 进出轴到P1
        /// </summary>
        SO_09_InoutBack,

        /// <summary>
        /// 料仓出库:升降轴,旋转轴到待机点P1
        /// </summary>
        SO_10_GoBack,



        /// <summary>
        /// 单盘出库:移动到出料口,旋转轴到P11,升降轴到P12高点
        /// </summary>
        SO_21_ToOutDoor,
        /// <summary>
        /// 单盘出库:打开出料口门
        /// </summary>
        SO_22_OpenOutDoor,
        /// <summary>
        /// 单盘出库:进出轴到_P11-出料口取放料点
        /// </summary>
        SO_23_InoutToP11,
        /// <summary>
        /// 单盘出库:升降轴到_P11-出料口-低点,压紧轴到压紧前点P3
        /// </summary>
        SO_24_PurReel,
        /// <summary>
        /// 单盘出库:进出轴返回待机点P1
        /// </summary>
        SO_25_InoutToP1,
        /// <summary>
        /// 单盘出库:升降轴,旋转轴,压紧轴返回P1,关闭出料口门
        /// </summary>
        SO_26_GoBack,
        #endregion

        #region 流水线模块复位 1001开始
        /// <summary>
        /// 复位:所有阻挡上升
        /// </summary>
        LR_01_StopUp = 1001,

        /// <summary>
        /// 复位:流水线转动3秒
        /// </summary>
        LR_02_LineRun,
        /// <summary>
        /// 复位:夹爪放松,提升轴回原点,上下轴回原点
        /// </summary>
        LR_03_BatchAxisHome,
        /// <summary>
        /// 复位:提升轴到P1点,上下轴到待机点P1
        /// </summary>
        LR_04_BatchToP1,
        /// <summary>
        /// 复位:取料电机后退,旋转轴回原点
        /// </summary>
        LR_05_Hoister_Back,
        /// <summary>
        /// 复位:顶升气缸下降,旋转轴到待机点P1
        /// </summary>
        LR_06_TopDown,
        /// <summary>
        /// 复位:等待料仓复位完成
        /// </summary>
        LR_07_WaitBox,
        #endregion



        #region 入料装置入料处理,2001 开始
        //线体入口料串检测到料架
        //    链条转动到线体上料等待区检测

        //提升伺服先上升到待机点,SL1升降盘定位气缸1后退,定位气缸下降,料架才能进入上料工位
        //料架进入上料工位后,定位气缸先上升
        //提升伺服下降到P2
        ////升降盘定位气缸前进
        //提升伺服缓慢上升,绝对位置=P1,若上升到P1么有X105,那么没有料盘
        //    检测到X105信号,提升伺服停止

        //    上料横移机构取料
        //    上料横移机构下降
        //    上料横移机构夹紧
        //    上料横移机构上升
        //                          提升伺服开始缓慢上升到位
        // 计算高度,宽度并记录 
        // 上料横移机构到放料端
        //等待拦截到托盘,并顶升上升,定位上升
        // 上料横移机构下降
        // 移栽伺服下降到对应盘高位置
        //上料气缸放松
        // 移栽伺服上升,
        // 上料横移机构上升
        /// <summary>
        /// 提升轴先返回P1
        /// </summary>
        LI_00_BatchAxisToP1 = 2001,
        /// <summary>
        /// 入料流程:升降盘定位气缸后退
        /// </summary>
        LI_01_TrayLocation_After,
        /// <summary>
        /// 入料流程:定位气缸下降
        /// </summary>
        LI_02_LocationCylinder_Down,
        /// <summary>
        /// 入口流水线转动,等待入料检测信号消失
        /// </summary>
        LI_03_LineStart,
        /// <summary>
        /// 入口流水线转动,等待定位工位信号稳定1秒
        /// </summary>
        LI_04_WaitTime,


        /// <summary>
        ///入料检测:  工位检测信号,定位气缸上升
        /// </summary>
        LI_05_LocationCylinder_Up,

        /// <summary>
        /// 入料检测:提升轴下降到位P2
        /// </summary>
        LI_06_BatchAxisToP2,
        /// <summary>
        /// 入料检测:升降盘定位气缸第一次前进
        /// </summary>
        LI_07_TrayLocation_Before,
        /// <summary>
        /// 入料检测:升降盘定位气缸第一次后退
        /// </summary>
        LI_08_TrayLocation_Back,
        /// <summary>
        /// 入料检测:升降盘定位气缸前进
        /// </summary>
        LI_09_TrayLocation_Before,
        /// <summary>
        /// 入料检测:上料轴开始慢速上升到P3点,等待检测到料盘
        /// </summary>
        LI_10_AxisUpMove,

        /// <summary>
        /// 入料取料:横移机构先上升
        /// </summary>
        LI_11_CylinderUp,

        /// <summary>
        /// 入料取料:上料机构到放料端
        /// </summary>
        LI_12_CylinderGive,
        /// <summary>
        /// 入料检测到料盘:扫码
        /// </summary>
        LI_13_ScanCode,

        /// <summary> 
        /// 料盘移栽:有料盘:上料横移机构取料
        /// </summary>
        LI_14_CylinderTake,

        /// <summary>
        ///  料盘移栽:升降轴到P3
        /// </summary>
        LI_15_UpdownAxisToP3,

        /// <summary>
        ///  料盘移栽:上料横移机构夹紧
        /// </summary>
        LI_16_CylinderTighten,
        /// <summary>
        ///  料盘移栽:升降伺服到P1点
        /// </summary>
        LI_17_UpdownAxisToP1,
        /// <summary>
        /// 料盘移栽:等待没有伺服料盘检测信号
        /// </summary>
        LI_18_WaitNoLocationCheck,
        /// <summary>
        /// 料盘移栽:批量轴到P3点,检测是否有料盘
        /// </summary>
        LI_19_BatchAxisToP3,
        /// <summary>
        ///  料盘移栽:记录高度尺寸
        /// </summary>
        LI_20_SaveSize,

        /// <summary>
        /// 料盘移栽: 上料横移气缸放料SOL
        /// </summary>
        LI_21_CylinderGive,
        /// <summary>
        /// 提升轴下降到料盘不溢出的位置
        /// </summary>
        LI_22_BatchAxisDown,
        /// <summary>
        ///  料盘移栽:从服务器获取入库库位号
        /// </summary>
        LI_23_GetPosID,

        /// <summary>
        ///  料盘移栽:等待空托盘到达,移栽伺服下降到P2,并预扫码
        /// </summary>
        LI_24_WaitTray,

        /// <summary>
        /// 料盘移栽:  上料机构下降
        /// </summary>
        LI_25_CylinderDown,

        /// <summary>
        /// 料盘移栽: 上料气缸放松
        /// </summary>
        LI_26_CylinderRelax,
        /// <summary>
        /// 料盘移栽: 上料横移机构上升
        /// </summary>
        LI_27_WaitCylinderUp,
        /// <summary>
        ///  料盘移栽:上料横移机构上升,定位或者顶升可以先下降
        /// </summary>
        LI_28_CylinderUp,
        /// <summary>
        ///  料盘移栽:升降伺服到P1点
        /// </summary>
        LI_29_UpDownAxisToP1,



        /// <summary>
        /// 上料完成,未检测到料盘,提升伺服到P2点
        /// </summary>
        LI_31_BatchAxisToP2 = 11031,
        /// <summary>
        /// 上料完成,升降盘定位气缸后退
        /// </summary>
        LI_32_TrayLocationCylinder_After = 11032,

        /// <summary>
        /// 上料完成,提升伺服到P1点
        /// </summary>
        LI_33_BatchAxisToP1 = 11033,

        /// <summary>
        /// 上料完成,等待出料线体无料架
        /// </summary>
        LI_34_OutCheck = 11034,
        /// <summary>
        /// 上料完成,出口顶升气缸上升
        /// </summary>
        LI_35_OutTopCylinder_Up = 11035,

        /// <summary>
        ///上料完成, 线体横移电机运转,等待料架到达出口
        /// </summary>
        LI_36_SideWayLineRun = 11036,
        /// <summary>
        ///上料完成,等待料架到达出口
        /// </summary>
        LI_37_WaitShelfGo = 11307,

        /// <summary>
        ///上料完成, 料架到达出口,线体横移电机停止
        /// </summary>
        LI_38_LineStop,
        /// <summary>
        ///上料完成, 料架到达出口,出口顶升下降,定位气缸下降, 
        /// </summary>
        LI_39_TopDown,

        /// <summary>
        ///上料完成, 出口线体运转,料架到达出口处, 通知AGV取空料架
        /// </summary>
        LI_39_OutLineRun,
        /// <summary>
        ///上料完成, AGV到达,继续转动出口线体,送走出料料架, 
        /// </summary>
        LI_40_OutLineRun,

        /// <summary>
        ///上料完成, 料架送出, 
        /// </summary>
        LI_41_OutLineRun,
        #endregion
         

         

        #region 把料架送出步骤 4000开始

        /// <summary>
        /// 送出空料架:顶升气缸下降
        /// </summary>
        BS_01_TopDown = 4001,
        /// <summary>
        /// 送出空料架:定位气缸下降
        /// </summary>
        BS_02_LocatinDown = 4002,

        /// <summary>
        /// 通知AGV准备空车
        /// </summary>
        BS_03_WaitEmptyAgv = 4003,
        /// <summary>
        /// 送出空料架:打开仓门
        /// </summary>
        BS_04_DoorOpen = 4004,
        /// <summary>
        /// 送出空料架:等待agvReady
        /// </summary>
        BS_05_WaitReady = 4005,
        /// <summary>
        /// 送出空料架:线体反转
        /// </summary>
        BS_06_LineBackRun = 4006,
        /// <summary>
        /// 送出空料架:等待取料工位无信号
        /// </summary>
        BS_07_WaitShelfOut = 4007,
        /// <summary>
        /// 送出空料架:等待取料工位无信号,入料口有信号
        /// </summary>
        BS_08_WaitLineIn = 4008,
        /// <summary>
        /// 送出空料架:再转动3000时间
        /// </summary>
        BS_09_WaitTime = 4009,
        /// <summary>
        /// 送出空料架:等待AGV离开后关闭仓门
        /// </summary>
        BS_10_WaitAGVLeave = 4010,
        /// <summary>
        /// 送出空料架:关闭仓门
        /// </summary>
        BS_11_CloseDoor = 4011,
        #endregion
         

    }

    public enum AlarmType
    {
        /// <summary>
        /// 没有报警
        /// </summary>
        None = 0,
        /// <summary>
        /// 轴报警
        /// </summary>
        AxisAlarm = 1,
        /// <summary>
        /// 收到急停
        /// </summary>
        SuddenStop = 10,
        /// <summary>
        /// 没有气压信号
        /// </summary>
        NoAirCheck = 11,
        /// <summary>
        /// 轴运动错误,没有达到指定脉冲,但是io判断已停止运动
        /// </summary>
        AxisMoveError = 20,
        /// <summary>
        /// io信号超时未收到
        /// </summary>
        IoSingleTimeOut = 30,
        /// <summary>
        /// 电钢报警
        /// </summary>
        StellAlarm = 50,
    }
}