Class: F4R::GlobalFit::Helper
- Inherits:
-
Object
- Object
- F4R::GlobalFit::Helper
- Defined in:
- lib/f4r.rb
Overview
Helper class to get all types and messages in a usable format for F4R.
Instance Method Summary collapse
-
#get_base_types ⇒ Hash
Provides base types to base_types.
-
#get_messages ⇒ Array<Hash>
Provides messages to messages.
-
#get_types ⇒ Hash
Provides types to types.
Instance Method Details
#get_base_types ⇒ Hash
Provides base types to F4R::GlobalFit.base_types.
519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
# File 'lib/f4r.rb', line 519 def get_base_types csv = CSV.read(Config.directory + '/base_types.csv', converters: %i[numeric]) csv[1..-1].inject([]) do |r, row| r << { number: row[0], fit: row[1].to_sym, bindata: row[2].to_sym, bindata_en: row[3].to_sym, endian: row[4], bytes: row[5], undef: row[6], };r end end |
#get_messages ⇒ Array<Hash>
Provides messages to F4R::GlobalFit.messages.
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'lib/f4r.rb', line 457 def = {} .keys.each do |name| [name] = [] if [name] [name] = [name] | [name] else [name] = [name] end end (.keys - .keys).each do |name| [name] = [name] end .keys.inject([]) do |r, name| type = GlobalFit.types[:mesg_num][:values].find { |v| v[:value_name] == name } source = undocumented_types[:mesg_num][:values]. find { |t| t[:value_name] == name } unless type Log.error <<~ERROR Message "#{name}" not found in FIT profile or undocumented messages types. ERROR end r << { name: name, number: type[:value].to_i, source: source ? "F4R #{VERSION}" : "FIT SDK #{FIT_PROFILE_REV}", fields: [name.to_sym].select { |f| f[:field_def] } };r end end |
#get_types ⇒ Hash
Provides types to F4R::GlobalFit.types.
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/f4r.rb', line 498 def get_types types = {} profile_types.keys.each do |name| types[name] = {} if undocumented_types[name] values = profile_types[name][:values] | undocumented_types[name][:values] types[name][:values] = values else types[name] = profile_types[name] end end types end |