3 changes: 2 additions & 1 deletion lib/postrunner/ActivityView.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def initialize(activity, unit_system)
def generate_html(doc)
doc.unique(:activityview_style) {
doc.head {
[ 'jquery/jquery-2.1.1.min.js', 'flot/jquery.flot.js',
[ 'jquery/jquery-3.5.1.min.js', 'flot/jquery.flot.js',
#'flot/jquery.flot.time.js' ].each do |js|
'flot/jquery.flot.time.js' ].each do |js|
doc.script({ 'language' => 'javascript',
'type' => 'text/javascript', 'src' => js })
Expand Down
38 changes: 35 additions & 3 deletions lib/postrunner/ChartView.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(activity, unit_system)
:unit => select_unit('min/km'),
:graph => :line_graph,
:colors => '#0A7BEE',
:show => @sport == 'running' || @sport == 'multisport',
:show => @sport == 'running' || @sport == 'multisport'
},
{
:id => 'speed',
Expand All @@ -40,9 +40,17 @@ def initialize(activity, unit_system)
:colors => '#0A7BEE',
:show => @sport != 'running'
},
{
:id => 'Power_18FB2CF01A4B430DAD66988C847421F4',
:label => 'Power',
:unit => select_unit('Watts'),
:graph => :line_graph,
:colors => '#FFAC2E',
:show => @sport == 'running' || @sport == 'multisport'
},
{
:id => 'altitude',
:label => 'Elevation',
:label => 'Altitude',
:unit => select_unit('m'),
:graph => :line_graph,
:colors => '#5AAA44',
Expand Down Expand Up @@ -127,6 +135,22 @@ def initialize(activity, unit_system)
[ '#FF5558', nil ] ],
:show => @sport == 'running' || @sport == 'multisport'
},
{
:id => 'Form_Power_18FB2CF01A4B430DAD66988C847421F4',
:label => 'Form Power',
:unit => select_unit('Watts'),
:graph => :line_graph,
:colors => '#CBBB58',
:show => @sport == 'running' || @sport == 'multisport'
},
{
:id => 'Leg_Spring_Stiffness_18FB2CF01A4B430DAD66988C847421F4',
:label => 'Leg Spring Stiffness',
:unit => select_unit('kN/m'),
:graph => :line_graph,
:colors => '#358C88',
:show => @sport == 'running' || @sport == 'multisport'
},
{
:id => 'stance_time',
:label => 'Ground Contact Time',
Expand Down Expand Up @@ -157,6 +181,14 @@ def initialize(activity, unit_system)
:colors => '#A88BBB',
:show => @sport == 'cycling'
},
{
:id => "Air_Power_18FB2CF01A4B430DAD66988C847421F4",
:label => 'Air Power',
:unit => select_unit('Watts'),
:graph => :line_graph,
:colors => '#919498',
:show => @sport == 'running' || @sport == 'multisport'
},
{
:id => 'temperature',
:label => 'Temperature',
Expand Down Expand Up @@ -229,7 +261,7 @@ def style
end

def java_script
s = "$(function() {\n"
s = "$(document).ready(function() {\n"

s << tooltip_div
@charts.each do |chart|
Expand Down
2 changes: 1 addition & 1 deletion lib/postrunner/DailyMonitoringView.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def initialize(db, date, monitoring_files)
def generate_html(doc)
doc.unique(:dailymonitoringview_style) {
doc.head {
[ 'jquery/jquery-2.1.1.min.js', 'flot/jquery.flot.js',
[ 'jquery/jquery-3.5.1.min.js', 'flot/jquery.flot.js',
'flot/jquery.flot.time.js' ].each do |js|
doc.script({ 'language' => 'javascript',
'type' => 'text/javascript', 'src' => js })
Expand Down
21 changes: 21 additions & 0 deletions lib/postrunner/DeviceList.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ def devices
t.new_row
end

if (ant_id = device.ant_id)
t.cell('ANT ID:')
t.cell(ant_id)
t.new_row
end

if ant_id && (sensor_settings = find_settings_by_ant_id(ant_id)) &&
(calibration_factor = sensor_settings.calibration_factor)
t.cell('Calibration Factor')
t.cell('%.1f' % calibration_factor)
t.new_row
end

if (rx_ok = device.rx_packets_ok) && (rx_err = device.rx_packets_err)
t.cell('Packet Errors:')
t.cell('%d%%' % ((rx_err.to_f / (rx_ok + rx_err)) * 100).to_i)
Expand All @@ -148,6 +161,14 @@ def devices
tables
end

private

def find_settings_by_ant_id(ant_id)
@fit_activity.sensor_settings.find do |sensor|
sensor.ant_id == ant_id
end
end

end

end
Expand Down
14 changes: 12 additions & 2 deletions lib/postrunner/EventList.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def event_name_and_value(table, event)
case event.event
when 'timer'
name = "Timer (#{event.event_type.gsub(/_/, ' ')})"
value = event.timer_trigger
value = '-'
when 'course_point'
name = 'Course Point'
value = event.message_index
Expand Down Expand Up @@ -121,12 +121,19 @@ def event_name_and_value(table, event)
when 'comm_timeout'
name 'Communication timeout'
value = event.comm_timeout
when 'off_course'
name = 'Off Course'
value = '-'
when 'recovery_hr'
name = 'Recovery heart rate'
value = "#{event.recovery_hr} bpm"
when 'recovery_time'
name = 'Recovery time'
value = "#{secsToDHMS(event.recovery_time * 60)}"
if event.recovery_time
value = "#{secsToDHMS(event.recovery_time * 60)}"
else
value = '-'
end
when 'recovery_info'
name = 'Recovery info'
mins = event.recovery_info
Expand All @@ -140,6 +147,9 @@ def event_name_and_value(table, event)
when 'lactate_threshold_speed'
name = 'Lactate Threshold Pace'
value = pace(event, 'lactate_threshold_speed')
when 'functional_threshold_power'
name = 'Functional Threshold Power'
value = "#{event.functional_threshold_power} W"
else
name = event.event
value = event.data
Expand Down
4 changes: 1 addition & 3 deletions lib/postrunner/FitFileStore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,7 @@ def extract_fit_file_id(fit_entity)
# Not all FIT file have indexed device sections. In case the device
# index is nil we'll take the first entry.
if (di.device_index.nil? || di.device_index == 0) &&
(di.manufacturer &&
(di.garmin_product || di.product) &&
di.numeric_product && di.serial_number)
di.numeric_manufacturer && di.numeric_product
return {
:manufacturer => di.manufacturer,
:product => di.garmin_product || di.product,
Expand Down
12 changes: 8 additions & 4 deletions lib/postrunner/MonitoringStatistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def time_as_hm(t, utc_offset)
t.localtime(utc_offset).strftime('%H:%M')
end

def prefix_for_time(t, a)
a.window_start_time.strftime('%Y-%m-%d') == t.strftime('%Y-%m-%d') ? ' ' : '+'
end

def daily_sleep_cycle_table(analyzer)
ti = FlexiTable.new
ti.head
Expand All @@ -129,8 +133,8 @@ def daily_sleep_cycle_table(analyzer)
if last_to_time && c.from_time > last_to_time
# We have a gap in the sleep cycles.
ti.cell('Wake')
cell_right_aligned(ti, time_as_hm(last_to_time, utc_offset))
cell_right_aligned(ti, time_as_hm(c.from_time, utc_offset))
cell_right_aligned(ti, prefix_for_time(last_to_time, analyzer) + time_as_hm(last_to_time, utc_offset))
cell_right_aligned(ti, prefix_for_time(c.from_time, analyzer) + time_as_hm(c.from_time, utc_offset))
cell_right_aligned(ti, "(#{secsToHM(c.from_time - last_to_time)})")
ti.cell('')
ti.cell('')
Expand All @@ -139,8 +143,8 @@ def daily_sleep_cycle_table(analyzer)
end

ti.cell((idx + 1).to_s, format)
ti.cell(c.from_time.localtime(utc_offset).strftime('%H:%M'), format)
ti.cell(c.to_time.localtime(utc_offset).strftime('%H:%M'), format)
ti.cell(prefix_for_time(c.from_time.localtime(utc_offset), analyzer) + c.from_time.localtime(utc_offset).strftime('%H:%M'), format)
ti.cell(prefix_for_time(c.to_time.localtime(utc_offset), analyzer) + c.to_time.localtime(utc_offset).strftime('%H:%M'), format)

duration = c.to_time - c.from_time
totals[:duration] += duration
Expand Down
2 changes: 1 addition & 1 deletion lib/postrunner/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#

module PostRunner
VERSION = '1.0.2'
VERSION = '1.0.4'
end
Loading