StoreStep.cs 14.0 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
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>
    ///0= 等待启动/已经停止,1=初始化完成, 2=正常运行中,3=可以进行新的处理,4=忙碌,重置
    /// </summary>
    public enum LineRunStatus
    {
        /// <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 LineStatus
    {
        None=0,
        /// <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 LineMoveStep
    {
        /// <summary>
        /// 无操作,等待状态
        /// </summary>
        Wait = 0,


        #region 移栽装置原点返回和重置步骤
        /// <summary>
        /// 上下气缸回原点
        /// </summary>
        MH_UpDownHomeMove=2000,
        /// <summary>
        /// 料仓移栽装置,上下气缸上升端
        /// </summary>
        MH_UpDownCylinder_Up = 2001,
        /// <summary>
        /// 料仓移载装置,其他气缸运行到初始状态( 顶升气缸下降端,前后气缸后退端,夹料气缸放松端,阻挡气缸输入=0 )
        /// </summary>
        MH_OtherCylinder_Back = 2002,

        #endregion


        #region 流水线入仓操作 10000开始
        /// <summary>
        /// 流水线入仓,开始扫码  扫描枪触发,数据处理
        /// </summary>
        LI_Scannering = 10001,
        /// <summary>
        /// 流水线入仓,料仓号及库位号发送, 夹具号编码记忆(X5,X6.X7)数据接收
        /// </summary>
        LI_WaitServerResult = 10002,
        /// <summary>
        /// 等待100毫秒后再放行
        /// </summary>
        LI_00_Wait100 = 10003,
        /// <summary>
        /// 阻挡气缸0-2下降
        /// </summary>
        LI_01_StopCylinder2Down = 10004,
        /// <summary>
        /// 检测夹具检测1=0 ) 开始
        /// </summary>
        LI_02_FixtureCheck = 10005,
        /// <summary>
        /// 阻挡气缸0-2上升
        /// </summary>
        LI_03_StopCylinder2Up = 10006,   
        /// <summary>
        /// 阻挡气缸0-1下降
        /// </summary>
        LI_04_StopCylinder1Down = 10007,
        #endregion

        #region 流水线出库操作
        /// <summary>
        /// 流水线出库,等待100毫秒之后在放行
        /// </summary>
        LO_00_Wait100 = 11000,
        /// <summary>
        /// 流水线出库,阻挡气缸0-2下降 
        /// </summary>
        LO_01_StopCylinder2Down = 11001,
        /// <summary>
        /// 流水线出库, 检测夹具检测1=0
        /// </summary>
        LO_02_FixtureCheck = 11002,
        /// <summary>
        /// 流水线出库,阻挡气缸0-2上升 
        /// </summary>
        LO_03_StopCylinder2Up = 11003,
        /// <summary>
        /// 阻挡气缸0-1下降 
        /// </summary>
        LO_04_StopCylinder1Up = 11004,

        #endregion

        #region 移栽装置出入库共同模块 3080开始
        /// <summary>
        ///移载(流水线)装置出入库处理,阻挡气缸1-1下降 
        /// </summary>
        MIO_01_StopCylinder1Down = 3081,
        /// <summary>
        ///移载(流水线)装置出入库处理,夹具检测1-4=1 
        /// </summary>
        MIO_02_FixtureCheck = 3082,
        /// <summary>
        ///移载(流水线)装置出入库处理,阻挡气缸1-1上升 
        /// </summary>
        MIO_03_StopCylinder2Down = 3083,
        /// <summary>
        /// 检测夹具检测IO1=1
        /// </summary>
        MIO_04_Wait = 3084,
        /// <summary>
        /// 等待一秒钟
        /// </summary>
        MIO_05_WaitTime = 3085,

        /// <summary>
        ///移载(流水线)装置出入库处理,顶 升气缸上升 
        /// </summary>
        MIO_06_TopCylinderUp = 3086,
        /// <summary>
        /// 此处 顶升气缸上升时等待一秒钟,再下降,现在看起来没有升到位就下降
        /// </summary>
        MIO_07_TopCylinderUpWait = 3087,
        /// <summary>
        /// 等待StoreMove完成当前操作开始入库
        /// </summary>
        MIO_08_WaitInStore=3088,
        /// <summary>
        /// 等待StoreMove移走料盘开始放托盘通过
        /// </summary>
        MIO_09_WaitLetFixtureGo=3089,
        #endregion 

        #region 移栽装置出库处理 3100开始
        /// <summary>
        /// 移载(流水线)装置出库处理, 检测夹具编码并记忆,托盘 是空盘,并且BOX在出库等待中,开始移栽料盘
        /// </summary>
        MO_05_CodeRember = 3105,
        /// <summary>
        /// 移载(流水线)装置出库处理 ,顶升气缸1下降 
        /// </summary> 
        MO_06_TopCylinder_Down = 3106,
        /// <summary>
        /// 如果是移栽2需要等待托盘是否可以走
        /// </summary>
        MO_07_WaitCanGo=3107,
        /// <summary>
        /// 移载(流水线)装置出库处理, 阻挡气缸1-2下降 
        /// </summary>
        MO_10_StopCylinder2_Down = 3110,
        /// <summary>
        /// 移载(流水线)装置出库处理,  夹具检测1-4=0, 
        /// </summary>
        MO_11_Tray_Check = 3111,
        /// <summary>
        /// 移载(流水线)装置出库处理, 阻挡气缸1-1下降 阻挡气缸1-2上升 
        /// </summary>
        MO_12_StopCylinder_Back = 3112,

        /// <summary>
        /// 移栽装置出库处理,开始出库
        /// </summary>
        MO_50_StartOutProcess=3150,
        /// <summary>
        /// 移栽装置出库处理。。前后气缸1前进 
        /// </summary>
        MO_51_BeforeAfterCylinderBefore = 3151,
        /// <summary>
        /// 移栽装置出库处理。上下气缸1下降 
        /// </summary>
        MO_52_UpDownCylinderDown = 3152,
        /// <summary>
        /// 移栽装置出库处理。上下气缸1下降后,等待0.3秒再夹紧,防止没有下降到位就夹紧操作
        /// </summary>
        MO_53_UpDownCylinderDownWait = 3153,

        /// <summary>
        /// 移栽装置出库处理。 夹料气缸1夹紧 
        /// </summary>
        MO_54_ClampCylinderSlack = 3154,
        /// <summary>
        /// 移栽装置出库处理。 上下气缸1上升 
        /// </summary>
        MO_55_UpDownCylinderUp = 3155,
        /// <summary>
        /// 移栽装置出库处理。 前后气缸1后退 
        /// </summary>
        MO_56_BeforeAfterCylinderAfter = 3156,
        
        /// <summary>
        /// 移载(流水线)装置出库处理,上下气缸1下降 
        /// </summary>
        MO_58_UpDownCylinderDown = 3158,
        /// <summary>
        /// 移载(流水线)装置出库处理,夹料气缸1放松 
        /// </summary>
        MO_59_ClampCylinderTighten = 3159,
        /// <summary>
        /// 移载(流水线)装置出库处理,上下气缸1上升 
        /// </summary>
        MO_60_UpDownCylinderUp = 3160,
       

      

        #endregion


        #region 移载装置入库处理 3000开始

        /// <summary>
        ///移载装置入库处理,检测 夹具编码
        /// </summary>
        MI_05_CodeCheck = 3005,
     
        /// <summary>
        ///移载装置入库处理,编码与仓位一致,上下气缸1下降
        /// </summary>
        MI_07_UpDownCylinderDown = 3007,
        /// <summary>
        ///移载装置入库处理,编码与仓位一致,上下气缸1下降后,等待0.3秒,防止没有 下降到位就夹紧
        /// </summary>
        MI_07_UpDownCylinderDownWait = 3024,
        /// <summary>
        ///移载装置入库处理,夹料气缸1夹紧
        /// </summary>
        MI_08_ClampCylinderSlack = 3008,
        /// <summary>
        ///移载装置入库处理,上下气缸1上升
        /// </summary>
        MI_09_UpDownCylinderUp = 3009,
        /// <summary>
        ///移载装置入库处理,,前后气缸1前进
        /// </summary>
        MI_10_BeforeAfterCylinderBefore = 3010,

        /// <summary>
        /// 移载装置入库处理,等待box等待状态才能继续操作
        /// </summary>
        MI_10_WaitBox = 3006,
        /// <summary>
        ///移载装置入库处理,上下气缸1下降
        /// </summary>
        MI_11_UpDownCylinderDown = 3011,
        /// <summary>
        ///移载装置入库处理,,夹料气缸1放松
        /// </summary>
        MI_12_ClampCylinderTighten = 3012,
        /// <summary>
        ///移载装置入库处理,上下气缸1上升
        /// </summary>
        MI_13_UpdownCylinderUp = 3013,
        /// <summary>
        ///移载装置入库处理,,前后气缸1后退
        /// </summary>
        MI_14_BeforeAfterCylinderAfter = 3014,
        /// <summary>
        ///移载装置入库处理,检测到X102-1=1送料流程完成
        /// </summary>
        MI_15_SendEnd = 3015,
        /// <summary>
        ///移载装置入库处理,编码不一致,顶升气缸1下降
        /// </summary>
        MI_20_TopCylinderDown = 3020,
        /// <summary>
        ///移载装置入库处理,阻挡气缸1-2下降
        /// </summary>
        MI_21_StopCylinderDown = 3021,
        /// <summary>
        ///移载装置入库处理,检测Check4=0,
        /// </summary>
        MI_22_FixtureCheck_Low = 3022,
        /// <summary>
        ///移载装置入库处理,,,阻挡气缸1-2  上升,等待200毫秒
        /// </summary>
        MI_23_StopCylinderReset = 3023,

        #endregion
    
        
        #region 横移轨道处理
        SW00_Wait=5000,
        /// <summary>
        /// 阻挡气缸下降
        /// </summary>
        SW01_StopCylinderDown=5001,

        /// <summary>
        /// 等待轨道1夹具检测信号
        /// </summary>
        SW02_WaitFixtureCheck=5002,

        /// <summary>
        /// 横移轨道顶升气缸上升
        /// </summary>
        SW03_TopCylinderUp=5003,
        /// <summary>
        /// 横移轨道点击转动
        /// </summary>
        SW04_DriveMotorMove=5004,

        /// <summary>
        /// 收到横移轨道2夹具检测信号
        /// </summary>
        SW05_WaitOutFixtureCheck=5005,
        /// <summary>
        /// 等待出口信号持续一段时间
        /// </summary>
        SW06_WatOutFixture2=5006,
        /// <summary>
        /// 停止横移轨道转动,横移轨道顶升气缸下降
        /// </summary>
        SW07_TopCylinderDown=5007,

        /// <summary>
        /// 阻挡2下降,等待托盘流出
        /// </summary>
        SW08_StopDrive=5008,
        /// <summary>
        /// 等待托盘流出,上升阻挡气缸
        /// </summary>
        SW09_WaitTrayGo=5009,

        #endregion

    }

    public enum LineAlarmType
    {
        /// <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,
    }
}