MainMachine_StoreDemo.cs 28.3 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
using CodeLibrary;
using Newtonsoft.Json;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

namespace DeviceLibrary
{
    partial class MainMachine
    {
        public const string LabelP = "LabelP";
        public const string RFIDP = "RFIDP";

        StoreJobList OutStoreJobList = new StoreJobList(crc.GetString("Res0108", "批量"));
        public bool HasJob { get => OutStoreJobList.Count > 0; }
        public void AddOutStoreTask(string warecode, string posId)
        {
            JobInfo jobInfo = new JobInfo(warecode, posId);
            OutStoreJobList.Enqueue(jobInfo);
            LogUtil.info($"添加出库任务队列: {posId},当前任务数量: {OutStoreJobList.Count}");
        }
        public bool IsInStoreReady { get => true; }

        List<string> nglist = new List<string>();

        void StoreDemoProcess()
        {
            if (CheckWait(StoreMoveInfo))
                return;
            //常规上料扫码流程
            switch (StoreMoveInfo.MoveStep)
            {
                case MoveStep.Wait:
                    StoreMoveInfo.MoveParam.ReelOnFixture = false;
                    if (IOValue(IO_Type.Taking_Clamp).Equals(IO_VALUE.LOW)) {
                        if (Setting_Init.Runtime_Step == Runtime_StepE.LabelProcess)
                        {
                            StoreMoveInfo.log("检测到上次正在贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid + "," + Setting_Init.Runtime_FromPosid);
                            if (!string.IsNullOrEmpty(Setting_Init.Runtime_FromPosid))
                            {
                                LabelingMoveInfo.NewMove(MoveStep.Labeling01);
                                StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
                            }
                            else
                            {
                                Msg.add(crc.GetString("Res0133", "重置前物料正在贴标,无法继续,请手动处理"), MsgLevel.warning, ErrInfo.LabelInPaste);
                                RobotManage.UserPause(crc.GetString("Res0133", "重置前物料正在贴标,无法继续,请手动处理"));
                            }
                            return;

                        }
                        else if (Setting_Init.Runtime_Step == Runtime_StepE.LabelPasteFinish)
                        {
                            StoreMoveInfo.log("检测到上次已完成贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid + "," + Setting_Init.Runtime_RFID);
                            StoreMoveInfo.NewMove(MoveStep.StoreIn03);
                            if (Setting_Init.Runtime_Posid.Val == "NG")
                                LabelingMoveInfo.MoveParam.IsNg = true;                            
                            StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
                            StoreMoveInfo.MoveParam.RFID = Setting_Init.Runtime_RFID;
                            return;
                        }
                        else if (Setting_Init.Runtime_Step >= Runtime_StepE.Printed && Setting_Init.Runtime_Step < Runtime_StepE.LabelPasteFinish)
                        {
                            StoreMoveInfo.log("检测到上次正在贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid+","+ Setting_Init.Runtime_FromPosid);
                            Msg.add(crc.GetString("Res0133","重置前物料正在贴标,无法继续,请手动处理"), MsgLevel.warning, ErrInfo.LabelInPaste);
                            RobotManage.UserPause(crc.GetString("Res0133","重置前物料正在贴标,无法继续,请手动处理"));
                            return;
                        }
                        else if (OutStoreJobList.Dequeue(out JobInfo jobInfo))
                        {

                            IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
                            StoreMoveInfo.NewMove(MoveStep.StoreOut10);
                            StoreMoveInfo.MoveParam.PosID = jobInfo.PosId;
                            StoreMoveInfo.MoveParam.WareCode = jobInfo.WareNum;
                            StoreMoveInfo.MoveParam.PlateH = jobInfo.plateH;
                            StoreMoveInfo.MoveParam.PlateW = jobInfo.plateW;
                            StoreMoveInfo.log($"开始出库任务:" + jobInfo.ToStr());
                            ServerCM.storeStatus = StoreStatus.OutStoreExecute;
                        }
                        else if (IOValue(IO_Type.Entry_Drawer_Lock).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Entry_Drawer).Equals(IO_VALUE.HIGH))
                        {
                            //NGInfoList = new List<ReelParam>();
                            //StoreMoveInfo.NewMove(MoveStep.StoreIn01);
                            //StoreMoveInfo.log($"检测到入库抽屉已锁定");
                        }
                        Setting_Init.Runtime_Step = Runtime_StepE.None;
                        return;
                    }
                    if (Setting_Init.Runtime_Step!= Runtime_StepE.None)
                        StoreMoveInfo.log("Runtime_Step:"+ Setting_Init.Runtime_Step);
                    if (Setting_Init.Runtime_Step == Runtime_StepE.InToLabel) {
                        StoreMoveInfo.log("检测到上次正在准备去贴标:"+ Setting_Init.Runtime_Posid);
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
                        var acto = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
                        StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
                        StoreMoveInfo.MoveParam.ReelOnFixture = true;
                        boxTransport.Start(new BoxStorePosition(Config, acto, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, acto, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
                        StoreMoveInfo.log($"开始转运入贴标机构");
                    }else if (Setting_Init.Runtime_Step == Runtime_StepE.InToStore)
                    {
                        StoreMoveInfo.log("检测到上次正在准备去库位:" + Setting_Init.Runtime_Posid);
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreIn04);
                        StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
                        StoreMoveInfo.MoveParam.RFID = Setting_Init.Runtime_RFID;
                        StoreMoveInfo.MoveParam.ReelOnFixture = true;
                    }
                    else if (Setting_Init.Runtime_Step == Runtime_StepE.Out)
                    {
                        StoreMoveInfo.log("检测到上次正在出库:" + Setting_Init.Runtime_Posid+","+ Setting_Init.Runtime_WareCode);
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10_1);
                        StoreMoveInfo.MoveParam.ReelOnFixture = true;
                        StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
                        StoreMoveInfo.MoveParam.WareCode= Setting_Init.Runtime_WareCode;
                    }


                    break;
                case MoveStep.StoreIn01:
                    string inposid;
                    var slist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
                    foreach (var o in nglist.ToArray())
                    {
                        if (slist.Contains(o))
                            slist.Remove(o);
                    }
                    if (slist.Count == 0)
                    {
                        StoreMoveInfo.NextMoveStep(MoveStep.Wait);
                        //IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.LOW);
                        StoreMoveInfo.log($"没有检测到有入库物料");
                        return;
                    }
                    else
                    {
                        inposid = slist[0];
                        StoreMoveInfo.log($"检测到入库位有料:{inposid}, 其他有料入库位:{string.Join(",", slist)}");
                    }
                    StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
                    var from = CSVPositionReader<ACStorePosition>.GetPositon(inposid);
                    var to = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
                    StoreMoveInfo.MoveParam.PosID = inposid;
                    Setting_Init.Runtime_FromPosid = inposid;
                    //StoreMoveInfo.MoveParam.ReelOnFixture = false;
                    boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
                    StoreMoveInfo.log($"开始转运入贴标机构");
                    ServerCM.storeStatus = StoreStatus.InStoreExecute;
                    break;
                case MoveStep.StoreIn02:
                    if (boxTransport.IsComplateOrFree)
                    {
                        if (LabelingMoveInfo.MoveStep == MoveStep.Wait)
                        {
                            StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
                            LabelingMoveInfo.NewMove(MoveStep.Labeling01);
                            StoreMoveInfo.log($"等待贴标完成");
                        }
                        else
                        {
                            StoreMoveInfo.log($"等待贴标机构空闲");
                        }
                    }
                    break;
                case MoveStep.StoreIn03:
                    if (LabelingMoveInfo.MoveStep == MoveStep.Wait)
                    {
                        StoreMoveInfo.MoveParam = LabelingMoveInfo.MoveParam.clone();


                        
                        if (StoreMoveInfo.MoveParam.IsNg)
                        {
                            StoreMoveInfo.NextMoveStep(MoveStep.StoreIn06);
                            StoreMoveInfo.log($"收到完成贴标NG");
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(LabelingMoveInfo.MoveParam.PosID))
                            {
                                Msg.add(crc.GetString("Res0138","等待服务器返回库位"), MsgLevel.info);
                                StoreMoveInfo.log($"等待服务器返回库位");
                                return;
                            }
                            StoreMoveInfo.NextMoveStep(MoveStep.StoreIn04);
                            StoreMoveInfo.log($"收到完成贴标");
                            ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreExecute);
                        }
                    }
                    else
                    {
                        StoreMoveInfo.log($"等待贴标完成");
                    }
                    break;
                case MoveStep.StoreIn04:
                    if (boxTransport.IsComplateOrFree)
                    {
                        //var outposid= StoreMoveInfo.MoveParam.PosID;                        

                        StoreMoveInfo.NextMoveStep(MoveStep.StoreIn05);
                        from = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
                        to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
                        
                        //StoreMoveInfo.MoveParam.PosID = outposid;
                        //StoreMoveInfo.MoveParam.ReelOnFixture = false;
                        boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
                        StoreMoveInfo.log($"开始转运到RFID位置");
                    }
                    break;
                case MoveStep.StoreIn05:
                    if (boxTransport.IsComplateOrFree)
                    {
                        if (StoreMoveInfo.MoveParam.RFID.Length > 12)
                            StoreMoveInfo.MoveParam.RFID = StoreMoveInfo.MoveParam.RFID.Substring(0, 12);
                        bool writeok = false;
                        for (int i = 0; i < 15; i++)
                        {
                            if (string.IsNullOrEmpty(StoreMoveInfo.MoveParam.RFID))
                                break;
                            RobotManage.RFID.WriteEPC(Encoding.ASCII.GetBytes(StoreMoveInfo.MoveParam.RFID));
                            Thread.Sleep(500);
                            if (RobotManage.RFID.ReadEPC(12, out byte[] data))
                            {
                                if (data[0] != 0xFF)
                                {
                                    var ds = Encoding.ASCII.GetString(data).Trim();
                                    if (ds == StoreMoveInfo.MoveParam.RFID)
                                    {
                                        StoreMoveInfo.log("RFID 写入成功:" + ds);
                                        writeok = true;
                                        break;
                                    }
                                    else
                                    {
                                        StoreMoveInfo.log("失败的 RFID:" + ds);
                                    }
                                }
                            }
                            if (!writeok)
                            {
                                var of = i * 1000 * (i % 2 == 0 ? 1 : -1);
                                var zp = Z_Axis.GetAclPosition() + of;
                                var yp = Y_Axis.GetAclPosition() + of;
                                var zt = Z_Axis.AbsMoveASYNC(zp, Config.Z_Axis_P1_speed);
                                var yt = Y_Axis.AbsMoveASYNC(yp, Config.Y_Axis_P1_speed);
                                Task.WaitAll(new Task[] { zt, yt }, 10000);
                            }
                            //Thread.Sleep(100);
                        }
                        if (!writeok) {
                            StoreMoveInfo.NextMoveStep(MoveStep.StoreIn06);
                            StoreMoveInfo.MoveParam.ReelOnFixture = true;
                            StoreMoveInfo.MoveParam.IsNg = true;
                            StoreMoveInfo.MoveParam.NgMsg = crc.GetString("Res0139", "RFID 写入失败");
                            StoreMoveInfo.log($"RFID 写入失败 NG");
                            ServerCM.cancelPutInTask("", StoreMoveInfo.MoveParam.WareCode);
                            //Msg.add(crc.GetString("Res0139","RFID 写入失败"),MsgLevel.alarm);
                            //RobotManage.UserPause(crc.GetString("Res0139","RFID 写入失败"));
                            return;
                        }

                        StoreMoveInfo.NextMoveStep(MoveStep.StoreIn09);
                        from = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
                        to = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);

                        StoreMoveInfo.MoveParam.ReelOnFixture = true;
                        boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
                        StoreMoveInfo.log($"开始转运到入库位置");
                    }
                    break;
                case MoveStep.StoreIn06:
                    StoreMoveInfo.NextMoveStep(MoveStep.StoreIn07);
                    Z_Axis.AbsMove(StoreMoveInfo, Config.Z_Axis_P1, Config.Z_Axis_P1_speed);
                    break;
                case MoveStep.StoreIn07:
                    StoreMoveInfo.NextMoveStep(MoveStep.StoreIn08);
                    X_Axis.AbsMove(StoreMoveInfo, Config.X_Axis_P1, Config.X_Axis_P1_speed);
                    Y_Axis.AbsMove(StoreMoveInfo, Config.Y_Axis_P1, Config.Y_Axis_P1_speed);
                    break;
                case MoveStep.StoreIn08:
                    if (boxTransport.IsComplateOrFree)
                    {
                        //var outposid = "";
                        //var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
                        //olist = RobotManage.PositionNumList.ToList().Where(p => { return p.StartsWith("L") && !olist.Contains(p); }).ToList();
                        //olist.Remove(LabelP);
                        //if (olist.Count == 0)
                        //{
                        //    StoreMoveInfo.NextMoveStep(MoveStep.Wait);
                        //    StoreMoveInfo.log($"没有检测到有空余库位");
                        //    return;
                        //}
                        //else
                        //{
                        //    outposid = olist[olist.Count-1];
                        //    StoreMoveInfo.log($"检测到空库位:{outposid}, 其他空库位:{string.Join(",", olist)}");
                        //}
                        //nglist.Add(outposid);
                        ServerCM.cancelPutInTask("", StoreMoveInfo.MoveParam.PosID);
                        nglist.Add(Setting_Init.Runtime_FromPosid);
                        StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_FromPosid;
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreIn09);
                        from = CSVPositionReader<ACStorePosition>.GetPositon(LabelP);
                        to = CSVPositionReader<ACStorePosition>.GetPositon(Setting_Init.Runtime_FromPosid);

                        //StoreMoveInfo.MoveParam.PosID = outposid;
                        StoreMoveInfo.MoveParam.dateTime = DateTime.Now;
                        NGInfoList.Add(StoreMoveInfo.MoveParam.clone());
                        Setting_Init.Runtime_NGINFOLIST = JsonConvert.SerializeObject(NGInfoList);
                        //StoreMoveInfo.MoveParam.ReelOnFixture = false;
                        boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.InStore, true);
                        StoreMoveInfo.log($"开始转运");
                    }
                    break;
                case MoveStep.StoreIn09:
                    if (boxTransport.IsComplateOrFree)
                    {
                        if(!StoreMoveInfo.MoveParam.IsNg)
                            ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreEnd);
                        if (OutStoreJobList.Count==0)
                            StoreMoveInfo.NewMove(MoveStep.StoreIn01);
                        else
                            StoreMoveInfo.NewMove(MoveStep.Wait);
                        StoreMoveInfo.log($"入库完成");
                        
                        CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
                    }
                    break;
                case MoveStep.StoreOut10:
                    if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Out_Drawer_Lock).Equals(IO_VALUE.HIGH))
                    {
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10_1);
                    }
                    else if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW) && IOValue(IO_Type.Out_Drawer_Lock).Equals(IO_VALUE.HIGH))
                    {
                        IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.LOW);
                    }
                    else if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW))
                    {
                        Msg.add(crc.GetString("Res0137","出库任务正在执行,请关好抽屉"), MsgLevel.warning);
                    }
                    else {
                        IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
                    }
                    break;
                case MoveStep.StoreOut10_1:

                    inposid = StoreMoveInfo.MoveParam.PosID;
                    Setting_Init.Runtime_Posid = inposid;
                    Setting_Init.Runtime_WareCode = StoreMoveInfo.MoveParam.WareCode;
                    {
                        var outposid="";
                        var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
                        StoreMoveInfo.log($"检测到出库口有料库位:{string.Join(",", olist)}");
                        olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("U") && !olist.Contains(p); }).ToList();
                        if (olist.Count == 0)
                        {
                            OutStoreJobList.ClearLastPosid();
                            StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
                            StoreMoveInfo.log($"没有检测到出库未有空位");
                            return;
                        }
                        else
                        {
                            outposid = olist[0];
                            StoreMoveInfo.log($"检测到出库位有料:{outposid}, 其他有料出库位:{string.Join(",", olist)}");
                        }

                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
                        from = CSVPositionReader<ACStorePosition>.GetPositon(inposid);
                        to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
                        StoreMoveInfo.MoveParam.OutPosID = outposid;
                        //StoreMoveInfo.MoveParam.ReelOnFixture = false;
                        boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
                        StoreMoveInfo.log($"开始转运出库");
                        ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreExecute);
                    }
                    break;
                case MoveStep.StoreOut11:
                    if (boxTransport.IsComplateOrFree)
                    {
                        ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreBoxEnd);
                        bool issame = false;
                        string ds="";
                        for (int i = 0; i < 15; i++)
                        {                            
                            if (RobotManage.RFID.ReadEPC(12, out byte[] data))
                            {
                                if (data[0] != 0xFF)
                                {
                                    ds = Encoding.ASCII.GetString(data).Trim();
                                    if (StoreMoveInfo.MoveParam.WareCode.IndexOf(ds)>-1)
                                    {
                                        StoreMoveInfo.MoveParam.RFID = ds;
                                        StoreMoveInfo.log("读取到 RFID:" + ds + " , "+ RobotManage.RFID.HexBuff(data));
                                        issame = true;
                                        break;
                                    }
                                    
                                }
                            }
                            Thread.Sleep(200);
                        }

                        if (!issame)
                        {
                            StoreMoveInfo.log("读取到 RFID:" + ds);
                            Msg.add(crc.GetString("Res0140","读取到的RFID与物料信息不符:") + ds, MsgLevel.alarm);
                            RobotManage.UserPause(crc.GetString("Res0141","读取到的RFID与物料信息不符"));
                        }

                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
                        from = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
                        to = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.OutPosID);
                        StoreMoveInfo.MoveParam.ReelOnFixture = true;
                        boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
                        StoreMoveInfo.log($"开始转运出库");
                    }
                    break;
                case MoveStep.StoreOut12:
                    if (boxTransport.IsComplateOrFree)
                    {
                        ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd);
                        StoreMoveInfo.log("出库完成");
                        StoreMoveInfo.NextMoveStep(MoveStep.Wait);
                        OutStoreJobList.ClearLastPosid();
                        
                        var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
                        StoreMoveInfo.log($"检测到出库口有料库位:{string.Join(",", olist)}");
                        olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("U") && !olist.Contains(p); }).ToList();
                        if (olist.Count == 0) {
                            StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
                            StoreMoveInfo.log($"出库库位已用完");
                        }
                        if (OutStoreJobList.Count==0)
                        {
                            StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
                            StoreMoveInfo.log($"没有出库任务了");
                        }
                    }
                    break;
                case MoveStep.StoreOut13:
                    StoreMoveInfo.NextMoveStep(MoveStep.StoreOut14);
                    IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.LOW);
                    StoreMoveInfo.log($"出库抽屉解锁");
                    break;
                case MoveStep.StoreOut14:
                    if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW))
                    {
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut15);
                        StoreMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
                    }
                    else
                    {
                        Msg.add(crc.GetString("Res0115", "出库已完成请取走锡膏"), MsgLevel.warning);
                    }
                    break;
                case MoveStep.StoreOut15:
                    if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH))
                    {
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut16);
                        StoreMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
                    }
                    else
                    {
                        Msg.add(crc.GetString("Res0116", "等待出料抽屉关闭"), MsgLevel.warning);
                    }
                    break;
                case MoveStep.StoreOut16:
                    StoreMoveInfo.NextMoveStep(MoveStep.StoreOut17);
                    IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
                    break;
                case MoveStep.StoreOut17:
                    if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH))
                    {
                        StoreMoveInfo.NewMove(MoveStep.StoreIn01);
                    }
                    else
                    {                        
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut15);
                        IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.LOW);
                    }
                    break;
                default:
                    StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}");
                    break;
            }
        }
        string StoreState()
        {
            string state = crc.GetString("Res0107", "空闲中");
            if (StoreMoveInfo.MoveStep >= MoveStep.StoreOut10)
            {
                state = crc.GetString("Res0113", "出库中") + "," + crc.GetString("Res0071", "库位号") + StoreMoveInfo.MoveParam.PosID;
            }
            else if (StoreMoveInfo.MoveStep >= MoveStep.StoreIn01)
            {
                state = crc.GetString("Res0114", "入库中") + "," + crc.GetString("Res0071", "库位号") + StoreMoveInfo.MoveParam.PosID;
                if (StoreMoveInfo.MoveStep >= MoveStep.StoreIn09)
                {
                    state += "RFID:" + StoreMoveInfo.MoveParam.RFID;
                }
            }
            return state;
        }
    }
}