Class: SGS::GPS

Inherits:
RedisBase show all
Defined in:
lib/sgs/gps.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RedisBase

#count, #count_name, #load, load, #make_redis_name, #publish, redis, redis_handle, #redis_read_var, #save, #save_and_publish, setup, subscribe, to_redis, var_init

Constructor Details

#initialize(lat = nil, long = nil) ⇒ GPS

Returns a new instance of GPS.



39
40
41
42
43
44
45
46
47
# File 'lib/sgs/gps.rb', line 39

def initialize(lat = nil, long = nil)
  @time = Time.new(2000, 1, 1)
  @location = Location.new(lat, long)
  @sog = 0.0
  @cmg = 0.0
  @magvar = nil
  @valid = false
  super()
end

Instance Attribute Details

#cmgObject

Returns the value of attribute cmg.



37
38
39
# File 'lib/sgs/gps.rb', line 37

def cmg
  @cmg
end

#locationObject

Returns the value of attribute location.



37
38
39
# File 'lib/sgs/gps.rb', line 37

def location
  @location
end

#magvarObject

Returns the value of attribute magvar.



37
38
39
# File 'lib/sgs/gps.rb', line 37

def magvar
  @magvar
end

#sogObject

Returns the value of attribute sog.



37
38
39
# File 'lib/sgs/gps.rb', line 37

def sog
  @sog
end

#timeObject

Returns the value of attribute time.



37
38
39
# File 'lib/sgs/gps.rb', line 37

def time
  @time
end

Class Method Details

.daemonObject

Main daemon function (called from executable)



51
52
53
54
55
# File 'lib/sgs/gps.rb', line 51

def self.daemon
  loop do
    sleep 300
  end
end

Instance Method Details

#is_validObject

Set the validity



59
60
61
# File 'lib/sgs/gps.rb', line 59

def is_valid
  @valid = true
end

#valid?Boolean

Is the GPS data valid?

Returns:

  • (Boolean)


65
66
67
# File 'lib/sgs/gps.rb', line 65

def valid?
  @valid == true
end