tac_scribe 0.6.4-java → 0.7.4-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 +29 -5
- data/exe/tac_scribe +21 -1
- data/lib/tac_scribe/cache.rb +22 -10
- data/lib/tac_scribe/daemon.rb +37 -4
- data/lib/tac_scribe/event_processor.rb +3 -0
- data/lib/tac_scribe/version.rb +1 -1
- data/tac_scribe.gemspec +4 -2
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d3c391d45f97fa714cfb09bffa0d39dabe856d8134c417161b04288284f0d96
|
4
|
+
data.tar.gz: 9ccac0c9cfec6c821ddd5d586d3217114d97e9126781cc4bf02139c7d8dda296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce1858aad7fd25207d5f389cf6f81e82842c99bc75cdedba90efef1b8ad53c22ffe6a367eed95c7d5f35eda951f9812ca163a18c6c9460d7e8b3d9c058eb1847
|
7
|
+
data.tar.gz: ff8af8ccb4d0f1d00e09e780cf54dca943ec2a3426a4f8cc33c6333f06ce7bdab9a1ccffcb69723af132c96da826e4a9206364152597f48234e1179f372c9cb4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.7.0
|
data/CHANGELOG.md
CHANGED
@@ -4,28 +4,52 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.7.4] - 2020-08-10
|
10
|
+
### Changed
|
11
|
+
^ Fix typo that was causing all objects to be registered as airbases
|
12
|
+
|
13
|
+
## [0.7.3] - 2020-08-10
|
14
|
+
### Changed
|
15
|
+
- Bug fixes after adding CinC support
|
16
|
+
|
17
|
+
## [0.7.2] - 2020-08-10
|
18
|
+
### Added
|
19
|
+
- Support for "Commander-In-Chief" to get airbase information
|
20
|
+
|
21
|
+
## [0.7.1] - 2020-08-10
|
22
|
+
### Changed
|
23
|
+
- Fixed issue where "name" fields were not being populated
|
24
|
+
if airfields were not being loaded first
|
25
|
+
|
26
|
+
## [0.7.0] - 2020-07-5
|
27
|
+
### Changed
|
28
|
+
- Synced Lat/Lon calculations with DCS and fixed issue where
|
29
|
+
calculations were incorrect if only one value was updated
|
30
|
+
|
31
|
+
## [0.6.2] - 2020-04-19
|
8
32
|
### Changed
|
9
33
|
- Fixed typo causing app to fail
|
10
34
|
|
11
|
-
## [0.6.1]
|
35
|
+
## [0.6.1] - 2020-04-19
|
12
36
|
### Changed
|
13
37
|
- Test build for gem issue
|
14
38
|
|
15
|
-
## [0.6.0]
|
39
|
+
## [0.6.0] - 2020-04-19
|
16
40
|
### Added
|
17
41
|
- Calculates and stores speed of units
|
18
42
|
|
19
43
|
### Fixed
|
20
44
|
- Made more robust against failures and more logging messages
|
21
45
|
|
22
|
-
## [0.5.0]
|
46
|
+
## [0.5.0] - 2020-03-17
|
23
47
|
### Changed
|
24
48
|
- Added missing db column to migration file
|
25
49
|
- Clear the cache on server restart
|
26
50
|
- Add more info to logging
|
27
51
|
|
28
|
-
## [0.4.0]
|
52
|
+
## [0.4.0] - 2020-03-13
|
29
53
|
### Changed
|
30
54
|
- Switch to periodic writing to the database
|
31
55
|
|
data/exe/tac_scribe
CHANGED
@@ -10,6 +10,8 @@ options = {
|
|
10
10
|
tacview_port: 42_674,
|
11
11
|
tacview_password: nil,
|
12
12
|
tacview_client_name: 'TacScribe',
|
13
|
+
cinc_enabled: false,
|
14
|
+
cinc_port: 9000,
|
13
15
|
db_host: 'localhost',
|
14
16
|
db_port: 5432,
|
15
17
|
db_name: 'tac_scribe',
|
@@ -43,6 +45,17 @@ OptionParser.new do |opts|
|
|
43
45
|
options[:tacview_client_name] = v
|
44
46
|
end
|
45
47
|
|
48
|
+
opts.separator "\nCommander-In-Chief Options"
|
49
|
+
opts.on('-b', '--enable-cinc',
|
50
|
+
'Is Cinc enabled? (Default: false)') do |_v|
|
51
|
+
options[:cinc_enabled] = true
|
52
|
+
end
|
53
|
+
opts.on('-m', '--cinc-port=port',
|
54
|
+
'Cinc server port (Default: 9001)') do |v|
|
55
|
+
options[:cinc_port] = v
|
56
|
+
end
|
57
|
+
|
58
|
+
|
46
59
|
opts.separator "\nDatabase Options"
|
47
60
|
opts.on('-o', '--db-host=host',
|
48
61
|
'Postgresql server hostname / IP (Default: localhost)') do |v|
|
@@ -92,6 +105,11 @@ end.parse!
|
|
92
105
|
exit(1)
|
93
106
|
end
|
94
107
|
|
108
|
+
if(options[:populate_airfields] && options[:cinc_enabled])
|
109
|
+
puts "You cannot populate airfields AND enable Cinc at the same time"
|
110
|
+
exit(1)
|
111
|
+
end
|
112
|
+
|
95
113
|
TacScribe::Daemon.new(
|
96
114
|
tacview_host: options[:tacview_host],
|
97
115
|
tacview_port: options[:tacview_port],
|
@@ -105,5 +123,7 @@ TacScribe::Daemon.new(
|
|
105
123
|
verbose_logging: options[:verbose],
|
106
124
|
thread_count: options[:threads].to_i,
|
107
125
|
populate_airfields: options[:populate_airfields],
|
108
|
-
whitelist: options[:whitelist]
|
126
|
+
whitelist: options[:whitelist],
|
127
|
+
cinc_enabled: options[:cinc_enabled],
|
128
|
+
cinc_port: options[:cinc_port]
|
109
129
|
).start_processing
|
data/lib/tac_scribe/cache.rb
CHANGED
@@ -23,11 +23,12 @@ module TacScribe
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def write_object(object)
|
26
|
-
if reference_latitude != 0 || reference_longitude != 0
|
26
|
+
if (reference_latitude != 0 || reference_longitude != 0) && object[:type] != "Ground+Static+Aerodrome"
|
27
27
|
localize_position(object)
|
28
28
|
end
|
29
29
|
|
30
30
|
id = object[:object_id]
|
31
|
+
id ||= object[:id].to_s
|
31
32
|
object[:id] = id
|
32
33
|
|
33
34
|
cache_object = @@cache[id]
|
@@ -38,18 +39,29 @@ module TacScribe
|
|
38
39
|
object.delete(key)
|
39
40
|
end
|
40
41
|
|
41
|
-
|
42
|
+
# https://wiki.hoggitworld.com/view/DCS_singleton_coalition
|
43
|
+
# Tacview returns a string, CinC returns an integer so we
|
44
|
+
# only do the conversion if there is a string.
|
45
|
+
if object[:coalition] && object[:coalition].is_a?(String)
|
42
46
|
object[:coalition] = case object[:coalition]
|
43
|
-
when '
|
44
|
-
0
|
45
|
-
when 'Enemies'
|
46
|
-
1
|
47
|
-
else
|
47
|
+
when 'Enemies' # Enemies is Bluefor
|
48
48
|
2
|
49
|
+
when 'Allies' # Allies is Redfor
|
50
|
+
1
|
51
|
+
else # Neutral
|
52
|
+
0
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
52
|
-
if
|
56
|
+
if object[:type] == "Ground+Static+Aerodrome"
|
57
|
+
object[:heading] = object[:wind_heading] ? object[:wind_heading] : 0
|
58
|
+
object[:speed] = object[:wind_speed] ? object[:wind_speec] : 0
|
59
|
+
object.delete(:wind_heading)
|
60
|
+
object.delete(:wind_speed)
|
61
|
+
object.delete(:category)
|
62
|
+
cache_object = object
|
63
|
+
# No-op
|
64
|
+
elsif cache_object
|
53
65
|
object[:heading] = calculate_heading(cache_object, object)
|
54
66
|
object[:speed] = calculate_speed(cache_object, object)
|
55
67
|
cache_object.merge!(object)
|
@@ -102,13 +114,13 @@ module TacScribe
|
|
102
114
|
longitude = if object.key?(:longitude)
|
103
115
|
object[:longitude]
|
104
116
|
else
|
105
|
-
cache_object[:position].
|
117
|
+
cache_object[:position].x
|
106
118
|
end
|
107
119
|
|
108
120
|
latitude = if object.key?(:latitude)
|
109
121
|
object[:latitude]
|
110
122
|
else
|
111
|
-
cache_object[:position].
|
123
|
+
cache_object[:position].y
|
112
124
|
end
|
113
125
|
|
114
126
|
# This "Point" class is not lat/long aware which is why we are
|
data/lib/tac_scribe/daemon.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'json'
|
4
4
|
require 'tacview_client'
|
5
5
|
require 'set'
|
6
|
+
require 'cinc'
|
6
7
|
require_relative 'datastore'
|
7
8
|
require_relative 'cache'
|
8
9
|
require_relative 'event_queue'
|
@@ -15,7 +16,7 @@ module TacScribe
|
|
15
16
|
def initialize(db_host:, db_port:, db_name:, db_user:, db_password:,
|
16
17
|
tacview_host:, tacview_port:, tacview_password:,
|
17
18
|
tacview_client_name:, verbose_logging:, thread_count:,
|
18
|
-
populate_airfields:, whitelist: nil)
|
19
|
+
populate_airfields:, whitelist: nil, cinc_enabled:, cinc_port:)
|
19
20
|
Datastore.instance.configure do |config|
|
20
21
|
config.host = db_host
|
21
22
|
config.port = db_port
|
@@ -34,13 +35,20 @@ module TacScribe
|
|
34
35
|
@threads = {}
|
35
36
|
@whitelist = Set.new(IO.read(whitelist).split) if whitelist
|
36
37
|
|
37
|
-
@
|
38
|
+
@tacview_client = TacviewClient::Client.new(
|
38
39
|
host: tacview_host,
|
39
40
|
port: tacview_port,
|
40
41
|
password: tacview_password,
|
41
42
|
processor: @event_queue,
|
42
43
|
client_name: tacview_client_name
|
43
44
|
)
|
45
|
+
|
46
|
+
if cinc_enabled
|
47
|
+
@cinc_client = Cinc::Client.new(
|
48
|
+
host: tacview_host,
|
49
|
+
port: cinc_port
|
50
|
+
)
|
51
|
+
end
|
44
52
|
end
|
45
53
|
|
46
54
|
# Starts processing and reconnects if the client was disconnected.
|
@@ -55,13 +63,14 @@ module TacScribe
|
|
55
63
|
Datastore.instance.truncate_table
|
56
64
|
Cache.instance.clear
|
57
65
|
start_processing_threads
|
66
|
+
start_cinc_thread
|
58
67
|
start_db_sync_thread
|
59
68
|
start_reporting_thread
|
60
69
|
populate_airfields if @populate_airfields
|
61
70
|
@threads.each_pair do |key, _value|
|
62
71
|
puts "#{key} thread started"
|
63
72
|
end
|
64
|
-
@
|
73
|
+
@tacview_client.connect
|
65
74
|
# If this code is executed it means we have been disconnected without
|
66
75
|
# exceptions. We will still sleep to stop a retry storm. Just not as
|
67
76
|
# long.
|
@@ -103,6 +112,30 @@ module TacScribe
|
|
103
112
|
@threads[:processing] = event_processor_thread
|
104
113
|
end
|
105
114
|
|
115
|
+
def start_cinc_thread
|
116
|
+
return unless @cinc_client
|
117
|
+
cinc_thread = Thread.new do
|
118
|
+
loop do
|
119
|
+
@cinc_client.connect
|
120
|
+
while true
|
121
|
+
@cinc_client.get_airbases.each do |airbase|
|
122
|
+
@event_queue.update_object Hash[airbase.map{ |k, v| [k.to_sym, v] }]
|
123
|
+
end
|
124
|
+
sleep 60
|
125
|
+
end
|
126
|
+
rescue StandardError => e
|
127
|
+
puts 'Exception in cinc thread'
|
128
|
+
puts e.message
|
129
|
+
puts e.backtrace
|
130
|
+
sleep 30
|
131
|
+
next
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
cinc_thread.name = 'Cinc Processor'
|
136
|
+
@threads[:cinc] = cinc_thread
|
137
|
+
end
|
138
|
+
|
106
139
|
def start_db_sync_thread
|
107
140
|
db_write_thread = Thread.new do
|
108
141
|
loop do
|
@@ -154,7 +187,7 @@ module TacScribe
|
|
154
187
|
altitude: BigDecimal(airfield['alt'].to_s),
|
155
188
|
type: 'Ground+Static+Aerodrome',
|
156
189
|
name: airfield['name'],
|
157
|
-
coalition:
|
190
|
+
coalition: 0 # Neutral
|
158
191
|
)
|
159
192
|
end
|
160
193
|
end
|
@@ -68,6 +68,9 @@ module TacScribe
|
|
68
68
|
def update_object(event, time)
|
69
69
|
return if ignore_unit?(event)
|
70
70
|
|
71
|
+
# Hack to make sure the :name field is present so that it is included
|
72
|
+
# in the SQL
|
73
|
+
event[:name] = nil unless event.has_key?(:name)
|
71
74
|
event[:game_time] = time
|
72
75
|
|
73
76
|
self.events_processed += 1
|
data/lib/tac_scribe/version.rb
CHANGED
data/tac_scribe.gemspec
CHANGED
@@ -26,11 +26,11 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.metadata['yard.run'] = 'yri'
|
28
28
|
|
29
|
+
spec.platform = RUBY_PLATFORM == 'java' ? 'java' : 'ruby'
|
30
|
+
|
29
31
|
if RUBY_PLATFORM == 'java'
|
30
|
-
spec.platform = 'java'
|
31
32
|
spec.add_dependency 'activerecord-jdbcpostgresql-adapter'
|
32
33
|
else
|
33
|
-
spec.platform = 'ruby'
|
34
34
|
spec.add_dependency 'pg', '~>1.1'
|
35
35
|
end
|
36
36
|
|
@@ -43,6 +43,7 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_dependency 'haversine', '~>0.3'
|
44
44
|
spec.add_dependency 'sequel-postgis-georuby', '0.1.2'
|
45
45
|
spec.add_dependency 'tacview_client', '~>0.1'
|
46
|
+
spec.add_dependency 'cinc', '~>0.1'
|
46
47
|
|
47
48
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
48
49
|
spec.add_development_dependency 'rake', '~> 10.0'
|
@@ -50,4 +51,5 @@ Gem::Specification.new do |spec|
|
|
50
51
|
spec.add_development_dependency 'rubocop', '~>0.73'
|
51
52
|
spec.add_development_dependency 'simplecov', '~>0.17'
|
52
53
|
spec.add_development_dependency 'yard', '~>0.9'
|
54
|
+
spec.add_development_dependency 'pry-byebug', '~>3.9'
|
53
55
|
end
|
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.7.4
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Jeffrey Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.1'
|
117
|
+
name: cinc
|
118
|
+
prerelease: false
|
119
|
+
type: :runtime
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.1'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
requirement: !ruby/object:Gem::Requirement
|
113
127
|
requirements:
|
@@ -192,6 +206,20 @@ dependencies:
|
|
192
206
|
- - "~>"
|
193
207
|
- !ruby/object:Gem::Version
|
194
208
|
version: '0.9'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
requirement: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - "~>"
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '3.9'
|
215
|
+
name: pry-byebug
|
216
|
+
prerelease: false
|
217
|
+
type: :development
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '3.9'
|
195
223
|
description: Write Tacview data to PostGIS database
|
196
224
|
email:
|
197
225
|
- jeff@jones.be
|