Module: GPSTool::Devices::RBT2300

Defined in:
lib/gpstool/devices/rbt-2300.rb,
lib/gpstool/devices/rbt-2300/data-parser.rb,
lib/gpstool/devices/rbt-2300/data-buckets.rb

Defined Under Namespace

Classes: DataBuckets, DataParser, Message

Constant Summary collapse

MAX_PACKET_SIZE =
0xF0

Class Method Summary collapse

Class Method Details

.estimate_packet_count(frame_sz, count) ⇒ Object


95
96
97
# File 'lib/gpstool/devices/rbt-2300.rb', line 95

def self.estimate_packet_count(frame_sz, count)
	((frame_sz * count).to_f / MAX_PACKET_SIZE).ceil.to_i
end

.floats_for_format(format) ⇒ Object


8
9
10
# File 'lib/gpstool/devices/rbt-2300/data-parser.rb', line 8

def self.floats_for_format(format)
	return 2 + format.to_i
end

.frame_size(format) ⇒ Object


12
13
14
15
# File 'lib/gpstool/devices/rbt-2300/data-parser.rb', line 12

def self.frame_size(format)
	# HEADER(4 bytes) + (sizeof(float) * count)
	return 4 + (floats_for_format(format) * 4)
end

.frames_per_packet(format) ⇒ Object


17
18
19
# File 'lib/gpstool/devices/rbt-2300/data-parser.rb', line 17

def self.frames_per_packet(format)
	return 240 / frame_size(format)
end

.parse_date(log) ⇒ Object


60
61
62
63
64
65
# File 'lib/gpstool/devices/rbt-2300.rb', line 60

def self.parse_date(log)
	log[:date].match(/([0-9]{4})([0-9]{2})([0-9]{2})/)
	date = Date.civil($1.to_i, $2.to_i, $3.to_i)

	return date
end

.read_log_data(data) ⇒ Object


88
89
90
91
92
93
# File 'lib/gpstool/devices/rbt-2300.rb', line 88

def self.read_log_data(data)
	header = data[0..3].unpack("CCC")
	data = data[3..-1]

	return header, data
end

.update_config(update_time, mode) ⇒ Object


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/gpstool/devices/rbt-2300.rb', line 67

def self.update_config(update_time, mode)
	update_time = update_time.to_i

	if update_time < 1 or update_time > 60
		raise ArgumentError.new("Update time must be between 1-60 inclusive.")
	end

	mode = mode.to_i

	if mode < 0 || mode > 3
		raise ArgumentError.new("Mode must be one of 0, 1, 2.")
	end

	a = 0
	b = update_time.to_i
	c = mode
	d = 0

	return Message.parse("PROY104,#{a},#{b},#{c},#{d}")
end