Showing 1 of 1 files from the diff.

@@ -78,7 +78,7 @@
Loading
78 78
    #
79 79
    # Read file header and return it as a list with following elements
80 80
    #   uniqueSerialCode is unque serial code of used device
81 -
    #   samfreq is measurement frequency. All data will be resampled
81 +
    #   frequency is measurement frequency. All data will be resampled
82 82
    #       for this frequency.
83 83
    #   start is timestamp in numeric form. To get text representation
84 84
    #       it is enough to use
@@ -113,7 +113,7 @@
Loading
113 113
      # sensorConfig = readBin(fid, raw(), size = 1) #offset 35
114 114
      # sample rate and dynamic range accelerometer
115 115
      samplerate_dynrange = readBin(fid, integer(), size = 1) #offset 36
116 -
      sf = round( 3200 / bitwShiftL(1, 15 - bitwAnd(samplerate_dynrange, 15)))
116 +
      frequency_header = round( 3200 / bitwShiftL(1, 15 - bitwAnd(samplerate_dynrange, 15)))
117 117
      accrange = bitwShiftR(16,(bitwShiftR(samplerate_dynrange,6)))
118 118
      suppressWarnings(readChar(fid, 4, useBytes = TRUE)) #offset 37..40
119 119
      version = readBin(fid, integer(), size = 1) #offset 41
@@ -124,9 +124,9 @@
Loading
124 124
      if (is.null(datas)){
125 125
        stop("Error in the first data block reading")
126 126
      }
127 -
      if (samfreq != datas$samfreq){
127 +
      if (frequency_header != datas$frequency){
128 128
        warning("Inconsistent value of measurement frequency: there is ",
129 -
                samfreq, " in header and ", datas$samfreq, " in the first data block ")
129 +
                frequency_header, " in header and ", datas$frequency, " in the first data block ")
130 130
      }
131 131
    } else {
132 132
      return(invisible(NULL))
@@ -135,7 +135,7 @@
Loading
135 135
    start = as.POSIXct(datas$start, origin = "1970-01-01", tz=desiredtz)
136 136
    
137 137
    returnobject = list(
138 -
      uniqueSerialCode = uniqueSerialCode, samfreq = samfreq,
138 +
      uniqueSerialCode = uniqueSerialCode, frequency = frequency_header,
139 139
      start = start,
140 140
      device = "Axivity", firmwareVersion = version, blocks = numDBlocks,
141 141
      accrange = accrange, hardwareType=hardwareType
@@ -197,7 +197,7 @@
Loading
197 197
  
198 198
  readDataBlock = function(fid, complete = TRUE){
199 199
    # Read one block of data and return list with following elements
200 -
    #   samfreq is frequency recorded in this block
200 +
    #   frequency is frequency recorded in this block
201 201
    #   start is start time in nummeric form. To create string representation
202 202
    #       it is necesarry to use
203 203
    #           as.POSIXct(start, origin = "1970-01-01", tz=desiredtz)
@@ -260,7 +260,7 @@
Loading
260 260
        # If tsOffset is not null then timestamp offset was artificially
261 261
        # modified for backwards-compatibility ... therefore undo this...
262 262
        if (bitwAnd(tsOffset, 0x8000L) != 0) {
263 -
          samfreq = round( 3200 / bitwShiftL(1, 15 - bitwAnd(samplerate_dynrange, 15)))
263 +
          frequency_data = round( 3200 / bitwShiftL(1, 15 - bitwAnd(samplerate_dynrange, 15)))
264 264
          accrange = bitwShiftR(16,(bitwShiftR(samplerate_dynrange,6)))
265 265
          # Need to undo backwards-compatible shim:
266 266
          # Take into account how many whole samples the fractional part
@@ -274,13 +274,13 @@
Loading
274 274
          # use 15-bits as 16-bit fractional time
275 275
          fractional = bitwShiftL(bitwAnd(tsOffset, 0x7fffL), 1);
276 276
          # frequency is truncated to int in firmware
277 -
          shift = shift + bitwShiftR((fractional * samfreq), 16);
278 -
        } else if (bitwAnd(tsOffset, 0x8000L) == 0) {
279 -
          samfreq = round( 3200 / bitwShiftL(1, 15 - bitwAnd(samplerate_dynrange, 15)))
277 +
          shift = shift + bitwShiftR((fractional * frequency_data), 16);
278 +
        } else if (bitwAnd(tsOffset, 0x8000L) == 0) { # & class(frequency_data) ==  "function") {
279 +
          frequency_data = round( 3200 / bitwShiftL(1, 15 - bitwAnd(samplerate_dynrange, 15)))
280 280
        }
281 281
      } else {
282 282
        #Very old format, where offset 26 contains frequency
283 -
        samfreq = temp
283 +
        frequency_data = temp
284 284
      }
285 285
      # Read data if necessary
286 286
      if (complete){
@@ -319,8 +319,8 @@
Loading
319 319
        suppressWarnings(readChar(fid, 482, useBytes = TRUE))
320 320
      }
321 321
      l = list(
322 -
        samfreq = samfreq,
323 -
        start = timestampDecoder(timeStamp, fractional,-shift / samfreq),
322 +
        frequency = frequency_data,
323 +
        start = timestampDecoder(timeStamp, fractional,-shift / frequency_data),
324 324
        temperature = temperature,
325 325
        battery = battery,
326 326
        light = light,
@@ -353,7 +353,7 @@
Loading
353 353
  header = readHeader(fid, numDBlocks)
354 354
  # preprocess start and stop
355 355
  origin = as.numeric(header$start)
356 -
  step = 1/header$samfreq
356 +
  step = 1/header$frequency
357 357
  if (is.numeric(start)) {
358 358
    if (start<0)
359 359
      start = 0
Files Coverage
R 74.09%
src 100.00%
Project Totals (78 files) 74.20%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading