tac_scribe 0.2.1-java → 0.3.0-java
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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +10 -0
- data/README.md +24 -1
- data/exe/{start_scribe → tac_scribe} +8 -2
- data/lib/tac_scribe/daemon.rb +15 -12
- data/lib/tac_scribe/event_processor.rb +14 -1
- data/lib/tac_scribe/event_queue.rb +1 -1
- data/lib/tac_scribe/version.rb +1 -1
- data/tac_scribe.gemspec +1 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f53013c85197970f92c1b1d77608bbb6c0f6d7d70b09640a4d566282ecd2ecd0
|
4
|
+
data.tar.gz: e05a92c6f3da05c2f2925bb0ab18740ec31e3629906c56472e3fa94b5c1891c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54e42d58f65f1d4e49f1affc4211d8829d4b26a1dfc810c5656c37346e552fad692371c3e0738f7a7629d378d88e481aad570a1a8ab47e329cc2c91aac601f20
|
7
|
+
data.tar.gz: 71d84cd363227f4ffd2684e00c04ae97e714b74f25339f1cf004d5741c33bf770131d7fb51b2b346f112d575135549ef001c0cb6c71b914cf0a72310659c926b
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
jruby
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.3.0] - 2019-10-27
|
10
|
+
### Changed
|
11
|
+
- Changed the command-line name to match gem
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
- Sleep between connection attempts
|
15
|
+
|
16
|
+
### Added
|
17
|
+
- Unit type filtering
|
18
|
+
|
9
19
|
## [0.2.1] - 2019-10-13
|
10
20
|
### Changed
|
11
21
|
- Added separate events in / events out for the queue logging
|
data/README.md
CHANGED
@@ -21,9 +21,32 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
You can run the tool using the `
|
24
|
+
You can run the tool using the `tac_scribe` command. Use the `--help`
|
25
25
|
option for information on required arguments
|
26
26
|
|
27
|
+
### Whitelist
|
28
|
+
|
29
|
+
If you want to restrict what units get written to the database (e.g. for
|
30
|
+
performance reasons) then create a whitelist file and pass that in with
|
31
|
+
the whitelist option. For example if you only care about air units
|
32
|
+
and landing areas create a file like the following:
|
33
|
+
|
34
|
+
`whitelist.txt`
|
35
|
+
|
36
|
+
With the following content
|
37
|
+
|
38
|
+
```
|
39
|
+
Sea+Watercraft+AircraftCarrier
|
40
|
+
Air+Rotorcraft
|
41
|
+
Air+FixedWing
|
42
|
+
Ground+Static+Aerodrome
|
43
|
+
Navaid+Static+Bullseye
|
44
|
+
```
|
45
|
+
|
46
|
+
and add `-w whitelist.txt` to the command-line.
|
47
|
+
|
48
|
+
The unit type is the type provided by Tacview and it must be an exact match
|
49
|
+
|
27
50
|
## Development
|
28
51
|
|
29
52
|
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
@@ -15,7 +15,8 @@ options = {
|
|
15
15
|
db_name: 'tac_scribe',
|
16
16
|
verbose_logging: false,
|
17
17
|
threads: 1,
|
18
|
-
populate_airfields: false
|
18
|
+
populate_airfields: false,
|
19
|
+
whitelist: nil
|
19
20
|
}
|
20
21
|
|
21
22
|
OptionParser.new do |opts|
|
@@ -76,6 +77,10 @@ OptionParser.new do |opts|
|
|
76
77
|
'Verbose logging') do |_v|
|
77
78
|
options[:verbose] = true
|
78
79
|
end
|
80
|
+
opts.on('-w', '--whitelist=whitelist',
|
81
|
+
'Whitelist filename') do |v|
|
82
|
+
options[:whitelist] = v
|
83
|
+
end
|
79
84
|
end.parse!
|
80
85
|
|
81
86
|
%i[db_user db_password].each do |parameter|
|
@@ -99,5 +104,6 @@ TacScribe::Daemon.new(
|
|
99
104
|
db_password: options[:db_password],
|
100
105
|
verbose_logging: options[:verbose],
|
101
106
|
thread_count: options[:threads].to_i,
|
102
|
-
populate_airfields: options[:populate_airfields]
|
107
|
+
populate_airfields: options[:populate_airfields],
|
108
|
+
whitelist: options[:whitelist]
|
103
109
|
).start_processing
|
data/lib/tac_scribe/daemon.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'tacview_client'
|
5
|
+
require 'set'
|
5
6
|
require_relative 'datastore'
|
6
7
|
require_relative 'event_queue'
|
7
8
|
require_relative 'event_processor'
|
@@ -13,7 +14,7 @@ module TacScribe
|
|
13
14
|
def initialize(db_host:, db_port:, db_name:, db_user:, db_password:,
|
14
15
|
tacview_host:, tacview_port:, tacview_password:,
|
15
16
|
tacview_client_name:, verbose_logging:, thread_count:,
|
16
|
-
populate_airfields:)
|
17
|
+
populate_airfields:, whitelist: nil)
|
17
18
|
Datastore.instance.configure do |config|
|
18
19
|
config.host = db_host
|
19
20
|
config.port = db_port
|
@@ -28,6 +29,7 @@ module TacScribe
|
|
28
29
|
@populate_airfields = populate_airfields
|
29
30
|
@thread_count = thread_count
|
30
31
|
@processing_threads = []
|
32
|
+
@whitelist = Set.new(IO.read(whitelist).split) if whitelist
|
31
33
|
|
32
34
|
@client = TacviewClient::Client.new(
|
33
35
|
host: tacview_host,
|
@@ -51,7 +53,6 @@ module TacScribe
|
|
51
53
|
start_processing_threads
|
52
54
|
populate_airfields if @populate_airfields
|
53
55
|
@client.connect
|
54
|
-
sleep 30
|
55
56
|
# Rescuing reliably from Net::HTTP is a complete bear so rescue
|
56
57
|
# StandardError. It ain't pretty but it is reliable. We will puts
|
57
58
|
# the exception just in case
|
@@ -59,6 +60,7 @@ module TacScribe
|
|
59
60
|
rescue StandardError => e
|
60
61
|
puts e.message
|
61
62
|
puts e.backtrace
|
63
|
+
sleep 30
|
62
64
|
next
|
63
65
|
end
|
64
66
|
end
|
@@ -74,7 +76,8 @@ module TacScribe
|
|
74
76
|
@thread_count.times do
|
75
77
|
@processing_threads << Thread.new do
|
76
78
|
EventProcessor.new(datastore: Datastore.instance,
|
77
|
-
event_queue: @event_queue
|
79
|
+
event_queue: @event_queue,
|
80
|
+
whitelist: @whitelist).start
|
78
81
|
end
|
79
82
|
end
|
80
83
|
end
|
@@ -83,15 +86,15 @@ module TacScribe
|
|
83
86
|
json = File.read(File.join(File.dirname(__FILE__), '../../data/airfields.json'))
|
84
87
|
airfields = JSON.parse(json)
|
85
88
|
airfields.each_with_index do |airfield, i|
|
86
|
-
@event_queue.update_object(
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
89
|
+
@event_queue.update_object(
|
90
|
+
object_id: (45_000_000 + i).to_s,
|
91
|
+
latitude: BigDecimal(airfield['lat'].to_s),
|
92
|
+
longitude: BigDecimal(airfield['lon'].to_s),
|
93
|
+
altitude: BigDecimal(airfield['alt'].to_s),
|
94
|
+
type: 'Ground+Static+Aerodrome',
|
95
|
+
name: airfield['name'],
|
96
|
+
coalition: 2
|
97
|
+
)
|
95
98
|
end
|
96
99
|
end
|
97
100
|
end
|
@@ -2,14 +2,18 @@
|
|
2
2
|
|
3
3
|
require 'tacview_client/base_processor'
|
4
4
|
require 'time'
|
5
|
+
require 'concurrent-ruby'
|
5
6
|
require_relative 'datastore'
|
6
7
|
|
7
8
|
module TacScribe
|
8
9
|
# Processes the events emitted by the Ruby Tacview Client
|
9
10
|
class EventProcessor
|
10
|
-
|
11
|
+
@@ignored_units = Concurrent::Set.new
|
12
|
+
|
13
|
+
def initialize(datastore:, event_queue:, whitelist: nil)
|
11
14
|
@datastore = datastore
|
12
15
|
@event_queue = event_queue
|
16
|
+
@whitelist = whitelist
|
13
17
|
end
|
14
18
|
|
15
19
|
def start
|
@@ -52,6 +56,13 @@ module TacScribe
|
|
52
56
|
# @option event [BigDecimal] :altitude The object altitude above sea level
|
53
57
|
# in meters to 1 decimal place.
|
54
58
|
def update_object(event, time)
|
59
|
+
return if @@ignored_units.include?(event[:object_id])
|
60
|
+
|
61
|
+
if @whitelist && event[:type] && !@whitelist.include?(event[:type])
|
62
|
+
@@ignored_units << event[:object_id]
|
63
|
+
return
|
64
|
+
end
|
65
|
+
|
55
66
|
if @event_queue.reference_latitude || @event_queue.reference_longitude
|
56
67
|
localize_position(event)
|
57
68
|
end
|
@@ -64,6 +75,8 @@ module TacScribe
|
|
64
75
|
# @param object_id [String] A hexadecimal number representing the object
|
65
76
|
# ID
|
66
77
|
def delete_object(object_id)
|
78
|
+
return if @@ignored_units.delete?(object_id)
|
79
|
+
|
67
80
|
@datastore.delete_object(object_id)
|
68
81
|
end
|
69
82
|
|
@@ -18,7 +18,7 @@ module TacScribe
|
|
18
18
|
|
19
19
|
Thread.new do
|
20
20
|
loop do
|
21
|
-
puts "#{Time.now.strftime(
|
21
|
+
puts "#{Time.now.strftime('%FT%T')} - Queue Size: #{@events.size} \t Events Added: #{@event_write} \t Events Processed: #{@event_read}"
|
22
22
|
@event_write = 0
|
23
23
|
@event_read = 0
|
24
24
|
sleep 1
|
data/lib/tac_scribe/version.rb
CHANGED
data/tac_scribe.gemspec
CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
# The following gem is newish and not heavily updated so the chances
|
38
38
|
# of an API breaking change are higher then normal. Therefore lock the
|
39
39
|
# version
|
40
|
+
spec.add_dependency 'concurrent-ruby', '~>1.1.5'
|
40
41
|
spec.add_dependency 'sequel-postgis-georuby', '0.1.2'
|
41
42
|
spec.add_dependency 'tacview_client', '~>0.1'
|
42
43
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tac_scribe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Jeffrey Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.22'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.1.5
|
61
|
+
name: concurrent-ruby
|
62
|
+
prerelease: false
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.5
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
requirement: !ruby/object:Gem::Requirement
|
57
71
|
requirements:
|
@@ -168,7 +182,7 @@ description: Write Tacview data to PostGIS database
|
|
168
182
|
email:
|
169
183
|
- jeff@jones.be
|
170
184
|
executables:
|
171
|
-
-
|
185
|
+
- tac_scribe
|
172
186
|
extensions: []
|
173
187
|
extra_rdoc_files: []
|
174
188
|
files:
|
@@ -189,7 +203,7 @@ files:
|
|
189
203
|
- data/airfields.json
|
190
204
|
- db/001_create_unit_table.rb
|
191
205
|
- db/README.md
|
192
|
-
- exe/
|
206
|
+
- exe/tac_scribe
|
193
207
|
- lib/tac_scribe.rb
|
194
208
|
- lib/tac_scribe/daemon.rb
|
195
209
|
- lib/tac_scribe/datastore.rb
|