예제 #1
0
        //生成加样移动组合
        public void GenerateInjectActGroup(ref Sequence seque, ref int index, ref ActionPoint[] tager, ref int[] point, ref int[] width, ref bool is_ok, ActionBase move_x = null, Spawn move_zt = null)
        {
            if (index == 4)
            {
                is_ok = true;
                return;
            }
            else if (tager[index].y == point[index] || tager[index].y == -1)
            {
                if (tager[index].y == point[index])
                {
                    var action_point        = tager[index];
                    var move_act            = Sequence.create();
                    List <Enterclose> ents  = new List <Enterclose>();
                    int[]             injz  = IMask.Gen(-1);
                    int[]             injzl = IMask.Gen(-1);
                    int[]             injzd = IMask.Gen(-1);
                    ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[index]);
                    move_act.AddAction(SkWaitForAction.create(move_x));
                    if (action_point.type == TestStepEnum.JXZT)
                    {
                        int[] absorbs   = IMask.Gen(-1);
                        var   injact_sp = Spawn.create();
                        injz[index]    = action_point.z;
                        absorbs[index] = (int)ents[0].PumpMotor.Maximum.SetValue;
                        injact_sp.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2));
                        injact_sp.AddAction(InjectAbsorbMove.create(3001, ents.ToArray(), 100, absorbs));
                        move_act.AddAction(injact_sp);
                        injz[index] = action_point.zb;
                        move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz));
                    }
                    else if (action_point.type == TestStepEnum.PutTip)
                    {
                        injz[index] = action_point.z;
                        var sequ = Sequence.create();
                        sequ.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2));
                        sequ.AddAction(MoveTo.create(3001, action_point.puttip_x, -1, -1));
                        injz[index] = action_point.z - 1000;
                        sequ.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 100));
                        injz[index] = action_point.zb;
                        sequ.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz));
                        move_act.AddAction(sequ);
                    }
                    else if (action_point.type == TestStepEnum.AbsLiquid)
                    {
                        int[] absorbs = IMask.Gen(-1);
                        absorbs[index] = -(action_point.capacity);
                        move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 0));
                        injz[index] = action_point.z + action_point.deep;
                        move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, action_point.deepspeed));
                        move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), action_point.absbspeed, absorbs));
                        //回吸
                        var back_act = Spawn.create();
                        if (action_point.backcapacity != 0)
                        {
                            absorbs[index] = -(action_point.backcapacity);
                            back_act.AddAction(Sequence.create(SKSleep.create(500), InjectAbsorb.create(3001, ents.ToArray(), action_point.backspeed, absorbs)));
                        }
                        injz[index] = action_point.zb;
                        back_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz));
                        move_act.AddAction(back_act);
                    }
                    else if (action_point.type == TestStepEnum.FollowAbsLiquid)
                    {
                        int[] absorbs = IMask.Gen(-1);
                        injz[index]    = action_point.z;
                        injzl[index]   = action_point.z + action_point.detectordeep;
                        injzd[index]   = action_point.deep;
                        absorbs[index] = -(action_point.capacity);
                        move_act.AddAction(InjectDetector.create(3001, ents.ToArray(), injz, injzl, injzd, 2, 1));
                        move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), action_point.absbspeed, absorbs));
                        //回吸
                        var back_act = Spawn.create();
                        if (action_point.backcapacity != 0)
                        {
                            absorbs[index] = -(action_point.backcapacity);
                            back_act.AddAction(Sequence.create(SKSleep.create(500), InjectAbsorb.create(3001, ents.ToArray(), action_point.backspeed, absorbs)));
                        }
                        injz[index] = action_point.zb;
                        back_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz));
                        move_act.AddAction(back_act);
                    }
                    else if (action_point.type == TestStepEnum.SpuLiquid)
                    {
                        int[] absorbs = IMask.Gen(-1);
                        injz[index]    = action_point.z;
                        absorbs[index] = action_point.spucapacity + action_point.backcapacity;
                        move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2));
                        move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), action_point.spuspeed, absorbs));
                        //回吸
                        var back_act = Spawn.create();
                        if (action_point.backcapacity != 0)
                        {
                            absorbs[index] = -(action_point.backcapacity);
                            back_act.AddAction(Sequence.create(SKSleep.create(100), InjectAbsorb.create(3001, ents.ToArray(), action_point.backcapacity, absorbs)));
                        }
                        injz[index] = action_point.zb;
                        back_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz));
                        move_act.AddAction(back_act);
                    }
                    else if (action_point.type == TestStepEnum.MixLiquid)
                    {
                        int[] absorbs = IMask.Gen(-1);
                        injz[index] = action_point.z;
                        move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2));
                        absorbs[index] = action_point.capacity;
                        move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), 100, absorbs));//把稀释液放进去
                        //混合操作
                        if (action_point.mixtimes != 0)
                        {
                            for (int i = 0; i < action_point.mixtimes * 2; i++)
                            {
                                int mixz = action_point.z - action_point.mixdeep;//混合高度
                                if (mixz <= 0)
                                {
                                    mixz = action_point.z;
                                }
                                absorbs[index] = i % 2 == 0 ? -action_point.capacity : action_point.capacity;
                                injz[index]    = i % 2 == 0 ? action_point.z: mixz;
                                move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2));
                                move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), 100, absorbs));
                            }
                            injz[index] = action_point.z;
                            move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz, 2));
                            absorbs[index] = (int)ents[0].PumpMotor.Maximum.SetValue;
                            move_act.AddAction(InjectAbsorbMove.create(3001, ents.ToArray(), 100, absorbs));
                            absorbs[index] = -(action_point.GetTubeList().Count *action_point.spucapacity);
                            move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), 100, absorbs));
                        }
                        //回吸
                        if (action_point.backcapacity != 0)
                        {
                            injz[index] = action_point.z;
                            move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz));
                            absorbs[index] = -(action_point.backcapacity);
                            move_act.AddAction(InjectAbsorb.create(3001, ents.ToArray(), action_point.backspeed, absorbs));
                        }
                        injz[index] = action_point.zb;
                        move_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, IMask.Gen(-1), injz));
                    }
                    //查找前面的
                    if (move_zt != null)
                    {
                        move_zt.AddAction(move_act);
                    }
                    else
                    {
                        seque.AddAction(move_act);
                    }
                }
                index++;
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok, move_x, move_zt);
            }
            else
            {
                List <int[]> node_list = new List <int[]>();
                for (int i = 0; i < 4; i++)
                {
                    for (int j = i; j < 4; j++)
                    {
                        for (int k = j; k < 4; k++)
                        {
                            for (int l = k; l < 4; l++)
                            {
                                int[] point_tem = { 0, 0, 0, 0 };
                                point_tem[i] = tager[i].y;
                                point_tem[j] = tager[j].y;
                                point_tem[k] = tager[k].y;
                                point_tem[l] = tager[l].y;
                                for (int n = 0; n < 4; n++)
                                {
                                    if (point_tem[n] < 0)
                                    {
                                        point_tem[n] = 0;
                                    }
                                }
                                bool ispass = true;
                                int  frist  = 0;
                                for (int n = 0; n < 4; n++)
                                {
                                    if (point_tem[n] != 0)
                                    {
                                        frist = n;
                                        break;
                                    }
                                }
                                for (int n = frist; n < 4; n++)
                                {
                                    if (point_tem[n] == 0 && n - 1 >= 0)
                                    {
                                        point_tem[n] = point_tem[n - 1] + width[n];
                                    }
                                }
                                for (int n = 0; n < frist; n++)
                                {
                                    if (point_tem[n] == 0 && n + 1 <= 3)
                                    {
                                        point_tem[n] = point_tem[frist] - width[n] * (frist - n);
                                    }
                                }
                                for (int n = 0; n < 4; n++)
                                {
                                    bool isforward = n - 1 >= 0 ? point_tem[n] >= point_tem[n - 1] + width[n - 1] : true;
                                    bool isback    = n + 1 <= 3 ? point_tem[n] + width[n] <= point_tem[n + 1] : true;

                                    ispass = isforward && isforward;
                                    if (!ispass)
                                    {
                                        break;
                                    }
                                }
                                if (ispass && point_tem[index] == tager[index].y)
                                {
                                    node_list.Add(point_tem);
                                }
                            }
                        }
                    }
                }
                int[] minnode = node_list[0];
                foreach (var node in node_list)
                {
                    if (GetLoss(tager, node) < GetLoss(tager, minnode))
                    {
                        minnode = node;
                    }
                }
                List <int> left  = new List <int>();
                List <int> right = new List <int>();
                for (int i = 0; i < 4; i++)
                {
                    if (point[i] - minnode[i] < 0)
                    {
                        left.Add(i);
                    }
                    else
                    {
                        right.Add(i);
                    }
                }
                left.Sort((a, b) => { return(a < b ? 1 : -1); });
                right.Sort((a, b) => { return(a > b ? 1 : -1); });
                var    movesp_act = Spawn.create();
                var    move_act   = Sequence.create();
                string msg        = "";

                int[]             yy   = { -1, -1, -1, -1 };
                int[]             zz   = { -1, -1, -1, -1 };
                List <Enterclose> ents = new List <Enterclose>();
                for (int i = 0; i < left.Count; i++)
                {
                    int indextem = left[i];
                    if (point[indextem] != minnode[indextem])
                    {
                        ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]);
                        yy[indextem] = minnode[indextem];
                    }
                }
                movesp_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, yy, zz));
                ents.Clear();
                for (int i = 0; i < right.Count; i++)
                {
                    int indextem = right[i];
                    if (point[indextem] != minnode[indextem])
                    {
                        ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]);
                        yy[indextem] = minnode[indextem];
                    }
                }
                movesp_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, yy, zz));
                for (int i = 0; i < 4; i++)
                {
                    point[i] = minnode[i];
                }
                move_act.AddAction(movesp_act);
                //同步Z动作
                var spawz_action = Spawn.create();
                move_act.AddAction(spawz_action);
                seque.AddAction(move_act);
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok, move_x, spawz_action);
            }
        }
예제 #2
0
        /// <summary>
        /// 探测液面
        /// </summary>
        public void Detect()
        {
            if (this.SelectedBJ == null)
            {
                return;
            }
            var move_act = Sequence.create();

            move_act.AddAction(InjectMoveTo.create(10000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0)));
            int    x   = 0;
            int    y   = 0;
            int    z   = 0;
            int    zl  = (int)ZDeepWhenDetecting;
            double gap = 0;

            if (SelectedBJ is T_BJ_SampleRack sampleseat)
            {
                x = (int)(sampleseat.X);
                y = (int)(sampleseat.Y + SeatYIndex * sampleseat.Gap);
                z = (int)sampleseat.Z;
                if (zl == 0)
                {
                    zl = (int)sampleseat.Z + 1000;
                }
                else
                {
                    zl = (int)sampleseat.Z + (int)ZDeepWhenDetecting;
                }
                gap = (double)sampleseat.Gap;
            }
            else if (SelectedBJ is T_BJ_DeepPlate deepplate)
            {
                x = (int)(deepplate.X + SeatXIndex * deepplate.GapX);
                y = (int)(deepplate.Y + SeatYIndex * deepplate.GapY);
                z = (int)deepplate.Z;
                if (zl == 0)
                {
                    zl = (int)deepplate.Z;
                }
                else
                {
                    zl = (int)deepplate.Z + (int)ZDeepWhenDetecting;
                }
                gap = (double)deepplate.GapX;
            }
            else if (SelectedBJ is T_BJ_AgentiaWarehouse agentiaware)
            {
                x = (int)(agentiaware.X);
                y = (int)(agentiaware.Y + SeatYIndex * agentiaware.Gap);
                z = (int)agentiaware.Z;
                if (zl == 0)
                {
                    zl = (int)agentiaware.Z + 1000;
                }
                else
                {
                    zl = (int)agentiaware.Z + (int)ZDeepWhenDetecting;
                }
                gap = (double)agentiaware.Gap;
            }
            var points = IMask.Gen(new ActionPoint(-1, -1, -1));

            foreach (var ent in injectorDevice.GetSeleteced())
            {
                points[ent.Index].x  = x;
                points[ent.Index].y  = y + (int)(ent.Index * gap);
                points[ent.Index].z  = z;
                points[ent.Index].zb = z;
            }
            move_act.AddAction(InjectMoveActs.create(3001, points.ToArray(), true));
            move_act.AddAction(InjectDetector.create(30000, injectorDevice.GetSeleteced(), IMask.Gen(z), IMask.Gen((int)zl), IMask.Gen((int)0)));
            move_act.runAction(injectorDevice);
        }
예제 #3
0
        //生成加样移动组合
        public void GenerateInjectActGroup(ref Sequence seque, int [] hitsort, ref int index, ref ActionPoint[] tager, ref int[] point, ref int[] width, ref double[] width_rate, ref bool is_ok, ActionBase move_x = null)
        {
            int hit_index = 0;

            if (index < 4)
            {
                hit_index = hitsort[index];
            }

            if (index == 4)
            {
                is_ok = true;
                return;
            }
            else if ((tager[hit_index].isdone && tager[hit_index].y == point[hit_index]) || tager[hit_index].y == -1)
            {
                index++;
                GenerateInjectActGroup(ref seque, hitsort, ref index, ref tager, ref point, ref width, ref width_rate, ref is_ok, move_x);
            }
            else
            {
                List <int[]> node_list = new List <int[]>();
                int[]        width_tem = IMask.Gen(0);
                for (int i = 0; i < 4; i++)
                {
                    width_tem[i] = (int)(width[i] * width_rate[hit_index]);
                }
                for (int i = 0; i < 4; i++)
                {
                    for (int j = i; j < 4; j++)
                    {
                        for (int k = j; k < 4; k++)
                        {
                            for (int l = k; l < 4; l++)
                            {
                                int[] point_tem = { 0, 0, 0, 0 };
                                point_tem[i] = tager[i].y;
                                point_tem[j] = tager[j].y;
                                point_tem[k] = tager[k].y;
                                point_tem[l] = tager[l].y;
                                for (int n = 0; n < 4; n++)
                                {
                                    if (point_tem[n] < 0)
                                    {
                                        point_tem[n] = 0;
                                    }
                                }
                                bool ispass = true;
                                int  frist  = 0;
                                for (int n = 0; n < 4; n++)
                                {
                                    if (point_tem[n] != 0)
                                    {
                                        frist = n;
                                        break;
                                    }
                                }
                                for (int n = frist; n < 4; n++)
                                {
                                    if (point_tem[n] == 0 && n - 1 >= 0)
                                    {
                                        point_tem[n] = point_tem[n - 1] + width_tem[n];
                                    }
                                }
                                for (int n = 0; n < frist; n++)
                                {
                                    if (point_tem[n] == 0 && n + 1 <= 3)
                                    {
                                        point_tem[n] = point_tem[frist] - width_tem[n] * (frist - n);
                                    }
                                }
                                for (int n = 0; n < 4; n++)
                                {
                                    bool isforward = n - 1 >= 0 ? point_tem[n] >= point_tem[n - 1] + width_tem[n - 1] : true;
                                    bool isback    = n + 1 <= 3 ? point_tem[n] + width_tem[n] <= point_tem[n + 1] : true;

                                    ispass = isforward && isforward;
                                    if (!ispass)
                                    {
                                        break;
                                    }
                                }
                                if (ispass && point_tem[hit_index] == tager[hit_index].y)
                                {
                                    node_list.Add(point_tem);
                                }
                            }
                        }
                    }
                }
                int[] minnode = node_list[0];
                foreach (var node in node_list)
                {
                    if (GetLoss(tager, node) < GetLoss(tager, minnode))
                    {
                        minnode = node;
                    }
                }
                List <int> left  = new List <int>();
                List <int> right = new List <int>();
                for (int i = 0; i < 4; i++)
                {
                    if (point[i] - minnode[i] < 0)
                    {
                        left.Add(i);
                    }
                    else
                    {
                        right.Add(i);
                    }
                }
                left.Sort((a, b) => { return(a < b ? 1 : -1); });
                right.Sort((a, b) => { return(a > b ? 1 : -1); });
                var    movesp_act = Spawn.create();
                var    move_act   = Sequence.create();
                string msg        = "";

                int[]             yy   = IMask.Gen(-1);
                int[]             zz   = IMask.Gen(-1);
                List <Enterclose> ents = new List <Enterclose>();
                for (int i = 0; i < left.Count; i++)
                {
                    int indextem = left[i];
                    if (point[indextem] != minnode[indextem])
                    {
                        ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]);
                        yy[indextem] = minnode[indextem];
                    }
                }
                for (int i = 0; i < right.Count; i++)
                {
                    int indextem = right[i];
                    if (point[indextem] != minnode[indextem])
                    {
                        ents.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[indextem]);
                        yy[indextem] = minnode[indextem];
                    }
                }
                movesp_act.AddAction(InjectMoveTo.create(3001, ents.ToArray(), -1, yy, zz));
                for (int i = 0; i < 4; i++)
                {
                    point[i] = minnode[i];
                }
                move_act.AddAction(movesp_act);

                //得到到达的点
                List <ActionPoint> done_points = new List <ActionPoint>();
                List <Enterclose>  entcloses   = new List <Enterclose>();
                for (int i = 0; i < 4; i++)
                {
                    if (tager[i].y == point[i] && tager[i].isdone == false)
                    {
                        done_points.Add(tager[i]);
                        entcloses.Add(Engine.getInstance().injectorDevice.Injector.Entercloses[i]);
                        tager[i].isdone = true;
                    }
                }
                var run_act = Sequence.create();
                //对到达的点进行分类生成
                int[] injz    = IMask.Gen(-1);
                int[] injzl   = IMask.Gen(-1);
                int[] injzd   = IMask.Gen(-1);
                int[] absorbs = IMask.Gen(-1);
                run_act.AddAction(SkWaitForAction.create(move_x));
                if (done_points.Count != 0)
                {
                    if (done_points[0].type == TestStepEnum.JXZT)
                    {
                        var injact_sp = Spawn.create();
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index]    = done_points[i].z;
                            absorbs[entcloses[i].Index] = (int)entcloses[0].PumpMotor.Maximum.SetValue;
                        }
                        injact_sp.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2));
                        injact_sp.AddAction(InjectAbsorbMove.create(3001, entcloses.ToArray(), 100, absorbs));
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index] = done_points[i].zb;
                        }
                        run_act.AddAction(injact_sp);
                        run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz));
                    }
                    else if (done_points[0].type == TestStepEnum.PutTip)
                    {
                        var sequ = Sequence.create();
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index] = done_points[i].z;
                        }
                        sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2));
                        sequ.AddAction(MoveTo.create(3001, done_points[0].puttip_x, -1, -1));
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index] = done_points[i].z - 1000;
                        }
                        sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 1));
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index] = done_points[i].zb;
                        }
                        sequ.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz));
                        run_act.AddAction(sequ);
                    }
                    else if (done_points[0].type == TestStepEnum.AbsLiquid)
                    {
                        run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), IMask.Gen(-1), 0));
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index]    = done_points[i].z + done_points[i].deep;
                            absorbs[entcloses[i].Index] = -(done_points[i].capacity);
                        }
                        run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, done_points[0].deepspeed));
                        run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].absbspeed, absorbs));
                        //回吸
                        var back_act = Spawn.create();
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            if (done_points[i].backcapacity != 0)
                            {
                                absorbs[entcloses[i].Index] = -(done_points[i].backcapacity);
                                List <Enterclose> ent_tem = new List <Enterclose>();
                                ent_tem.Add(entcloses[i]);
                                back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs)));
                            }
                        }
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index] = done_points[i].zb;
                        }
                        back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz));
                        run_act.AddAction(back_act);
                    }
                    else if (done_points[0].type == TestStepEnum.FollowAbsLiquid)
                    {
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index]    = done_points[i].z;
                            injzl[entcloses[i].Index]   = done_points[i].z + done_points[i].detectordeep;
                            injzd[entcloses[i].Index]   = done_points[i].deep;
                            absorbs[entcloses[i].Index] = -(done_points[i].capacity);
                        }
                        run_act.AddAction(InjectDetector.create(3001, entcloses.ToArray(), injz, injzl, injzd, 2, 1));
                        run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].absbspeed, absorbs));
                        //回吸
                        var back_act = Spawn.create();
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            if (done_points[i].backcapacity != 0)
                            {
                                absorbs[entcloses[i].Index] = -(done_points[i].backcapacity);
                                List <Enterclose> ent_tem = new List <Enterclose>();
                                ent_tem.Add(entcloses[i]);
                                back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs)));
                            }
                        }
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index] = done_points[i].zb;
                        }
                        back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz));
                        run_act.AddAction(back_act);
                    }
                    else if (done_points[0].type == TestStepEnum.SpuLiquid)
                    {
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index]    = done_points[i].z;
                            absorbs[entcloses[i].Index] = done_points[i].spucapacity + done_points[i].backcapacity;
                        }
                        run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2));
                        run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), done_points[0].spuspeed, absorbs));
                        //回吸
                        var back_act = Spawn.create();
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            if (done_points[i].backcapacity != 0)
                            {
                                absorbs[entcloses[i].Index] = -(done_points[i].backcapacity);
                                List <Enterclose> ent_tem = new List <Enterclose>();
                                ent_tem.Add(entcloses[i]);
                                back_act.AddAction(Sequence.create(SKSleep.create(200), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs)));
                            }
                        }
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index] = done_points[i].zb;
                        }
                        back_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz));
                        run_act.AddAction(back_act);
                    }
                    else if (done_points[0].type == TestStepEnum.MixLiquid)
                    {
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index]    = done_points[i].z;
                            absorbs[entcloses[i].Index] = done_points[i].capacity + done_points[i].backcapacity;
                        }
                        run_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz, 2));
                        run_act.AddAction(InjectAbsorb.create(3001, entcloses.ToArray(), 100, absorbs));//把稀释液放进去
                        //混合操作
                        var mix_act = Spawn.create();
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            List <Enterclose> ent_tem = new List <Enterclose>();
                            ent_tem.Add(entcloses[i]);
                            var mix_seq_act = Sequence.create();
                            if (done_points[i].mixtimes != 0)
                            {
                                for (int j = 0; j < done_points[i].mixtimes * 2; j++)
                                {
                                    int mixz = done_points[i].z - done_points[i].mixdeep;//混合高度
                                    if (mixz <= 0)
                                    {
                                        mixz = done_points[i].z;
                                    }
                                    absorbs[entcloses[i].Index] = j % 2 == 0 ? -done_points[i].capacity : done_points[i].capacity;
                                    injz[entcloses[i].Index]    = j % 2 == 0 ? done_points[i].z : mixz;
                                    mix_seq_act.AddAction(InjectMoveTo.create(3001, ent_tem.ToArray(), -1, IMask.Gen(-1), injz, 2));
                                    mix_seq_act.AddAction(InjectAbsorb.create(30001, ent_tem.ToArray(), 100, absorbs));
                                }
                                injz[entcloses[i].Index] = done_points[i].z;
                                mix_seq_act.AddAction(InjectMoveTo.create(3001, ent_tem.ToArray(), -1, IMask.Gen(-1), injz, 2));
                                absorbs[entcloses[i].Index] = (int)ent_tem[0].PumpMotor.Maximum.SetValue;
                                mix_seq_act.AddAction(InjectAbsorbMove.create(3001, ent_tem.ToArray(), 100, absorbs));
                                absorbs[entcloses[i].Index] = -(done_points[i].GetTubeList().Count *done_points[i].spucapacity);
                                mix_seq_act.AddAction(InjectAbsorb.create(3001, ent_tem.ToArray(), 100, absorbs));
                            }

                            mix_act.AddAction(mix_seq_act);
                        }
                        run_act.AddAction(mix_act);
                        var zb_act = Spawn.create();
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            injz[entcloses[i].Index] = done_points[i].zb;
                        }
                        zb_act.AddAction(InjectMoveTo.create(3001, entcloses.ToArray(), -1, IMask.Gen(-1), injz));
                        //回吸
                        var back_act = Spawn.create();
                        for (int i = 0; i < done_points.Count; i++)
                        {
                            List <Enterclose> ent_tem = new List <Enterclose>();
                            ent_tem.Add(entcloses[i]);
                            if (done_points[i].backcapacity != 0 && done_points[i].mixtimes != 0)
                            {
                                absorbs[entcloses[i].Index] = -(done_points[i].backcapacity);
                                back_act.AddAction(Sequence.create(SKSleep.create(500), InjectAbsorb.create(3001, ent_tem.ToArray(), done_points[i].backspeed, absorbs)));
                            }
                        }
                        zb_act.AddAction(back_act);
                        run_act.AddAction(zb_act);
                    }
                }
                move_act.AddAction(run_act);
                seque.AddAction(move_act);
                GenerateInjectActGroup(ref seque, hitsort, ref index, ref tager, ref point, ref width, ref width_rate, ref is_ok, move_x);
            }
        }
예제 #4
0
        private bool RunLogic(IList <T_LogicStep> steps, out String msg)
        {
            msg = null;
            var seque_root = Sequence.create();
            var seque      = Sequence.create();
            var resmanager = ResManager.getInstance();
            var generater  = ActionGenerater.getInstance();
            int loop_times = 0;

            foreach (var step in steps)
            {
                switch (step.StepEnum)
                {
                case LogicStepEnum.Alert:
                    seque.AddAction(SkCallBackFun.create((ActionBase act_tem) =>
                    {
                        ErrorSystem.WriteActError(step.Parameters, true, false, 9999);
                        return(true);
                    }));
                    break;

                case LogicStepEnum.InitAll:
                    var act_init = opDevice.InitAllDevice();
                    seque.AddAction(act_init);
                    break;

                case LogicStepEnum.Centrifuge:
                {
                    CommonAction action = Convert2T <CommonAction>(step.Parameters);
                    var          cen    = cenMrg.GetCentrifugeByCode(action.Code);
                    if (cen != null)
                    {
                        if (action.DoAction == 0)        //正常离心程序
                        {
                            int hspeed  = (int)cen.Centrifugem.HightSpeed.SetValue;
                            int lspeed  = (int)cen.Centrifugem.LowSpeed.SetValue;
                            int htime   = (int)cen.Centrifugem.HightSpeedTime.SetValue;
                            int ltime   = (int)cen.Centrifugem.LowSpeedTime.SetValue;
                            int uphtime = (int)cen.Centrifugem.AddHSpeedTime.SetValue;
                            int upltime = (int)cen.Centrifugem.AddLSpeedTime.SetValue;
                            int stime   = (int)cen.Centrifugem.StopSpeedTime.SetValue;
                            var act     = CentrifugeStart.create(cen, 3000000, hspeed, lspeed, htime, ltime, uphtime, upltime, stime);
                            seque.AddAction(act);
                        }
                        else if (action.DoAction == 1)        //移动指定卡位
                        {
                            var resinfo = ResManager.getInstance().SearchGelCard("T_BJ_Centrifuge", action.Code, "", (int)action.SeatIndex);
                            var act     = MoveTo.create(cen, 30000, -1, -1, resinfo.CenGelP[resinfo.CountX], 5);
                            seque.AddAction(act);
                        }
                        else if (action.DoAction == 2)        //开舱门
                        {
                            var act = HandOpenCloseDoor.create(handDevice, 3000, action.Code, true);
                            seque.AddAction(act);
                        }
                        else if (action.DoAction == 3)        //关舱门
                        {
                            var act = HandOpenCloseDoor.create(handDevice, 3000, action.Code, false);
                            seque.AddAction(act);
                        }
                        else if (action.DoAction == 4)        //初始化
                        {
                            var act = InitXyz.create(cen, 3000, false, false, true);
                            seque.AddAction(act);
                        }
                    }
                    else
                    {
                        ErrorSystem.WriteActError("找不到指定离心机", true, false, 9999);
                    }
                }
                break;

                case LogicStepEnum.Couveuse:
                {
                }
                break;

                case LogicStepEnum.Delay:
                {
                    int DelayTime = Convert.ToInt32(step.Parameters);
                    seque.AddAction(SKSleep.create(DelayTime));
                }
                break;

                case LogicStepEnum.DetectSquid:
                {
                    DetectAction      action   = Convert2T <DetectAction>(step.Parameters);
                    List <Enterclose> iinjects = new List <Enterclose>();
                    foreach (var entindex in action.Indexs)
                    {
                        iinjects.Add(injDevice.Injector.Entercloses[entindex]);
                    }
                    seque.AddAction(InjectDetector.create(3000, iinjects.ToArray(), IMask.Gen((int)action.Start), IMask.Gen((int)action.ZLimit), IMask.Gen(0)));
                }
                break;

                case LogicStepEnum.SimpleAction:
                {
                    SimpleAction      action = Convert2T <SimpleAction>(step.Parameters);
                    AbstractCanDevice device = null;
                    switch (action.Device)
                    {
                    case "加样器":
                        device = injDevice;
                        break;

                    case "机械手":
                        device = handDevice;
                        break;

                    case "卡仓":
                        device = gelwareDevice;
                        break;

                    case "破孔器":
                        device = gelwareDevice;
                        break;
                    }
                    if (action.Action == "移动")
                    {
                        ActionBase act_move = null;
                        int        x        = action.Direction == "X" ? (int)action.Value : -1;
                        int        y        = action.Direction == "Y" ? (int)action.Value : -1;
                        int        z        = action.Direction == "Z"? (int)action.Value:-1;
                        if (action.Direction == "XYZ")
                        {
                            x = y = z = (int)action.Value;
                        }
                        if (device is InjectorDevice)
                        {
                            act_move = InjectMoveTo.create(device, 3000, injDevice.Injector.Entercloses, x, IMask.Gen(y), IMask.Gen(z));
                        }
                        else
                        {
                            act_move = MoveTo.create(device, 3000, x, y, z);
                        }
                        seque.AddAction(act_move);
                    }
                    else if (action.Action == "初始化")
                    {
                        ActionBase act_move = null;
                        bool       x        = action.Direction == "X" ? true : false;
                        bool       y        = action.Direction == "Y" ? true : false;
                        bool       z        = action.Direction == "Z" ? true : false;
                        if (action.Direction == "XYZ")
                        {
                            x = y = z = true;
                        }
                        if (device is InjectorDevice)
                        {
                            act_move = InitXyz.create(device, 30000, injDevice.Injector.Entercloses, x, y, z);
                        }
                        else
                        {
                            act_move = InitXyz.create(device, 30000, x, y, z);
                        }
                        seque.AddAction(act_move);
                    }
                }
                break;

                case LogicStepEnum.TakeAndPutDownGel:
                {
                    GelAction[] actions = Convert2T <GelAction[]>(step.Parameters);
                    seque.AddAction(MoveTo.create(handDevice, 3000, -1, -1, 0));
                    ResInfoData take_seat = null;
                    if (actions[0].BJType == "T_BJ_GelSeat")
                    {
                        take_seat = resmanager.SearchGelCard("T_BJ_GelSeat", "", "", actions[0].Index, 0, true, actions[0].BJName);
                        generater.GenerateTakeGelFromNormal(take_seat, ref seque);
                    }
                    else if (actions[0].BJType == "T_BJ_Centrifuge")
                    {
                        take_seat = resmanager.SearchGelCard("T_BJ_Centrifuge", "", "", actions[0].Index, 0, true, actions[0].BJName);
                        var act = generater.GenerateTakeGelFromCent(take_seat, "", ref seque);
                    }
                    else if (actions[0].BJType == "T_BJ_GelWarehouse")
                    {
                        take_seat = resmanager.SearchGelCard("T_BJ_GelWarehouse", "", "", actions[0].Index, 0, true, actions[0].BJName);
                        var act = generater.GenerateTakeGelFromWare(take_seat, ref seque);
                    }

                    if (actions[1].BJType == "T_BJ_GelSeat")
                    {
                        var put_seat = resmanager.SearchGelCard("T_BJ_GelSeat", "", "", actions[1].Index, 0, true, actions[1].BJName);
                        generater.GeneratePutGelToNormal(put_seat, take_seat, ref seque);
                    }
                    else if (actions[1].BJType == "T_BJ_Centrifuge")
                    {
                        var put_seat = resmanager.SearchGelCard("T_BJ_Centrifuge", "", "", actions[1].Index, 0, true, actions[1].BJName);
                        generater.GeneratePutGelToCent(put_seat.CenCode, put_seat, take_seat, ref seque);
                    }
                    else if (actions[1].BJType == "T_BJ_GelWarehouse")
                    {
                        var put_seat = resmanager.SearchGelCard("T_BJ_GelWarehouse", "", "", actions[1].Index, 0, true, actions[1].BJName);
                        generater.GeneratePutGelToWare(put_seat, take_seat, ref seque);
                    }
                }
                break;

                case LogicStepEnum.TakeGel:
                {
                    GelAction   action    = Convert2T <GelAction>(step.Parameters);
                    ResInfoData take_seat = null;
                    if (action.BJType == "T_BJ_GelSeat")
                    {
                        take_seat = resmanager.SearchGelCard("T_BJ_GelSeat", "", "", action.Index, 0, true, action.BJName);
                        generater.GenerateTakeGelFromNormal(take_seat, ref seque);
                    }
                    else if (action.BJType == "T_BJ_Centrifuge")
                    {
                        take_seat = resmanager.SearchGelCard("T_BJ_Centrifuge", "", "", action.Index, 0, true, action.BJName);
                        var act = generater.GenerateTakeGelFromCent(take_seat, "", ref seque);
                    }
                    else if (action.BJType == "T_BJ_GelWarehouse")
                    {
                        take_seat = resmanager.SearchGelCard("T_BJ_GelWarehouse", "", "", action.Index, 0, true, action.BJName);
                        var act = generater.GenerateTakeGelFromWare(take_seat, ref seque);
                    }
                    break;
                }

                case LogicStepEnum.PutDownGel:
                {
                    GelAction   action    = Convert2T <GelAction>(step.Parameters);
                    ResInfoData take_seat = resmanager.handseat_resinfo;
                    if (action.BJType == "T_BJ_GelSeat")
                    {
                        var put_seat = resmanager.SearchGelCard("T_BJ_GelSeat", "", "", action.Index, 0, true, action.BJName);
                        generater.GeneratePutGelToNormal(put_seat, take_seat, ref seque);
                    }
                    else if (action.BJType == "T_BJ_Centrifuge")
                    {
                        var put_seat = resmanager.SearchGelCard("T_BJ_Centrifuge", "", "", action.Index, 0, true, action.BJName);
                        generater.GeneratePutGelToCent(put_seat.CenCode, put_seat, take_seat, ref seque);
                    }
                    else if (action.BJType == "T_BJ_GelWarehouse")
                    {
                        var put_seat = resmanager.SearchGelCard("T_BJ_GelWarehouse", "", "", action.Index, 0, true, action.BJName);
                        generater.GeneratePutGelToWare(put_seat, take_seat, ref seque);
                    }
                    break;
                }

                case LogicStepEnum.TakeTip:
                {
                    TakeTipAction      action   = Convert2T <TakeTipAction>(step.Parameters);
                    var                ents     = injDevice.Injector.Entercloses.Where(ent => ent.Valid && action.Indexs.Contains(ent.Index)).ToArray();
                    var                tipseat  = Constants.BJDict[typeof(T_BJ_Tip).Name].Where(item => item.Name == action.TipBoxName).FirstOrDefault() as T_BJ_Tip;
                    List <ActionPoint> tip_seat = new List <ActionPoint>();
                    foreach (var ent in ents)
                    {
                        int x     = (int)(tipseat.X - action.C * tipseat.GapX);
                        int y     = (int)(tipseat.Y + action.R * tipseat.GapY);
                        var point = new ActionPoint();
                        point.x     = x;
                        point.y     = y;
                        point.z     = (int)tipseat.Limit;
                        point.type  = TestStepEnum.JXZT;
                        point.index = ent.Index;
                        tip_seat.Add(point);
                    }
                    var sequ_taketip = Sequence.create();
                    var move_act     = InjectMoveActs.create(injDevice, 3000, tip_seat.ToArray(), false);
                    sequ_taketip.AddAction(InjectMoveTo.create(injDevice, 3000, ents, -1, IMask.Gen(-1), IMask.Gen(0)));
                    sequ_taketip.AddAction(move_act);
                    seque.AddAction(sequ_taketip);
                }
                break;

                case LogicStepEnum.OutTip:
                {
                    TakeTipAction      action        = Convert2T <TakeTipAction>(step.Parameters);
                    var                ents          = injDevice.Injector.Entercloses.Where(ent => ent.Valid && action.Indexs.Contains(ent.Index)).ToArray();
                    var                sequ_puttip   = Sequence.create();
                    List <ActionPoint> unload_seat   = new List <ActionPoint>();
                    var                inject_unload = resmanager.unload_list;
                    if (inject_unload.Count() == 1)
                    {
                        var unloader = inject_unload[0];
                        for (int i = 0; i < 4; i++)
                        {
                            var unload_point = new ActionPoint((int)unloader.X, (int)unloader.Y + i * (int)unloader.FZ, (int)unloader.Z, TestStepEnum.JXZT);
                            unload_point.puttip_x = (int)unloader.FirstX;
                            unload_seat.Add(unload_point);
                        }
                        sequ_puttip.AddAction(InjectMoveTo.create(injDevice, 3000, ents, -1, IMask.Gen(-1), IMask.Gen(0)));
                        sequ_puttip.AddAction(InjectMoveActs.create(injDevice, 3000, unload_seat.ToArray(), true));
                        seque.AddAction(sequ_puttip);
                    }
                }
                break;

                case LogicStepEnum.Piercer:
                {
                    var paper_seat = resmanager.GetResByCode("", "T_BJ_GelSeat", "", "4");
                    seque.AddAction(PaperCard.create(pieDevice, 3000, paper_seat, 0));
                }
                break;

                case LogicStepEnum.LoopStart:
                {
                    LogicLoop logicLoop = Convert2T <LogicLoop>(step.Parameters);
                    loop_times = logicLoop.Count;
                    seque_root.AddAction(seque);
                    seque = Sequence.create();
                }
                break;

                case LogicStepEnum.LoopEnd:
                {
                    var act_repat = Repeat.create(seque, loop_times);
                    seque_root.AddAction(act_repat);
                    seque      = Sequence.create();
                    loop_times = 0;
                }
                break;
                }
            }
            seque_root.AddAction(seque);
            seque_root.runAction(opDevice);
            return(true);
        }