Sha256: c4c9b19d8f279172514c1a3619f04937c48b138cb30b1f036caf37cdf5cf635c

Contents?: true

Size: 1.36 KB

Versions: 30

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = MonitoringDB.rb -- PostRunner - Manage the data from your Garmin sport devices.
#
# Copyright (c) 2014, 2015 by Chris Schlaeger <cs@taskjuggler.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#

module PostRunner

  class MonitoringDB

    def initialize(store, cfg)
      @store = store
    end

    def add(fit_file_name, fit_monitoring_b)
      start_time = fit_monitoring_b.monitoring_infos[0].timestamp

      fit_monitoring_b.monitorings.each do |monitoring|
        if (cati = monitoring.current_activity_type_intensity)
          data.activity_type = decode_activity_type(cati & 0x1F)
          data.intensity = (cati >> 5) & 0x7
          #puts "#{monitoring.timestamp}: #{decode_activity_type(cati & 0x1F)}" +
          #     "  #{(cati >> 5) & 0x7}"
        end
      end
    end

    private

    def decode_activity_type(activity_type)
      types = [ :generic, :running, :cycling, :transition,
                :fitness_equipment, :swimming, :walking, :unknown7,
                :resting, :unknown9 ]
      if (decoded_type = types[activity_type])
        decoded_type
      else
        Log.error "Unknown activity type #{activity_type}"
        :generic
      end
    end

  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
postrunner-0.7.0 lib/postrunner/MonitoringDB.rb
postrunner-0.6.0 lib/postrunner/MonitoringDB.rb
postrunner-0.5.0 lib/postrunner/MonitoringDB.rb
postrunner-0.4.0 lib/postrunner/MonitoringDB.rb
postrunner-0.3.0 lib/postrunner/MonitoringDB.rb
postrunner-0.2.1 lib/postrunner/MonitoringDB.rb
postrunner-0.2.0 lib/postrunner/MonitoringDB.rb
postrunner-0.1.0 lib/postrunner/MonitoringDB.rb
postrunner-0.0.11 lib/postrunner/MonitoringDB.rb
postrunner-0.0.10 lib/postrunner/MonitoringDB.rb