Esempio n. 1
0
        public override void run(double dt)
        {
            bool resulty = true;

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

            switch (step)
            {
            case 0:
                resulty = device.MovePump(injects, speed, absorbs);
                if (resulty)
                {
                    step++;
                }
                break;

            case 1:
                isfinish = device.DonePump(injects);
                break;
            }
        }
Esempio n. 2
0
        public override void run(double dt)
        {
            bool resultx = true;

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

            switch (step)
            {
            case 0:
            {
                int[] absorbs = { 0, 0, 0, 0 };
                foreach (var ent in injects)
                {
                    absorbs[ent.Index] = (int)ent.PumpMotor.Maximum.SetValue;
                }
                resultx = device.MovePump(injects, 100, absorbs);
                if (resultx)
                {
                    step++;
                }
            }
            break;

            case 1:
                if (device.DonePump(injects))
                {
                    step++;
                }
                isfinish = injects.Count() == 0;
                break;

            case 2:
            {
                int[] absorbs = { 0, 0, 0, 0 };
                resultx = device.MovePump(injects, 100, absorbs);
                if (resultx)
                {
                    step++;
                }
            }
            break;

            case 3:
                if (device.DonePump(injects))
                {
                    step++;
                }
                break;

            case 4:
                isfinish = true;
                break;
            }
        }
Esempio n. 3
0
        //x轴移动约束
        public bool MoveXConstrains(int x, double dt)
        {
            if (node is MachineHandDevice || node is InjectorDevice)
            {
                contime += dt;
                if (contime > 500)
                {
                    contime = 0;
                    MachineHandDevice handDevice     = Engine.getInstance().handDevice;
                    InjectorDevice    injectorDevice = Engine.getInstance().injectorDevice;
                    OtherPartDevice   opDevice       = Engine.getInstance().opDevice;
                    int hand_rx     = 0;
                    int inj_rx      = 0;
                    var hand_device = new ActionDevice(handDevice);
                    var inj_device  = new ActionDevice(injectorDevice);
                    hand_device.GetRealX(ref hand_rx);
                    inj_device.GetRealX(ref inj_rx);
                    if (node is MachineHandDevice)
                    {
                        hand_tx = x;
                    }
                    if (node is InjectorDevice)
                    {
                        inj_tx = x;
                    }
                    int hand_cx     = hand_rx != hand_old_rx ? hand_tx : hand_rx;
                    int inj_cx      = inj_rx != inj_old_rx ? inj_tx : inj_rx;
                    int total_space = opDevice.OP.AvoidanceTotal.SetValue;
                    int limt_space  = opDevice.OP.AvoidanceSpace.SetValue;
                    int l_space     = total_space - (hand_cx + inj_cx) - limt_space;
                    int hand_lx     = hand_cx + l_space;
                    int inj_lx      = inj_cx + l_space;
                    hand_old_rx = hand_rx;
                    inj_old_rx  = inj_rx;

                    bool is_hand_in_con_space = hand_rx >= hand_tx ? false : hand_tx >= hand_lx;
                    bool is_inj_in_con_space  = inj_rx >= inj_tx ? false : inj_tx >= inj_lx;
                    //System.Diagnostics.Debug.Assert(!(is_hand_in_con_space && is_inj_in_con_space));
                    is_all_in_con_space = is_hand_in_con_space && is_inj_in_con_space;
                    if (node is MachineHandDevice)
                    {
                        return(is_hand_in_con_space == false);
                    }
                    else if (node is InjectorDevice)
                    {
                        return(is_inj_in_con_space == false);
                    }
                }
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        public override void run(double dt)
        {
            bool resultx = true;
            bool resulty = true;
            bool resultz = true;

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

            switch (step)
            {
            case 0:
                //inject_device.CanComm.SetByte(inject_device.Injector.TMotor.PickTMotor.Addr, 0x0000);
                resultx = xdone || device.MoveX(x);
                resulty = ydone || device.MoveY(injects, speed, y);
                resultz = zdone || device.MoveZ(injects, speed, z);
                if (resultx && resulty && resultz)
                {
                    step++;
                }
                break;

            case 1:
                if (xdone == false)
                {
                    xdone = device.DoneX();
                }
                if (ydone == false)
                {
                    ydone = device.DoneY(injects);
                }
                if (zdone == false)
                {
                    zdone = device.DoneZ(injects);
                }
                isfinish = xdone && ydone && zdone;
                break;
            }
        }
        public void ActLogic(List <T_GelStep> act_group, List <T_GelStep> act_group_next, double dt)
        {
            if (act_group != null && act_group.Count != 0 && act_group[0].State == 0)
            {
                int next_state    = 2;
                var seque_act     = Sequence.create();
                var exper_package = ((ExperimentPackage)act_group[0].ExperPackage);
                seque_act.exp_pack = exper_package;
                AbstractCanDevice device = null;
                foreach (var act in act_group)
                {
                    resmanager.tip_count += act.InjectCount;
                }
                if (act_group[0].InjectCount != 0)
                {
                    var act_next = act_group_next == null ? null : act_group_next[0];
                    device = injectorDevice;
                    act_group.Sort((a, b) => { return(((ExperimentPackage)a.ExperPackage).piercer_index > ((ExperimentPackage)b.ExperPackage).piercer_index ? 1 : -1); });
                    seque_act = generater.GenerateAction(act_group);
                    if (act_next != null && act_next.InjectCount == 0)
                    {
                        seque_act.AddAction(SkCallBackFun.create((ActionBase act_tem) =>
                        {
                            inj_wait_time = 9999;
                            return(true);
                        }));
                    }
                }
                else
                {
                    var act      = act_group[0];
                    var act_next = act_group_next == null ? null : act_group_next[0];
                    var resinfo  = resmanager.GetResByCode(exper_package.GetGelMask(), "T_BJ_GelSeat");
                    if (resinfo == null)
                    {
                        resinfo = resmanager.GetResByCode(exper_package.GetGelMask(), "T_BJ_Centrifuge");
                    }
                    if ((resinfo == null || !resinfo.PutOk) && act.StepClass != TestStepEnum.LoadGel)
                    {
                        return;
                    }
                    switch (act.StepClass)
                    {
                    case TestStepEnum.LoadGel:
                    {
                        if (actionmanager.getAllActionsCount(handDevice) == 0)
                        {
                            var take_seat  = resmanager.GetResByCode(exper_package.GetGelMask(), "T_BJ_GelSeat", "", "3");
                            var paper_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "4", null, exper_package.is_crossmatching);
                            if (paper_seat != null)
                            {
                                device = handDevice;
                                if (take_seat != null)
                                {
                                    generater.GenerateTakeGelFromNormal(take_seat, ref seque_act);
                                }
                                else
                                {
                                    seque_act.AddAction(HandTakeGelFromWare.create(handDevice, 3001, gelwareDevice, exper_package.gel_mask_id, exper_package.GetGelMask(), exper_package.GetSampleCode(act.SampleIndex)));
                                }
                                seque_act.AddAction(HandPutGelToNormal.create(handDevice, 3001, gelwareDevice, paper_seat));
                                if (act_next != null && act_next.StepClass != TestStepEnum.LoadGel)
                                {
                                    seque_act.AddAction(SkCallBackFun.create((ActionBase act_tem) => {
                                            hand_wait_time = 999999;
                                            var ware_act   = MoveTo.create(gelwareDevice, 3000, 0);
                                            ware_act.runAction(gelwareDevice);
                                            return(true);
                                        }));
                                }
                                exper_package.piercer_index             = paper_seat.CountX;
                                paper_seat.Values[paper_seat.CountX, 0] = new ResInfoData();
                                seque_act.destroyfun = (ActionBase act_tem) =>
                                {
                                    paper_seat.Values[paper_seat.CountX, 0] = null;
                                    return(true);
                                };
                                next_state = 2;
                            }
                            else
                            {
                                next_state = 0;
                            }
                        }
                        else
                        {
                            next_state = 0;
                        }
                    }
                    break;

                    case TestStepEnum.KaiKongGel:
                    {
                        int handrx      = 0;
                        int injrx       = 0;
                        var device_hand = new ActionDevice(handDevice);
                        var device_inj  = new ActionDevice(injectorDevice);
                        next_state = 0;
                        if (resinfo.Purpose != "4")
                        {
                            var put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "4");
                            if (put_seat == null && resinfo.Purpose != "3")
                            {
                                put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3");
                            }
                            if (put_seat != null)
                            {
                                device = handDevice;
                                ResInfoData put_gel = null;
                                if (resinfo.Purpose == "lxj")
                                {
                                    put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act);
                                }
                                else
                                {
                                    put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque_act);
                                }
                                generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque_act);
                                next_state = 0;
                            }
                        }
                        else
                        {
                            bool is_next_kaikong = act_next != null ? act_next.StepClass == TestStepEnum.KaiKongGel : false;
                            var  paper_seat      = resmanager.GetResByCode(exper_package.GetGelMask(), "T_BJ_GelSeat", "", "4");
                            int  yb = is_next_kaikong ? -1 : 0;
                            if (paper_seat != null &&
                                device_hand.GetRealX(ref handrx) &&
                                (handrx + 1000) < paper_seat.X && ActionDevice.hand_tx < paper_seat.X &&
                                device_inj.GetRealX(ref injrx) &&
                                (injrx + 1000) < paper_seat.InjectorX && ActionDevice.inj_tx < paper_seat.InjectorX + 1000)
                            {
                                device = piercerDevice;
                                seque_act.AddAction(PaperCard.create(piercerDevice, 3000, paper_seat, yb));
                                seque_act.AddAction(SkCallBackFun.create((ActionBase acttem) =>
                                    {
                                        exper_package.is_open = true;
                                        resmanager.gel_count++;
                                        return(true);
                                    }));
                                next_state = 2;
                            }
                        }
                    }
                    break;

                    case TestStepEnum.JYJS:
                    {
                        exper_package.is_jyjs = true;
                        next_state            = 2;
                    }
                    break;

                    case TestStepEnum.ZKDFY:
                    {
                        next_state = 0;
                        if (resinfo.Purpose == "1")
                        {
                            next_state = 0;
                            exper_package.hatch_cur_time += dt;
                            if (exper_package.hatch_cur_time >= exper_package.hatch_time)
                            {
                                next_state = 2;
                            }
                        }
                        else if (!(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0))
                        {
                            var put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "1");
                            if (put_seat == null && resinfo.Purpose != "3")
                            {
                                put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3");
                            }
                            if (put_seat != null)
                            {
                                device = handDevice;
                                ResInfoData put_gel = null;
                                if (resinfo.Purpose == "lxj")
                                {
                                    put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act);
                                }
                                else
                                {
                                    put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque_act);
                                }
                                exper_package.hatch_cur_time = 0;
                                generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque_act);
                                next_state = 0;
                            }
                            else
                            {
                                next_state = 0;
                            }
                        }
                    }
                    break;

                    case TestStepEnum.ZKDLXJ:
                    {
                        if (actionmanager.getAllActionsCount(handDevice) == 0)
                        {
                            next_state = 0;
                            if (resinfo.Purpose != "lxj" && !(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0))
                            {
                                //查看可用离心机
                                var centrifuge_list = resmanager.centrifuge_list.Where(item => item.Status == 1).ToList();
                                centrifuge_list.Sort((a, b) => { return(a.LastUseTime < b.LastUseTime ? 1 : -1); });
                                foreach (var seat in centrifuge_list)
                                {
                                    CentrifugeMDevice cendev = cenMrg.GetCentrifugeByCode(seat.Code);
                                    if (seat.Status == 1 && cendev != null)
                                    {
                                        device = handDevice;
                                        bool is_last_cent = seat == centrifuge_list[centrifuge_list.Count - 1];
                                        bool iscanputcen  = IsCanPutCen(cendev);
                                        var  put_seat     = resmanager.GetResByCode("null", "T_BJ_Centrifuge", cendev.Centrifugem.Code.SetValue);
                                        if (iscanputcen == false)
                                        {
                                            put_seat = null;
                                        }
                                        //放进待定位
                                        if (put_seat == null && resinfo.Purpose != "3" && is_last_cent)
                                        {
                                            put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3");
                                        }
                                        if (put_seat != null)
                                        {
                                            var spaw      = Spawn.create();
                                            var put_seque = Sequence.create();
                                            if (put_seat.Purpose == "lxj")
                                            {
                                                //打开离心机门
                                                var opendoor_act = HandOpenCloseDoor.create(handDevice, 5000, cendev.Centrifugem.Code.SetValue, true);
                                                put_seque.AddAction(opendoor_act);
                                            }
                                            var put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref put_seque);
                                            spaw.AddAction(put_seque);
                                            seque_act.AddAction(spaw);
                                            if (put_seat.Purpose == "lxj")
                                            {
                                                spaw.AddAction(MoveTo.create(cendev, 30001, -1, -1, put_seat.CenGelP[put_seat.CountX]));
                                                generater.GeneratePutGelToCent(cendev.Centrifugem.Code.SetValue, put_seat, put_gel, ref seque_act);
                                            }
                                            else
                                            {
                                                generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque_act);
                                            }
                                            seat.LastUseTime = Engine.getInstance().getSystemMs();
                                            break;
                                        }
                                        else
                                        {
                                            next_state = 0;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            next_state = 0;
                        }
                    }
                    break;

                    case TestStepEnum.PutPeiGelBack:
                    {
                        var put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "2");
                        if (put_seat != null && resinfo.Purpose == "lxj")
                        {
                            device = handDevice;
                            var put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act);
                            generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque_act);
                            next_state = 2;
                        }
                    }
                    break;

                    case TestStepEnum.XJPD:
                    {
                        var put_seat     = resmanager.GetResByCode("", "T_BJ_Camera");               //相机位
                        var wasted_seat  = resmanager.GetResByCode("", "T_BJ_WastedSeat", "", "1");  //垃圾位
                        var daiding_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3"); //待定位
                        if (put_seat != null && wasted_seat != null && !(resinfo.Purpose == "4" && actionmanager.getAllActionsCount(piercerDevice) != 0))
                        {
                            device = handDevice;
                            ResInfoData put_gel = null;
                            if (resinfo.Purpose == "lxj")
                            {
                                put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act);
                            }
                            else
                            {
                                put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque_act);
                            }

                            seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0));
                            seque_act.AddAction(MoveTo.create(handDevice, 3000, (int)put_seat.X, (int)(put_seat.Y), -1));
                            seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, (int)(put_seat.Z)));
                            //拍照分析
                            seque_act.AddAction(SkCallBackFun.create((ActionBase acttem) =>
                                {
                                    opDevice.CameraLight(true);
                                    bool result = true;
                                    if (cameraDevice.IsOpen == false)
                                    {
                                        result = cameraDevice.Open();
                                    }
                                    var bm = cameraDevice.CaptureImage();
                                    cameraDevice.Save(bm, exper_package);
                                    opDevice.CameraLight(false);
                                    return(true);
                                }));
                            //是否还有动作
                            if (exper_package.action_list.Count > 1 && daiding_seat != null)
                            {
                                seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0));
                                generater.GeneratePutGelToNormal(daiding_seat, put_gel, ref seque_act);
                            }
                            else
                            {
                                seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0));
                                seque_act.AddAction(MoveTo.create(handDevice, 3000, (int)wasted_seat.X, (int)(wasted_seat.Y)));
                                seque_act.AddAction(HandPutCard.create(handDevice, 3000, (int)wasted_seat.ZPut, 0));
                                seque_act.AddAction(SkCallBackFun.create((ActionBase act_tem) => {
                                        DelPackage(exper_package);
                                        return(true);
                                    }));
                            }
                            next_state = 2;
                        }
                    }
                    break;

                    case TestStepEnum.ECONOMIZECOUNTTIME:
                    {
                        next_state = 0;
                        if (exper_package.is_open)
                        {
                            exper_package.after_kktime -= dt;
                            if (exper_package.after_kktime <= 0)
                            {
                                device     = handDevice;
                                next_state = 2;
                                exper_package.after_kktime = 0;
                                ResInfoData put_gel = null;
                                if (resinfo.Purpose == "lxj")
                                {
                                    put_gel = generater.GenerateTakeGelFromCent(resinfo, resinfo.CenCode, ref seque_act);
                                }
                                else
                                {
                                    put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque_act);
                                }

                                var wasted_seat = resmanager.GetResByCode("", "T_BJ_WastedSeat");        //垃圾位
                                seque_act.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0));
                                seque_act.AddAction(MoveTo.create(handDevice, 3000, (int)wasted_seat.X, (int)(wasted_seat.Y)));
                                seque_act.AddAction(HandPutCard.create(handDevice, 3000, (int)wasted_seat.ZPut, 0));
                            }
                        }
                    }
                    break;
                    }
                }
                if (device != null)
                {
                    seque_act.AddAction(SkCallBackFun.create((ActionBase act) =>
                    {
                        foreach (var act_tem in act_group)
                        {
                            act_tem.State = next_state;
                        }
                        return(true);
                    }));
                    foreach (var act_tem in act_group)
                    {
                        act_tem.State = 1;
                    }
                    seque_act.runAction(device);
                }
                else
                {
                    foreach (var act_tem in act_group)
                    {
                        act_tem.State = next_state;
                    }
                }
            }
        }
        //排序
        public void UpDataAction()
        {
            lock (mylock)
            {
                //融合两个试验
                foreach (var package in experiment_package_list)
                {
                    if (package.is_used_gel && package.action_list.Count != 0 && package.ren_fen != package.GetCurRenFen())
                    {
                        var exp_pack_tem = GetCombinationExpPackage(package);
                        if (exp_pack_tem != null)
                        {
                            if (exp_pack_tem.samples_barcode.Count == 1)
                            {
                                package.Combination(exp_pack_tem);
                            }
                            else
                            {
                                exp_pack_tem.Combination(package);
                            }
                        }
                    }
                }
                ClsAction();
                //把交叉配血卡的动作ID更新
                //foreach (var package in experiment_package_list)
                //{
                //    if (package.is_crossmatching) package.UpDataCrossMatchingSetpIndex();
                //}
                inj_action_list = new List <T_GelStep>();
                List <List <T_GelStep> > action_group = new List <List <T_GelStep> >();
                int index         = 0;
                int max_goup_size = 12;
                //按有孵育的就组
                experiment_package_list = experiment_package_list.OrderByDescending(a => a.sort_index).ToList();
                //12个一组
                int group_last_gel_test_id = -1;
                for (int i = 0; i < experiment_package_list.Count; i++)
                {
                    //不同卡为一组
                    if (experiment_package_list[i].is_jyjs == false)
                    {
                        if (index % max_goup_size == 0 || (group_last_gel_test_id != experiment_package_list[i].gel_test_id))
                        {
                            action_group.Add(new List <T_GelStep>());
                            index = 1;
                        }
                        else
                        {
                            index++;
                        }
                        action_group[action_group.Count - 1] = action_group[action_group.Count - 1].Concat(experiment_package_list[i].action_list).ToList();
                        group_last_gel_test_id = experiment_package_list[i].gel_test_id;
                    }
                }

                for (int i = 0; i < action_group.Count; i++)
                {
                    action_group[i] = action_group[i].OrderBy(u => u.StepIndex).ToList();
                    inj_action_list = inj_action_list.Concat(action_group[i]).ToList();
                }
                //试剂(最多两个针头加样,分配,把脱针去掉,把加样去掉,把容量合并)
                //查找连续试剂(如果超过三个就合并)
                AgentiaCombination(inj_action_list, 0);
                SlysCombination(inj_action_list, 0);
                //交叉配血合并
                CrossMatchingCombination(inj_action_list, 0);
                //破空器返回
                int pier_y      = 0;
                var pier_device = new ActionDevice(piercerDevice);
                pier_device.GetRealY(ref pier_y);
                if (pier_y != 0 && inj_action_list.Count != 0 && inj_action_list[0].StepClass != TestStepEnum.KaiKongGel)
                {
                    var pier_back = MoveTo.create(piercerDevice, 3000, -1, 0, -1);
                    pier_back.runAction();
                }
            }
        }
Esempio n. 7
0
        public override void run(double dt)
        {
            bool resultx = true;
            bool resulty = true;
            bool resultz = true;

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

            switch (step)
            {
            case 0:
                if (injects == null)
                {
                    if (x)
                    {
                        resultx = device.InitX();
                    }
                    if (y)
                    {
                        resulty = device.InitY();
                    }
                    if (z)
                    {
                        resultz = device.InitZ();
                    }
                }
                else
                {
                    if (x)
                    {
                        resultx = device.InitX();
                    }
                    if (y)
                    {
                        resulty = device.InitY(injects);
                    }
                    if (z)
                    {
                        resultz = device.InitZ(injects);
                    }
                }
                if (resultx && resulty && resultz)
                {
                    step++;
                }
                break;

            case 1:
                if (injects == null)
                {
                    if (xdone == false)
                    {
                        xdone = device.DoneX();
                    }
                    if (ydone == false)
                    {
                        ydone = device.DoneY();
                    }
                    if (zdone == false)
                    {
                        zdone = device.DoneZ();
                    }
                }
                else
                {
                    if (xdone == false)
                    {
                        xdone = device.DoneX();
                    }
                    if (ydone == false)
                    {
                        ydone = device.DoneY(injects);
                    }
                    if (zdone == false)
                    {
                        zdone = device.DoneZ(injects);
                    }
                }

                isfinish = xdone && ydone && zdone;
                break;
            }
        }
Esempio n. 8
0
        public override void run(double dt)
        {
            bool resulty = true;

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

            switch (step)
            {
            case 0:
                //容量检测
                bool is_ok = true;
                int  index = 0;
                foreach (var inject in injects)
                {
                    bool is_timeout = false;
                    inject_device.CanComm.ReadRegister(inject.PumpMotor.RealDistance.Addr);
                    int curz = inject_device.CanComm.GetIntBlock(inject.PumpMotor.RealDistance.Addr, 1000, out is_timeout);
                    movez[inject.Index] = curz + absorbs[inject.Index];
                    bool is_enough = is_timeout == false && movez[inject.Index] <= (int)inject.PumpMotor.Maximum.SetValue && movez[inject.Index] >= 0;
                    if (is_enough == false || is_timeout)
                    {
                        index = inject.Index;
                        is_ok = false;
                        break;
                    }
                }
                if (is_ok)
                {
                    step++;
                }
                else
                {
                    bool ret = ErrorSystem.WriteActError("液泵:" + index + "容量不足!");
                    if (ret == false)
                    {
                        istimeout = true;
                        errmsg    = "液泵:" + index + "容量不足!";
                        return;
                    }
                }
                if (injects.Count() == 0)
                {
                    bool ret = ErrorSystem.WriteActError("没有可用加样器");
                    if (ret == false)
                    {
                        istimeout = true;
                        errmsg    = "没有可用加样器";
                        return;
                    }
                }
                break;

            case 1:
                resulty = device.MovePump(injects, speed, movez);
                if (resulty)
                {
                    step++;
                }
                break;

            case 2:
                isfinish = device.DonePump(injects);
                break;
            }
        }
Esempio n. 9
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;
            }
        }
Esempio n. 10
0
        //排序
        public void UpDataAction()
        {
            lock (mylock)
            {
                //融合两个试验
                foreach (var package in experiment_package_list)
                {
                    if (package.is_used_gel && package.action_list.Count != 0 && package.ren_fen != package.GetCurRenFen())
                    {
                        var exp_pack_tem = GetCombinationExpPackage(package);
                        if (exp_pack_tem != null)
                        {
                            if (exp_pack_tem.action_list.Count != 1)
                            {
                                package.Combination(exp_pack_tem);
                            }
                            else
                            {
                                exp_pack_tem.Combination(package);
                            }
                        }
                    }
                }
                ClsAction();
                inj_action_list = new List <T_GelStep>();
                List <List <T_GelStep> > action_group = new List <List <T_GelStep> >();
                int index         = 0;
                int max_goup_size = 12;
                //加载卡打孔12个一组
                for (int i = 0; i < experiment_package_list.Count; i++)
                {
                    if (experiment_package_list[i].is_jyjs == false)
                    {
                        if (index % max_goup_size == 0)
                        {
                            action_group.Add(new List <T_GelStep>());
                        }
                        var loadgel_list    = experiment_package_list[i].action_list.Where(item => item.StepClass == TestStepEnum.LoadGel);
                        var kaikonggel_list = experiment_package_list[i].action_list.Where(item => item.StepClass == TestStepEnum.KaiKongGel);
                        action_group[action_group.Count - 1] = action_group[action_group.Count - 1].Concat(loadgel_list).ToList();
                        action_group[action_group.Count - 1] = action_group[action_group.Count - 1].Concat(kaikonggel_list).ToList();
                        index++;
                    }
                }
                //加样动作4个一组
                index         = 0;
                max_goup_size = 4;
                for (int i = 0; i < experiment_package_list.Count; i++)
                {
                    if (experiment_package_list[i].is_jyjs == false)
                    {
                        if (index % max_goup_size == 0)
                        {
                            action_group.Add(new List <T_GelStep>());
                        }
                        var jyact_list   = experiment_package_list[i].action_list.Where(item => item.StepClass == TestStepEnum.JYJS).ToList();
                        int jyjs_index   = jyact_list.Count != 0?jyact_list[0].StepIndex:1000;
                        var nomoact_list = experiment_package_list[i].action_list.Where(item => item.StepIndex < jyjs_index && item.StepClass != TestStepEnum.LoadGel && item.StepClass != TestStepEnum.KaiKongGel);
                        action_group[action_group.Count - 1] = action_group[action_group.Count - 1].Concat(nomoact_list).ToList();
                        index++;
                    }
                }
                //加样后动作12个一组
                index         = 0;
                max_goup_size = 12;
                for (int i = 0; i < experiment_package_list.Count; i++)
                {
                    if (experiment_package_list[i].is_jyjs == false)
                    {
                        if (index % max_goup_size == 0)
                        {
                            action_group.Add(new List <T_GelStep>());
                        }
                        var jyact_list   = experiment_package_list[i].action_list.Where(item => item.StepClass == TestStepEnum.JYJS).ToList();
                        int jyjs_index   = jyact_list.Count != 0 ? jyact_list[0].StepIndex : 1000;
                        var nomoact_list = experiment_package_list[i].action_list.Where(item => item.StepIndex >= jyjs_index && item.StepClass != TestStepEnum.LoadGel && item.StepClass != TestStepEnum.KaiKongGel);
                        action_group[action_group.Count - 1] = action_group[action_group.Count - 1].Concat(nomoact_list).ToList();
                        index++;
                    }
                }

                for (int i = 0; i < action_group.Count; i++)
                {
                    action_group[i] = action_group[i].OrderBy(u => u.StepIndex).ToList();
                    inj_action_list = inj_action_list.Concat(action_group[i]).ToList();
                }
                //试剂(最多两个针头加样,分配,把脱针去掉,把加样去掉,把容量合并)
                //查找连续试剂(如果超过三个就合并)
                AgentiaCombination(inj_action_list, 0);
                //破空器返回
                int pier_y      = 0;
                var pier_device = new ActionDevice(piercerDevice);
                pier_device.GetRealY(ref pier_y);
                if (pier_y != 0 && inj_action_list.Count != 0 && inj_action_list[0].StepClass != TestStepEnum.KaiKongGel)
                {
                    var pier_back = MoveTo.create(piercerDevice, 3000, -1, 0, -1);
                    pier_back.runAction();
                }
            }
        }
Esempio n. 11
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;
                    }
                }
            }
        }