AC_BOX_Bean_Shelf.cs 30.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 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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OnlineStore.DeviceLibrary
{
    public partial class AC_BOX_Bean
    {
        #region 料架进出料仓处理:出入库模块共用

        private void BI_04_WaitTakeSingle(string moveName)
        {
            MoveInfo.NextMoveStep(StoreMoveStep.BI_04_WaitTakeSingle);
            InOutStoreLog(moveName + MoveInfo.SLog + " 线体正转,等待LineIn_Check=Low, 信号LineTake_Check=High");
            LineRun();
            MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.LOW));
            MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.HIGH));
        }
        private void ShelfEnterProcess()
        {
            string moveName = "料架入库";
            bool instoreShelf = true;
            if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
            {
                instoreShelf = false;
                moveName = "空料架进入";
            }
            if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_01_ReadyShelf))
            {
                if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
                {
                    BI_04_WaitTakeSingle(moveName);
                }
                else if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
                {
                    BI_04_WaitTakeSingle(moveName);
                }
                else
                {
                    // MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
                    InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.MayEnter,小车已到达,打开入料口移门");
                    MoveInfo.NextMoveStep(StoreMoveStep.BI_02_DoorOpen);
                    DoorBean.StartOpen(MoveInfo);
                }
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_02_DoorOpen))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BI_03_LineRun);
                InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.MayEnter,线体正转,等待LineIn_Check信号");
                AgvClient.MayEnter(Config.AgvNodeName);
                LineRun();
                MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
            {
                BI_04_WaitTakeSingle(moveName);
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BI_05_LineStop);
                InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.FinishEnter,取料位检测到信号,停止线体正转");
                LineStop();
                AgvClient.FinishEnter(Config.AgvNodeName);

                if (!instoreShelf)
                {
                    EmprtShelfList = new System.Collections.Concurrent.ConcurrentQueue<string>(ShelfPosList);
                    if (MoveInfo.MoveParam.ShelfPosID.Equals(""))
                    {
                        string shelfPosId = "";
                        bool result = EmprtShelfList.TryDequeue(out shelfPosId);
                        if (result)
                        {
                            MoveInfo.MoveParam.UpdateShelfPosId(shelfPosId);
                            InOutStoreLog("出库 " + MoveInfo.SLog + ":重置EmprtShelfList列表,设置料架位置:" + MoveInfo.MoveParam.ShelfPosID);
                        }
                        else
                        {
                            waitOutStoreList.Enqueue(MoveInfo.MoveParam);
                            InOutStoreLog("出库 " + MoveInfo.SLog + ":重置EmprtShelfList列表,获取料架位置失败!结束出库,并将" + MoveInfo.MoveParam.ToStr() + "放入等待列表");

                            MoveEndToRuningStatus();
                        }
                    }
                }

            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_05_LineStop))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BI_06_DoorClose);
                InOutStoreLog(moveName + MoveInfo.SLog + "入料口移门关闭");
                //   CylinderMove(MoveInfo, IO_Type.EntranceDoor_Open, IO_Type.EntranceDoor_Close); 
                DoorBean.StartClose(MoveInfo);
                if (!instoreShelf)
                {
                    InOutStoreLog("出库 " + MoveInfo.SLog + ": 走到库位,压紧轴至P3(压紧前点) ,旋转轴至P2(库位点),升降轴至P5(库位出库前点)");
                    ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P3, Config.CompAxis_P3_Speed);
                    ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
                    ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
                }
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_06_DoorClose))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BI_07_LineRun);
                InOutStoreLog(moveName + MoveInfo.SLog + "继续转动1500");
                LineRun();
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_07_LineRun))
            {
                LineStop();
                MoveInfo.NextMoveStep(StoreMoveStep.BI_08_LocationUp);
                InOutStoreLog(moveName + MoveInfo.SLog + "线体停止转动,定位装置上升,读取料架编号");
                // CylinderMove(MoveInfo, IO_Type.LocationCylinder_Down, IO_Type.LocationCylinder_Up);
                UpdateShelfId();
                if (!instoreShelf)
                {
                    InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子进入库位中,  进出轴至P3(库位取放料点) ");
                    ACAxisMove(Config.InOut_Axis, MoveInfo.MoveParam.MoveP.InOut_P3, Config.InOutAxis_P3_Speed);
                }
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_08_LocationUp))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BI_09_TopCylinderUp);
                InOutStoreLog(moveName + MoveInfo.SLog + "顶升装置上升");
                CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);

                if (!instoreShelf)
                {
                    InOutStoreLog("出库 " + MoveInfo.SLog + ": 拿起物品,升降轴至P6(库位出料缓冲点),压紧轴至P2(压紧点) ");
                    ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P2, Config.CompAxis_P2_Speed);
                    ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
                }
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_09_TopCylinderUp))
            {
                if (instoreShelf)
                {
                    MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
                    InOutStoreLog(moveName + MoveInfo.SLog + "开始循环从第一个空位逐个取料盘,扫码入库");
                }
                else
                {
                    MoveInfo.NextMoveStep(StoreMoveStep.SO_06_BagDeviceBack);
                    InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子从库位返回,进出轴至P1(待机点) ");
                    //ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
                    InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
                    //把库位的物品放到取到叉子上之后是出仓完成 
                    string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
                    lastPosId = posId;
                    lastPosIdStatus = StoreStatus.OutStoreBoxEnd;
                    storeStatus = StoreStatus.OutStoreBoxEnd;
                }
            }
        }

        private void StartShelfOut()
        {
            MoveInfo.NextMoveStep(StoreMoveStep.BS_01_TopCylinder_Down);
            if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
            {
                InOutStoreLog("送出出库料架:顶升气缸下降");
            }
            else
            {
                InOutStoreLog("送出空料架:顶升气缸下降");
            }
            CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
        }
        private void ShelfOutProcess()
        {
            string moveName = "送出空料架";
            bool instoreShelf = true;
            if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
            {
                instoreShelf = false;
                moveName = "送出出库料架";
            }

            if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_01_TopCylinder_Down))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BS_02_LocatinCylinder_Down);
                InOutStoreLog(moveName + MoveInfo.SLog + " :定位气缸下降");
                // CylinderMove(MoveInfo, IO_Type.LocationCylinder_Up, IO_Type.LocationCylinder_Down);
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_02_LocatinCylinder_Down))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BS_03_DoorOpen);
                InOutStoreLog(moveName + MoveInfo.SLog + ":打开入料口移门");
                DoorBean.StartOpen(MoveInfo);

            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_DoorOpen))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BS_04_ReadyEmpty);
                InOutStoreLog(moveName + MoveInfo.SLog + ":调用AgvClient.ReadyEmpty,等待Agv小车到达");
                AgvClient.ReadyEmpty(Config.AgvNodeName);
                //等待小车到达
                MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)Asa.Actions.Arrive));
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_04_ReadyEmpty))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BS_05_LineBackRun);

                if (instoreShelf)
                {
                    InOutStoreLog(moveName + MoveInfo.SLog + ":调用AgvClient.SendRFID【" + LastShelfData.ToData() + "】,调用AgvClient.MayOut,线体开始反转");
                    //TODO AGV到达,发送料架信息,是否需要重新读取?
                    AgvClient.SendRFID(Config.AgvNodeName, LastShelfData.ToData());
                }
                else
                {
                    InOutStoreLog(moveName + MoveInfo.SLog + ": 调用AgvClient.MayOut,线体开始反转");
                }
                AgvClient.MayOut(Config.AgvNodeName);
                LineBackRun();
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_05_LineBackRun))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BS_06_WaitInLineSingle);
                InOutStoreLog(moveName + MoveInfo.SLog + ":等待取料工位无信号,入料口有信号");
                MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.LOW));
                MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_06_WaitInLineSingle))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BS_07_WaitTime);
                InOutStoreLog(moveName + MoveInfo.SLog + ":再转动3000时间,同时等待收到FinishOut");
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
                //等到小车离开
                MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)Asa.Actions.FinishOut));
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_07_WaitTime))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BS_08_WaitAGVLeave);
                InOutStoreLog(moveName + MoveInfo.SLog + ": ,同时等待 AGV离开,最多等待5000");
                MoveInfo.OneWaitCanEndStep = true;
                MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
                MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)Asa.Actions.FinishOut));
            }

            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_08_WaitAGVLeave))
            {
                MoveInfo.NextMoveStep(StoreMoveStep.BS_09_CloseDoor);
                InOutStoreLog(moveName + MoveInfo.SLog + ":停止线体转动,关闭仓门");
                LineStop();
                DoorBean.StartClose(MoveInfo);
            }
            else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_09_CloseDoor))
            {
                //结束 
                MoveEndToRuningStatus();
                EmprtShelfList = new ConcurrentQueue<string>();
                InOutStoreLog(moveName + MoveInfo.SLog + ":停止转动,送出料架结束");
            }
        }

        #endregion

        #region AGV

        internal bool ProcessAGVAction(string name, Asa.Actions action)
        {
            string logN = name + "收到调度【" + name + "】=【" + action + "】";
            //状态处理
            if (action.Equals(Asa.Actions.Usable))
            {
                //判断入口是否可用:入口无料架,缓冲工位无料架,不在入料架处理中
                bool usable = (storeRunStatus.Equals(StoreRunStatus.Runing) &&
                    waitOutStoreList.Count <= 0 &&
                    MoveInfo.MoveType.Equals(StoreMoveType.None) &&
                    alarmType.Equals(StoreAlarmType.None)
                    && IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW)
                    && IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW));

                LogUtil.info(logN + ":" + usable);
                return usable;
            }
            else if (action.Equals(Asa.Actions.Arrive))
            {
                //出库处理中不处理
                if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
                {
                    return true;
                }
                if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW))
                {
                    LogUtil.info(logN + " ,未检测到:LineIn_Check,不处理");
                    return false;
                }
                //小车到达,开始处理 
                if (storeRunStatus.Equals(StoreRunStatus.Runing) &&
                    MoveInfo.MoveType.Equals(StoreMoveType.None) &&
                    IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW))
                {
                    StartShelfInStore();
                    return true;
                }
            }
            else
            {
                LogUtil.info(name + logN + " ,未找到相关处理");
            }

            return false;
        }

        #endregion

        #region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作

        private string CodeMsg = "";
        private bool isInProcess = false;
        public void server_connect_timer_Tick(object sender, EventArgs e)
        {
            if (isInProcess)
            {
                return;
            }
            isInProcess = true;

            //HumitureController.QueryData();
            humBean.HumidityProcess(this);
            if (StoreManager.IsConnectServer)
            {
                try
                {
                    SendLineStatus();
                }
                catch (Exception ex)
                {
                    LogUtil.error(Name + "定时SendLineStatus出错:" + ex.ToString());
                }
            }
            isInProcess = false;
        }

        /// <summary>
        /// 获取整个料仓的状态
        /// </summary> 
        public Operation getLineBoxStatus()
        {
            //构建发送给服务器的对象
            Operation lineOperation = new Operation();
            lineOperation.msg = "";
            lineOperation.alarmList = new List<AlarmInfo>();
            lineOperation.cid = CID;
            lineOperation.seq = ConfigAppSettings.nextSeq();
            lineOperation.status = 1;
            if (WarnMsg != "")
            {
                lineOperation.status = (int)StoreStatus.Warning;
                lineOperation.msg = WarnMsg;
            }
            lineOperation.status = (int)StoreStatus.StoreOnline;

            BoxStatus boxStatus = new BoxStatus();
            boxStatus.boxId = 1;

            boxStatus.msg = WarnMsg;
            lineOperation.msg = WarnMsg;

            if (WarnMsg.Equals(""))
            {
                boxStatus.msg = CodeMsg;
                lineOperation.msg = CodeMsg;
            }
            CodeMsg = "";
            //WarnMsg = ""; 
            //状态
            boxStatus.status = (int)storeStatus;
            if (IsDebug)
            {
                boxStatus.status = (int)StoreStatus.Debugging;
            }
            else if (storeStatus.Equals(StoreStatus.OutStoreBoxEnd) || storeStatus.Equals(StoreStatus.InStoreEnd))
            {
                boxStatus.data.Add(ParamDefine.posId, lastPosId);
            }
            else if (!lastPosId.Equals(""))
            {
                boxStatus.data.Add(ParamDefine.posId, lastPosId);
                boxStatus.status = (int)lastPosIdStatus;
                if (lastPosId != "")
                {
                    LogUtil.info("给服务器发送出入库完成消息:" + Name + ",status【" + lastPosIdStatus + "】posId【" + lastPosId + "】");
                }
                lastPosId = "";
            }

            //温湿度
            //ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
            HumitureParam param = humBean.LastData;
            if (param != null)
            {
                boxStatus.humidity = param.Humidity.ToString();
                boxStatus.temperature = param.Temperate.ToString();
            }
            lineOperation.boxStatus.Add(1, boxStatus);

            if (!alarmType.Equals(StoreAlarmType.None))
            {
                lineOperation.alarmList.Add(alarmInfo);
            }
            return lineOperation;
        }

        public void SendLineStatus()
        {
            DateTime time = DateTime.Now;
            //构建发送给服务器的对象
            Operation lineOperation = getLineBoxStatus();
            //如果还没湿度范围,先获取
            if (humBean.NeedGetTem())
            {
                lineOperation.op = 5;
                LogInfo("没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op);
            }
            string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
            Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), lineOperation, false);

            //发送状态信息到服务器 
            if (resultOperation == null || (resultOperation.op <= 0))
            {
                //判断服务端是否返回出库操作
                return;
            }
            if (resultOperation.op.Equals(1))
            {
                //  ReviceInStoreProcess("", resultOperation);
            }
            else if (resultOperation.op.Equals(2))
            {
                ReviceOutStoreProcess(resultOperation);
            }
            else if (resultOperation.op.Equals(5))
            {
                humBean.ProcessHumidityCMD(resultOperation);
            }
            else
            {
                LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
            }
            TimeSpan span = DateTime.Now - time;
            if (span.TotalMilliseconds > 10)
            {
                LogUtil.info(Name + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
            }
        }


        private void ReviceOutStoreProcess(Operation resultOperation)
        {
            DateTime time = DateTime.Now;
            Dictionary<string, string> data = resultOperation.data;
            if (data != null && data.ContainsKey(ParamDefine.posId)
                      && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
            {
                char splitChar = '|';
                string[] posIdArray = data[ParamDefine.posId].Split(splitChar);
                string[] plateWArray = data[ParamDefine.plateW].Split(splitChar);
                string[] plateHArray = data[ParamDefine.plateH].Split(splitChar);

                bool urgentReel = FormUtil.GetBoolData(data, ParamDefine.urgentReel);
                bool cutReel = FormUtil.GetBoolData(data, ParamDefine.cutReel);
                bool smallReel = FormUtil.GetBoolData(data, ParamDefine.smallReel);
                string rfid = data.ContainsKey(ParamDefine.rfid) ? data[ParamDefine.rfid] : "";
                int rfidLoc = FormUtil.GetIntData(data, ParamDefine.rfidLoc);
                string barcode = data.ContainsKey(ParamDefine.barcode) ? data[ParamDefine.barcode] : "";
                //urgentReel: true 表示紧急料,需要出到料串上
                //cutReel: true 表示分盘料,需要出到料串上
                //smallReel: true  小料(7x8),放置到小料架上
                //rfid: 分配的料架RFID
                //rfidLoc: 料架的架位,值为 - 1时,可以自由分配皮带线, 小料时,架位为1 - 46优先走1 / 2号皮带线,47 - 92优先走3 / 4号皮带线, 70,71,72时只能分配到3 / 4号皮带线; 大料时,架位1 - 6优先走1 / 2号皮带线, 7 - 12优先走3 / 4号皮带线

                string dataStr = JsonHelper.SerializeObject(data);
                LogUtil.info("收到服务器出库消息:【" + dataStr + "】");

                int index = -1;
                foreach (string posId in posIdArray)
                {
                    index++;
                    string plateW = plateWArray[index];
                    string plateH = plateHArray[index];
                    InOutParam inoutParam = new InOutParam(barcode, posId, "", plateW, plateH, urgentReel, cutReel, smallReel, rfid, rfidLoc);
                    //根据发送的posId获取位置列表
                    ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
                    if (position == null)
                    {
                        //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
                        WarnMsg = Name + "未找到库位:【" + inoutParam.ToStr() + "】";
                        LogUtil.error(WarnMsg);
                        continue;
                    }
                    try
                    {
                        //判断是否接收过此库位的出库信息
                        if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore) && MoveInfo.MoveParam.PosID.Equals(posId))
                        {
                            LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,正在【" + posId + "】出库中");
                            continue;
                        }

                        //判断排队列表中是否已存在
                        List<InOutParam> reviceList = new List<InOutParam>(waitOutStoreList);
                        reviceList = (from m in reviceList where m.PosID.Equals(posId) select m).ToList<InOutParam>();
                        if (reviceList.Count > 0)
                        {
                            LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,排队列表中已存在【" + reviceList[0].ToStr() + "】");
                            continue;
                        }

                    }
                    catch (Exception ex)
                    {
                        LogUtil.error(Name + "验证出库【" + inoutParam.ToStr() + "】是否重复出错:" + ex.ToString());
                    }
                    string shelfPosID = "";
                    if (inoutParam.rfidLoc > 0 && ShelfPosList.Count >= inoutParam.rfidLoc)
                    {
                        shelfPosID = ShelfPosList[inoutParam.rfidLoc - 1];
                        inoutParam.NeedEnterShelf = false;
                        inoutParam.NeedOutShelf = false;
                        inoutParam.ShelfPosID = shelfPosID;
                    }
                    else
                    {
                        bool hasShelf = EmprtShelfList.TryDequeue(out shelfPosID);
                        if (hasShelf)
                        {
                            inoutParam.NeedEnterShelf = false;
                            inoutParam.NeedOutShelf = false;
                            inoutParam.ShelfPosID = shelfPosID;
                        }
                        else
                        {
                            inoutParam.NeedEnterShelf = true;
                            inoutParam.NeedOutShelf = false;
                            LogInfo(Name + "执行出库【" + inoutParam.ToStr() + "】,没有空料架,需要使用新料架");
                        }
                    }
                    StartExecuctOut(inoutParam);
                }

                TimeSpan span = DateTime.Now - time;
                if (span.TotalMilliseconds > 10)
                {
                    LogInfo(Name + "执行 ReviceOutStoreProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
                }
            }
        }
        #endregion


        #region 扫码获取库位 

        /// <summary>
        /// 扫码枪数据接收
        /// </summary>
        /// <param name="message"></param>
        private bool GetPosIdByCode()
        {
            try
            {
                string message = StoreManager.ProcessCode(LastWidth, LastHeight, LastScanCodes);
                if (message.Equals("") || string.IsNullOrEmpty(message))
                {
                    CodeMsg = "未扫到二维码";
                    LogInfo("未扫到二维码");
                    return false;
                }

                if (storeRunStatus.Equals(StoreRunStatus.Wait))
                {
                    LogInfo("二维码【 " + message + "】,设备未启动,不需要发送服务器");
                    return false;
                }
                // CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
                LogUtil.info(Name + "二维码【 " + message + "】,发送给服务器获取入库PosID");
                //发送扫码内容到服务器进行入库操作
                Operation operation = getLineBoxStatus();
                operation.op = 1;
                operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", 1.ToString() } };
                string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
                Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false);
                if (resultOperation == null)
                {
                    CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
                    LogInfo("二维码【 " + message + "】没有收到服务器反馈!");
                    return false;
                }
                else if (!string.IsNullOrEmpty(resultOperation.msg))
                {
                    //如果有提示消息,直接显示提示
                    LogInfo("二维码【 " + message + "】  :" + resultOperation.msg);
                    return false;
                }


                if (resultOperation.op.Equals(1))
                {
                    Dictionary<string, string> data = resultOperation.data;
                    if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
                    {
                        //服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
                        //postId格式BoxId#位置
                        string posId = data[ParamDefine.posId];
                        string plateW = data[ParamDefine.plateW];
                        string plateH = data[ParamDefine.plateH];
                        int storeId = InOutParam.GetPosStoreId(posId);
                        //根据发送的posId获取位置列表
                        ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
                        if (position == null)
                        {   //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
                            WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
                            LogUtil.error(Name + "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
                            return false;
                        }
                        LogInfo(" 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】设置入库参数 , 开始入库!");
                        int p3 = ComTargetPosition + Config.CompAxis_P3_P2_Value;
                        MoveInfo.MoveParam.UpdatePosId(message, posId, plateW, plateH, ComTargetPosition, p3);
                        return true;
                    }
                }
                else if (resultOperation.op.Equals(2))
                {
                    ReviceOutStoreProcess(resultOperation);
                }
                else if (resultOperation.op.Equals(5))
                {
                    humBean.ProcessHumidityCMD(resultOperation);
                }
                else
                {
                    LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
                }
            }
            catch (Exception ex)
            {
                LogUtil.error(Name + "GetPosIdByCode" + ex.StackTrace);
            }
            return false;
        }

        #endregion

    }
}