Class: PostRunner::FFS_Monitoring

Inherits:
PEROBS::Object
  • Object
show all
Includes:
DirUtils
Defined in:
lib/postrunner/FFS_Monitoring.rb

Overview

The FFS_Monitoring objects can store a reference to the FIT file data and caches some frequently used values.

Instance Method Summary collapse

Methods included from DirUtils

#create_directory

Constructor Details

#initialize(p, device, fit_file_name, fit_entity) ⇒ FFS_Monitoring

Create a new FFS_Monitoring object.

Parameters:

  • p (PEROBS::Handle)

    PEROBS handle

  • fit_file_name (String)

    The fully qualified file name of the FIT file to add

  • fit_entity (Fit4Ruby::FitEntity)

    The content of the loaded FIT file



32
33
34
35
36
37
38
39
40
# File 'lib/postrunner/FFS_Monitoring.rb', line 32

def initialize(p, device, fit_file_name, fit_entity)
  super(p)

  self.device = device
  self.fit_file_name = fit_file_name ? File.basename(fit_file_name) : nil
  self.name = fit_file_name ? File.basename(fit_file_name) : nil

  extract_summary_values(fit_entity)
end

Instance Method Details

#<=>(a) ⇒ Object

FFS_Monitoring objects are sorted by their start time values and then by their device long_uids.



61
62
63
64
65
# File 'lib/postrunner/FFS_Monitoring.rb', line 61

def <=>(a)
  @period_start == a.period_start ?
    a.device.long_uid <=> self.device.long_uid :
    a.period_start <=> @period_start
end

#store_fit_file(fit_file_name) ⇒ Object

Store a copy of the given FIT file in the corresponding directory.

Parameters:

  • fit_file_name (String)

    Fully qualified name of the FIT file.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/postrunner/FFS_Monitoring.rb', line 44

def store_fit_file(fit_file_name)
  # Get the right target directory for this particular FIT file.
  dir = @store['file_store'].fit_file_dir(File.basename(fit_file_name),
                                          @device.long_uid, 'monitor')
  # Create the necessary directories if they don't exist yet.
  create_directory(dir, 'Device monitoring diretory')

  # Copy the file into the target directory.
  begin
    FileUtils.cp(fit_file_name, dir)
  rescue StandardError
    Log.fatal "Cannot copy #{fit_file_name} into #{dir}: #{$!}"
  end
end