tac_scribe 0.7.1 → 0.7.3.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '099cde73f8075ae6ce15559bb91931382992c4182f78656beab7846adb7a7ba4'
4
- data.tar.gz: ffd9790d498398f6bb4777d50fecb2aeb426af5484d766be55c3f04aa18934cb
3
+ metadata.gz: d9a4c4ff87f88c46b4a02e0cd8a0ac729f9932b5a82db7b8851aa9180183e0f9
4
+ data.tar.gz: 3011df9a3162d4209bd12f5d6a1383de4e4f26f624316112dcf6c973f8bfabbc
5
5
  SHA512:
6
- metadata.gz: 74ff0905ea7250214c73287bd17b85d82002c3bcaa74c13618a7887a20298ba0b4e0f2b54476a4cc36f0f2d579dced61c63b345e4fbe4892de91ac235343c16d
7
- data.tar.gz: 607fb4c5f77035783ec06fe0382aad023d45e26c3b08dc163a2293e957a3937c298107dd80613dc74b5e21d04283fa557bdbcfddee4fd9bf179c068a844d8a5f
6
+ metadata.gz: 5434ff0ddcae2e7f9036695851b5a309b5d33a28f2b7be01a3fe61914aedb0f99fe2e5e4b7260c5b0da1f86e780e6761ec80c8de3fbad94ade95c4375b380066
7
+ data.tar.gz: 38b1e100620beed93ce87f813cdcbbe42646cfbc1e3bba8ac59ee564f1b219ca96f7e3959fb171fb2f7e5ce19dd6217c767940f5758bec1954fa43cdf0f28b19
@@ -4,38 +4,48 @@ 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
- ## [0.7.1]
7
+ ## [Unreleased]
8
+
9
+ ## [0.7.3] - 2020-08-10
10
+ ### Changed
11
+ - Bug fixes after adding CinC support.
12
+
13
+ ## [0.7.2] - 2020-08-10
14
+ ### Added
15
+ - Support for "Commander-In-Chief" to get airbase information
16
+
17
+ ## [0.7.1] - 2020-08-10
8
18
  ### Changed
9
19
  - Fixed issue where "name" fields were not being populated
10
20
  if airfields were not being loaded first
11
21
 
12
- ## [0.7.0]
22
+ ## [0.7.0] - 2020-07-5
13
23
  ### Changed
14
24
  - Synced Lat/Lon calculations with DCS and fixed issue where
15
25
  calculations were incorrect if only one value was updated
16
26
 
17
- ## [0.6.2]
27
+ ## [0.6.2] - 2020-04-19
18
28
  ### Changed
19
29
  - Fixed typo causing app to fail
20
30
 
21
- ## [0.6.1]
31
+ ## [0.6.1] - 2020-04-19
22
32
  ### Changed
23
33
  - Test build for gem issue
24
34
 
25
- ## [0.6.0]
35
+ ## [0.6.0] - 2020-04-19
26
36
  ### Added
27
37
  - Calculates and stores speed of units
28
38
 
29
39
  ### Fixed
30
40
  - Made more robust against failures and more logging messages
31
41
 
32
- ## [0.5.0]
42
+ ## [0.5.0] - 2020-03-17
33
43
  ### Changed
34
44
  - Added missing db column to migration file
35
45
  - Clear the cache on server restart
36
46
  - Add more info to logging
37
47
 
38
- ## [0.4.0]
48
+ ## [0.4.0] - 2020-03-13
39
49
  ### Changed
40
50
  - Switch to periodic writing to the database
41
51
 
@@ -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
@@ -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]
@@ -39,7 +40,9 @@ module TacScribe
39
40
  end
40
41
 
41
42
  # https://wiki.hoggitworld.com/view/DCS_singleton_coalition
42
- if object[: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)
43
46
  object[:coalition] = case object[:coalition]
44
47
  when 'Enemies' # Enemies is Bluefor
45
48
  2
@@ -50,7 +53,15 @@ module TacScribe
50
53
  end
51
54
  end
52
55
 
53
- if cache_object
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
54
65
  object[:heading] = calculate_heading(cache_object, object)
55
66
  object[:speed] = calculate_speed(cache_object, object)
56
67
  cache_object.merge!(object)
@@ -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
- @client = TacviewClient::Client.new(
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
- @client.connect
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
@@ -70,7 +70,7 @@ module TacScribe
70
70
 
71
71
  # Hack to make sure the :name field is present so that it is included
72
72
  # in the SQL
73
- event[:name] = "" unless event.has_key?(:name)
73
+ event[:name] = nil unless event.has_key?(:name)
74
74
  event[:game_time] = time
75
75
 
76
76
  self.events_processed += 1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TacScribe
4
- VERSION = '0.7.1'
4
+ VERSION = '0.7.3.rc1'
5
5
  end
@@ -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'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tac_scribe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.3.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Jones
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: cinc
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.1'
118
+ type: :runtime
119
+ prerelease: false
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
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -258,9 +272,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
272
  version: '0'
259
273
  required_rubygems_version: !ruby/object:Gem::Requirement
260
274
  requirements:
261
- - - ">="
275
+ - - ">"
262
276
  - !ruby/object:Gem::Version
263
- version: '0'
277
+ version: 1.3.1
264
278
  requirements: []
265
279
  rubygems_version: 3.1.2
266
280
  signing_key: