Пример #1
0
 public void TakeTip()
 {
     if (this.SelectedBJ == null)
     {
         return;
     }
     if (SelectedBJ is T_BJ_Tip tipseat)
     {
         var tip_seat = IMask.Gen(new ActionPoint(-1, -1, -1));
         int x        = (int)(tipseat.X - SeatXIndex * tipseat.GapX);
         int y        = (int)(tipseat.Y + SeatYIndex * tipseat.GapY);
         foreach (var ent in injectorDevice.GetSeleteced())
         {
             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[ent.Index] = point;
         }
         var sequ_taketip = Sequence.create();
         var move_act     = InjectMoveActs.create(3000, tip_seat.ToArray(), false);
         sequ_taketip.AddAction(InjectMoveTo.create(3000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0)));
         sequ_taketip.AddAction(move_act);
         sequ_taketip.runAction(injectorDevice);
     }
 }
Пример #2
0
        public void MoveZ()
        {
            int[] z   = { (int)DistanceZ, (int)DistanceZ, (int)DistanceZ, (int)DistanceZ };
            var   act = Sequence.create(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), z));

            act.runAction(injectorDevice);
        }
Пример #3
0
 public void SubLiquid()
 {
     if (SelectedBJ is T_BJ_GelSeat gelseat)
     {
         int x = (int)(gelseat.InjectorX);
         int y = gelseat.GetInjectorY(SeatYIndex);
         var sequ_putsample = Sequence.create(
             InjectMoveTo.create(injectorDevice, 3000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0)),
             InjectAbsorbMove.create(300, injectorDevice.GetSeleteced(), 100, IMask.Gen(0)));
         for (int i = 0; i < 8; i++)
         {
             var points = IMask.Gen(new ActionPoint(-1, -1, -1));
             foreach (var ent in injectorDevice.GetSeleteced())
             {
                 points[ent.Index].x        = x + i * (int)gelseat.InjectorGapX;
                 points[ent.Index].y        = y + ent.Index * (int)gelseat.InjectorGapY;
                 points[ent.Index].z        = (int)gelseat.InjectorZ;
                 points[ent.Index].zb       = points[ent.Index].z - 1500;
                 points[ent.Index].minwidth = (double)gelseat.MinWidth;
                 points[ent.Index].type     = TestStepEnum.SpuLiquid;
                 points[ent.Index].capacity = 500;
             }
             sequ_putsample.AddAction(InjectMoveActs.create(3000, points.ToArray(), true));
         }
         sequ_putsample.runAction(injectorDevice);
     }
 }
Пример #4
0
        public void MoveXY()
        {
            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;
            double min_width = 1.0f;

            if (SelectedBJ is T_BJ_Tip tipseat)
            {
                x         = (int)(tipseat.X - SeatXIndex * tipseat.GapX);
                y         = tipseat.GetY(SeatYIndex);
                min_width = (double)tipseat.MinWidth;
            }
            else if (SelectedBJ is T_BJ_SampleRack sampleseat)
            {
                x         = (int)(sampleseat.X);
                y         = (int)sampleseat.GetY(SeatYIndex);
                min_width = (double)sampleseat.MinWidth;
            }
            else if (SelectedBJ is T_BJ_DeepPlate deepplate)
            {
                x         = (int)(deepplate.X + SeatXIndex * deepplate.GapX);
                y         = deepplate.GetY(SeatYIndex);
                min_width = (double)deepplate.MinWidth;
            }
            else if (SelectedBJ is T_BJ_AgentiaWarehouse agentiaware)
            {
                x         = (int)(agentiaware.X);
                y         = agentiaware.GetY(SeatYIndex);
                min_width = (double)agentiaware.MinWidth;
            }
            else if (SelectedBJ is T_BJ_GelSeat gelseat)
            {
                x         = (int)(gelseat.InjectorX + SeatXIndex * gelseat.InjectorGapX);
                y         = gelseat.GetInjectorY(SeatYIndex);
                min_width = (double)gelseat.MinWidth;
            }
            else if (SelectedBJ is T_BJ_Unload unload)
            {
                x = (int)(unload.X);
                y = (int)(unload.Y + SeatYIndex * unload.FZ);
            }
            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;
                points[ent.Index].minwidth = min_width;
            }
            move_act.AddAction(InjectMoveActs.create(3001, points.ToArray(), true));
            move_act.runAction(injectorDevice);
        }
Пример #5
0
        /// <summary>
        /// 移动Y
        /// </summary>
        public void MoveY()
        {
            var move_act = Sequence.create();
            var device   = new ActionDevice(injectorDevice);

            move_act.AddAction(InjectMoveTo.create(10000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0)));
            int    x         = 0;
            int    y         = (int)DistanceY;
            double min_width = 1.0f;
            var    points    = IMask.Gen(new ActionPoint(-1, -1, -1));

            if (device.GetRealX(ref x))
            {
                var   ens = injectorDevice.Injector.Entercloses;
                int[] py  = { 0, (int)(ens[1].TipDis), (int)(ens[2].TipDis + ens[2].InjWidth), (int)(ens[3].TipDis + ens[3].InjWidth) };
                foreach (var ent in injectorDevice.GetSeleteced())
                {
                    points[ent.Index].x        = x;
                    points[ent.Index].y        = y + py[ent.Index];
                    points[ent.Index].minwidth = min_width;
                }
                move_act.AddAction(InjectMoveActs.create(3001, points.ToArray(), true));
                move_act.runAction(injectorDevice);
            }
            //var canComm = IoC.Get<AbstractCanComm>();
            //var injects = injectorDevice.GetSeleteced();
            //if(IsUseTMotor)
            //{
            //    var act = InjectMoveTo.create(5001, injects.ToArray(), -1, IMask.Gen((int)DistanceY), IMask.Gen(0), 2);
            //    act.runAction(injectorDevice);
            //}
            //else
            //{
            //    var points = IMask.Gen(new ActionPoint(-1, -1, -1));
            //    var device = new ActionDevice(injectorDevice);
            //    int x = 0;
            //    if(device.GetRealX(ref x))
            //    {
            //        var min_index = injects.Min(et => et.Index);
            //        points[min_index].x = x;
            //        points[min_index].y = (int)DistanceY;
            //        points[min_index].minwidth = 1.0f;
            //        var act = InjectMoveActs.create(3001, points.ToArray(), true);
            //        act.runAction(injectorDevice);
            //    }
            //}
        }
Пример #6
0
        public void PutTip()
        {
            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.PutTip);
                    unload_point.puttip_x = (int)unloader.FirstX;
                    unload_seat.Add(unload_point);
                }
                sequ_puttip.AddAction(InjectMoveTo.create(3000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0)));
                sequ_puttip.AddAction(InjectMoveActs.create(3000, unload_seat.ToArray(), true));
                sequ_puttip.runAction(injectorDevice);
            }
        }
Пример #7
0
        //得到恢复当前状态的动作
        public bool GetReSetAct(ref Sequence seque_act)
        {
            int x = 0;

            int [] y           = IMask.Gen(-1);
            int[]  z           = IMask.Gen(-1);
            var    device      = new ActionDevice(this);
            var    inject_list = Injector.Entercloses.Where(item => item.InjEnable).ToList();
            bool   ret         = device.GetRealX(ref x);

            ret = ret && device.GetRealY(inject_list.ToArray(), ref y);
            ret = ret && device.GetRealZ(inject_list.ToArray(), ref z);
            for (int i = 0; i < inject_list.Count; i++)
            {
                y[inject_list[i].Index] += (int)inject_list[i].TipDis;
            }
            seque_act.AddAction(InjectMoveTo.create(3000, inject_list.ToArray(), -1, IMask.Gen(-1), IMask.Gen(0)));
            seque_act.AddAction(InjectMoveTo.create(3000, inject_list.ToArray(), x, y, IMask.Gen(-1)));
            seque_act.AddAction(InjectMoveTo.create(3000, inject_list.ToArray(), -1, IMask.Gen(-1), z));
            return(ret);
        }
Пример #8
0
        //生成加样移动组合
        public void GenerateInjectActGroup(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok)
        {
            if (index == 4)
            {
                is_ok = true;
                return;
            }
            else if (tager[index] == point[index] || tager[index] == -1)
            {
                if (tager[index] == point[index])
                {
                    List <Enterclose> ents = new List <Enterclose>();
                    if (index == 0)
                    {
                        var move_act = Sequence.create();
                        ents.Add(injectorDevice.Injector.Entercloses[index]);
                        move_act.AddAction(InjectMoveTo.create(300000, ents.ToArray(), -1, IMask.Gen(-1), IMask.Gen(400, -1, -1, -1)));
                        move_act.AddAction(InjectMoveTo.create(300000, ents.ToArray(), -1, IMask.Gen(-1), IMask.Gen(0, -1, -1, -1)));
                        seque.AddAction(move_act);
                    }
                    else
                    {
                        var move_act = Sequence.create();
                        move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 100));
                        move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 0));
                        seque.AddAction(move_act);
                    }
                }
                index++;
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
            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];
                                point_tem[j] = tager[j];
                                point_tem[k] = tager[k];
                                point_tem[l] = tager[l];
                                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])
                                {
                                    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(injectorDevice.Injector.Entercloses[indextem]);
                        yy[indextem] = minnode[indextem];
                    }
                }
                movesp_act.AddAction(InjectMoveTo.create(300000, 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(injectorDevice.Injector.Entercloses[indextem]);
                        yy[indextem] = minnode[indextem];
                    }
                }
                movesp_act.AddAction(InjectMoveTo.create(300000, ents.ToArray(), -1, yy, zz));



                //for (int i = 0; i < 4; i++)
                //{
                //    for (int j = 0; j < 4; j++)
                //    injectorDevice.Injector.Entercloses[j].Selected = false;
                //    int[] yy = { -1, -1, -1, -1 };
                //    int[] zz = { -1, -1, -1, -1 };
                //    if (i < left.Count)
                //    {
                //        //msg = msg + "left " + left[i] + ":" + point[left[i]] + "->" + (minnode[left[i]] + " ");
                //        int indextem = left[i];
                //        if (point[indextem] !=minnode[indextem])
                //        {
                //            yy[indextem] = minnode[indextem];
                //            injectorDevice.Injector.Entercloses[indextem].Selected = true;
                //            movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz));
                //        }
                //    }
                //    for (int j = 0; j < 4; j++)
                //    injectorDevice.Injector.Entercloses[j].Selected = false;
                //    if (i < right.Count)
                //    {
                //        //msg = msg + "right " + right[i] + ":" + point[right[i]] + "->" + (minnode[right[i]] + " ");
                //        int indextem = right[i];
                //        if (point[indextem] != minnode[indextem])
                //        {
                //            yy[indextem] = minnode[indextem];
                //            injectorDevice.Injector.Entercloses[indextem].Selected = true;
                //            movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz));
                //        }
                //    }
                //}
                for (int i = 0; i < 4; i++)
                {
                    point[i] = minnode[i];
                }
                move_act.AddAction(movesp_act);
                move_act.AddAction(SKSleep.create(1));
                seque.AddAction(move_act);
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
        }
Пример #9
0
        //按小组生成动作
        public Sequence GenerateAction(List <T_GelStep> act_group, SampleInfo sample_info)
        {
            //更新坐标计算针头个数
            int zt_count = 0;

            foreach (var act in act_group)
            {
                zt_count += act.InjectCount;
                act.UpdataPoints(sample_info);
            }
            var resmanager = ResManager.getInstance();

            Enterclose[] enters = new Enterclose[zt_count];//使用加样器个数
            for (int i = 0; i < zt_count; i++)
            {
                enters[i] = injectorDevice.Injector.Entercloses[i];
            }
            //生成装帧动作
            var tip_seat = resmanager.GetFreeTip(zt_count);

            int [] absorbs =
            {
                (int)injectorDevice.Injector.Entercloses[0].PumpMotor.Maximum.SetValue,
                (int)injectorDevice.Injector.Entercloses[1].PumpMotor.Maximum.SetValue,
                (int)injectorDevice.Injector.Entercloses[2].PumpMotor.Maximum.SetValue,
                (int)injectorDevice.Injector.Entercloses[3].PumpMotor.Maximum.SetValue
            };
            var sequ_taketip = Sequence.create(
                InjectTakeTip.create(30000, tip_seat.Z, 0, 0, tip_seat),
                InjectAbsorbMove.create(30000, enters, 100, absorbs));
            //生成加样动作
            var sequ_takesample = Sequence.create();
            var act_tree        = DivideXIntoGroups(act_group);
            int inject_beg      = 0;

            int[] point = { 0, 0, 0, 0 };
            for (int i = 0; i < 4; i++)
            {
                point[i] = (int)injectorDevice.Injector.Entercloses[i].YMotor.CurrentDistance;
                if (point[i] == 0)
                {
                    point[i] += (int)injectorDevice.Injector.Entercloses[i].YZero;
                }
            }
            foreach (var act_g in act_tree)
            {
                var   sque_movey = Sequence.create();
                int   index      = 0;
                bool  is_ok      = false;
                int[] tager      = { -1, -1, -1, -1 };
                int[] width      = { 0, 0, 0, 0 };
                for (int i = 0; i < 4; i++)
                {
                    width[i] = (int)injectorDevice.Injector.Entercloses[1].YZero;
                    if (i < act_g.Count())
                    {
                        tager[inject_beg + i] = act_g[i].Abs_Y;
                    }
                }
                GenerateSampleAddAct(ref sque_movey, ref index, ref tager, ref point, ref width, ref is_ok);
                inject_beg += act_g.Count();
                if (is_ok)
                {
                    sequ_takesample.AddAction(MoveTo.create(30000, act_g[0].Abs_X, -1, -1));//移动X
                    sequ_takesample.AddAction(sque_movey);
                }
            }
            //生成混合液体
            var sequ_mixsample = Sequence.create();

            foreach (var act in act_group)
            {
                if (act.IsMix())
                {
                    sequ_mixsample.AddAction(MoveTo.create(30000, act.Mix_X, act.Mix_Y, -1));
                    sequ_mixsample.AddAction(InjectMoveTo.create(30000, enters, -1, IMask.Gen(-1), IMask.Gen(act.Mix_Z)));
                    if (act.StepClass == TestStepEnum.FPXSY)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            absorbs[0] = 1000;
                            sequ_mixsample.AddAction(InjectAbsorb.create(30000, enters, 100, absorbs));
                            absorbs[0] = -1000;
                            sequ_mixsample.AddAction(InjectAbsorb.create(30000, enters, 100, absorbs));
                        }
                    }
                    if (act.IsSpu() == false)
                    {
                        absorbs[0] = 1000;
                        sequ_mixsample.AddAction(InjectAbsorb.create(30000, enters, 100, absorbs));
                    }
                    sequ_mixsample.AddAction(InjectMoveTo.create(30000, enters, -1, IMask.Gen(-1), IMask.Gen(0)));
                }
            }
            //生成分配动作
            var sequ_putsample = Sequence.create();

            foreach (var act in act_group)
            {
                if (act.IsSpu())
                {
                    sequ_putsample.AddAction(MoveTo.create(30000, act.Spu_X, act.Spu_Y, -1));
                    sequ_putsample.AddAction(InjectMoveTo.create(30000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(act.Spu_Z)));
                    absorbs[0] = 1000;
                    sequ_putsample.AddAction(InjectAbsorb.create(30000, injectorDevice.GetSeleteced(), 100, absorbs));
                    sequ_putsample.AddAction(InjectMoveTo.create(30000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0)));
                }
            }

            var action_list = Sequence.create();
            //生成脱针动作
            var sequ_puttip   = Sequence.create();
            var inject_unload = resmanager.unload_list;

            if (inject_unload.Count() == 1)
            {
                sequ_puttip.AddAction(InjectPutTip.create(30000, (int)inject_unload[0].Z, 800, (int)inject_unload[0].FirstX, 0, new TakeTipData((int)inject_unload[0].X, (int)inject_unload[0].Y, 0, 1)));
                sequ_puttip.AddAction(InitXyz.create(30000, injectorDevice.GetSeleteced(), false, false, true));
            }
            action_list.AddAction(sequ_taketip);
            action_list.AddAction(sequ_takesample);
            action_list.AddAction(sequ_mixsample);
            action_list.AddAction(sequ_putsample);
            action_list.AddAction(sequ_puttip);
            return(action_list);
        }
Пример #10
0
        //生成加样移动
        public void GenerateSampleAddAct(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok)
        {
            bool isforward = false;
            bool isback    = false;

            if (index == 4)
            {
                is_ok = true;
                return;
            }
            else
            {
                isforward = index - 1 >= 0 ? tager[index] >= point[index - 1] + width[index - 1] : true;
                isback    = index + 1 <= 3 ? tager[index] + width[index] <= point[index + 1] : true;
            }
            if (tager[index] < 0)
            {
                index++;
                GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
            else if (isforward && isback)
            {
                //单移
                point[index] = tager[index];
                int[] y = { -1, -1, -1, -1 };
                int[] z = { -1, -1, -1, -1 };
                y[index] = point[index] - width[index] * index;
                z[index] = -1;
                var move_act = Sequence.create(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, y, z), SKSleep.create(index * 500), MoveTo.create(handDevice, 300000, -1, -1, 100), MoveTo.create(handDevice, 300000, -1, -1, 0));
                //查找上一个sp
                if (seque.actionlist[seque.actionlist.Count() - 1] is Spawn)
                {
                    var spawn = (Spawn)seque.actionlist[seque.actionlist.Count() - 1];
                    spawn.AddAction(move_act);
                }
                else
                {
                    var spawn = Spawn.create();
                    spawn.AddAction(move_act);
                    seque.AddAction(spawn);
                }
                index++;
                GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
            else if (isforward && isback == false)
            {
                //全移
                int movew = tager[index] - point[index];
                for (int i = index; i < 4; i++)
                {
                    point[i] = point[i] + movew;
                }
                int indexx   = index;
                int y        = point[index] - width[index] * index;
                var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) =>
                {
                    for (int i = 0; i < 4; i++)
                    {
                        injectorDevice.Injector.Entercloses[i].Selected = i >= indexx;
                    }
                    return(true);
                }), MoveTo.create(injectorDevice, 300000, -1, y, -1));
                seque.AddAction(move_act);
                GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
            else if (isforward == false && isback)
            {
                //等待前面完成
                int movew = tager[index] - point[index];
                for (int i = 0; i < 4; i++)
                {
                    point[i] = point[i] + movew;
                    if (point[i] < 0)
                    {
                        is_ok = false;
                        return;
                    }
                }
                int y        = point[0];
                var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) => {
                    for (int i = 0; i < 4; i++)
                    {
                        injectorDevice.Injector.Entercloses[i].Selected = true;
                    }
                    return(true);
                }), MoveTo.create(injectorDevice, 300000, -1, y, -1));
                seque.AddAction(move_act);
                GenerateSampleAddAct(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
        }
Пример #11
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);
            }
        }
Пример #12
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);
            }
        }
Пример #13
0
        //生成加样移动组合
        public void GenerateInjectActGroup(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok)
        {
            if (index == 4)
            {
                is_ok = true;
                return;
            }
            bool isforward = index - 1 >= 0 ? tager[index] >= point[index - 1] + width[index - 1] : true;
            bool isback    = index + 1 <= 3 ? tager[index] + width[index] <= point[index + 1] : true;

            if (tager[index] < 0)
            {
                index++;
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
            else if (isforward && isback)
            {
                //单移
                bool is_moveok = point[index] == tager[index];//是否已经在那个位置了
                point[index] = tager[index];
                int[] y = { -1, -1, -1, -1 };
                int[] z = { -1, -1, -1, -1 };
                y[index] = point[index];
                z[index] = -1;
                for (int i = 0; i < 4; i++)
                {
                    injectorDevice.Injector.Entercloses[i].Selected = i == index;
                }
                var move_act = Sequence.create();
                if (is_moveok == false)
                {
                    move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, y, z));
                }
                if (index == 0)
                {
                    move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(400, -1, -1, -1)));
                    move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0, -1, -1, -1)));
                }
                else
                {
                    move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 100));
                    move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 0));
                }
                //查找上一个sp
                if (seque.actionlist.Count != 0 && seque.actionlist[seque.actionlist.Count() - 1] is Spawn)
                {
                    int inster = is_moveok?0:1;
                    var spawn  = (Spawn)seque.actionlist[seque.actionlist.Count() - 1];
                    if (index != 0)
                    {
                        move_act.actionlist.Insert(inster, SKSleep.create(spawn.actionlist.Count * 1000));
                    }
                    spawn.AddAction(move_act);
                }
                else
                {
                    var spawn = Spawn.create();
                    spawn.AddAction(move_act);
                    seque.AddAction(spawn);
                }
                index++;
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
            else if (isforward == false || isback == false)
            {
                int   movew    = tager[index] - point[index];
                int[] stori    = isback ? IMask.Gen(0, 1, 2, 3): IMask.Gen(3, 2, 1, 0);
                int   count    = isback ? (index + 1) : (4 - index);
                int   fx       = isback ? -1 : 1;
                int[] pointtem = { point[0], point[1], point[2], point[3] };
                for (int i = 0; i < count; i++)
                {
                    if (pointtem[stori[i]] + movew >= 0)
                    {
                        pointtem[stori[i]] = pointtem[stori[i]] + movew;
                    }
                    else
                    {
                        pointtem[stori[i]] = tager[index] + width[stori[i]] * (stori[i] - index);
                    }
                    if (pointtem[stori[i]] < 0)
                    {
                        is_ok = false;
                        return;
                    }
                }
                var movesp_act = Spawn.create();
                var move_act   = Sequence.create();
                for (int i = 0; i < count; i++)
                {
                    int[] yy       = { -1, -1, -1, -1 };
                    int[] zz       = { -1, -1, -1, -1 };
                    int   indextem = stori[i];
                    point[indextem] = pointtem[indextem];
                    for (int j = 0; j < 4; j++)
                    {
                        injectorDevice.Injector.Entercloses[j].Selected = false;
                    }
                    yy[indextem] = point[indextem];
                    injectorDevice.Injector.Entercloses[indextem].Selected = true;
                    movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz));
                }
                move_act.AddAction(movesp_act);
                move_act.AddAction(SKSleep.create(1));
                seque.AddAction(move_act);
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
        }
Пример #14
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);
        }
Пример #15
0
        public void AbsLiquid()
        {
            if (this.SelectedBJ == null)
            {
                return;
            }
            var  move_act = Sequence.create();
            bool is_find  = false;

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

            if (SelectedBJ is T_BJ_SampleRack sampleseat)
            {
                x       = (int)(sampleseat.X);
                y       = (int)(sampleseat.Y + SeatYIndex * sampleseat.Gap);
                z       = (int)(sampleseat.Z);
                is_find = true;
            }
            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);
                is_find = true;
            }
            else if (SelectedBJ is T_BJ_AgentiaWarehouse agentiaware)
            {
                x       = (int)(agentiaware.X);
                y       = (int)(agentiaware.Y + SeatYIndex * agentiaware.Gap);
                z       = (int)(agentiaware.Z);
                is_find = true;
            }
            else if (SelectedBJ is T_BJ_GelSeat gelseat)
            {
                x       = (int)(gelseat.InjectorX + SeatXIndex * gelseat.InjectorGapX);
                y       = (int)(gelseat.InjectorY + SeatYIndex * gelseat.InjectorGapY);
                z       = (int)(gelseat.InjectorZ);
                is_find = true;
            }
            else if (SelectedBJ is T_BJ_Unload unload)
            {
                x       = (int)(unload.X);
                y       = (int)(unload.Y);
                z       = (int)(unload.Z);
                is_find = true;
            }
            if (is_find)
            {
                var tip_seat = IMask.Gen(new ActionPoint(-1, -1, -1));
                foreach (var ent in injectorDevice.GetSeleteced())
                {
                    var point = new ActionPoint();
                    point.x             = x;
                    point.y             = y;
                    point.z             = z;
                    point.zb            = 0;
                    point.type          = TestStepEnum.JXZT;
                    point.index         = ent.Index;
                    tip_seat[ent.Index] = point;
                }
                move_act.AddAction(InjectMoveActs.create(3000, tip_seat.ToArray(), false));
                move_act.runAction(injectorDevice);
            }
        }
Пример #16
0
        //生成加样移动组合
        public void GenerateInjectActGroup(ref Sequence seque, ref int index, ref int[] tager, ref int[] point, ref int[] width, ref bool is_ok)
        {
            bool isforward = false;
            bool isback    = false;

            if (index == 4)
            {
                is_ok = true;
                return;
            }
            else
            {
                isforward = index - 1 >= 0 ? tager[index] >= point[index - 1] + width[index - 1] : true;
                isback    = index + 1 <= 3 ? tager[index] + width[index] <= point[index + 1] : true;
            }
            if (tager[index] < 0)
            {
                index++;
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
            else if (isforward && isback)
            {
                //单移
                bool is_moveok = point[index] == tager[index];//是否已经在那个位置了
                point[index] = tager[index];
                int[] y = { -1, -1, -1, -1 };
                int[] z = { -1, -1, -1, -1 };
                y[index] = point[index];
                z[index] = -1;
                for (int i = 0; i < 4; i++)
                {
                    injectorDevice.Injector.Entercloses[i].Selected = i == index;
                }
                var move_act = Sequence.create();
                if (is_moveok == false)
                {
                    move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, y, z));
                }
                if (index == 0)
                {
                    move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(400, -1, -1, -1)));
                    move_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, IMask.Gen(-1), IMask.Gen(0, -1, -1, -1)));
                }
                else
                {
                    move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 100));
                    move_act.AddAction(MoveTo.create(handDevice, 300000, -1, -1, 0));
                }
                //查找上一个sp
                if (seque.actionlist.Count != 0 && seque.actionlist[seque.actionlist.Count() - 1] is Spawn)
                {
                    int inster = is_moveok?0:1;
                    var spawn  = (Spawn)seque.actionlist[seque.actionlist.Count() - 1];
                    if (index != 0)
                    {
                        move_act.actionlist.Insert(inster, SKSleep.create(spawn.actionlist.Count * 1000));
                    }
                    spawn.AddAction(move_act);
                }
                else
                {
                    var spawn = Spawn.create();
                    spawn.AddAction(move_act);
                    seque.AddAction(spawn);
                }
                index++;
                GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
            }
            else if (isforward && isback == false)
            {
                //全移
                int  movew   = tager[index] - point[index];
                bool is_once = true;
                for (int i = 0; i <= index; i++)
                {
                    if (point[i] + movew > 20000)
                    {
                        is_once = false;
                        break;
                    }
                }
                if (is_once)
                {
                    int injcount = index + 1;
                    for (int i = index; i < injcount; i++)
                    {
                        point[i] = point[i] + movew;
                        bool is_pass = i + 1 <= 3 ? point[i] + width[i] <= point[i + 1] : true;
                        if (!is_pass)
                        {
                            injcount++;
                        }
                    }
                    int indexx = index;
                    int y      = point[index];
                    //全轴
                    //var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) =>
                    //{
                    //    for (int i = 0; i < 4; i++)
                    //        injectorDevice.Injector.Entercloses[i].Selected = false;
                    //    for (int i = indexx; i < injcount; i++)
                    //        injectorDevice.Injector.Entercloses[i].Selected = true;
                    //    return true;
                    //}), MoveTo.create(injectorDevice, 300000, -1, y, -1));
                    //单轴测
                    var movesp_act            = Spawn.create();
                    var move_act              = Sequence.create();
                    List <ActionBase> actlist = new List <ActionBase>();
                    for (int i = indexx; i < injcount; i++)
                    {
                        int[] yy = { -1, -1, -1, -1 };
                        int[] zz = { -1, -1, -1, -1 };
                        for (int j = 0; j < 4; j++)
                        {
                            injectorDevice.Injector.Entercloses[j].Selected = false;
                        }
                        injectorDevice.Injector.Entercloses[i].Selected = true;
                        yy[i] = point[i];
                        actlist.Add(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz));
                    }
                    for (int i = actlist.Count - 1; i >= 0; i--)
                    {
                        movesp_act.AddAction(actlist[i]);
                    }
                    move_act.AddAction(movesp_act);
                    move_act.AddAction(SKSleep.create(1));
                    seque.AddAction(move_act);
                    GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
                }
                else
                {
                    int[] pointtem   = { -1, -1, -1, -1 };
                    var   movesp_act = Spawn.create();
                    var   move_act   = Sequence.create();
                    for (int i = indexx; i < injcount; i++)
                    {
                        pointtem[i] = tager[index] - width[i] * (index - i);
                        if (pointtem[i] < 0)
                        {
                            is_ok = false;
                            return;
                        }
                    }
                    for (int i = 0; i <= index; i++)
                    {
                        int[] yy = { -1, -1, -1, -1 };
                        int[] zz = { -1, -1, -1, -1 };
                        point[i] = pointtem[i];
                        for (int j = 0; j < 4; j++)
                        {
                            injectorDevice.Injector.Entercloses[j].Selected = false;
                        }
                        yy[i] = point[i];
                        injectorDevice.Injector.Entercloses[i].Selected = true;
                        movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz));
                    }
                    move_act.AddAction(movesp_act);
                    move_act.AddAction(SKSleep.create(1));
                    seque.AddAction(move_act);
                    GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
                }
            }
            else if (isforward == false && isback)
            {
                //等待前面完成
                int  movew   = tager[index] - point[index];
                bool is_once = true;
                for (int i = 0; i <= index; i++)
                {
                    if (point[i] + movew < 0)
                    {
                        is_once = false;
                        break;
                    }
                }
                if (is_once)
                {
                    for (int i = 0; i <= index; i++)
                    {
                        point[i] = point[i] + movew;
                    }
                    int y     = point[0];
                    int count = index;
                    //全轴
                    //var move_act = Sequence.create(SkCallBackFun.create((ActionBase act) => {
                    //    for (int i = 0; i < count; i++)
                    //        injectorDevice.Injector.Entercloses[i].Selected = true;
                    //    return true;
                    //}), MoveTo.create(injectorDevice, 300000, -1, y, -1));
                    //单轴测
                    var movesp_act = Spawn.create();
                    var move_act   = Sequence.create();
                    for (int i = 0; i <= count; i++)
                    {
                        int[] yy = { -1, -1, -1, -1 };
                        int[] zz = { -1, -1, -1, -1 };
                        for (int j = 0; j < 4; j++)
                        {
                            injectorDevice.Injector.Entercloses[j].Selected = false;
                        }
                        yy[i] = point[i];
                        injectorDevice.Injector.Entercloses[i].Selected = true;
                        movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz));
                    }
                    move_act.AddAction(movesp_act);
                    move_act.AddAction(SKSleep.create(1));
                    seque.AddAction(move_act);
                    GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
                }
                else
                {
                    int[] pointtem   = { -1, -1, -1, -1 };
                    var   movesp_act = Spawn.create();
                    var   move_act   = Sequence.create();
                    for (int i = 0; i <= index; i++)
                    {
                        pointtem[i] = tager[index] - width[i] * (index - i);
                        if (pointtem[i] < 0)
                        {
                            is_ok = false;
                            return;
                        }
                    }
                    for (int i = 0; i <= index; i++)
                    {
                        int[] yy = { -1, -1, -1, -1 };
                        int[] zz = { -1, -1, -1, -1 };
                        point[i] = pointtem[i];
                        for (int j = 0; j < 4; j++)
                        {
                            injectorDevice.Injector.Entercloses[j].Selected = false;
                        }
                        yy[i] = point[i];
                        injectorDevice.Injector.Entercloses[i].Selected = true;
                        movesp_act.AddAction(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), -1, yy, zz));
                    }
                    move_act.AddAction(movesp_act);
                    move_act.AddAction(SKSleep.create(1));
                    seque.AddAction(move_act);
                    GenerateInjectActGroup(ref seque, ref index, ref tager, ref point, ref width, ref is_ok);
                }
            }
        }
Пример #17
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);
        }