Skip to content

Commit

Permalink
more naming fixes!
Browse files Browse the repository at this point in the history
  • Loading branch information
quicklywilliam committed Mar 8, 2017
1 parent 1ec2352 commit 5a9f534
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions RandomForestManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ bool randomForestLoadModel(RandomForestManager *r, const char* pathToModelFile)
/**
* Maximum spacing between accelerometer readings, in seconds
*/
float randomForestGetDesiredSpacing(RandomForestManager *r) {
float randomForestGetDesiredSamplingInterval(RandomForestManager *r) {
return 1. / r->samplingRateHz;
}

/**
* Minimum length of continuous readings, in seconds
*/
float randomForestGetDesiredDuration(RandomForestManager *r) {
float randomForestGetDesiredReadingDuration(RandomForestManager *r) {
// Desired duration is the difference between the time of the first
// and the time of the last
return (r->sampleCount - 1) / r->samplingRateHz;
Expand Down
6 changes: 3 additions & 3 deletions RandomForestManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#define RANDOM_FOREST_VECTOR_SIZE (13)
#define RANDOM_FOREST_SAMPLING_RATE_HZ 20f

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -25,8 +25,8 @@ extern "C" {
RandomForestManager *createRandomForestManagerFromFile(const char* pathToJson);
bool randomForestLoadModel(RandomForestManager *r, const char* pathToModelFile);

float randomForestGetDesiredDuration(RandomForestManager *r);
float randomForestGetDesiredSpacing(RandomForestManager *r);
float randomForestGetDesiredReadingDuration(RandomForestManager *r);
float randomForestGetDesiredSamplingInterval(RandomForestManager *r);
const char* randomForestGetModelUniqueIdentifier(RandomForestManager *r);

bool randomForestManagerCanPredict(RandomForestManager *r);
Expand Down
27 changes: 20 additions & 7 deletions RandomForestManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ class RandomForestManager {
var _ptr: COpaquePointer!
var classLables: [Int32]!
var classCount = 0
var desiredSampleInterval: NSTimeInterval {
get {
return Double(randomForestGetDesiredSamplingInterval(_ptr))
}
}

var desiredReadingDuration: NSTimeInterval {
get {
return Double(randomForestGetDesiredReadingDuration(_ptr))
}
}

struct Static {
static var onceToken : dispatch_once_t = 0
Expand All @@ -31,16 +42,22 @@ class RandomForestManager {
}
}

func startup() {
init () {
guard let configFilePath = NSBundle(forClass: self.dynamicType).pathForResource("config.json", ofType: nil) else {
return
}

let cConfigFilepath = configFilePath.cStringUsingEncoding(NSUTF8StringEncoding)

_ptr = createRandomForestManagerFromFile(UnsafeMutablePointer(cConfigFilepath!))

var modelUIDCString = randomForestGetModelUniqueIdentifier(_ptr)
}

deinit {
deleteRandomForestManager(_ptr)
}

func startup() {
let modelUIDCString = randomForestGetModelUniqueIdentifier(_ptr)

guard let modelUID = String.fromCString(UnsafePointer(modelUIDCString)) else {
return
Expand All @@ -61,10 +78,6 @@ class RandomForestManager {
self.classLables = [Int32](count:self.classCount, repeatedValue:0)
randomForestGetClassLabels(_ptr, UnsafeMutablePointer(self.classLables), Int32(self.classCount))
}

deinit {
deleteRandomForestManager(_ptr)
}

private func accelerometerReadings(forSensorData sensorData:NSOrderedSet)->[AccelerometerReading] {
var readings: [AccelerometerReading] = []
Expand Down
2 changes: 1 addition & 1 deletion json/jsoncpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ license you like.



#include "json/json.h"
#include "json.h"

#ifndef JSON_IS_AMALGAMATION
#error "Compile with -I PATH_TO_JSON_DIRECTORY"
Expand Down

0 comments on commit 5a9f534

Please sign in to comment.