Пример #1
0
        public override void run(double dt)
        {
            bool resultx = true;
            bool resulty = true;
            bool resultz = true;

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

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

            case 1:
                if (xdone == false)
                {
                    xdone = device.DoneX();
                }
                if (ydone == false)
                {
                    ydone = device.DoneY(injects);
                }
                if (zdone == false)
                {
                    zdone = device.DoneZ(injects);
                }
                isfinish = xdone && ydone && zdone;
                break;
            }
        }
Пример #2
0
        public override void run(double dt)
        {
            bool resultx               = true;
            bool resulty               = true;
            bool resultz               = true;
            int  device_rx             = 0;
            int  device_cx             = 0;
            AbstractCanDevice checkdev = null;
            var handdev   = ActionGenerater.getInstance().handDevice;
            var injectdev = ActionGenerater.getInstance().injectorDevice;

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

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

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

            case 2:
                if (xdone == false)
                {
                    xdone = device.DoneX();
                }
                if (ydone == false)
                {
                    ydone = device.DoneY();
                }
                if (zdone == false)
                {
                    zdone = device.DoneZ();
                }
                isfinish = xdone && ydone && zdone;
                break;
            }
        }