class Tengai::EphemerisRequest
Constants
- ACCEPT_DEFAULT_OUTPUT_PROMPT
- ANY_PROMPT
- COMPLETED_PROMPT
- CONFIRM_OBSERVER_PROMPT
- CORRECTIONS_PROMPT
- CSV_FORMAT_PROMPT
- DEFAULT_PROMPT
- END_TIME_PROMPT
- FIRST_OBSERVER_PROMPT
- INTERVAL_PROMPT
- LABEL_CARTESIAN_OUTPUT_PROMPT
- OBSERVER_PROMPT
- OUTPUT_REFERENCE_FRAME_PROMPT
- OUTPUT_UNITS
- REFERNCE_PLANE_PROMPT
- SELECT_OUTPUT_TABLE_TYPE_PROMPT
- SELECT_QUANTITIES_PROMPT
- START_TIME_PROMPT
- SUBSEQUENT_OBSERVER_PROMPT
- SYSTEM_PROMPT
- TABLE_PROMPT
- TIME_FORMAT
Public Class Methods
fetch(client, body, options={})
click to toggle source
# File lib/tengai/requests/ephemeris_request.rb, line 44 def self.fetch(client, body, options={}) new(client, body, options).fetch end
new(client, body, options={})
click to toggle source
# File lib/tengai/requests/ephemeris_request.rb, line 34 def initialize(client, body, options={}) @client = client @body = body.to_s @start_time = options[:start_time] @stop_time = options[:stop_time] @interval = options[:interval] || 1440 @options = options @state = :ready end
Public Instance Methods
fetch()
click to toggle source
Public: initiates the ephemeris request
Examples:
Tengai::EphemerisRequest.new(Tengai::Client.new, 499).fetch # => #<Tengai::EphemerisRequest @data=""B\n \r\n Working ... \b\b- \r\n\e[?1h\e=\r*...">
Returns the the request (self)
# File lib/tengai/requests/ephemeris_request.rb, line 56 def fetch raise "Not ready" unless @state == :ready @state = :fetching send_command(@body) @data end
Private Instance Methods
observer()
click to toggle source
# File lib/tengai/requests/ephemeris_request.rb, line 73 def observer @options[:observer] || '500@0' end
receive_data(data)
click to toggle source
# File lib/tengai/requests/ephemeris_request.rb, line 85 def receive_data(data) case data when DEFAULT_PROMPT send_command 'E' when TABLE_PROMPT send_command table when FIRST_OBSERVER_PROMPT send_command observer when SUBSEQUENT_OBSERVER_PROMPT send_command 'n' when CONFIRM_OBSERVER_PROMPT send_command 'y' when REFERNCE_PLANE_PROMPT send_command 'frame' when START_TIME_PROMPT send_command @start_time.strftime(TIME_FORMAT) when END_TIME_PROMPT send_command @stop_time.strftime(TIME_FORMAT) when INTERVAL_PROMPT send_command @interval.to_s + 'm' when ACCEPT_DEFAULT_OUTPUT_PROMPT send_command 'n' when OUTPUT_REFERENCE_FRAME_PROMPT send_command 'J2000' when CORRECTIONS_PROMPT send_command '1' when OUTPUT_UNITS send_command '2' when CSV_FORMAT_PROMPT send_command 'YES' when LABEL_CARTESIAN_OUTPUT_PROMPT send_command 'YES' when SELECT_OUTPUT_TABLE_TYPE_PROMPT send_command '03' when SELECT_QUANTITIES_PROMPT send_command 'B' when COMPLETED_PROMPT @data = data send_command 'N' when Client::PROMPT @state = :ready else puts "Unexpected data: #{data}" end end
send_command(command, prompt=ANY_PROMPT)
click to toggle source
# File lib/tengai/requests/ephemeris_request.rb, line 77 def send_command(command, prompt=ANY_PROMPT) Tengai.log "> #{command}" result = @client.cmd('String' => command, 'Match' => prompt) do |data| Tengai.log '< ' + data end receive_data(result) end
table()
click to toggle source
# File lib/tengai/requests/ephemeris_request.rb, line 64 def table case @options[:table] when :observer then 'o' when :vector then 'v' when :orbital_elements then 'e' else 'v' end end