sgslib 1.7.1 → 1.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e111aaff75b5c948f935ac6f76747487c2a6acf2c4e661e07b5e670aa48024b
4
- data.tar.gz: 8b0dae14c6a69c2222e38522d3f7e562b45c33e754cf5019a9f0b081d6191fc6
3
+ metadata.gz: 7bdbf4fe47373b9771e9727d8a259d5ddfb545ee64ef51a3fb4b569d4d4e3e1f
4
+ data.tar.gz: 5664da38c87316350e921af2432f81079732f1942b8fd9896bb59107ea1e49f2
5
5
  SHA512:
6
- metadata.gz: 101b2c3581effba8bc0fae32d4c68030649104862101336409fdeb4679ff25236adf0b67dfeac588eceb0196a7616175cc1112d1d926ee6d528c95c60cbeed60
7
- data.tar.gz: 981bf2364b073ae0d25e0fea03341b289db890836af399c4cee4079d0dcde1ceef20f9669d3fdeb36d2ea143b6566830bcc676ea705bf9bb6439dc8162234e52
6
+ metadata.gz: 10336b0228e40cd9b86e51206d4c0f33bdbe0a456ae6ab99de6e0cc57b2cff569f459f0fb94d0658bea9e248da8cd2eec874fafa8fa0bc14e6b25f1cb45818e2
7
+ data.tar.gz: a358fd0c6a7eb67c091d857428a70c2ad738c2f98658cc1d7daf60b0dc83e8623e37c5bb2df4ed7c27de65928c20809d943a2f2263b5e5a8cd2db78e835c0e2c
data/lib/sgs/bearing.rb CHANGED
@@ -113,7 +113,7 @@ module SGS
113
113
  # This code was derived from formulae on the Movable Type site:
114
114
  # http://www.movable-type.co.uk/scripts/latlong.html
115
115
  #
116
- # var d = Math.acos(Math.sin(lat1)*Math.sin(lat2) +
116
+ # var d = Math.acos(Math.sin(lat1)*Math.sin(lat2) +
117
117
  # Math.cos(lat1)*Math.cos(lat2) *
118
118
  # Math.cos(lon2-lon1)) * R;
119
119
  # var y = Math.sin(dLon) * Math.cos(lat2);
data/lib/sgs/location.rb CHANGED
@@ -75,9 +75,9 @@ module SGS
75
75
  # This code was derived from formulae on the Movable Type site:
76
76
  # http://www.movable-type.co.uk/scripts/latlong.html
77
77
  #
78
- # var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
78
+ # var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
79
79
  # Math.cos(lat1)*Math.sin(d/R)*Math.cos(angle) );
80
- # var lon2 = lon1 + Math.atan2(Math.sin(angle)*Math.sin(d/R)*Math.cos(lat1),
80
+ # var lon2 = lon1 + Math.atan2(Math.sin(angle)*Math.sin(d/R)*Math.cos(lat1),
81
81
  # Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));
82
82
  def +(bearing)
83
83
  loc = Location.new
@@ -144,7 +144,7 @@ module SGS
144
144
  #
145
145
  # Is this location valid?
146
146
  def valid?
147
- @latitude and @longitude
147
+ !@latitude.nil? and !@longitude.nil?
148
148
  end
149
149
 
150
150
  #
data/lib/sgs/mission.rb CHANGED
@@ -166,7 +166,10 @@ module SGS
166
166
  hash["attractors"] << waypt.to_hash
167
167
  end
168
168
  hash["repellors"] = []
169
- hash
169
+ @repellors.each do |waypt|
170
+ hash["repellors"] << waypt.to_hash
171
+ end
172
+ return hash
170
173
  end
171
174
  end
172
175
  end
data/lib/sgs/navigate.rb CHANGED
@@ -142,6 +142,8 @@ module SGS
142
142
  best_course = new_course
143
143
  end
144
144
  end
145
+ puts "Best course:"
146
+ p best_course
145
147
  if best_course.tack != @course.tack
146
148
  puts "TACKING!!!!"
147
149
  end
data/lib/sgs/nmea.rb CHANGED
@@ -58,7 +58,7 @@ module SGS
58
58
  end
59
59
  nmea
60
60
  end
61
-
61
+
62
62
  #
63
63
  # Parse an NMEA string into its component parts.
64
64
  def parse(str)
data/lib/sgs/otto.rb CHANGED
@@ -112,7 +112,7 @@ module SGS
112
112
 
113
113
  #
114
114
  # Set up some useful defaults. We assume rudder goes from 0 to 255 as does
115
- # the sail angle.
115
+ # the sail angle.
116
116
  def initialize
117
117
  serial_port = nil
118
118
  #
@@ -255,8 +255,6 @@ module SGS
255
255
  cmd = "R%d=%X\r\n" % params
256
256
  puts "Command: #{cmd}"
257
257
  @serial_port.write cmd
258
- puts "> Sending command: #{str}"
259
- @serial_port.puts "#{str}"
260
258
  end
261
259
  end
262
260
 
@@ -294,7 +292,7 @@ module SGS
294
292
  # representing the elapsed seconds since Otto restarted.
295
293
  def parse_tstamp(tstamp)
296
294
  newval = tstamp.to_i(16)
297
- if newval < @otto_timestamp
295
+ if @otto_timestamp.nil? or newval < @otto_timestamp
298
296
  puts "ALARM! Otto rebooted (or something)..."
299
297
  end
300
298
  @otto_timestamp = newval
@@ -96,7 +96,7 @@ module SGS
96
96
  # It's an array - iterate and read the values.
97
97
  lval.size.times do |idx|
98
98
  idx_val = lval[idx]
99
- lval[idx] = redis_read_var var, idx_val.class, :idx => idx
99
+ lval[idx] = redis_read_var var, idx_val.class, :idx => idx
100
100
  end
101
101
  elsif lval.kind_of? Location
102
102
  #
@@ -206,7 +206,7 @@ module SGS
206
206
  case
207
207
  when klass == Time
208
208
  redis_val = Time.at(redis_val.to_f).gmtime
209
- when klass == Fixnum
209
+ when klass == Integer
210
210
  redis_val = redis_val.to_i
211
211
  when klass == Float
212
212
  redis_val = redis_val.to_f
data/lib/sgs/version.rb CHANGED
@@ -33,5 +33,5 @@
33
33
  # ABSTRACT
34
34
  #
35
35
  module SGS
36
- VERSION = "1.7.1"
36
+ VERSION = "1.8.1"
37
37
  end
data/lib/sgs/waypoint.rb CHANGED
@@ -137,7 +137,7 @@ module SGS
137
137
  hash["name"] = @name
138
138
  hash["normal"] = @normal
139
139
  hash["range"] = @range
140
- hash
140
+ return hash
141
141
  end
142
142
 
143
143
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sgslib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dermot Tynan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-31 00:00:00.000000000 Z
11
+ date: 2023-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
206
  requirements: []
207
- rubygems_version: 3.1.6
207
+ rubygems_version: 3.0.3.1
208
208
  signing_key:
209
209
  specification_version: 4
210
210
  summary: Sailboat Guidance System