コード例 #1
0
        public static InitXyz create(double ttime = 0, Enterclose[] iinjects = null, bool xx = true, bool yy = true, bool zz = true)
        {
            InitXyz acttem = InitXyz.create(ttime, xx, yy, zz);

            acttem.injects = iinjects;
            return(acttem);
        }
コード例 #2
0
        public void ErrorCode(int tagerid, byte[] data)
        {
            string[] error_msg   = { "电机归零超时", "电机运动超时", "电机运动中停止" };
            int      error_index = data[7] % 3;
            int      moto_index  = handDevice.Hand.ZMotor.GetMotoIndex();

            if (error_index == 2 && moto_index == data[5])
            {
                //初始化电机
                var task = new Task(() =>
                {
                    stop();
                    var act_tem = InitXyz.create(handDevice, 30000, false, false, true);
                    act_tem.init();
                    long lasttime = getSystemMs();
                    while (true)
                    {
                        long dt = 100;
                        act_tem.run(dt);
                        Thread.Sleep(100);
                        if (act_tem.isfinish)
                        {
                            break;
                        }
                    }
                    start();
                });
                task.Start();
            }
            if (error_index != 2)
            {
                ErrorSystem.WriteActError(error_msg[error_index], true, false);
            }
        }
コード例 #3
0
        public static InitXyz create(AbstractCanDevice nodetem, double ttime = 0, bool xx = true, bool yy = true, bool zz = true)
        {
            InitXyz acttem = InitXyz.create(ttime, xx, yy, zz);

            acttem.node = nodetem;
            return(acttem);
        }
コード例 #4
0
 public static InitXyz getInstance()
 {
     if (instance == null)
     {
         instance = new InitXyz();
     }
     return(instance);
 }
コード例 #5
0
        public static InitXyz create(double ttime = 0, bool xx = true, bool yy = true, bool zz = true)
        {
            InitXyz acttem = new InitXyz();

            acttem.x    = xx;
            acttem.y    = yy;
            acttem.z    = zz;
            acttem.time = ttime;
            return(acttem);
        }
コード例 #6
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);
         }
     }
 }
コード例 #7
0
        //执行
        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;
            }
        }
コード例 #8
0
        //放卡到离心逻辑
        public bool CenPutLogic(CentrifugeMDevice cendev)
        {
            if (resmanager.handseat_resinfo != null ||
                actionmanager.getAllActionsCount(piercerDevice) != 0 ||
                actionmanager.getAllActionsCount(handDevice) != 0 ||
                actionmanager.getAllActionsCount(cendev) != 0)
            {
                return(false);
            }
            bool isallcen = true;//是否在离心机内的所有卡当前动作是离心

            foreach (var seat in resmanager.centrifuge_list)
            {
                if (seat.Code == cendev.Centrifugem.Code.SetValue)
                {
                    for (int i = 0; i < seat.Values.Length; i++)
                    {
                        ResInfoData resinfo = (ResInfoData)seat.Values[i, 0];
                        if (resinfo != null && resinfo.InjectFinish && resinfo.PutOk)
                        {
                            isallcen = resinfo.GetActionAt(0) == ActionPoint.ActionPointType.Centrifugal;
                            if (isallcen == false)
                            {
                                break;
                            }
                        }
                    }
                    break;
                }
            }
            //普通卡位
            List <ResInfoData> resinfo_list = new List <ResInfoData>();

            foreach (var seat in resmanager.gelseat_list)
            {
                for (int i = 0; i < seat.Values.Length; i++)
                {
                    ResInfoData resinfo = (ResInfoData)seat.Values[i, 0];
                    if (resinfo != null && resinfo.InjectFinish && resinfo.PutOk)
                    {
                        if (resinfo.GetActionAt(0) == ActionPoint.ActionPointType.Centrifugal)
                        {
                            resinfo_list.Add(resinfo);
                        }
                    }
                }
            }

            //把卡转到离心位
            if (resinfo_list.Count != 0)
            {
                var  seque  = Sequence.create();
                bool is_put = false;
                seque.AddAction(InitXyz.create(cendev, 30000, false, false, true));
                foreach (var resinfo in resinfo_list)
                {
                    var put_seat = resmanager.GetResByCode("null", "T_BJ_Centrifuge", cendev.Centrifugem.Code.SetValue);
                    if (isallcen == false)
                    {
                        put_seat = null;
                    }
                    if (put_seat == null && resinfo.Purpose != "3")
                    {
                        put_seat = resmanager.GetResByCode("null", "T_BJ_GelSeat", "", "3");
                    }
                    if (put_seat != null)
                    {
                        var put_gel = generater.GenerateTakeGelFromNormal(resinfo, ref seque);
                        if (put_seat.Purpose == "lxj")
                        {
                            generater.GeneratePutGelToCent(cendev.Centrifugem.Code.SetValue, put_seat, put_gel, ref seque);
                        }
                        else
                        {
                            generater.GeneratePutGelToNormal(put_seat, put_gel, ref seque);
                        }
                        is_put = true;
                    }
                }
                if (is_put)
                {
                    seque.runAction(handDevice);
                    return(true);
                }
            }
            return(false);
        }
コード例 #9
0
ファイル: CenLogicManager.cs プロジェクト: jume2003/SK800
        public void runLoop(double time)
        {
            double dt = time - lasttime;

            if (dt < 500)
            {
                return;
            }
            lasttime = time;
            //更新卡
            UpdataResInfoList();
            if (resinfo_list.Count == 0 && InjLogicManager.getInstance().action_tree.Count == 0)
            {
                return;
            }
            foreach (var resinfo in resinfo_list)
            {
                Logic(resinfo, dt);
            }
            ////离心逻辑
            foreach (var cent in cenMrg.CentrifugeMDevices)
            {
                //如果当前离心机在跑或已满卡就添加到下一个离心机中
                if (CenRunLogic(cent))
                {
                    return;                   // 离心启动逻辑
                }
                break;
            }
            //机器手空闲回零
            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, 0, 0, 0), InitXyz.create(20000, true, true, true));
                    act.runAction(handDevice);
                    hand_wait_time = 0;
                }
            }
        }
コード例 #10
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;
                    }
                }
            }
        }