예제 #1
0
        public static InjectMoveTo create(AbstractCanDevice nodetem, double ttime, Enterclose[] iinjects, int xx, int [] yy, int[] zz, int sspeed = 0)
        {
            InjectMoveTo acttem = InjectMoveTo.create(ttime, iinjects, xx, yy, zz, sspeed);

            acttem.node = nodetem;
            return(acttem);
        }
예제 #2
0
 public static InjectMoveTo getInstance()
 {
     if (instance == null)
     {
         instance = new InjectMoveTo();
     }
     return(instance);
 }
예제 #3
0
        public static InjectMoveTo create(double ttime, Enterclose[] iinjects, int xx, int[] yy, int[] zz, int sspeed = 0)
        {
            InjectMoveTo acttem = new InjectMoveTo();

            for (int i = 0; i < 4; i++)
            {
                acttem.y[i] = yy[i];
                acttem.z[i] = zz[i];
            }
            acttem.x       = xx;
            acttem.time    = ttime;
            acttem.speed   = sspeed;
            acttem.injects = iinjects;
            return(acttem);
        }
예제 #4
0
 public void ClsAction()
 {
     lock (mylock)
     {
         //清理完成动作
         bool iscls = false;
         for (int i = action_tree.Count - 1; i >= 0; i--)
         {
             if (action_tree[i][0].State == 2)
             {
                 action_tree.Remove(action_tree[i]);
                 iscls = true;
             }
         }
         if (iscls && action_tree.Count == 0)
         {
             var act = Sequence.create(
                 InjectMoveTo.create(injectorDevice, 3000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0)),
                 InjectMoveTo.create(injectorDevice, 3000, injectorDevice.GetSeleteced(), 0, IMask.Gen(0), IMask.Gen(-1)),
                 InitXyz.create(injectorDevice, 5000, injectorDevice.GetSeleteced(), true, true, true));
             act.runAction(injectorDevice);
         }
     }
 }
        //执行
        public void Logic(double dt)
        {
            ClsAction();
            //并行执行
            foreach (var pack in experiment_package_list)
            {
                if (pack.action_list.Count != 0)
                {
                    if (pack.is_jyjs)
                    {
                        var cen_tree = generater.DivideIntoGroups(pack.action_list, 1);
                        ActLogic(cen_tree[0], null, dt);
                    }
                }
            }
            //离心逻辑
            bool is_use_cent = false;

            foreach (var cent in cenMrg.CentrifugeMDevices)
            {
                if (resmanager.GetCenStatus(cent.Centrifugem.Code.SetValue))
                {
                    //如果当前离心机在跑或已满卡就添加到下一个离心机中
                    is_use_cent = CenRunLogic(cent);
                    if (is_use_cent)
                    {
                        break;             // 离心启动逻辑
                    }
                }
            }
            if (is_use_cent == false)
            {
                //顺序执行
                int inject_count        = 1;
                var inj_action_list_tem = inj_action_list.Where(item => ((ExperimentPackage)item.ExperPackage).is_jyjs == false).ToList();
                if (inj_action_list_tem.Count != 0)
                {
                    var action_tem = inj_action_list_tem[0];
                    var exp_pack   = (ExperimentPackage)action_tem.ExperPackage;
                    var paper_seat = resmanager.GetResByCode(exp_pack.GetGelMask(), "T_BJ_GelSeat", "", "4");
                    var liquidinfo = action_tem.GetLiquidInfo();
                    inject_count = GetInjectCount();
                    //如果是加样试剂最多两个针头
                    if (liquidinfo != null && liquidinfo.IsAgentia && inject_count > 2)
                    {
                        inject_count = 2;
                    }
                    var inj_tree       = generater.DivideIntoGroups(inj_action_list_tem, inject_count);
                    var act_group      = inj_tree[0];
                    var act_group_next = inj_tree.Count > 1 ? inj_tree[1] : null;
                    ActLogic(act_group, act_group_next, dt);
                }
            }
            //机器手空闲回零
            if (actionmanager.getAllActionsCount(handDevice) == 0 && handDevice.Hand.XMotor.CurrentDistance != 0)
            {
                hand_wait_time += dt;
                if (hand_wait_time > 1000)
                {
                    var act = Sequence.create(MoveTo.create(handDevice, 10000, -1, -1, 0),
                                              MoveTo.create(handDevice, 10000, 0, 0, 0),
                                              InitXyz.create(10000, true, true, true));
                    act.runAction(handDevice);
                    hand_wait_time = 0;
                }
            }
            //加样器空闲回零
            if (actionmanager.getAllActionsCount(injectorDevice) == 0 && injectorDevice.Injector.XMotor.CurrentDistance != 0)
            {
                inj_wait_time += dt;
                if (inj_wait_time > 1000)
                {
                    var by = IMask.Gen(0);
                    foreach (var ent in injectorDevice.Injector.Entercloses)
                    {
                        by[ent.Index] = (int)ent.YZero;
                    }
                    var act = Sequence.create(
                        InjectMoveTo.create(injectorDevice, 3000, injectorDevice.Injector.Entercloses, -1, IMask.Gen(-1), IMask.Gen(0)),
                        InjectMoveTo.create(injectorDevice, 3000, injectorDevice.Injector.Entercloses, 0, IMask.Gen(0), IMask.Gen(-1)),
                        InitXyz.create(injectorDevice, 20000, injectorDevice.Injector.Entercloses, true, true, true, by));
                    act.runAction(injectorDevice);
                    inj_wait_time = 0;
                }
            }
            else
            {
                inj_wait_time = 0;
            }
        }
예제 #6
0
        public override void run(double dt)
        {
            bool resultx               = true;
            bool resulty               = true;
            bool resultz               = true;
            int  device_rx             = 0;
            int  device_cx             = 0;
            AbstractCanDevice checkdev = null;
            var handdev   = ActionGenerater.getInstance().handDevice;
            var injectdev = ActionGenerater.getInstance().injectorDevice;

            if (CountTime(dt))
            {
                return;
            }
            var device = new ActionDevice(node);

            if (node is InjectorDevice)
            {
                checkdev  = ActionGenerater.getInstance().handDevice;
                device_cx = (int)handdev.Hand.XMotor.CurrentDistance;
            }
            else if (node is MachineHandDevice)
            {
                checkdev  = ActionGenerater.getInstance().injectorDevice;
                device_cx = (int)injectdev.Injector.XMotor.CurrentDistance;
            }
            switch (step)
            {
            case 0:
                if (x >= 0 && checkdev != null && false)
                {
                    sumdt      = 0;
                    wait_time += dt;
                    if (wait_time > 500)
                    {
                        wait_time = 0;
                        bool is_timeout = false;
                        if (checkdev is MachineHandDevice)
                        {
                            handdev.CanComm.ReadRegister(handdev.Hand.XMotor.RealDistance.Addr);
                            device_rx = handdev.CanComm.GetIntBlock(handdev.Hand.XMotor.RealDistance.Addr, 1000, out is_timeout);
                        }
                        else if (checkdev is InjectorDevice)
                        {
                            injectdev.CanComm.ReadRegister(injectdev.Injector.XMotor.RealDistance.Addr);
                            device_rx = injectdev.CanComm.GetIntBlock(injectdev.Injector.XMotor.RealDistance.Addr, 1000, out is_timeout);
                        }
                        if (is_timeout == false)
                        {
                            int device_max = 10000 - x;
                            if (device_max < 0)
                            {
                                device_max = 0;
                            }
                            if (device_rx <= device_max && device_cx <= device_max)
                            {
                                step++;
                            }
                            else if (ActionManager.getInstance().getAllRuningActionsCount(checkdev) == 0)
                            {
                                Sequence          sequ = null;
                                List <Enterclose> ents = new List <Enterclose>();
                                ents.Add(injectdev.Injector.Entercloses[0]);
                                if (checkdev is MachineHandDevice)
                                {
                                    sequ = Sequence.create(MoveTo.create(checkdev, 3000, -1, -1, 0), MoveTo.create(checkdev, 3000, device_max, -1, -1));
                                }
                                else if (checkdev is InjectorDevice)
                                {
                                    sequ = Sequence.create(InjectMoveTo.create(3000, ents.ToArray(), -1, IMask.Gen(-1), IMask.Gen(0)), MoveTo.create(checkdev, 3000, device_max, -1, -1));
                                }
                                sequ.runAction(checkdev);
                            }
                        }
                    }
                }
                else
                {
                }
                step++;
                break;

            case 1:
                if (x >= 0)
                {
                    resultx = device.MoveX((int)x);
                }
                if (y >= 0)
                {
                    resulty = device.MoveY((int)y);
                }
                if (z >= 0)
                {
                    resultz = device.MoveZ((int)z, speed);
                }
                if (resultx && resulty && resultz)
                {
                    step++;
                }
                break;

            case 2:
                if (xdone == false)
                {
                    xdone = device.DoneX();
                }
                if (ydone == false)
                {
                    ydone = device.DoneY();
                }
                if (zdone == false)
                {
                    zdone = device.DoneZ();
                }
                isfinish = xdone && ydone && zdone;
                break;
            }
        }
예제 #7
0
        public void Logic(double dt)
        {
            lock (mylock)
            {
                if (action_tree.Count == 0)
                {
                    return;
                }
                //机器手空闲回零
                if (actionmanager.getAllActionsCount(injectorDevice) == 0 && injectorDevice.Injector.XMotor.CurrentDistance != 0)
                {
                    inj_wait_time += dt;
                    if (inj_wait_time > 1000)
                    {
                        var act = Sequence.create(
                            InjectMoveTo.create(injectorDevice, 3000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0)),
                            InjectMoveTo.create(injectorDevice, 3000, injectorDevice.GetSeleteced(), 0, IMask.Gen(0), IMask.Gen(-1)),
                            InitXyz.create(injectorDevice, 10000, injectorDevice.GetSeleteced(), true, true, true));
                        act.runAction(injectorDevice);
                        inj_wait_time = 0;
                    }
                }
                var act_group = action_tree[0];
                if (act_group.Count != 0 && act_group[0].State == 0)
                {
                    var seque_act            = Sequence.create();
                    AbstractCanDevice device = null;
                    if (act_group[0].InjectCount != 0)
                    {
                        foreach (var act_tem in act_group)
                        {
                            resmanager.tip_count += act_tem.InjectCount;
                        }
                        device = injectorDevice;
                        foreach (var act in act_group)
                        {
                            act.UpdataPoints();
                        }
                        seque_act = generater.GenerateAction(act_group);
                    }
                    else
                    {
                        foreach (var act in act_group)
                        {
                            act.UpdataPoints();
                            switch (act.StepClass)
                            {
                            case TestStepEnum.LoadGel:
                            {
                                device = handDevice;
                                var paper_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "4");
                                //var ware_seat = resmanager.GetResByCode(act.GetGelMask(), "T_BJ_GelWarehouse");
                                seque_act.AddAction(HandTakeGelFromWare.create(handDevice, 3001, gelwareDevice, act.GelMaskID, act.GetGelMask(), act.SampleBarCode));
                                seque_act.AddAction(HandPutGelToNormal.create(handDevice, 3001, gelwareDevice, paper_seat));
                            }
                            break;

                            case TestStepEnum.KaiKongGel:
                            {
                                int handrx      = 0;
                                var device_hand = new ActionDevice(handDevice);
                                var paper_seat  = resmanager.GetResByCode(act.GetGelMask(), "T_BJ_GelSeat", "", "4");
                                if (paper_seat != null && device_hand.GetRealX(ref handrx) &&
                                    (handrx + 1000) < paper_seat.X && ActionDevice.hand_tx < paper_seat.X)
                                {
                                    device = piercerDevice;
                                    seque_act.AddAction(PaperCard.create(piercerDevice, 3000, paper_seat));
                                    seque_act.AddAction(SkCallBackFun.create((ActionBase acttem) => {
                                            resmanager.gel_count++;
                                            return(true);
                                        }));
                                }
                                else
                                {
                                    return;
                                }
                            }
                            break;

                            case TestStepEnum.JYJS:
                            {
                                device = injectorDevice;
                                //得到剩下动作
                                List <T_GelStep> act_list = new List <T_GelStep>();
                                foreach (var act_tem in action_tree)
                                {
                                    if (act_tem.Count == 1 && act_tem[0].StepClass != TestStepEnum.GELEND)
                                    {
                                        act_tem[0].State = 2;
                                        act_list.Add(act_tem[0]);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                act_list.Remove(act);
                                var actplist   = ActionPoint.GenActList(act_list);
                                var paper_seat = resmanager.GetResByCode(act.GetGelMask(), "T_BJ_GelSeat", "", "4");
                                foreach (var actp in actplist)
                                {
                                    paper_seat.ActionList.Add(actp.type);
                                    if (actp.hatchtime != 0)
                                    {
                                        paper_seat.HatchTime = actp.hatchtime;
                                    }
                                }
                                seque_act.AddAction(SkCallBackFun.create((ActionBase acttem) =>
                                    {
                                        paper_seat.InjectFinish = true;
                                        return(true);
                                    }));
                            }
                            break;
                            }
                        }
                    }

                    if (device != null)
                    {
                        seque_act.AddAction(SkCallBackFun.create((ActionBase act) =>
                        {
                            act_group[0].State = 2;
                            return(true);
                        }));
                        act_group[0].State = 1;
                        seque_act.runAction(device);
                    }
                    else
                    {
                        act_group[0].State = 2;
                    }
                }
            }
        }