예제 #1
0
 /// <summary>
 /// Creates declarations in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
 {
     if (_type == CodeType.Declaration)
     {
         RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t\t" + _code);
     }
 }
예제 #2
0
 /// <summary>
 /// Creates declarations in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
 {
     for (int i = 0; i < _actions.Count; i++)
     {
         _actions[i].ToRAPIDDeclaration(RAPIDGenerator);
     }
 }
예제 #3
0
        /// <summary>
        /// Creates declarations in the RAPID program module inside the RAPID Generator.
        /// This method is called inside the RAPID generator.
        /// </summary>
        /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
        public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
        {
            // Only adds target code if target is not already defined
            if (!RAPIDGenerator.Targets.ContainsKey(_name))
            {
                // Add to dictionary
                RAPIDGenerator.Targets.Add(_name, this);

                // Generate code
                string code = Enum.GetName(typeof(ReferenceType), _referenceType);
                code += " robtarget ";
                code += _name;
                code += " := [";
                code += "[" + _plane.Origin.X.ToString("0.##") + ", ";
                code += _plane.Origin.Y.ToString("0.##") + ", ";
                code += _plane.Origin.Z.ToString("0.##") + "]";
                code += ", ";
                code += "[" + _quat.A.ToString("0.######") + ", ";
                code += _quat.B.ToString("0.######") + ", ";
                code += _quat.C.ToString("0.######") + ", ";
                code += _quat.D.ToString("0.######") + "]";
                code += ", ";
                code += "[0,0,0," + _axisConfig + "]";
                code += ", ";
                code += RAPIDGenerator.Robot.InverseKinematics.ExternalJointPosition.ToRAPID();
                code += "];";

                // Add to stringbuilder
                RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t" + code);
            }
        }
예제 #4
0
 /// <summary>
 /// Creates instructions in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDInstruction(RAPIDGenerator RAPIDGenerator)
 {
     if (_type == CodeType.Instruction)
     {
         RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t\t" + "! " + _comment);
     }
 }
예제 #5
0
 /// <summary>
 /// Creates declarations in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
 {
     if (!RAPIDGenerator.Targets.ContainsKey(_name))
     {
         RAPIDGenerator.Targets.Add(_name, this);
         RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t" + this.ToRAPIDDeclaration(RAPIDGenerator.Robot));
     }
 }
예제 #6
0
        /// <summary>
        /// Creates declarations in the RAPID program module inside the RAPID Generator.
        /// This method is called inside the RAPID generator.
        /// </summary>
        /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
        public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
        {
            // Generate the code for the zone and speeddata
            _speedData.ToRAPIDDeclaration(RAPIDGenerator);
            _zoneData.ToRAPIDDeclaration(RAPIDGenerator);

            // Generate code from robot targets
            if (_target is RobotTarget robotTarget)
            {
                // Update the movement of the inverse kinematics
                RAPIDGenerator.Robot.InverseKinematics.Movement = this;

                // Generates the robot target variable for a MoveL or MoveJ instruction
                if (_movementType == MovementType.MoveL || _movementType == MovementType.MoveJ)
                {
                    RAPIDGenerator.Robot.InverseKinematics.CalculateExternalJointPosition();
                    robotTarget.ToRAPIDDeclaration(RAPIDGenerator);
                }

                // Generates the joint target variable from a robot target for a MoveAbsJ instruction
                else
                {
                    if (!RAPIDGenerator.Targets.ContainsKey(robotTarget.Name + "_jt"))
                    {
                        // Calculate the axis values from the robot target
                        RAPIDGenerator.Robot.InverseKinematics.Calculate();
                        RAPIDGenerator.ErrorText.AddRange(new List <string>(RAPIDGenerator.Robot.InverseKinematics.ErrorText));

                        // Create a joint target from the axis values
                        RobotJointPosition    robJointPosition = RAPIDGenerator.Robot.InverseKinematics.RobotJointPosition.Duplicate();
                        ExternalJointPosition extJointPosition = RAPIDGenerator.Robot.InverseKinematics.ExternalJointPosition.Duplicate();
                        JointTarget           jointTarget      = new JointTarget(robotTarget.Name + "_jt", robJointPosition, extJointPosition);
                        jointTarget.ReferenceType = _target.ReferenceType;

                        // Create the RAPID code
                        jointTarget.ToRAPIDDeclaration(RAPIDGenerator);
                    }
                }
            }

            // Generate code from joint targets
            else if (_target is JointTarget jointTarget)
            {
                // JointTarget with MoveAbsJ
                if (_movementType == MovementType.MoveAbsJ)
                {
                    jointTarget.ToRAPIDDeclaration(RAPIDGenerator);
                    RAPIDGenerator.ErrorText.AddRange(jointTarget.CheckAxisLimits(RAPIDGenerator.Robot));
                }

                // Joint Target combined with MoveL or MoveJ
                else
                {
                    throw new InvalidOperationException("Invalid Move instruction: A Joint Target cannot be combined with a MoveL or MoveJ instruction.");
                }
            }
        }
        /// <summary>
        /// Creates instructions in the RAPID program module inside the RAPID Generator.
        /// This method is called inside the RAPID generator.
        /// </summary>
        /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
        public override void ToRAPIDInstruction(RAPIDGenerator RAPIDGenerator)
        {
            RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t\t" + this.ToRAPIDInstruction(RAPIDGenerator.Robot));

            // Collect unique robot tools
            if (!RAPIDGenerator.RobotTools.ContainsKey(_robotTool.Name))
            {
                RAPIDGenerator.RobotTools.Add(_robotTool.Name, _robotTool);
            }
        }
예제 #8
0
 /// <summary>
 /// Creates instructions in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDInstruction(RAPIDGenerator RAPIDGenerator)
 {
     if (_isActive == true)
     {
         RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t\t" + "ConfJ\\on;");
     }
     else
     {
         RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t\t" + "ConfJ\\off;");
     }
 }
예제 #9
0
        /// <summary>
        /// Creates instructions in the RAPID program module inside the RAPID Generator.
        /// This method is called inside the RAPID generator.
        /// </summary>
        /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
        public override void ToRAPIDInstruction(RAPIDGenerator RAPIDGenerator)
        {
            RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t\t" + "! Start of group: " + _name);

            for (int i = 0; i < _actions.Count; i++)
            {
                _actions[i].ToRAPIDInstruction(RAPIDGenerator);
            }

            RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t\t" + "! End of group: " + _name);
        }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the RAPDI Generator class by duplicating an existing RAPID Generator instance.
 /// </summary>
 /// <param name="generator"> The RAPID Generator instance to duplicate. </param>
 public RAPIDGenerator(RAPIDGenerator generator)
 {
     _programModuleName       = generator.ProgramModuleName;
     _systemModuleName        = generator.SystemModuleName;
     _robot                   = generator.Robot.Duplicate();
     _actions                 = generator.Actions.ConvertAll(action => action.DuplicateAction());
     _filePath                = generator.FilePath;
     _saveToFile              = generator.SaveToFile;
     _programCode             = generator.ProgramCode;
     _systemCode              = generator.SystemCode;
     _firstMovementIsMoveAbsJ = generator.FirstMovementIsMoveAbsJ;
 }
예제 #11
0
 /// <summary>
 /// Creates declarations in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
 {
     if (_predefined == false)
     {
         // Only adds speedData Variable if not already in RAPID Code
         if (!RAPIDGenerator.SpeedDatas.ContainsKey(this.Name))
         {
             RAPIDGenerator.SpeedDatas.Add(this.Name, this);
             RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t" + this.ToRAPIDDeclaration(RAPIDGenerator.Robot));
         }
     }
 }
        /// <summary>
        /// Used to create variable definitions in the RAPID Code. It is typically called inside the CreateRAPIDCode() method of the RAPIDGenerator class.
        /// </summary>
        /// <param name="RAPIDGenerator"> Defines the RAPIDGenerator. </param>
        public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
        {
            // Creates SpeedData Variable Code
            _speedData.ToRAPIDDeclaration(RAPIDGenerator);

            // Creates ZoneData Variable Code
            _zoneData.ToRAPIDDeclaration(RAPIDGenerator);

            // Only adds target code if target is not already defined
            if (!RAPIDGenerator.Targets.ContainsKey(_name))
            {
                RAPIDGenerator.Targets.Add(_name, this.ConvertToJointTarget());
                RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t" + this.ToRAPIDDeclaration(RAPIDGenerator.Robot));
                RAPIDGenerator.ErrorText.AddRange(this.CheckForAxisLimits(RAPIDGenerator.Robot));
            }
        }
 /// <summary>
 /// Creates declarations in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
 {
     // We don't write a comment between our declarations.
 }
예제 #14
0
 /// <summary>
 /// Creates declarations in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator)
 {
 }
예제 #15
0
 /// <summary>
 /// Creates instructions in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDInstruction(RAPIDGenerator RAPIDGenerator)
 {
     RAPIDGenerator.StringBuilder.Append(Environment.NewLine + "\t\t" + this.ToRAPIDInstruction(RAPIDGenerator.Robot));
 }
예제 #16
0
 /// <summary>
 /// Creates instructions in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public override void ToRAPIDInstruction(RAPIDGenerator RAPIDGenerator)
 {
 }
예제 #17
0
 /// <summary>
 /// Creates declarations in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public abstract void ToRAPIDDeclaration(RAPIDGenerator RAPIDGenerator);
예제 #18
0
 /// <summary>
 /// Creates instructions in the RAPID program module inside the RAPID Generator.
 /// This method is called inside the RAPID generator.
 /// </summary>
 /// <param name="RAPIDGenerator"> The RAPID Generator. </param>
 public abstract void ToRAPIDInstruction(RAPIDGenerator RAPIDGenerator);