sgslib 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +40 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sgs/alarm.rb +103 -0
- data/lib/sgs/command.rb +167 -0
- data/lib/sgs/gps.rb +53 -0
- data/lib/sgs/location.rb +328 -0
- data/lib/sgs/logger.rb +96 -0
- data/lib/sgs/mission.rb +362 -0
- data/lib/sgs/navigate.rb +141 -0
- data/lib/sgs/nmea.rb +138 -0
- data/lib/sgs/otto.rb +163 -0
- data/lib/sgs/polar.rb +86 -0
- data/lib/sgs/redis_base.rb +251 -0
- data/lib/sgs/setup.rb +40 -0
- data/lib/sgs/timing.rb +45 -0
- data/lib/sgs/version.rb +3 -0
- data/lib/sgs/waypoint.rb +115 -0
- data/lib/sgslib.rb +46 -0
- data/sgslib.gemspec +35 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fc3371c28ba4e23106c0a6ec7438269c4e127a4
|
4
|
+
data.tar.gz: 513b37fe44496a798e3c9a332fa7446bd35d7a93
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cc840557ca82d76640c300cd2fb93745da198f5827444ff38afd84c2a11aabfd429dcfd600cc54ea30020c28acecd2a9b5719f820a8d277e8060e5ed97e20d73
|
7
|
+
data.tar.gz: a574b15c37a867713b01cf4583edfafa4623461c433d30ad87512d47b507d76224abe8b91aaaefed6ad65d4a3e8d57ed46f1921ce8e461aebd41f5fa3a8979b9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at tynan@hpe.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dermot Tynan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Sailboat Guidance System
|
2
|
+
|
3
|
+
The Sailboat Guidance System is a Ruby gem for managing an autonomous, robotic sailboat.
|
4
|
+
As it stands, it is quite specific to the [Beoga Beag](http://beogabeag.com) boat, but
|
5
|
+
this will change, over time.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sgslib'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sgslib
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sgs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sgslib"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/sgs/alarm.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013, Kalopa Research. All rights reserved. This is free
|
3
|
+
# software; you can redistribute it and/or modify it under the terms of the
|
4
|
+
# GNU General Public License as published by the Free Software Foundation;
|
5
|
+
# either version 2, or (at your option) any later version.
|
6
|
+
#
|
7
|
+
# It is distributed in the hope that it will be useful, but WITHOUT
|
8
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
10
|
+
# for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License along
|
13
|
+
# with this product; see the file COPYING. If not, write to the Free
|
14
|
+
# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA RESEARCH "AS IS" AND ANY EXPRESS OR
|
17
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19
|
+
# IN NO EVENT SHALL KALOPA RESEARCH BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
21
|
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
22
|
+
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
23
|
+
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
#
|
27
|
+
|
28
|
+
##
|
29
|
+
# Routines for handling sailboat alarms. Note that this is the definitive
|
30
|
+
# list of alarms on the system. To add or modify an alarm, do so here.
|
31
|
+
#
|
32
|
+
require 'date'
|
33
|
+
|
34
|
+
module SGS
|
35
|
+
##
|
36
|
+
# Deal with alarm subsystem.
|
37
|
+
#
|
38
|
+
class Alarm < RedisBase
|
39
|
+
attr_accessor :last_report, :time
|
40
|
+
|
41
|
+
OTTO_RESTART = 0
|
42
|
+
RUDDSRV_FAULT = 1
|
43
|
+
SAILSRV_FAULT = 2
|
44
|
+
VBATT_CRITICAL = 3
|
45
|
+
VBATT_UNDERVOLTAGE = 4
|
46
|
+
VBATT_OVERVOLTAGE = 5
|
47
|
+
IBATT_INRUSH = 6
|
48
|
+
IBATT_DRAIN = 7
|
49
|
+
VSOLAR_OVERVOLTAGE = 8
|
50
|
+
COMPASS_ERROR = 9
|
51
|
+
COMPASS_NOREAD = 10
|
52
|
+
WDI_STUCK = 11
|
53
|
+
WDI_NOREAD = 12
|
54
|
+
RUDDER_NOZERO = 13
|
55
|
+
SAIL_NOZERO = 14
|
56
|
+
MOTHER_UNRESP = 15
|
57
|
+
|
58
|
+
MISSION_COMMENCE = 16
|
59
|
+
MISSION_COMPLETE = 17
|
60
|
+
MISSION_ABORT = 18
|
61
|
+
WAYPOINT_REACHED = 19
|
62
|
+
CROSS_TRACK_ERROR = 20
|
63
|
+
INSIDE_FENCE = 21
|
64
|
+
|
65
|
+
MESSAGES = [
|
66
|
+
"OTTO Restarted",
|
67
|
+
"Rudder Servo Fault",
|
68
|
+
"Sail Servo Fault",
|
69
|
+
"Battery voltage is critically low",
|
70
|
+
"Battery voltage is low",
|
71
|
+
"Battery voltage is too high",
|
72
|
+
"Battery inrush current",
|
73
|
+
"Battery drain current",
|
74
|
+
"Solar voltage is too high",
|
75
|
+
"Compass module error",
|
76
|
+
"Compass not responding",
|
77
|
+
"WDI reading is misaligned",
|
78
|
+
"Cannot read from the WDI",
|
79
|
+
"Cannot zero the rudder position",
|
80
|
+
"Cannot zero the sail position",
|
81
|
+
"Mother is unresponsive",
|
82
|
+
"Mission has commenced",
|
83
|
+
"Mission is completed",
|
84
|
+
"*** MISSION ABORT ***",
|
85
|
+
"Waypoint has been reached",
|
86
|
+
"Significant cross-track error",
|
87
|
+
"Vessel is inside the fence"
|
88
|
+
].freeze
|
89
|
+
|
90
|
+
def initialize
|
91
|
+
@count = 0
|
92
|
+
@last_report = nil
|
93
|
+
@time = Array.new(32, Time.at(0))
|
94
|
+
super
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Convert an alarm number into a string.
|
99
|
+
def name(alarmno)
|
100
|
+
MESSAGES[alarmno]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/sgs/command.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013, Kalopa Research. All rights reserved. This is free
|
3
|
+
# software; you can redistribute it and/or modify it under the terms of the
|
4
|
+
# GNU General Public License as published by the Free Software Foundation;
|
5
|
+
# either version 2, or (at your option) any later version.
|
6
|
+
#
|
7
|
+
# It is distributed in the hope that it will be useful, but WITHOUT
|
8
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
10
|
+
# for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License along
|
13
|
+
# with this product; see the file COPYING. If not, write to the Free
|
14
|
+
# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA RESEARCH "AS IS" AND ANY EXPRESS OR
|
17
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19
|
+
# IN NO EVENT SHALL KALOPA RESEARCH BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
21
|
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
22
|
+
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
23
|
+
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
#
|
27
|
+
|
28
|
+
##
|
29
|
+
# Routines for handling sailboat alarms. Note that this is the definitive
|
30
|
+
# list of alarms on the system. To add or modify an alarm, do so here.
|
31
|
+
#
|
32
|
+
module SGS
|
33
|
+
##
|
34
|
+
# Deal with command subsystem.
|
35
|
+
#
|
36
|
+
# This code handles the Fonz packet commands.
|
37
|
+
#
|
38
|
+
class Command < RedisBase
|
39
|
+
attr_accessor :last_received, :time
|
40
|
+
|
41
|
+
FONZ_PING = 0
|
42
|
+
FONZ_MAGIC = 1
|
43
|
+
FONZ_ACK = 2
|
44
|
+
|
45
|
+
FONZ_GET_TIMEL = 4
|
46
|
+
FONZ_TIME_DATAL = 5
|
47
|
+
FONZ_GET_TIMEH = 6
|
48
|
+
FONZ_TIME_DATAH = 7
|
49
|
+
|
50
|
+
FONZ_GET_VOLTS1 = 8
|
51
|
+
FONZ_VOLTS1_DATA = 9
|
52
|
+
FONZ_GET_VOLTS2 = 10
|
53
|
+
FONZ_VOLTS2_DATA = 11
|
54
|
+
FONZ_GET_VOLTS3 = 12
|
55
|
+
FONZ_VOLTS3_DATA = 13
|
56
|
+
FONZ_GET_VOLTS4 = 14
|
57
|
+
FONZ_VOLTS4_DATA = 15
|
58
|
+
FONZ_GET_VOLTS5 = 16
|
59
|
+
FONZ_VOLTS5_DATA = 17
|
60
|
+
FONZ_GET_VOLTS6 = 18
|
61
|
+
FONZ_VOLTS6_DATA = 19
|
62
|
+
FONZ_GET_VOLTS7 = 20
|
63
|
+
FONZ_VOLTS7_DATA = 21
|
64
|
+
FONZ_GET_VOLTS8 = 22
|
65
|
+
FONZ_VOLTS8_DATA = 23
|
66
|
+
|
67
|
+
FONZ_GET_CURR1 = 24
|
68
|
+
FONZ_CURR1_DATA = 25
|
69
|
+
FONZ_GET_CURR2 = 26
|
70
|
+
FONZ_CURR2_DATA = 27
|
71
|
+
FONZ_GET_CURR3 = 28
|
72
|
+
FONZ_CURR3_DATA = 29
|
73
|
+
FONZ_GET_CURR4 = 30
|
74
|
+
FONZ_CURR4_DATA = 31
|
75
|
+
FONZ_GET_CURR5 = 32
|
76
|
+
FONZ_CURR5_DATA = 33
|
77
|
+
FONZ_GET_CURR6 = 34
|
78
|
+
FONZ_CURR6_DATA = 35
|
79
|
+
FONZ_GET_CURR7 = 36
|
80
|
+
FONZ_CURR7_DATA = 37
|
81
|
+
FONZ_GET_CURR8 = 38
|
82
|
+
FONZ_CURR8_DATA = 39
|
83
|
+
|
84
|
+
FONZ_GET_ALARMS = 40
|
85
|
+
FONZ_ALARM_RAISE = 41
|
86
|
+
|
87
|
+
FONZ_GET_OTTORST = 42
|
88
|
+
FONZ_OTTORST_DATA = 43
|
89
|
+
FONZ_GET_MISSION = 44
|
90
|
+
FONZ_MISSION_DATA = 45
|
91
|
+
FONZ_GET_COMPASS = 46
|
92
|
+
FONZ_COMPASS_DATA = 47
|
93
|
+
FONZ_GET_TWA = 48
|
94
|
+
FONZ_TWA_DATA = 49
|
95
|
+
FONZ_GET_RUDDER = 50
|
96
|
+
FONZ_RUDDER_DATA = 51
|
97
|
+
FONZ_GET_SAIL = 52
|
98
|
+
FONZ_SAIL_DATA = 53
|
99
|
+
FONZ_GET_PDOWN = 54
|
100
|
+
FONZ_PDOWN_DATA = 55
|
101
|
+
FONZ_GET_NAVLIGHT = 56
|
102
|
+
FONZ_NAVLIGHT_DATA = 57
|
103
|
+
FONZ_GET_BUZZER = 58
|
104
|
+
FONZ_BUZZER_DATA = 59
|
105
|
+
|
106
|
+
FONZ_GET_EEADDR = 60
|
107
|
+
FONZ_SET_EEADDR = 61
|
108
|
+
FONZ_GET_EEDATA = 62
|
109
|
+
FONZ_SET_EEDATA = 63
|
110
|
+
|
111
|
+
MESSAGES = [
|
112
|
+
"Ping", "Magic Word",
|
113
|
+
"ACK", "??",
|
114
|
+
"Get Time (Lo)", "Time Data (Lo)",
|
115
|
+
"Get Time (Hi)", "Time Data (Hi)",
|
116
|
+
"Get Voltage1", "Voltage1 Data",
|
117
|
+
"Get Voltage2", "Voltage2 Data",
|
118
|
+
"Get Voltage3", "Voltage3 Data",
|
119
|
+
"Get Voltage4", "Voltage4 Data",
|
120
|
+
"Get Voltage5", "Voltage5 Data",
|
121
|
+
"Get Voltage6", "Voltage6 Data",
|
122
|
+
"Get Voltage7", "Voltage7 Data",
|
123
|
+
"Get Voltage8", "Voltage8 Data",
|
124
|
+
"Get Current1", "Current1 Data",
|
125
|
+
"Get Current2", "Current2 Data",
|
126
|
+
"Get Current3", "Current3 Data",
|
127
|
+
"Get Current4", "Current4 Data",
|
128
|
+
"Get Current5", "Current5 Data",
|
129
|
+
"Get Current6", "Current6 Data",
|
130
|
+
"Get Current7", "Current7 Data",
|
131
|
+
"Get Current8", "Current8 Data",
|
132
|
+
"Get Alarms", "Alarm Raised!",
|
133
|
+
"Get Otto Reset", "Otto Reset Status",
|
134
|
+
"Get Mission", "Mission Data",
|
135
|
+
"Get Compass", "Compass Data",
|
136
|
+
"Get TWA", "TWA Data",
|
137
|
+
"Get Rudder Position", "Rudder Position Data",
|
138
|
+
"Get Sail Trim", "Sail Trim Data",
|
139
|
+
"Get Power Down", "Time to Power Down",
|
140
|
+
"Get Nav Light", "Nav Light Status",
|
141
|
+
"Get Buzzer", "Buzzer Status",
|
142
|
+
"Get EEPROM Address", "Set EEPROM Address",
|
143
|
+
"Get EEPROM Data", "Set EEPROM Data"
|
144
|
+
].freeze
|
145
|
+
|
146
|
+
def initialize
|
147
|
+
@count = 0
|
148
|
+
@last_report = nil
|
149
|
+
@time = Array.new(32, Time.at(0))
|
150
|
+
super
|
151
|
+
end
|
152
|
+
|
153
|
+
#
|
154
|
+
# Convert a command code into a string.
|
155
|
+
def name(code)
|
156
|
+
(code < MESSAGES.count) ? MESSAGES[code] : nil
|
157
|
+
end
|
158
|
+
|
159
|
+
#
|
160
|
+
# Send a command to the microcontroller
|
161
|
+
def send_command(cmd, arg = nil)
|
162
|
+
puts "Send command #{cmd} (#{name(cmd)})"
|
163
|
+
puts "Arg is #{arg}" if arg
|
164
|
+
return 0
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
data/lib/sgs/gps.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013, Kalopa Research. All rights reserved. This is free
|
3
|
+
# software; you can redistribute it and/or modify it under the terms of the
|
4
|
+
# GNU General Public License as published by the Free Software Foundation;
|
5
|
+
# either version 2, or (at your option) any later version.
|
6
|
+
#
|
7
|
+
# It is distributed in the hope that it will be useful, but WITHOUT
|
8
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
9
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
10
|
+
# for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU General Public License along
|
13
|
+
# with this product; see the file COPYING. If not, write to the Free
|
14
|
+
# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY KALOPA RESEARCH "AS IS" AND ANY EXPRESS OR
|
17
|
+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
18
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
19
|
+
# IN NO EVENT SHALL KALOPA RESEARCH BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
21
|
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
22
|
+
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
23
|
+
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
#
|
27
|
+
module SGS
|
28
|
+
class GPS < RedisBase
|
29
|
+
attr_accessor :time, :location, :sog, :cmg, :magvar
|
30
|
+
|
31
|
+
def initialize(lat = nil, long = nil)
|
32
|
+
@time = Time.new(2000, 1, 1)
|
33
|
+
@location = Location.new(lat, long)
|
34
|
+
@sog = 0.0
|
35
|
+
@cmg = 0.0
|
36
|
+
@magvar = nil
|
37
|
+
@valid = false
|
38
|
+
super()
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Set the validity
|
43
|
+
def is_valid
|
44
|
+
@valid = true
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Is the GPS data valid?
|
49
|
+
def valid?
|
50
|
+
@valid == true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|