Example #1
0
        /// <summary>
        /// Default constructor for G1Path between two G0/G1 commands.
        /// </summary>
        /// <param name="prevCommand">Previous command to get last position</param>
        /// <param name="command">Current G1 command</param>
        public G1Path(G01Command prevCommand, G01Command command)
        {
            PrevCommand = prevCommand;
            Command = command;

            if (command.F != null)
                RawSpeed = Speed = RecommendedSpeed = Convert.ToDouble(command.F / 60);

            if (prevCommand.X != null && command.X != null && prevCommand.Y != null && command.Y != null)
            {
                Length =
                    Math.Sqrt(Math.Pow(Convert.ToDouble(command.X - prevCommand.X), 2) +
                              Math.Pow(Convert.ToDouble(command.Y - prevCommand.Y), 2));

                RawTime = Time = Length / RawSpeed;
                BufferValue = Length / MAX_COMMAND_PER_SECOND;

                if (Time < MIN_COMMAND_TIME && Length > 0)
                {
                    SpeedModificator = RawTime / MIN_COMMAND_TIME;
                    RecommendedSpeed = RawSpeed * SpeedModificator;
                    //Speed = RecommendedSpeed;
                    Time = Length / Speed;
                }
                else
                {
                    SpeedModificator = 1;
                }
            }
            Command.Path = this;
        }
Example #2
0
        public void AddG01Command(int lineIndex, string commandName, double? x, double? y, double? z, double? e, double? f)
        {
            var newCommand = new G01Command(lineIndex, commandName, x, y, z, e, f);

            Commands.Add(newCommand);

            if (Commands.Count > 1 && Commands[Commands.Count - 2] != null)
            {
                var newPath = new G1Path(Commands[Commands.Count - 2], newCommand);
                Pathes.Add(newPath);

            }
        }