Ejemplo n.º 1
0
        public void ResetGantryY(MachineStep step)
        {
            if (GantryY != Gantry.None)
            {
                if (GantryCouplingY == GantryCoupling.None)
                {
                    throw new InvalidOperationException("Gantry coupling could not be none!");
                }
                var slaveUnhooked = GantryCouplingY == GantryCoupling.Single;

                if (GantryY == Gantry.First)
                {
                    step.Actions.Add(new LinearPositionLinkGantryOffAction()
                    {
                        Name = "Gantry off YV", MasterId = 101, SlaveId = 201, SlaveUnhooked = slaveUnhooked
                    });
                }
                else
                {
                    step.Actions.Add(new LinearPositionLinkGantryOffAction()
                    {
                        Name = "Gantry off YV", MasterId = 201, SlaveId = 101, SlaveUnhooked = slaveUnhooked
                    });
                }

                GantryY = Gantry.None;
            }

            GantryCouplingY = GantryCoupling.None;
        }
Ejemplo n.º 2
0
        public override List <MachineStep> Convert(GIstruction istruction, State state)
        {
            if (istruction.Parameters.TryGetValue('L', out double ln) && istruction.Parameters.TryGetValue('T', out double t))
            {
                MachineStep ms = null;

                if (t == 1.0)
                {
                    ms = GetMachineStepForBlowing(ln);
                }
                else if (t == 2.0)
                {
                    ms = GetMachineStepForGlue(ln);
                }
                else if (t == 3.0)
                {
                    //ms = GetMachineStepForDoweling(ln);
                    return(GetMachineStepsForDoweling(ln));
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Invalid doweling operation!");
                }

                return((ms != null) && (ms.Actions.Count > 0) ? new List <MachineStep>()
                {
                    ms
                } : null);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public override List <MachineStep> Convert(GIstruction istruction, State state)
        {
            var step = new MachineStep()
            {
                Id      = GetStepId(),
                Name    = $"G0",
                Actions = new List <BaseAction>()
            };

            if (istruction.Parameters != null && istruction.Parameters.Count > 0)
            {
                if (istruction.Parameters.TryGetValue('X', out double x))
                {
                    state.Axes.SetRapidX(x, step);
                }
                if (istruction.Parameters.TryGetValue('Y', out double y))
                {
                    state.Axes.SetRapidY(y, step);
                }
                if (istruction.Parameters.TryGetValue('Z', out double z))
                {
                    state.Axes.SetRapidZ(z, step);
                }

                SetActionsIds(step);
                SetMaxDuration(step);
            }

            return((step.Actions.Count() > 0) ? new List <MachineStep>()
            {
                step
            } : null);
        }
Ejemplo n.º 4
0
        public override List <MachineStep> Convert(SetVariableIstruction istruction, T state)
        {
            var bytes = BitConverter.GetBytes((uint)istruction.Value);
            var ar    = new BitArray(bytes);
            var s     = GetState(state);
            var r     = new BitArray(ar).Xor(s);
            var step  = new MachineStep()
            {
                Id      = GetStepId(),
                Name    = $"{istruction.Name}[{istruction.Index}]",
                Actions = new List <BaseAction>()
            };

            for (int i = 0; i < r.Length; i++)
            {
                if ((_linkIds[i] > 0) && r[i])
                {
                    AddAction(step, ar[i], _linkIds[i]);
                    s[i] = ar[i];
                }
            }

            FilterMultipleActionOnSameLink(step);
            SetActionsIds(step);

            return((step.Actions.Count() > 0) ? new List <MachineStep>()
            {
                step
            } : null);
        }
Ejemplo n.º 5
0
        public void ResetGantryZ2(MachineStep step)
        {
            if (GantryZ2 != Gantry.None)
            {
                if (GantryCouplingZ2 == GantryCoupling.None)
                {
                    throw new InvalidOperationException("Gantry coupling could not be none!");
                }
                var slaveUnhooked = GantryCouplingZ2 == GantryCoupling.Single;

                if (GantryZ2 == StateData.Axes.Gantry.First)
                {
                    step.Actions.Add(new LinearPositionLinkGantryOffAction()
                    {
                        Name = "Gantry off AB", MasterId = 112, SlaveId = 212, SlaveUnhooked = slaveUnhooked
                    });
                }
                else
                {
                    step.Actions.Add(new LinearPositionLinkGantryOffAction()
                    {
                        Name = "Gantry off AB", MasterId = 212, SlaveId = 112, SlaveUnhooked = slaveUnhooked
                    });
                }

                GantryZ2 = StateData.Axes.Gantry.None;
            }

            GantryCouplingZ2 = GantryCoupling.None;
        }
Ejemplo n.º 6
0
        public override List <MachineStep> Convert(GIstruction istruction, State state)
        {
            if (istruction.Parameters.TryGetValue('X', out double x))
            {
                var step = new MachineStep()
                {
                    Id      = GetStepId(),
                    Name    = $"G692",
                    Actions = new List <BaseAction>()
                };

                state.Axes.SetRapidX(x, step);
                SetActionsIds(step);
                SetMaxDuration(step);

                return(new List <MachineStep>()
                {
                    step
                });
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 7
0
        public void SetYV(double posY, double posV, MachineStep step, bool addOffset = true)
        {
            var offset = addOffset ? OY : 0.0;

            Y = GetNewPositionCalcolateDuration(Y, posY + offset, _maxSpeedY, out double t1);
            V = GetNewPositionCalcolateDuration(V, posV + offset, _maxSpeedY, out double t2);
            var t      = (t1 > t2) ? t1 : t2;
            var action = new LinearInterpolatedPositionLinkAction()
            {
                Name      = "Move Y V",
                Positions = new List <LinearInterpolatedPositionLinkAction.PositionItem>()
                {
                    new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 101, RequestPosition = Y
                    },
                    new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 201, RequestPosition = V
                    }
                },
                Duration = t
            };

            step?.Actions.Add(action);
        }
Ejemplo n.º 8
0
 static protected void SetActionsIds(MachineStep step)
 {
     for (int i = 0; i < step.Actions.Count; i++)
     {
         step.Actions[i].Id = i;
     }
 }
Ejemplo n.º 9
0
        private void ManagePreviousSynchro(GIstruction istruction, State state, List <MachineStep> steps)
        {
            var step = new MachineStep()
            {
                Id      = GetStepId(),
                Name    = "G140 - Reset previous",
                Actions = new List <BaseAction>()
            };
            var resetX  = istruction.Parameters.Keys.Contains('X') && istruction.Parameters.Keys.Contains('U') && istruction.Parameters.Keys.Contains('I');
            var resetY  = istruction.Parameters.Keys.Contains('Y') && istruction.Parameters.Keys.Contains('V') && istruction.Parameters.Keys.Contains('J');
            var resetZ  = istruction.Parameters.Keys.Contains('Z') && istruction.Parameters.Keys.Contains('W') && istruction.Parameters.Keys.Contains('K');
            var resetZ2 = istruction.Parameters.Keys.Contains('A') && istruction.Parameters.Keys.Contains('B') && istruction.Parameters.Keys.Contains('K');

            if (resetX)
            {
                state.Axes.ResetGantryX(step);
            }
            if (resetY)
            {
                state.Axes.ResetGantryY(step);
            }

            if (resetZ || resetZ2)
            {
                state.Axes.ResetGantryZ(step);
                state.Axes.ResetGantryZ2(step);
            }

            if (step.Actions.Count > 0)
            {
                steps.Add(step);
            }
        }
Ejemplo n.º 10
0
        public override List <MachineStep> Convert(GIstruction istruction, State state)
        {
            var step = new MachineStep()
            {
                Id      = GetStepId(),
                Name    = "G3",
                Actions = new List <BaseAction>()
            };

            istruction.Parameters.TryGetValue('X', out double x);
            istruction.Parameters.TryGetValue('Y', out double y);
            istruction.Parameters.TryGetValue('I', out double i);
            istruction.Parameters.TryGetValue('J', out double j);
            if (istruction.Parameters.TryGetValue('F', out double v))
            {
                state.FeedSpeed = (int)v;
            }

            state.Axes.SetPosition(step, state.FeedSpeed, x, y, i, j, false);
            SetActionsIds(step);

            return((step.Actions.Count() > 0) ? new List <MachineStep>()
            {
                step
            } : null);
        }
Ejemplo n.º 11
0
        public override List <MachineStep> Convert(GIstruction istruction, State state)
        {
            double g = -1;

            istruction.Parameters.TryGetValue('G', out g);

            var step = new MachineStep()
            {
                Id      = GetStepId(),
                Name    = $"G153 G{g}",
                Actions = new List <BaseAction>()
            };

            switch (g)
            {
            case 0:
                ConvertG0(istruction, state, step);
                break;

            case 1:
                ConvertG1(istruction, state, step);
                break;

            default:
                throw new NotImplementedException($"G153 G{g} not implemented!");
            }

            SetActionsIds(step);
            SetMaxDuration(step);

            return((step.Actions.Count() > 0) ? new List <MachineStep>()
            {
                step
            } : null);
        }
Ejemplo n.º 12
0
        private static void ConvertG1(GIstruction istruction, State state, MachineStep step)
        {
            var    x = new Nullable <double>();
            var    y = new Nullable <double>();
            var    z = new Nullable <double>();
            double v = 0.0;

            if (istruction.Parameters.TryGetValue('X', out v))
            {
                x = v;
            }
            if (istruction.Parameters.TryGetValue('Y', out v))
            {
                y = v;
            }
            if (istruction.Parameters.TryGetValue('Z', out v))
            {
                z = v;
            }
            if (istruction.Parameters.TryGetValue('F', out v))
            {
                state.FeedSpeed = (int)v;
            }

            state.Axes.SetPosition(step, state.FeedSpeed, x, y, z, false);
        }
Ejemplo n.º 13
0
        public void SetZW(double posZ, double posW, MachineStep step, bool addOffset = true)
        {
            var offset = addOffset ? OZ + L : 0.0;

            Z = GetNewPositionCalcolateDuration(Z, posZ + offset, _maxSpeedZ, out double t1);
            W = GetNewPositionCalcolateDuration(W, posW + offset, _maxSpeedY, out double t2);
            var t      = (t1 > t2) ? t1 : t2;
            var action = new LinearInterpolatedPositionLinkAction()
            {
                Name      = "Move Z W",
                Positions = new List <LinearInterpolatedPositionLinkAction.PositionItem>()
                {
                    new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 102, RequestPosition = Z
                    },
                    new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 202, RequestPosition = W
                    }
                },
                Duration = t
            };

            step?.Actions.Add(action);
        }
Ejemplo n.º 14
0
        public void SetAB(double posA, double posB, MachineStep step, bool addOffset = true)
        {
            var offset = addOffset ? OZ + L : 0.0;

            A = GetNewPositionCalcolateDuration(A, posA + offset, _maxSpeedZ, out double t1);
            B = GetNewPositionCalcolateDuration(B, posB + offset, _maxSpeedY, out double t2);
            var t      = (t1 > t2) ? t1 : t2;
            var action = new LinearInterpolatedPositionLinkAction()
            {
                Name      = "Move A B",
                Positions = new List <LinearInterpolatedPositionLinkAction.PositionItem>()
                {
                    new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 112, RequestPosition = A
                    },
                    new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 212, RequestPosition = B
                    }
                },
                Duration = t
            };

            step?.Actions.Add(action);
        }
Ejemplo n.º 15
0
        public void SetGantryZ(double g, MachineStep step, bool slaveUnhooked = false)
        {
            if ((g == 1) || (g == 2))
            {
                var gantry = (g == 1.0) ? Gantry.First : Gantry.Second;
                int master = (g == 1.0) ? 102 : 202;
                int slave  = (g == 1.0) ? 202 : 102;

                step.Actions.Add(new LinearPositionLinkGantryOnAction()
                {
                    Name = "Gantry on ZW", MasterId = master, SlaveId = slave, SlaveUnhooked = slaveUnhooked
                });
                GantryZ          = gantry;
                GantryCouplingZ  = slaveUnhooked ? GantryCoupling.Single : GantryCoupling.Couple;
                GantryZ2         = Gantry.None;
                GantryCouplingZ2 = GantryCoupling.None;
            }
            else if ((g == 3) || (g == 4))
            {
                var gantry = (g == 3.0) ? Gantry.First : Gantry.Second;
                int master = (g == 3.0) ? 112 : 212;
                int slave  = (g == 3.0) ? 212 : 112;

                step.Actions.Add(new LinearPositionLinkGantryOnAction()
                {
                    Name = "Gantry on AB", MasterId = master, SlaveId = slave, SlaveUnhooked = slaveUnhooked
                });
                GantryZ2         = gantry;
                GantryCouplingZ2 = slaveUnhooked ? GantryCoupling.Single : GantryCoupling.Couple;
                GantryZ          = Gantry.None;
                GantryCouplingZ  = GantryCoupling.None;
            }
        }
Ejemplo n.º 16
0
        public void SetXU(double posX, double posU, MachineStep step, bool addOffset = true)
        {
            var offset = addOffset ? OX : 0.0;

            X = GetNewPositionCalcolateDuration(X, posX + offset, _maxSpeedX, out double t1);
            U = GetNewPositionCalcolateDuration(U, posU + offset, _maxSpeedX, out double t2);
            var t      = (t1 > t2) ? t1 : t2;
            var action = new LinearInterpolatedPositionLinkAction()
            {
                Name      = "Move X U",
                Positions = new List <LinearInterpolatedPositionLinkAction.PositionItem>()
                {
                    new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 1, RequestPosition = X
                    },
                    new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 2, RequestPosition = U
                    }
                },
                Duration = t
            };

            step?.Actions.Add(action);
        }
Ejemplo n.º 17
0
        private static void FilterMultipleActionOnSameLink(MachineStep step)
        {
            var itemsToRemove = new List <BaseAction>();

            for (int i = 0; i < step.Actions.Count(); i++)
            {
                var ai = step.Actions[i] as TwoPositionLinkAction;

                for (int j = i + 1; j < step.Actions.Count(); j++)
                {
                    var aj = step.Actions[j] as TwoPositionLinkAction;

                    if ((ai.LinkId == aj.LinkId))
                    {
                        if (ai.RequestedState == aj.RequestedState)
                        {
                            itemsToRemove.Add(aj);
                        }
                        else
                        {
                            itemsToRemove.Add(ai);
                            itemsToRemove.Add(aj);
                        }
                    }
                }
            }

            foreach (var item in itemsToRemove)
            {
                step.Actions.Remove(item);
            }
        }
Ejemplo n.º 18
0
 protected virtual void AddAction(MachineStep step, bool rqState, int linkId)
 {
     step.Actions.Add(new TwoPositionLinkAction()
     {
         LinkId         = linkId,
         RequestedState = rqState ? TwoPositionLinkActionRequestedState.On : TwoPositionLinkActionRequestedState.Off
     });
 }
 static protected void SetMaxDuration(MachineStep step)
 {
     if ((step.Actions != null) && (step.Actions.Count > 1))
     {
         var d = step.Actions.Select((a) => (a as LinearPositionLinkAction)?.Duration).Max();
         step.Actions.ForEach((a) => (a as LinearPositionLinkAction).Duration = d.Value);
     }
 }
Ejemplo n.º 20
0
        public void SetPosition(MachineStep step, double speed, double?x, double?y, double?z)
        {
            double dif    = 0.0;
            bool   b      = false;
            var    steps  = new List <double>();
            var    action = new LinearInterpolatedPositionLinkAction()
            {
                Name = "G1 move", Positions = new List <LinearInterpolatedPositionLinkAction.PositionItem>()
            };

            if (x.HasValue)
            {
                X = UpdatePosition(X, x.Value, out dif, out b);
                steps.Add(dif);
                if (b)
                {
                    action.Positions.Add(new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 1, RequestPosition = X
                    });
                }
            }

            if (y.HasValue)
            {
                Y = UpdatePosition(Y, y.Value, out dif, out b);
                steps.Add(dif);
                if (b)
                {
                    action.Positions.Add(new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 2, RequestPosition = Y
                    });
                }
            }

            if (z.HasValue)
            {
                Z = UpdatePosition(Z, z.Value + L, out dif, out b);
                steps.Add(dif);
                if (b)
                {
                    action.Positions.Add(new LinearInterpolatedPositionLinkAction.PositionItem()
                    {
                        LinkId = 3, RequestPosition = Z
                    });
                }
            }

            if (action.Positions.Count() > 0)
            {
                var dist = Math.Sqrt(steps.Sum((d) => Math.Pow(d, 2.0)));
                var t    = (dist / speed) * 60.0;

                action.Duration = t;
                step?.Actions.Add(action);
            }
        }
Ejemplo n.º 21
0
        public override List <MachineStep> Convert(GIstruction istruction, State state)
        {
            var step = new MachineStep()
            {
                Id      = GetStepId(),
                Name    = $"G0",
                Actions = new List <BaseAction>()
            };

            if (istruction.Parameters != null && istruction.Parameters.Count > 0)
            {
                if (state.Axes.M.IsIdentity() || state.Axes.M.IsIdentityFlipped())
                {
                    if (istruction.Parameters.TryGetValue('X', out double x))
                    {
                        state.Axes.SetRapidX(x, step);
                    }
                    if (istruction.Parameters.TryGetValue('Y', out double y))
                    {
                        state.Axes.SetRapidY(y, step);
                    }
                    if (istruction.Parameters.TryGetValue('Z', out double z))
                    {
                        state.Axes.SetRapidZ(z, step);
                    }
                }
                else
                {
                    double?nx = null;
                    double?ny = null;
                    double?nz = null;

                    if (istruction.Parameters.TryGetValue('X', out double x))
                    {
                        nx = x;
                    }
                    if (istruction.Parameters.TryGetValue('Y', out double y))
                    {
                        ny = y;
                    }
                    if (istruction.Parameters.TryGetValue('Z', out double z))
                    {
                        nz = z;
                    }

                    state.Axes.SetRapid(nx, ny, nz, step);
                }

                SetActionsIds(step);
                SetMaxDuration(step);
            }

            return((step.Actions.Count() > 0) ? new List <MachineStep>()
            {
                step
            } : null);
        }
Ejemplo n.º 22
0
        protected override void AddAction(MachineStep step, bool rqState, int linkId)
        {
            base.AddAction(step, rqState, linkId);

            if (linkId == 9066)
            {
                base.AddAction(step, rqState, 9166);
            }
        }
Ejemplo n.º 23
0
        public void SetXI(double inc, MachineStep step)
        {
            var t = CalcolateDuration(inc, _maxSpeedX);

            X += inc;
            step?.Actions.Add(new LinearPositionLinkAction()
            {
                Name = "Move XI", LinkId = 1, RequestedPosition = X, Duration = t
            });
        }
Ejemplo n.º 24
0
        public void SetPosition(MachineStep step, double speed, double?x, double?y, double?z, bool addOffset = true)
        {
            var _x = new Nullable <double>();
            var _y = new Nullable <double>();
            var _z = new Nullable <double>();

            M.Transform(x, y, z, ref _x, ref _y, ref _z);

            SetPositionBase(step, speed, _x, _y, _z, addOffset);
        }
Ejemplo n.º 25
0
        public void SetYI(double inc, MachineStep step)
        {
            var t = CalcolateDuration(inc, _maxSpeedY);

            Y += inc;
            step?.Actions.Add(new LinearPositionLinkAction()
            {
                Name = "Move YI", LinkId = 2, RequestedPosition = Y, Duration = t
            });
        }
Ejemplo n.º 26
0
        public void SetZI(double inc, MachineStep step)
        {
            var t = CalcolateDuration(inc, _maxSpeedZ);

            Z += inc;
            step?.Actions.Add(new LinearPositionLinkAction()
            {
                Name = "Move ZI", LinkId = 3, RequestedPosition = Z, Duration = t
            });
        }
Ejemplo n.º 27
0
        private void AddSetGantrySteps(State state, List <MachineStep> steps)
        {
            var step = new MachineStep()
            {
                Id = GetStepId(), Name = "TCH - Gantry", Actions = new List <BaseAction>()
            };

            state.Axes.SetGantryY(1.0, step);
            steps.Add(step);
        }
Ejemplo n.º 28
0
        public void SetB(double pos, MachineStep step, bool addOffset = true)
        {
            var offset = addOffset ? OZ + L : 0.0;

            B = GetNewPositionCalcolateDuration(B, pos + offset, _maxSpeedZ, out double t);
            step?.Actions.Add(new LinearPositionLinkAction()
            {
                Name = "Move B", LinkId = 212, RequestedPosition = B, Duration = t
            });
        }
Ejemplo n.º 29
0
        public void SetV(double pos, MachineStep step, bool addOffset = true)
        {
            var offset = addOffset ? OY : 0.0;

            V = GetNewPositionCalcolateDuration(V, pos + offset, _maxSpeedY, out double t);
            step?.Actions.Add(new LinearPositionLinkAction()
            {
                Name = "Move V", LinkId = 201, RequestedPosition = V, Duration = t
            });
        }
Ejemplo n.º 30
0
        public void SetU(double pos, MachineStep step, bool addOffset = true)
        {
            var offset = addOffset ? OX : 0.0;

            U = GetNewPositionCalcolateDuration(U, pos + offset, _maxSpeedX, out double t);
            step?.Actions.Add(new LinearPositionLinkAction()
            {
                Name = "Move U", LinkId = 2, RequestedPosition = U, Duration = t
            });
        }