MainMachine_RFIDSelftest.cs 5.3 KB
using CodeLibrary;
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
    {
        List<string> DemoTestList;
        int DemoTestIndex = 0;
        int DemoTestCount = 0;
        void TFIDSelfTestProcess()
        {
            if (CheckWait(StoreMoveInfo))
                return;
            //常规上料扫码流程
            switch (StoreMoveInfo.MoveStep)
            {
                case MoveStep.Wait:
                    break;
                case MoveStep.StoreIn01:
                    DemoTestList = CameraPointTest.GetThingStoreName(TestStorePointPort.上层左侧);

                    if (DemoTestList.Count == 0)
                        return;
                    DemoTestIndex = 0;

                    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.StoreOut11);
                    }
                    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("出库任务正在执行,请关好抽屉", MsgLevel.warning);
                    }
                    else {
                        IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
                    }
                    break;
                case MoveStep.StoreOut11:
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
                        var from = CSVPositionReader<ACStorePosition>.GetPositon(DemoTestList[DemoTestIndex]);
                        var to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
                        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)
                    {
                        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("读取到的RFID与物料信息不符:" + ds, MsgLevel.alarm);
                            //RobotManage.UserPause("读取到的RFID与物料信息不符");
                        }

                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
                        from = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
                        to = CSVPositionReader<ACStorePosition>.GetPositon(DemoTestList[DemoTestIndex]);
                        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.StoreOut13:
                    if (boxTransport.IsComplateOrFree)
                    {
                        StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
                        DemoTestIndex++;
                        if (DemoTestIndex >= DemoTestList.Count)
                            DemoTestIndex = 0;
                        DemoTestCount++;
                    }
                    break;
                default:
                    StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}");
                    break;
            }
        }
    }
}