class TPPlus::Nodes::MotionNode
Public Class Methods
new(type, destination, modifiers)
click to toggle source
# File lib/tp_plus/nodes/motion_node.rb, line 4 def initialize(type, destination, modifiers) @type = type @destination = destination @modifiers = modifiers end
Public Instance Methods
actual_modifiers()
click to toggle source
# File lib/tp_plus/nodes/motion_node.rb, line 31 def actual_modifiers @actual_modifiers ||= @modifiers.reject {|m| m.is_a? SpeedNode}.reject {|m| m.is_a? TerminationNode } end
eval(context)
click to toggle source
# File lib/tp_plus/nodes/motion_node.rb, line 55 def eval(context) raise "Speed is invalid for motion type" unless speed_valid?(context) "#{prefix} #{@destination.eval(context)} #{speed_node.eval(context)} #{termination_node.eval(context)}#{modifiers_string(context)}" end
modifiers_string(context)
click to toggle source
# File lib/tp_plus/nodes/motion_node.rb, line 35 def modifiers_string(context) return "" unless actual_modifiers.any? strings_array = [""] << actual_modifiers.map { |m| m.eval(context) } @modifiers_string = strings_array.join(" ") end
prefix()
click to toggle source
# File lib/tp_plus/nodes/motion_node.rb, line 10 def prefix case @type when "linear_move" "L" when "joint_move" "J" when "circular_move" "C" else raise "Unsupported motion" end end
speed_node()
click to toggle source
# File lib/tp_plus/nodes/motion_node.rb, line 23 def speed_node @speed_node ||= @modifiers.select {|m| m.is_a? SpeedNode }.first end
speed_valid?(context)
click to toggle source
# File lib/tp_plus/nodes/motion_node.rb, line 42 def speed_valid?(context) case @type when "linear_move" return true if speed_node.eval(context) == "max_speed" ["mm/sec"].include? speed_node.units when "joint_move" return false if speed_node.eval(context) == "max_speed" ["%"].include? speed_node.units end end
termination_node()
click to toggle source
# File lib/tp_plus/nodes/motion_node.rb, line 27 def termination_node @termination_node ||= @modifiers.select {|m| m.is_a? TerminationNode }.first end