atc-tools 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/bin/fpv +3 -0
  3. data/doc/ATCTools.html +133 -0
  4. data/doc/ATCTools/Aircraft.html +309 -0
  5. data/doc/ATCTools/Airport.html +634 -0
  6. data/doc/ATCTools/FlightPlan.html +544 -0
  7. data/doc/ATCTools/FlightPlanValidator.html +265 -0
  8. data/doc/ATCTools/HeadingDiscoveryError.html +135 -0
  9. data/doc/ATCTools/HeadingError.html +135 -0
  10. data/doc/ATCTools/NameDiscoveryError.html +135 -0
  11. data/doc/ATCTools/NoAircraftSelectedError.html +135 -0
  12. data/doc/ATCTools/VRC.html +656 -0
  13. data/doc/Aircraft.html +127 -0
  14. data/doc/Airport.html +564 -0
  15. data/doc/FlightPlan.html +127 -0
  16. data/doc/HeadingError.html +127 -0
  17. data/doc/NameDiscoveryError.html +127 -0
  18. data/doc/created.rid +7 -0
  19. data/doc/images/add.png +0 -0
  20. data/doc/images/arrow_up.png +0 -0
  21. data/doc/images/brick.png +0 -0
  22. data/doc/images/brick_link.png +0 -0
  23. data/doc/images/bug.png +0 -0
  24. data/doc/images/bullet_black.png +0 -0
  25. data/doc/images/bullet_toggle_minus.png +0 -0
  26. data/doc/images/bullet_toggle_plus.png +0 -0
  27. data/doc/images/date.png +0 -0
  28. data/doc/images/delete.png +0 -0
  29. data/doc/images/find.png +0 -0
  30. data/doc/images/loadingAnimation.gif +0 -0
  31. data/doc/images/macFFBgHack.png +0 -0
  32. data/doc/images/package.png +0 -0
  33. data/doc/images/page_green.png +0 -0
  34. data/doc/images/page_white_text.png +0 -0
  35. data/doc/images/page_white_width.png +0 -0
  36. data/doc/images/plugin.png +0 -0
  37. data/doc/images/ruby.png +0 -0
  38. data/doc/images/tag_blue.png +0 -0
  39. data/doc/images/tag_green.png +0 -0
  40. data/doc/images/transparent.png +0 -0
  41. data/doc/images/wrench.png +0 -0
  42. data/doc/images/wrench_orange.png +0 -0
  43. data/doc/images/zoom.png +0 -0
  44. data/doc/index.html +87 -0
  45. data/doc/js/darkfish.js +155 -0
  46. data/doc/js/jquery.js +18 -0
  47. data/doc/js/navigation.js +142 -0
  48. data/doc/js/search.js +94 -0
  49. data/doc/js/search_index.js +1 -0
  50. data/doc/js/searcher.js +228 -0
  51. data/doc/rdoc.css +595 -0
  52. data/doc/table_of_contents.html +132 -0
  53. data/lib/atc-tools.rb +1 -0
  54. data/lib/atc-tools/aircraft.rb +36 -0
  55. data/lib/atc-tools/airport.rb +103 -0
  56. data/lib/atc-tools/flight_plan.rb +119 -0
  57. data/lib/atc-tools/script/flight_plan_validator.rb +65 -0
  58. data/lib/atc-tools/vrc.rb +165 -0
  59. data/license.txt +19 -0
  60. metadata +174 -0
@@ -0,0 +1,165 @@
1
+ require 'rautomation'
2
+ require 'atc-tools/flight_plan'
3
+ require 'atc-tools/aircraft'
4
+
5
+ module ATCTools
6
+ class NoAircraftSelectedError < StandardError; end
7
+
8
+ # A class for interfacing with the Virtual Radar Client application.
9
+ # http://www1.metacraft.com/VRC/
10
+ #
11
+ # Methods with a bang (!) at the end manipulate the window and
12
+ # could affect the user.
13
+ class VRC
14
+ # VRC log path for exporting aircraft info.
15
+ attr_accessor :aclog_path
16
+
17
+ # Params:
18
+ # :aclog_path - Location of the VRC log dump for the aircraft info query.
19
+ def initialize(**kvargs)
20
+ @aclog_path = kvargs.fetch :aclog_path, File.expand_path('Documents/VRC/acinfo.txt', '~')
21
+
22
+ @selected_aircraft = ''
23
+
24
+ #Window handles.
25
+ @vrc_win = RAutomation::Window.new title: /VRC.*Connected to server:/
26
+ @flight_plan_win = RAutomation::Window.new title: /Flight Plan - /
27
+ @terminal_win = RAutomation::Window.new title: /\\cmd.exe/
28
+
29
+ @command_win = @vrc_win.text_fields[0]
30
+ @callsign_win = @vrc_win.text_fields[1]
31
+ end
32
+
33
+ # Title of the VRC flight plan window.
34
+ # This includes the pilot's callsign and real name.
35
+ def flight_plan_title
36
+ @flight_plan_win.title
37
+ end
38
+
39
+ # Extracts the flight plan of the selected aircraft.
40
+ def selected_flight_plan!
41
+ raise ATCTools::NoAircraftSelectedError, "No aircraft selected." \
42
+ unless aircraft_selected?
43
+
44
+ execute_command ".ss #{@selected_aircraft}"
45
+
46
+ flight_plan = ATCTools::FlightPlan.new \
47
+ callsign: @selected_aircraft,
48
+ aircraft: ATCTools::Aircraft.new(
49
+ @flight_plan_win.text_fields[1].value,
50
+ info: selected_aircraft_info!
51
+ ),
52
+ rules: (RAutomation::Adapter::Win32::SelectList.new @flight_plan_win, index: 0)
53
+ .value.upcase.to_sym,
54
+ depart: ATCTools::Airport.new(@flight_plan_win.text_fields[2].value),
55
+ arrive: ATCTools::Airport.new(@flight_plan_win.text_fields[3].value),
56
+ alternate: ATCTools::Airport.new(@flight_plan_win.text_fields[4].value),
57
+ cruise: @flight_plan_win.text_fields[5].value.to_i,
58
+ scratchpad: @flight_plan_win.text_fields[6].value.strip,
59
+ squawk: @flight_plan_win.text_fields[7].value.strip,
60
+ route: @flight_plan_win.text_fields[8].value.strip,
61
+ remarks: @flight_plan_win.text_fields[9].value.strip
62
+ end
63
+
64
+ # Extracts the callsign of the selected aircraft.
65
+ # Returns an empty string if no aircraft is selected.
66
+ def selected_aircraft
67
+ @selected_aircraft = @callsign_win.value.strip
68
+ end
69
+
70
+ # True if an aircraft is selected.
71
+ def aircraft_selected?
72
+ selection_empty = selected_aircraft.empty?
73
+ @selected_aircraft = '' if selection_empty
74
+ not selection_empty
75
+ end
76
+
77
+ # Extracts the aircraft info for the selected aircraft.
78
+ def selected_aircraft_info!
79
+ # --------------------------------------------------------------------------
80
+ # TODO: Prompt for an aircraft model as the input and use .typeinfo instead.
81
+ # This way it can return info for cached aircraft.
82
+ # --------------------------------------------------------------------------
83
+
84
+ raise ATCTools::NoAircraftSelectedError, "No aircraft selected." \
85
+ unless aircraft_selected?
86
+
87
+ # ---------------------------
88
+ # TODO:
89
+ # ---------------------------
90
+
91
+ # Retrieve the aircraft info.
92
+ execute_command ".acinfo #{@selected_aircraft}"
93
+
94
+ # Dump the aircraft info to a log for processing.
95
+ execute_command ".log #{File.basename @aclog_path}"
96
+
97
+ # Process aircraft info.
98
+ aclog = ''
99
+ result = ''
100
+ attempts = 0
101
+
102
+ while attempts < 5
103
+ aclog_exists = File.exists? @aclog_path
104
+ break if aclog_exists
105
+
106
+ attempts += 1
107
+ sleep 0.5
108
+ end
109
+
110
+ if aclog_exists
111
+ aclog = File.open(@aclog_path).read
112
+
113
+ # Only keep the last few lines.
114
+ # Reverse the lines so the latest one is first.
115
+ aclog = aclog.lines[-6..-1].reverse.join
116
+
117
+ aclog.each_line do |line|
118
+ result = line.gsub /.*\s*(Aircraft info for \w*:\s*)/, '' if line.include? "Aircraft info for #{@selected_aircraft}"
119
+ break if result
120
+ end
121
+
122
+ # ---------------
123
+ # TODO: Implement
124
+ # ---------------
125
+ result = "Aircraft type code '#{'xxx'}' not found in database." if result.empty?
126
+
127
+ # File.delete @aclog_path
128
+ end
129
+
130
+ result
131
+ end
132
+
133
+ # Extract the text from the command line.
134
+ def command_line
135
+ @command_win.value
136
+ end
137
+
138
+ # Execute a command in the VRC client.
139
+ # Preserves partially-entered commands in the text box.
140
+ def execute_command(cmd)
141
+ old_cmd = command_line
142
+ execute_command! cmd
143
+ @command_win.set old_cmd
144
+ end
145
+
146
+ # Execute a command in the VRC client, overwriting any
147
+ # partially-entered command in the text box.
148
+ def execute_command!(cmd)
149
+ @command_win.set cmd
150
+ @command_win.send_keys :return
151
+ end
152
+
153
+ # Activate the VRC window, bringing it to the foreground.
154
+ def activate_vrc_window!
155
+ @vrc_win.activate
156
+ end
157
+
158
+ # Activate the terminal (command line) window, bringing
159
+ # it to the foreground.
160
+ def activate_terminal_window!
161
+ @terminal_win.activate
162
+ end
163
+
164
+ end
165
+ end
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Alex McLain
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atc-tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex McLain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rautomation
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.12.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.12.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: launchy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |-
84
+ A VATSIM flight plan validator for the VRC radar client.
85
+ NOTE: Only works with 32-bit Ruby installations due to the RAutomation gem.
86
+ email: alex@alexmclain.com
87
+ executables:
88
+ - fpv
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - license.txt
93
+ - bin/fpv
94
+ - lib/atc-tools/aircraft.rb
95
+ - lib/atc-tools/airport.rb
96
+ - lib/atc-tools/flight_plan.rb
97
+ - lib/atc-tools/script/flight_plan_validator.rb
98
+ - lib/atc-tools/vrc.rb
99
+ - lib/atc-tools.rb
100
+ - doc/Aircraft.html
101
+ - doc/Airport.html
102
+ - doc/ATCTools/Aircraft.html
103
+ - doc/ATCTools/Airport.html
104
+ - doc/ATCTools/FlightPlan.html
105
+ - doc/ATCTools/FlightPlanValidator.html
106
+ - doc/ATCTools/HeadingDiscoveryError.html
107
+ - doc/ATCTools/HeadingError.html
108
+ - doc/ATCTools/NameDiscoveryError.html
109
+ - doc/ATCTools/NoAircraftSelectedError.html
110
+ - doc/ATCTools/VRC.html
111
+ - doc/ATCTools.html
112
+ - doc/created.rid
113
+ - doc/FlightPlan.html
114
+ - doc/HeadingError.html
115
+ - doc/images/add.png
116
+ - doc/images/arrow_up.png
117
+ - doc/images/brick.png
118
+ - doc/images/brick_link.png
119
+ - doc/images/bug.png
120
+ - doc/images/bullet_black.png
121
+ - doc/images/bullet_toggle_minus.png
122
+ - doc/images/bullet_toggle_plus.png
123
+ - doc/images/date.png
124
+ - doc/images/delete.png
125
+ - doc/images/find.png
126
+ - doc/images/loadingAnimation.gif
127
+ - doc/images/macFFBgHack.png
128
+ - doc/images/package.png
129
+ - doc/images/page_green.png
130
+ - doc/images/page_white_text.png
131
+ - doc/images/page_white_width.png
132
+ - doc/images/plugin.png
133
+ - doc/images/ruby.png
134
+ - doc/images/tag_blue.png
135
+ - doc/images/tag_green.png
136
+ - doc/images/transparent.png
137
+ - doc/images/wrench.png
138
+ - doc/images/wrench_orange.png
139
+ - doc/images/zoom.png
140
+ - doc/index.html
141
+ - doc/js/darkfish.js
142
+ - doc/js/jquery.js
143
+ - doc/js/navigation.js
144
+ - doc/js/search.js
145
+ - doc/js/searcher.js
146
+ - doc/js/search_index.js
147
+ - doc/NameDiscoveryError.html
148
+ - doc/rdoc.css
149
+ - doc/table_of_contents.html
150
+ homepage: https://bitbucket.org/amclain/atc-tools
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.0.3
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: A VATSIM flight plan validator for the VRC radar client.
174
+ test_files: []